| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::platformFallbackForCharacter(const FontDes
cription& 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::SimpleFontFamily family; |
| 56 FontCache::getFontFamilyForCharacter(c, locale.getLanguage(), &family); | 56 FontCache::getFontFamilyForCharacter(c, locale.getLanguage(), &family); |
| 57 if (family.name.isEmpty()) | 57 if (family.name.isEmpty()) |
| 58 return 0; | 58 return nullptr; |
| 59 | 59 |
| 60 AtomicString atomicFamily(family.name); | 60 AtomicString atomicFamily(family.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 (family.isBold && description.weight() < FontWeightBold) |
| 68 description.setWeight(FontWeightBold); | 68 description.setWeight(FontWeightBold); |
| 69 if (!family.isBold && description.weight() >= FontWeightBold) { | 69 if (!family.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.italic() == FontItalicOff) | 73 if (family.isItalic && description.italic() == FontItalicOff) |
| 74 description.setItalic(FontItalicOn); | 74 description.setItalic(FontItalicOn); |
| 75 if (!family.isItalic && description.italic() == FontItalicOn) { | 75 if (!family.isItalic && description.italic() == FontItalicOn) { |
| 76 shouldSetSyntheticItalic = true; | 76 shouldSetSyntheticItalic = true; |
| 77 description.setItalic(FontItalicOff); | 77 description.setItalic(FontItalicOff); |
| 78 } | 78 } |
| 79 | 79 |
| 80 FontPlatformData* substitutePlatformData = getFontPlatformData(description,
atomicFamily); | 80 FontPlatformData* substitutePlatformData = getFontPlatformData(description,
atomicFamily); |
| 81 if (!substitutePlatformData) | 81 if (!substitutePlatformData) |
| 82 return 0; | 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); |
| 86 return fontDataFromFontPlatformData(&platformData, DoNotRetain); | 86 return fontDataFromFontPlatformData(&platformData, DoNotRetain); |
| 87 } | 87 } |
| 88 | 88 |
| 89 #endif // !OS(WINDOWNS) && !OS(ANDROID) | 89 #endif // !OS(WINDOWNS) && !OS(ANDROID) |
| 90 | 90 |
| 91 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& description, ShouldRetain shouldRetain) | 91 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& description, ShouldRetain shouldRetain) |
| 92 { | 92 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 fontSize, | 163 fontSize, |
| 164 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes
cription.isSyntheticBold(), | 164 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes
cription.isSyntheticBold(), |
| 165 (fontDescription.italic() && !tf->isItalic()) || fontDescription.isSynth
eticItalic(), | 165 (fontDescription.italic() && !tf->isItalic()) || fontDescription.isSynth
eticItalic(), |
| 166 fontDescription.orientation(), | 166 fontDescription.orientation(), |
| 167 fontDescription.useSubpixelPositioning()); | 167 fontDescription.useSubpixelPositioning()); |
| 168 return result; | 168 return result; |
| 169 } | 169 } |
| 170 #endif // !OS(WINDOWNS) | 170 #endif // !OS(WINDOWNS) |
| 171 | 171 |
| 172 } // namespace WebCore | 172 } // namespace WebCore |
| OLD | NEW |