bool Fonts::isFontFamily( const QString& name ) const { bool validFamily = false; QStringList fontList = getFontFamilies(); if ( fontList.contains(name)){ validFamily = true; } return validFamily; }
void Fonts::_initializeCallbacks(){ addCommandCallback( "getFontFamilies", [=] (const QString & /*cmd*/, const QString & /*params*/, const QString & /*sessionId*/) -> QString { QStringList fontList = getFontFamilies(); QString result = fontList.join(","); return result; }); addCommandCallback( "getFontSizes", [=] (const QString & /*cmd*/, const QString & /*params*/, const QString & /*sessionId*/) -> QString { QStringList fontList = getFontSizes(); QString result = fontList.join(","); return result; }); }
/* Load info from a configuration file that populates the system/fallback font structures */ static void load_font_info() { SkTDArray<FontFamily*> fontFamilies; if (gTestMainConfigFile) { getTestFontFamilies(fontFamilies, gTestMainConfigFile, gTestFallbackConfigFile); } else { getFontFamilies(fontFamilies); } SkTDArray<FontInitRec> fontInfo; bool firstInFamily = false; for (int i = 0; i < fontFamilies.count(); ++i) { FontFamily *family = fontFamilies[i]; firstInFamily = true; for (int j = 0; j < family->fFileNames.count(); ++j) { FontInitRec fontInfoRecord; fontInfoRecord.fFileName = family->fFileNames[j]; if (j == 0) { if (family->fNames.count() == 0) { // Fallback font fontInfoRecord.fNames = (char **)gFBNames; } else { SkTDArray<const char*> names = family->fNames; const char **nameList = (const char**) malloc((names.count() + 1) * sizeof(char*)); if (nameList == NULL) { // shouldn't get here SkDEBUGFAIL("Failed to allocate nameList"); break; } if (gDefaultNames == NULL) { gDefaultNames = (char**) nameList; } for (int i = 0; i < names.count(); ++i) { nameList[i] = names[i]; } nameList[names.count()] = NULL; fontInfoRecord.fNames = nameList; } } else { fontInfoRecord.fNames = NULL; } *fontInfo.append() = fontInfoRecord; } } gNumSystemFonts = fontInfo.count(); gSystemFonts = (FontInitRec*) malloc(gNumSystemFonts * sizeof(FontInitRec)); gFallbackFonts = (uint32_t*) malloc((gNumSystemFonts + 1) * sizeof(uint32_t)); if (gSystemFonts == NULL) { // shouldn't get here SkDEBUGFAIL("No system fonts were found"); gNumSystemFonts = 0; } #if SK_DEBUG_FONTS SkDebugf("---- We have %d system fonts", gNumSystemFonts); #endif for (size_t i = 0; i < gNumSystemFonts; ++i) { gSystemFonts[i].fFileName = fontInfo[i].fFileName; gSystemFonts[i].fNames = fontInfo[i].fNames; #if SK_DEBUG_FONTS SkDebugf("---- gSystemFonts[%d] fileName=%s", i, fontInfo[i].fFileName); #endif } fontFamilies.deleteAll(); }
int Fonts::getIndex( const QString& familyName ) const { QStringList families = getFontFamilies(); int index = families.indexOf( familyName ); return index; }