OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... | |
36 #include "platform/fonts/FontDescription.h" | 36 #include "platform/fonts/FontDescription.h" |
37 #include "platform/fonts/FontFaceCreationParams.h" | 37 #include "platform/fonts/FontFaceCreationParams.h" |
38 #include "third_party/skia/include/core/SkTypeface.h" | 38 #include "third_party/skia/include/core/SkTypeface.h" |
39 #include "third_party/skia/include/ports/SkFontMgr.h" | 39 #include "third_party/skia/include/ports/SkFontMgr.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontDescription) | 43 static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontDescription) |
44 { | 44 { |
45 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); | 45 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
46 RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFo ntStyle(), fontDescription.locale().isEmpty() ? defaultLanguage().ascii().data() : fontDescription.locale().ascii().data(), c)); | 46 const char* bcp47Locales[2]; |
47 int localeCount = 0; | |
48 CString fontLocale; | |
49 if (!fontDescription.locale().isEmpty()) { | |
50 fontLocale = fontDescription.locale().ascii(); | |
51 bcp47Locales[localeCount++] = fontLocale.data(); | |
52 } | |
53 CString defaultLocale = defaultLanguage().ascii(); | |
54 bcp47Locales[localeCount++] = defaultLocale.data(); | |
bungeman-chromium
2014/10/23 16:55:41
I now have this documented and working more like a
| |
55 RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFo ntStyle(), bcp47Locales, localeCount, c)); | |
47 if (!typeface) | 56 if (!typeface) |
48 return emptyAtom; | 57 return emptyAtom; |
49 | 58 |
50 SkString skiaFamilyName; | 59 SkString skiaFamilyName; |
51 typeface->getFamilyName(&skiaFamilyName); | 60 typeface->getFamilyName(&skiaFamilyName); |
52 return skiaFamilyName.c_str(); | 61 return skiaFamilyName.c_str(); |
53 } | 62 } |
54 | 63 |
55 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*) | 64 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*) |
56 { | 65 { |
(...skipping 20 matching lines...) Expand all Loading... | |
77 break; | 86 break; |
78 default: | 87 default: |
79 // For other scripts, use the default generic family mapping logic. | 88 // For other scripts, use the default generic family mapping logic. |
80 return familyName; | 89 return familyName; |
81 } | 90 } |
82 | 91 |
83 return getFamilyNameForCharacter(examplerChar, fontDescription); | 92 return getFamilyNameForCharacter(examplerChar, fontDescription); |
84 } | 93 } |
85 | 94 |
86 } // namespace blink | 95 } // namespace blink |
OLD | NEW |