#define SK_FONT_FILE_PREFIX "/fonts/"
#endif
+// For test only.
+static const char* gTestMainConfigFile = NULL;
+static const char* gTestFallbackConfigFile = NULL;
+static const char* gTestFontFilePrefix = NULL;
+
bool find_name_and_attributes(SkStream* stream, SkString* name,
SkTypeface::Style* style, bool* isFixedWidth);
static void GetFullPathForSysFonts(SkString* full, const char name[]) {
- full->set(getenv("ANDROID_ROOT"));
- full->append(SK_FONT_FILE_PREFIX);
+ if (gTestFontFilePrefix) {
+ full->set(gTestFontFilePrefix);
+ } else {
+ full->set(getenv("ANDROID_ROOT"));
+ full->append(SK_FONT_FILE_PREFIX);
+ }
full->append(name);
}
}
if (isExpected) {
- SkDebugf("---- failed to open <%s> as a font\n", fullpath.c_str());
+ SkDebugf("---- failed to open <%s> as a font", fullpath.c_str());
}
return false;
}
*/
static void load_font_info() {
SkTDArray<FontFamily*> fontFamilies;
- getFontFamilies(fontFamilies);
+ if (gTestMainConfigFile) {
+ getTestFontFamilies(fontFamilies, gTestMainConfigFile, gTestFallbackConfigFile);
+ } else {
+ getFontFamilies(fontFamilies);
+ }
SkTDArray<FontInitRec> fontInfo;
bool firstInFamily = false;
isFixedWidth) // filename
);
- SkDEBUGF(("---- SkTypeface[%d] %s fontID %d\n",
+ SkDEBUGF(("---- SkTypeface[%d] %s fontID %d",
i, rec[i].fFileName, tf->uniqueID()));
if (rec[i].fNames != NULL) {
// see if this is one of our fallback fonts
if (rec[i].fNames == gFBNames) {
- SkDEBUGF(("---- adding %s as fallback[%d] fontID %d\n",
+ SkDEBUGF(("---- adding %s as fallback[%d] fontID %d",
rec[i].fFileName, fallbackCount, tf->uniqueID()));
gFallbackFonts[fallbackCount++] = tf->uniqueID();
}
}
static void reload_fallback_fonts() {
+ if (gTestFallbackConfigFile) {
+ // No need to reload fallback fonts in test environment.
+ return;
+ }
+
SkGraphics::PurgeFontCache();
SkTDArray<FontFamily*> fallbackFamilies;
size_t uniqueID = find_uniqueID(family->fFileNames[j]);
SkASSERT(uniqueID != 0);
- SkDEBUGF(("---- reload %s as fallback[%d] fontID %d oldFontID %d\n",
+ SkDEBUGF(("---- reload %s as fallback[%d] fontID %d oldFontID %d",
family->fFileNames[j], fallbackCount, uniqueID,
gFallbackFonts[fallbackCount]));
}
// If we get here, currFontID was not a fallback, so we start at the
- // beginning of our list.
+ // beginning of our list. Assuming there is at least one fallback font,
+ // i.e. gFallbackFonts[0] != 0.
const SkTypeface* firstTypeface = find_from_uniqueID(list[0]);
return find_typeface(firstTypeface, origTypeface->style())->uniqueID();
}
// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
static void initFBScriptInfo() {
-
if (gFBScriptInitialized) {
return;
}
// bold is requested and no bold font exists for the typeface containing
// the character the next best style is chosen (e.g. normal).
scriptInfo.fFontID = findFontIDForChar(scriptInfo.fChar, scriptInfo.fStyle);
+ SkDEBUGF(("gFBScriptInfo[%s] --> %d", scriptInfo.fScriptID, scriptInfo.fFontID));
}
// mark the value as initialized so we don't repeat our work unnecessarily
gFBScriptInitialized = true;
}
return kFallbackScriptNumber; // Use kFallbackScriptNumber as an invalid value.
}
+
+void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
+ const char* fontsdir) {
+ gTestMainConfigFile = mainconf;
+ gTestFallbackConfigFile = fallbackconf;
+ gTestFontFilePrefix = fontsdir;
+ SkASSERT(gTestMainConfigFile);
+ SkASSERT(gTestFallbackConfigFile);
+ SkASSERT(gTestFontFilePrefix);
+ SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
+ gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix));
+}