OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, 2009 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const FontDescription& fontDescription, UChar32 character) | 69 const FontDescription& fontDescription, UChar32 character) |
70 { | 70 { |
71 FontDescription substituteDescription(fontDescription); | 71 FontDescription substituteDescription(fontDescription); |
72 substituteDescription.setStyle(FontStyleNormal); | 72 substituteDescription.setStyle(FontStyleNormal); |
73 substituteDescription.setWeight(FontWeightNormal); | 73 substituteDescription.setWeight(FontWeightNormal); |
74 | 74 |
75 FontFaceCreationParams creationParams(substituteDescription.family().family(
)); | 75 FontFaceCreationParams creationParams(substituteDescription.family().family(
)); |
76 FontPlatformData* substitutePlatformData = getFontPlatformData(substituteDes
cription, creationParams); | 76 FontPlatformData* substitutePlatformData = getFontPlatformData(substituteDes
cription, creationParams); |
77 if (substitutePlatformData && substitutePlatformData->fontContainsCharacter(
character)) { | 77 if (substitutePlatformData && substitutePlatformData->fontContainsCharacter(
character)) { |
78 FontPlatformData platformData = FontPlatformData(*substitutePlatformData
); | 78 FontPlatformData platformData = FontPlatformData(*substitutePlatformData
); |
79 platformData.setSyntheticBold(fontDescription.weight() >= FontWeightBold
); | 79 platformData.setSyntheticBold(fontDescription.weight() >= FontWeight600)
; |
80 platformData.setSyntheticItalic(fontDescription.style() == FontStyleItal
ic); | 80 platformData.setSyntheticItalic(fontDescription.style() == FontStyleItal
ic); |
81 return fontDataFromFontPlatformData(&platformData, DoNotRetain); | 81 return fontDataFromFontPlatformData(&platformData, DoNotRetain); |
82 } | 82 } |
83 | 83 |
84 return nullptr; | 84 return nullptr; |
85 } | 85 } |
86 | 86 |
87 #if !OS(WIN) && !OS(ANDROID) | 87 #if !OS(WIN) && !OS(ANDROID) |
88 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip
tion& fontDescription, UChar32 c, const SimpleFontData*) | 88 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip
tion& fontDescription, UChar32 c, const SimpleFontData*) |
89 { | 89 { |
90 // First try the specified font with standard style & weight. | 90 // First try the specified font with standard style & weight. |
91 if (fontDescription.style() == FontStyleItalic | 91 if (fontDescription.style() == FontStyleItalic |
92 || fontDescription.weight() >= FontWeightBold) { | 92 || fontDescription.weight() >= FontWeight600) { |
93 RefPtr<SimpleFontData> fontData = fallbackOnStandardFontStyle( | 93 RefPtr<SimpleFontData> fontData = fallbackOnStandardFontStyle( |
94 fontDescription, c); | 94 fontDescription, c); |
95 if (fontData) | 95 if (fontData) |
96 return fontData; | 96 return fontData; |
97 } | 97 } |
98 | 98 |
99 icu::Locale locale = icu::Locale::getDefault(); | 99 icu::Locale locale = icu::Locale::getDefault(); |
100 FontCache::PlatformFallbackFont fallbackFont; | 100 FontCache::PlatformFallbackFont fallbackFont; |
101 FontCache::getFontForCharacter(c, locale.getLanguage(), &fallbackFont); | 101 FontCache::getFontForCharacter(c, locale.getLanguage(), &fallbackFont); |
102 if (fallbackFont.name.isEmpty()) | 102 if (fallbackFont.name.isEmpty()) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the
name into | 175 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the
name into |
176 // the fallback name (like "monospace") that fontconfig understands. | 176 // the fallback name (like "monospace") that fontconfig understands. |
177 if (!family.length() || family.startsWith("-webkit-")) { | 177 if (!family.length() || family.startsWith("-webkit-")) { |
178 name = getFallbackFontFamily(fontDescription).string().utf8(); | 178 name = getFallbackFontFamily(fontDescription).string().utf8(); |
179 } else { | 179 } else { |
180 // convert the name to utf8 | 180 // convert the name to utf8 |
181 name = family.utf8(); | 181 name = family.utf8(); |
182 } | 182 } |
183 | 183 |
184 int style = SkTypeface::kNormal; | 184 int style = SkTypeface::kNormal; |
185 if (fontDescription.weight() >= FontWeightBold) | 185 if (fontDescription.weight() >= FontWeight600) |
186 style |= SkTypeface::kBold; | 186 style |= SkTypeface::kBold; |
187 if (fontDescription.style()) | 187 if (fontDescription.style()) |
188 style |= SkTypeface::kItalic; | 188 style |= SkTypeface::kItalic; |
189 | 189 |
190 #if OS(WIN) | 190 #if OS(WIN) |
191 if (s_sideloadedFonts) { | 191 if (s_sideloadedFonts) { |
192 HashMap<String, SkTypeface*>::iterator sideloadedFont = s_sideloadedFont
s->find(name.data()); | 192 HashMap<String, SkTypeface*>::iterator sideloadedFont = s_sideloadedFont
s->find(name.data()); |
193 if (sideloadedFont != s_sideloadedFonts->end()) { | 193 if (sideloadedFont != s_sideloadedFonts->end()) { |
194 return adoptRef(sideloadedFont->value); | 194 return adoptRef(sideloadedFont->value); |
195 } | 195 } |
(...skipping 10 matching lines...) Expand all Loading... |
206 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const FontFaceCreationParams& creationParams, float fontSize) | 206 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const FontFaceCreationParams& creationParams, float fontSize) |
207 { | 207 { |
208 CString name; | 208 CString name; |
209 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name))
; | 209 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name))
; |
210 if (!tf) | 210 if (!tf) |
211 return 0; | 211 return 0; |
212 | 212 |
213 FontPlatformData* result = new FontPlatformData(tf, | 213 FontPlatformData* result = new FontPlatformData(tf, |
214 name.data(), | 214 name.data(), |
215 fontSize, | 215 fontSize, |
216 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes
cription.isSyntheticBold(), | 216 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc
ription.isSyntheticBold(), |
217 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe
ticItalic(), | 217 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe
ticItalic(), |
218 fontDescription.orientation(), | 218 fontDescription.orientation(), |
219 fontDescription.useSubpixelPositioning()); | 219 fontDescription.useSubpixelPositioning()); |
220 return result; | 220 return result; |
221 } | 221 } |
222 #endif // !OS(WIN) | 222 #endif // !OS(WIN) |
223 | 223 |
224 } // namespace WebCore | 224 } // namespace WebCore |
OLD | NEW |