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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "wtf/text/CString.h" | 42 #include "wtf/text/CString.h" |
43 #include <unicode/locid.h> | 43 #include <unicode/locid.h> |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 void FontCache::platformInit() | 47 void FontCache::platformInit() |
48 { | 48 { |
49 } | 49 } |
50 | 50 |
51 #if !OS(WIN) && !OS(ANDROID) | 51 #if !OS(WIN) && !OS(ANDROID) |
52 PassRefPtr<SimpleFontData> FontCache::platformFallbackForCharacter(const FontDes
cription& fontDescription, UChar32 c, const SimpleFontData*) | 52 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip
tion& fontDescription, UChar32 c, const SimpleFontData*) |
53 { | 53 { |
54 icu::Locale locale = icu::Locale::getDefault(); | 54 icu::Locale locale = icu::Locale::getDefault(); |
55 FontCache::SimpleFontFamily family; | 55 FontCache::PlatformFallbackFont fallbackFont; |
56 FontCache::getFontFamilyForCharacter(c, locale.getLanguage(), &family); | 56 FontCache::getFontForCharacter(c, locale.getLanguage(), &fallbackFont); |
57 if (family.name.isEmpty()) | 57 if (fallbackFont.name.isEmpty()) |
58 return nullptr; | 58 return nullptr; |
59 | 59 |
60 AtomicString atomicFamily(family.name); | 60 AtomicString atomicFamily(fallbackFont.name); |
61 // Changes weight and/or italic of given FontDescription depends on | 61 // Changes weight and/or italic of given FontDescription depends on |
62 // the result of fontconfig so that keeping the correct font mapping | 62 // the result of fontconfig so that keeping the correct font mapping |
63 // of the given character. See http://crbug.com/32109 for details. | 63 // of the given character. See http://crbug.com/32109 for details. |
64 bool shouldSetSyntheticBold = false; | 64 bool shouldSetSyntheticBold = false; |
65 bool shouldSetSyntheticItalic = false; | 65 bool shouldSetSyntheticItalic = false; |
66 FontDescription description(fontDescription); | 66 FontDescription description(fontDescription); |
67 if (family.isBold && description.weight() < FontWeightBold) | 67 if (fallbackFont.isBold && description.weight() < FontWeightBold) |
68 description.setWeight(FontWeightBold); | 68 description.setWeight(FontWeightBold); |
69 if (!family.isBold && description.weight() >= FontWeightBold) { | 69 if (!fallbackFont.isBold && description.weight() >= FontWeightBold) { |
70 shouldSetSyntheticBold = true; | 70 shouldSetSyntheticBold = true; |
71 description.setWeight(FontWeightNormal); | 71 description.setWeight(FontWeightNormal); |
72 } | 72 } |
73 if (family.isItalic && description.style() == FontStyleNormal) | 73 if (fallbackFont.isItalic && description.style() == FontStyleNormal) |
74 description.setStyle(FontStyleItalic); | 74 description.setStyle(FontStyleItalic); |
75 if (!family.isItalic && description.style() == FontStyleItalic) { | 75 if (!fallbackFont.isItalic && description.style() == FontStyleItalic) { |
76 shouldSetSyntheticItalic = true; | 76 shouldSetSyntheticItalic = true; |
77 description.setStyle(FontStyleNormal); | 77 description.setStyle(FontStyleNormal); |
78 } | 78 } |
79 | 79 |
80 FontPlatformData* substitutePlatformData = getFontPlatformData(description,
atomicFamily); | 80 FontPlatformData* substitutePlatformData = getFontPlatformData(description,
atomicFamily); |
81 if (!substitutePlatformData) | 81 if (!substitutePlatformData) |
82 return nullptr; | 82 return nullptr; |
83 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); | 83 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); |
84 platformData.setSyntheticBold(shouldSetSyntheticBold); | 84 platformData.setSyntheticBold(shouldSetSyntheticBold); |
85 platformData.setSyntheticItalic(shouldSetSyntheticItalic); | 85 platformData.setSyntheticItalic(shouldSetSyntheticItalic); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 fontSize, | 152 fontSize, |
153 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes
cription.isSyntheticBold(), | 153 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes
cription.isSyntheticBold(), |
154 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe
ticItalic(), | 154 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe
ticItalic(), |
155 fontDescription.orientation(), | 155 fontDescription.orientation(), |
156 fontDescription.useSubpixelPositioning()); | 156 fontDescription.useSubpixelPositioning()); |
157 return result; | 157 return result; |
158 } | 158 } |
159 #endif // !OS(WIN) | 159 #endif // !OS(WIN) |
160 | 160 |
161 } // namespace WebCore | 161 } // namespace WebCore |
OLD | NEW |