| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 142 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 143 | 143 |
| 144 NSFontTraitMask traits; | 144 NSFontTraitMask traits; |
| 145 NSInteger weight; | 145 NSInteger weight; |
| 146 CGFloat size; | 146 CGFloat size; |
| 147 | 147 |
| 148 if (nsFont) { | 148 if (nsFont) { |
| 149 traits = [fontManager traitsOfFont:nsFont]; | 149 traits = [fontManager traitsOfFont:nsFont]; |
| 150 if (platformData.m_syntheticBold) | 150 if (platformData.m_syntheticBold) |
| 151 traits |= NSBoldFontMask; | 151 traits |= NSBoldFontMask; |
| 152 if (platformData.m_syntheticItalic) | 152 if (platformData.m_syntheticOblique) |
| 153 traits |= NSFontItalicTrait; | 153 traits |= NSFontItalicTrait; |
| 154 weight = [fontManager weightOfFont:nsFont]; | 154 weight = [fontManager weightOfFont:nsFont]; |
| 155 size = [nsFont pointSize]; | 155 size = [nsFont pointSize]; |
| 156 } else { | 156 } else { |
| 157 // For custom fonts nsFont is nil. | 157 // For custom fonts nsFont is nil. |
| 158 traits = fontDescription.style() ? NSFontItalicTrait : 0; | 158 traits = fontDescription.style() ? NSFontItalicTrait : 0; |
| 159 weight = toAppKitFontWeight(fontDescription.weight()); | 159 weight = toAppKitFontWeight(fontDescription.weight()); |
| 160 size = fontDescription.computedPixelSize(); | 160 size = fontDescription.computedPixelSize(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteF
ont]; | 163 NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteF
ont]; |
| 164 NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont]; | 164 NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont]; |
| 165 | 165 |
| 166 if (traits != substituteFontTraits || weight != substituteFontWeight || !nsF
ont) { | 166 if (traits != substituteFontTraits || weight != substituteFontWeight || !nsF
ont) { |
| 167 if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont
familyName] traits:traits weight:weight size:size]) { | 167 if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont
familyName] traits:traits weight:weight size:size]) { |
| 168 if ((!nsFont || [fontManager traitsOfFont:bestVariation] != substitu
teFontTraits || [fontManager weightOfFont:bestVariation] != substituteFontWeight
) | 168 if ((!nsFont || [fontManager traitsOfFont:bestVariation] != substitu
teFontTraits || [fontManager weightOfFont:bestVariation] != substituteFontWeight
) |
| 169 && [[bestVariation coveredCharacterSet] longCharacterIsMember:ch
aracter]) | 169 && [[bestVariation coveredCharacterSet] longCharacterIsMember:ch
aracter]) |
| 170 substituteFont = bestVariation; | 170 substituteFont = bestVariation; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 substituteFont = useHinting() ? [substituteFont screenFont] : [substituteFon
t printerFont]; | 174 substituteFont = useHinting() ? [substituteFont screenFont] : [substituteFon
t printerFont]; |
| 175 | 175 |
| 176 substituteFontTraits = [fontManager traitsOfFont:substituteFont]; | 176 substituteFontTraits = [fontManager traitsOfFont:substituteFont]; |
| 177 substituteFontWeight = [fontManager weightOfFont:substituteFont]; | 177 substituteFontWeight = [fontManager weightOfFont:substituteFont]; |
| 178 | 178 |
| 179 FontPlatformData alternateFont(substituteFont, platformData.size(), | 179 FontPlatformData alternateFont(substituteFont, platformData.size(), |
| 180 isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFont
Weight), | 180 isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFont
Weight), |
| 181 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), | 181 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), |
| 182 platformData.orientation()); | 182 platformData.m_orientation); |
| 183 | 183 |
| 184 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); | 184 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); |
| 185 } | 185 } |
| 186 | 186 |
| 187 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) | 187 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) |
| 188 { | 188 { |
| 189 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::Construc
tFromLiteral)); | 189 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::Construc
tFromLiteral)); |
| 190 | 190 |
| 191 // FIXME: Would be even better to somehow get the user's default font here.
For now we'll pick | 191 // FIXME: Would be even better to somehow get the user's default font here.
For now we'll pick |
| 192 // the default that the user would get without changing any prefs. | 192 // the default that the user would get without changing any prefs. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 213 return 0; | 213 return 0; |
| 214 | 214 |
| 215 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 215 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 216 NSFontTraitMask actualTraits = 0; | 216 NSFontTraitMask actualTraits = 0; |
| 217 if (fontDescription.style()) | 217 if (fontDescription.style()) |
| 218 actualTraits = [fontManager traitsOfFont:nsFont]; | 218 actualTraits = [fontManager traitsOfFont:nsFont]; |
| 219 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; | 219 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; |
| 220 | 220 |
| 221 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; | 221 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; |
| 222 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); | 222 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); |
| 223 bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSF
ontItalicTrait)) || fontDescription.isSyntheticItalic(); | 223 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS
FontItalicTrait)) || fontDescription.isSyntheticItalic(); |
| 224 | 224 |
| 225 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. | 225 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. |
| 226 // In that case, we don't want to use the platformData. | 226 // In that case, we don't want to use the platformData. |
| 227 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation(), fon
tDescription.widthVariant())); | 227 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticOblique, fontDescription.orientation(), fo
ntDescription.widthVariant())); |
| 228 if (!platformData->font()) | 228 if (!platformData->font()) |
| 229 return 0; | 229 return 0; |
| 230 return platformData.leakPtr(); | 230 return platformData.leakPtr(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |