Adaptation to Skia FontMgr API change

Pass multiple locales to font resolution; handles mixed-language documents which need to know device default language to resolve font fallback correctly.

Depends on https://codereview.chromium.org/670243002/.
    
BUG=422180
R=djsollen@chromium.org,bungeman@chromium.org,dominik.rottsches@intel.com,eae@chromium.org

Review URL: https://codereview.chromium.org/665223004

git-svn-id: svn://svn.chromium.org/blink/trunk@184380 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c24561b3
...@@ -43,7 +43,16 @@ namespace blink { ...@@ -43,7 +43,16 @@ namespace blink {
static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontDescription) static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontDescription)
{ {
RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), fontDescription.locale().isEmpty() ? defaultLanguage().ascii().data() : fontDescription.locale().ascii().data(), c)); const char* bcp47Locales[2];
int localeCount = 0;
CString defaultLocale = defaultLanguage().ascii();
bcp47Locales[localeCount++] = defaultLocale.data();
CString fontLocale;
if (!fontDescription.locale().isEmpty()) {
fontLocale = fontDescription.locale().ascii();
bcp47Locales[localeCount++] = fontLocale.data();
}
RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c));
if (!typeface) if (!typeface)
return emptyAtom; return emptyAtom;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
# Defines should be in single quotes and a comma must appear after every one. # Defines should be in single quotes and a comma must appear after every one.
# DO NOT remove the define until you are ready to rebaseline, and # DO NOT remove the define until you are ready to rebaseline, and
# AFTER the flag has been removed from skia.gyp in Chromium. # AFTER the flag has been removed from skia.gyp in Chromium.
'SK_FM_NEW_MATCH_FAMILY_STYLE_CHARACTER=1',
], ],
}, },
}, },
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
# DO NOT remove the define until you are ready to rebaseline, and # DO NOT remove the define until you are ready to rebaseline, and
# AFTER the flag has been removed from skia.gyp in Chromium. # AFTER the flag has been removed from skia.gyp in Chromium.
'blink_skia_defines': [ 'blink_skia_defines': [
'SK_FM_NEW_MATCH_FAMILY_STYLE_CHARACTER=1',
], ],
}, },
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment