// ensure that if any value is added to the public enum it is also added here
SK_COMPILE_ASSERT(gFBScriptInfoCount == kFallbackScriptNumber, FBScript_count_mismatch);
+// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
static bool typefaceContainsChar(SkTypeface* face, SkUnichar uni) {
SkPaint paint;
paint.setTypeface(face);
return glyphID != 0;
}
+// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
static SkTypeface* findFallbackTypefaceForChar(SkUnichar uni) {
SkASSERT(gFallbackFonts);
const uint32_t* list = gFallbackFonts;
for (int i = 0; list[i] != 0; i++) {
- SkTypeface* face = find_from_uniqueID(list[i]);
+ SkTypeface* face;
+ {
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
+ face = find_from_uniqueID(list[i]);
+ }
if (typefaceContainsChar(face, uni)) {
return face;
}
return 0;
}
+// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
static SkFontID findFallbackFontIDForChar(SkUnichar uni, SkTypeface::Style style) {
const SkTypeface* tf = findFallbackTypefaceForChar(uni);
if (!tf) {
SkTypeface* SkCreateFallbackTypefaceForChar(SkUnichar uni,
SkTypeface::Style style) {
- SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
- load_system_fonts();
+ {
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
+ load_system_fonts();
+ }
SkTypeface* tf = findFallbackTypefaceForChar(uni);
if (!tf) {
return NULL;
}
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
tf = find_typeface(tf, style);
// we ref(), since the semantic is to return a new instance
tf->ref();
bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
SkASSERT(name);
- SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
- load_system_fonts();
+ {
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
+ load_system_fonts();
+ }
const SkTypeface* tf = findFallbackTypefaceForChar(uni);
if (!tf) {
return false;
}
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
name->set(find_family_name(tf));
return true;
}