| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. |
| 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "RuntimeEnabledFeatures.h" | 35 #include "RuntimeEnabledFeatures.h" |
| 36 #include "SkFontMgr.h" | 36 #include "SkFontMgr.h" |
| 37 #include "SkTypeface_win.h" | 37 #include "SkTypeface_win.h" |
| 38 #include "platform/fonts/FontDescription.h" | 38 #include "platform/fonts/FontDescription.h" |
| 39 #include "platform/fonts/SimpleFontData.h" | 39 #include "platform/fonts/SimpleFontData.h" |
| 40 #include "platform/fonts/harfbuzz/FontPlatformDataHarfbuzz.h" | 40 #include "platform/fonts/harfbuzz/FontPlatformDataHarfbuzz.h" |
| 41 #include "platform/fonts/win/FontFallbackWin.h" | 41 #include "platform/fonts/win/FontFallbackWin.h" |
| 42 | 42 |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 // Minimum size, in pixels, at which anti alias is enabled for certain | |
| 46 // scripts. Only applies to the Direct Write backend for now. | |
| 47 static const unsigned s_minSizeForComplexScriptsAntiAlias = 32; | |
| 48 | |
| 49 FontCache::FontCache() | 45 FontCache::FontCache() |
| 50 : m_purgePreventCount(0) | 46 : m_purgePreventCount(0) |
| 51 { | 47 { |
| 52 SkFontMgr* fontManager; | 48 SkFontMgr* fontManager; |
| 53 | 49 |
| 54 if (s_useDirectWrite) { | 50 if (s_useDirectWrite) { |
| 55 fontManager = SkFontMgr_New_DirectWrite(); | 51 fontManager = SkFontMgr_New_DirectWrite(); |
| 56 } else { | 52 } else { |
| 57 fontManager = SkFontMgr_New_GDI(); | 53 fontManager = SkFontMgr_New_GDI(); |
| 58 // Subpixel text positioning is not supported by the GDI backend. | 54 // Subpixel text positioning is not supported by the GDI backend. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (!matchesRequestedFamily) { | 180 if (!matchesRequestedFamily) { |
| 185 SkString familyName; | 181 SkString familyName; |
| 186 tf->getFamilyName(&familyName); | 182 tf->getFamilyName(&familyName); |
| 187 if (equalIgnoringCase(family, familyName)) | 183 if (equalIgnoringCase(family, familyName)) |
| 188 matchesRequestedFamily = true; | 184 matchesRequestedFamily = true; |
| 189 } | 185 } |
| 190 | 186 |
| 191 return matchesRequestedFamily; | 187 return matchesRequestedFamily; |
| 192 } | 188 } |
| 193 | 189 |
| 190 // Minimum size, in pixels, at which anti alias is enabled for certain |
| 191 // scripts. Only applies to the Direct Write backend for now. |
| 192 static unsigned minSizeForAntiAlias(UScriptCode script) |
| 193 { |
| 194 switch (script) { |
| 195 case USCRIPT_TRADITIONAL_HAN: |
| 196 return 24; |
| 197 case USCRIPT_SIMPLIFIED_HAN: |
| 198 case USCRIPT_HIRAGANA: |
| 199 case USCRIPT_KATAKANA: |
| 200 case USCRIPT_KATAKANA_OR_HIRAGANA: |
| 201 case USCRIPT_HANGUL: |
| 202 case USCRIPT_BENGALI: |
| 203 return 16; |
| 204 case USCRIPT_THAI: |
| 205 case USCRIPT_HEBREW: |
| 206 case USCRIPT_ARABIC: |
| 207 case USCRIPT_DEVANAGARI: |
| 208 case USCRIPT_GURMUKHI: |
| 209 case USCRIPT_GUJARATI: |
| 210 case USCRIPT_TAMIL: |
| 211 case USCRIPT_TELUGU: |
| 212 case USCRIPT_KANNADA: |
| 213 case USCRIPT_GEORGIAN: |
| 214 case USCRIPT_ARMENIAN: |
| 215 case USCRIPT_THAANA: |
| 216 case USCRIPT_CANADIAN_ABORIGINAL: |
| 217 case USCRIPT_CHEROKEE: |
| 218 case USCRIPT_MONGOLIAN: |
| 219 default: |
| 220 return 0; |
| 221 } |
| 222 } |
| 223 |
| 194 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const AtomicString& family, float fontSize) | 224 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const AtomicString& family, float fontSize) |
| 195 { | 225 { |
| 196 CString name; | 226 CString name; |
| 197 RefPtr<SkTypeface> tf = createTypeface(fontDescription, family, name); | 227 RefPtr<SkTypeface> tf = createTypeface(fontDescription, family, name); |
| 198 if (!tf) | 228 if (!tf) |
| 199 return 0; | 229 return 0; |
| 200 | 230 |
| 201 // Windows will always give us a valid pointer here, even if the face name | 231 // Windows will always give us a valid pointer here, even if the face name |
| 202 // is non-existent. We have to double-check and see if the family name was | 232 // is non-existent. We have to double-check and see if the family name was |
| 203 // really used. | 233 // really used. |
| 204 // FIXME: Do we need to use predefined fonts "guaranteed" to exist | 234 // FIXME: Do we need to use predefined fonts "guaranteed" to exist |
| 205 // when we're running in layout-test mode? | 235 // when we're running in layout-test mode? |
| 206 if (!typefacesMatchesFamily(tf.get(), family)) { | 236 if (!typefacesMatchesFamily(tf.get(), family)) { |
| 207 return 0; | 237 return 0; |
| 208 } | 238 } |
| 209 | 239 |
| 210 FontPlatformData* result = new FontPlatformData(tf, | 240 FontPlatformData* result = new FontPlatformData(tf, |
| 211 name.data(), | 241 name.data(), |
| 212 fontSize, | 242 fontSize, |
| 213 fontDescription.weight() >= FontWeightBold && !tf->isBold() || fontDescr
iption.isSyntheticBold(), | 243 fontDescription.weight() >= FontWeightBold && !tf->isBold() || fontDescr
iption.isSyntheticBold(), |
| 214 fontDescription.style() == FontStyleItalic && !tf->isItalic() || fontDes
cription.isSyntheticItalic(), | 244 fontDescription.style() == FontStyleItalic && !tf->isItalic() || fontDes
cription.isSyntheticItalic(), |
| 215 fontDescription.orientation(), | 245 fontDescription.orientation(), |
| 216 s_useSubpixelPositioning); | 246 s_useSubpixelPositioning); |
| 217 | 247 |
| 218 // FIXME: Turn this into a script to min-size table. | 248 if (s_useDirectWrite) { |
| 219 if (s_useDirectWrite | 249 result->setMinSizeForAntiAlias( |
| 220 && (fontDescription.script() == USCRIPT_SIMPLIFIED_HAN | 250 minSizeForAntiAlias(fontDescription.script())); |
| 221 || fontDescription.script() == USCRIPT_TRADITIONAL_HAN | |
| 222 || fontDescription.script() == USCRIPT_HIRAGANA | |
| 223 || fontDescription.script() == USCRIPT_KATAKANA | |
| 224 || fontDescription.script() == USCRIPT_KATAKANA_OR_HIRAGANA | |
| 225 || fontDescription.script() == USCRIPT_HANGUL | |
| 226 || fontDescription.script() == USCRIPT_THAI | |
| 227 || fontDescription.script() == USCRIPT_HEBREW | |
| 228 || fontDescription.script() == USCRIPT_ARABIC | |
| 229 || fontDescription.script() == USCRIPT_DEVANAGARI | |
| 230 || fontDescription.script() == USCRIPT_BENGALI | |
| 231 || fontDescription.script() == USCRIPT_GURMUKHI | |
| 232 || fontDescription.script() == USCRIPT_GUJARATI | |
| 233 || fontDescription.script() == USCRIPT_TAMIL | |
| 234 || fontDescription.script() == USCRIPT_TELUGU | |
| 235 || fontDescription.script() == USCRIPT_KANNADA | |
| 236 || fontDescription.script() == USCRIPT_GEORGIAN | |
| 237 || fontDescription.script() == USCRIPT_ARMENIAN | |
| 238 || fontDescription.script() == USCRIPT_THAANA | |
| 239 || fontDescription.script() == USCRIPT_CANADIAN_ABORIGINAL | |
| 240 || fontDescription.script() == USCRIPT_CHEROKEE | |
| 241 || fontDescription.script() == USCRIPT_MONGOLIAN)) { | |
| 242 result->setMinSizeForAntiAlias(s_minSizeForComplexScriptsAntiAlias); | |
| 243 } | 251 } |
| 244 | 252 |
| 245 return result; | 253 return result; |
| 246 } | 254 } |
| 247 | 255 |
| 248 } | 256 } |
| OLD | NEW |