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 13 matching lines...) Expand all Loading... |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #import "config.h" | 30 #import "config.h" |
31 #import "platform/fonts/FontCache.h" | 31 #import "platform/fonts/FontCache.h" |
32 | 32 |
33 #import <AppKit/AppKit.h> | 33 #import <AppKit/AppKit.h> |
| 34 #import "platform/LayoutTestSupport.h" |
34 #import "platform/fonts/FontDescription.h" | 35 #import "platform/fonts/FontDescription.h" |
35 #import "platform/fonts/FontPlatformData.h" | 36 #import "platform/fonts/FontPlatformData.h" |
36 #import "platform/fonts/SimpleFontData.h" | 37 #import "platform/fonts/SimpleFontData.h" |
37 #import "platform/mac/WebFontCache.h" | 38 #import "platform/mac/WebFontCache.h" |
38 #import <wtf/MainThread.h> | 39 #import <wtf/MainThread.h> |
39 #import <wtf/StdLibExtras.h> | 40 #import <wtf/StdLibExtras.h> |
40 | 41 |
41 // Forward declare Mac SPIs. | 42 // Forward declare Mac SPIs. |
42 // Request for public API: rdar://13803570 | 43 // Request for public API: rdar://13803570 |
43 @interface NSFont (WebKitSPI) | 44 @interface NSFont (WebKitSPI) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont]; | 154 NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont]; |
154 | 155 |
155 if (traits != substituteFontTraits || weight != substituteFontWeight || !nsF
ont) { | 156 if (traits != substituteFontTraits || weight != substituteFontWeight || !nsF
ont) { |
156 if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont
familyName] traits:traits weight:weight size:size]) { | 157 if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont
familyName] traits:traits weight:weight size:size]) { |
157 if (!nsFont || (([fontManager traitsOfFont:bestVariation] != substit
uteFontTraits || [fontManager weightOfFont:bestVariation] != substituteFontWeigh
t) | 158 if (!nsFont || (([fontManager traitsOfFont:bestVariation] != substit
uteFontTraits || [fontManager weightOfFont:bestVariation] != substituteFontWeigh
t) |
158 && [[bestVariation coveredCharacterSet] longCharacterIsMember:ch
aracter])) | 159 && [[bestVariation coveredCharacterSet] longCharacterIsMember:ch
aracter])) |
159 substituteFont = bestVariation; | 160 substituteFont = bestVariation; |
160 } | 161 } |
161 } | 162 } |
162 | 163 |
163 substituteFont = fontDescription.usePrinterFont() ? [substituteFont printerF
ont] : [substituteFont screenFont]; | 164 // Enable hinting, which is equivalent to using the screen font, |
| 165 // only when running the set of standard non-subpixel layout tests, |
| 166 // otherwise use subpixel glyph positioning. |
| 167 substituteFont = !isRunningLayoutTest() || isFontAntialiasingEnabledForTest(
) ? [substituteFont printerFont] : [substituteFont screenFont]; |
164 | 168 |
165 substituteFontTraits = [fontManager traitsOfFont:substituteFont]; | 169 substituteFontTraits = [fontManager traitsOfFont:substituteFont]; |
166 substituteFontWeight = [fontManager weightOfFont:substituteFont]; | 170 substituteFontWeight = [fontManager weightOfFont:substituteFont]; |
167 | 171 |
168 FontPlatformData alternateFont(substituteFont, platformData.size(), platform
Data.isPrinterFont(), | 172 FontPlatformData alternateFont(substituteFont, platformData.size(), |
169 isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFont
Weight), | 173 isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFont
Weight), |
170 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), | 174 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), |
171 platformData.m_orientation); | 175 platformData.m_orientation); |
172 | 176 |
173 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); | 177 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); |
174 } | 178 } |
175 | 179 |
176 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) | 180 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) |
177 { | 181 { |
178 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::Construc
tFromLiteral)); | 182 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::Construc
tFromLiteral)); |
(...skipping 21 matching lines...) Expand all Loading... |
200 NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:we
ight size:size]; | 204 NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:we
ight size:size]; |
201 if (!nsFont) | 205 if (!nsFont) |
202 return 0; | 206 return 0; |
203 | 207 |
204 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 208 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
205 NSFontTraitMask actualTraits = 0; | 209 NSFontTraitMask actualTraits = 0; |
206 if (fontDescription.style()) | 210 if (fontDescription.style()) |
207 actualTraits = [fontManager traitsOfFont:nsFont]; | 211 actualTraits = [fontManager traitsOfFont:nsFont]; |
208 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; | 212 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; |
209 | 213 |
210 NSFont *platformFont = fontDescription.usePrinterFont() ? [nsFont printerFon
t] : [nsFont screenFont]; | 214 // Enable hinting, which is equivalent to using the screen font, |
| 215 // only when running the set of standard non-subpixel layout tests, |
| 216 // otherwise use subpixel glyph positioning. |
| 217 NSFont *platformFont = !isRunningLayoutTest() || isFontAntialiasingEnabledFo
rTest() ? [nsFont printerFont] : [nsFont screenFont]; |
211 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); | 218 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); |
212 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS
FontItalicTrait)) || fontDescription.isSyntheticItalic(); | 219 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS
FontItalicTrait)) || fontDescription.isSyntheticItalic(); |
213 | 220 |
214 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. | 221 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. |
215 // In that case, we don't want to use the platformData. | 222 // In that case, we don't want to use the platformData. |
216 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique,
fontDescription.orientation(), fontDescription.widthVariant())); | 223 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticOblique, fontDescription.orientation(), fo
ntDescription.widthVariant())); |
217 if (!platformData->font()) | 224 if (!platformData->font()) |
218 return 0; | 225 return 0; |
219 return platformData.leakPtr(); | 226 return platformData.leakPtr(); |
220 } | 227 } |
221 | 228 |
222 } // namespace WebCore | 229 } // namespace WebCore |
OLD | NEW |