/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Copy the charsets in the list into the local list. // An exception is thrown if a mismatch in the default // charset is detected // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void updateCharsets(const tCharsetsList* pCharsetsList, tCharsetsList* pDestinationCharsetsList) { PUNTOEXE_FUNCTION_START(L"charsetsList::updateCharsets"); // Check the default charset /////////////////////////////////////////////////////////// if(!pCharsetsList->empty() && !pDestinationCharsetsList->empty() && pCharsetsList->front() != pDestinationCharsetsList->front()) { PUNTOEXE_THROW(charsetListExceptionDiffDefault, "Different default charsets"); } // Copy the charsets in the local list (if they are not // already there) /////////////////////////////////////////////////////////// for(tCharsetsList::const_iterator scanCharsets = pCharsetsList->begin(); scanCharsets != pCharsetsList->end(); ++scanCharsets) { std::string charsetName(*scanCharsets); if(charsetName.empty()) { charsetName = "ISO 2022 IR 6"; } bool bExist = false; for(tCharsetsList::iterator scanExistingCharsets = pDestinationCharsetsList->begin(); scanExistingCharsets != pDestinationCharsetsList->end(); ++scanExistingCharsets) { if(charsetName == *scanExistingCharsets) { bExist = true; break; } } if(!bExist) { pDestinationCharsetsList->push_back(charsetName); } } PUNTOEXE_FUNCTION_END(); }
void nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes) { int j; PRBool rslt; PRUint32 count, i; char *pattern, *foundry, *family, *charset, *encoding; const char *charSetName; nsFontNode *node; nsCOMPtr<nsIArray> arrayFC; nsCAutoString familyTmp, languageTmp; FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern)); nsCAutoString patt(aPattern); ToLowerCase(patt); pattern = strdup(patt.get()); NS_ASSERTION(pattern, "failed to copy pattern"); if (!pattern) goto cleanup_and_return; rslt = ParseXLFD(pattern, &foundry, &family, &charset, &encoding); if (!rslt) goto cleanup_and_return; // unable to handle "name-charset-*" if (charset && !encoding) { goto cleanup_and_return; } if (family) familyTmp.Assign(family); sFcs->GetFontCatalogEntries(familyTmp, languageTmp, 0, 0, 0, 0, getter_AddRefs(arrayFC)); if (!arrayFC) goto cleanup_and_return; arrayFC->GetLength(&count); for (i = 0; i < count; i++) { nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryElementAt(arrayFC, i); if (!fce) continue; nsCAutoString foundryName, familyName; PRUint32 flags, codePageRange1, codePageRange2; PRUint16 weight, width; fce->GetFamilyName(familyName); fce->GetFlags(&flags); fce->GetWidth(&width); fce->GetWeight(&weight); fce->GetCodePageRange1(&codePageRange1); fce->GetCodePageRange2(&codePageRange2); if (!charset) { // get all encoding FONT_CATALOG_PRINTF(("found FreeType %s-%s-*-*", foundryName.get(), familyName.get())); for (j=0; j<32; j++) { unsigned long bit = 1 << j; if (bit & codePageRange1) { charSetName = nsFreeType2::GetRange1CharSetName(bit); NS_ASSERTION(charSetName, "failed to get charset name"); if (!charSetName) continue; node = LoadNode(fce, charSetName, aNodes); } if (bit & codePageRange2) { charSetName = nsFreeType2::GetRange2CharSetName(bit); if (!charSetName) continue; LoadNode(fce, charSetName, aNodes); } } if (foundryName.IsEmpty() && !familyName.IsEmpty() && flags&FCE_FLAGS_SYMBOL) { // the "registry-encoding" is not used but LoadNode will fail without // some value for this LoadNode(fce, "symbol-fontspecific", aNodes); } } if (charset && encoding) { // get this specific encoding PRUint32 cpr1_bits, cpr2_bits; nsCAutoString charsetName(charset); charsetName.Append('-'); charsetName.Append(encoding); CharSetNameToCodeRangeBits(charsetName.get(), &cpr1_bits, &cpr2_bits); if (!(cpr1_bits & codePageRange1) && !(cpr2_bits & codePageRange2)) continue; FONT_CATALOG_PRINTF(("found FreeType -%s-%s-%s", familyName.get(),charset,encoding)); LoadNode(fce, charsetName.get(), aNodes); } } FREE_IF(pattern); return; cleanup_and_return: FONT_CATALOG_PRINTF(("nsFT2FontNode::GetFontNames failed")); FREE_IF(pattern); return; }