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 #include "platform/LayoutTestSupport.h" | 34 #import "platform/LayoutTestSupport.h" |
35 #include "platform/RuntimeEnabledFeatures.h" | 35 #import "platform/RuntimeEnabledFeatures.h" |
36 #include "platform/fonts/FontDescription.h" | 36 #import "platform/fonts/FontDescription.h" |
37 #include "platform/fonts/FontFaceCreationParams.h" | 37 #import "platform/fonts/FontFaceCreationParams.h" |
38 #include "platform/fonts/FontPlatformData.h" | 38 #import "platform/fonts/FontPlatformData.h" |
39 #include "platform/fonts/SimpleFontData.h" | 39 #import "platform/fonts/SimpleFontData.h" |
40 #include "platform/fonts/mac/FontFamilyMatcherMac.h" | 40 #import "platform/fonts/mac/FontFamilyMatcherMac.h" |
41 #include "public/platform/Platform.h" | 41 #import "public/platform/Platform.h" |
42 #include "public/platform/WebTraceLocation.h" | 42 #import "public/platform/WebTraceLocation.h" |
43 #include <wtf/Functional.h> | 43 #import <wtf/Functional.h> |
44 #include <wtf/MainThread.h> | 44 #import <wtf/MainThread.h> |
45 #include <wtf/StdLibExtras.h> | 45 #import <wtf/StdLibExtras.h> |
46 | 46 |
47 // Forward declare Mac SPIs. | 47 // Forward declare Mac SPIs. |
48 // Request for public API: rdar://13803570 | 48 // Request for public API: rdar://13803570 |
49 @interface NSFont (WebKitSPI) | 49 @interface NSFont (WebKitSPI) |
50 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; | 50 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; |
51 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us
eNil; | 51 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us
eNil; |
52 @end | 52 @end |
53 | 53 |
54 namespace blink { | 54 namespace blink { |
55 | 55 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (character <= 0xFFFF) { | 112 if (character <= 0xFFFF) { |
113 codeUnits[0] = character; | 113 codeUnits[0] = character; |
114 codeUnitsLength = 1; | 114 codeUnitsLength = 1; |
115 } else { | 115 } else { |
116 codeUnits[0] = U16_LEAD(character); | 116 codeUnits[0] = U16_LEAD(character); |
117 codeUnits[1] = U16_TRAIL(character); | 117 codeUnits[1] = U16_TRAIL(character); |
118 codeUnitsLength = 2; | 118 codeUnitsLength = 2; |
119 } | 119 } |
120 | 120 |
121 const FontPlatformData& platformData = fontDataToSubstitute->platformData(); | 121 const FontPlatformData& platformData = fontDataToSubstitute->platformData(); |
122 NSFont* nsFont = toNSFont(platformData.ctFont()); | 122 NSFont *nsFont = platformData.font(); |
123 | 123 |
124 NSString *string = [[NSString alloc] initWithCharactersNoCopy:codeUnits leng
th:codeUnitsLength freeWhenDone:NO]; | 124 NSString *string = [[NSString alloc] initWithCharactersNoCopy:codeUnits leng
th:codeUnitsLength freeWhenDone:NO]; |
125 NSFont *substituteFont = [NSFont findFontLike:nsFont forString:string withRa
nge:NSMakeRange(0, codeUnitsLength) inLanguage:nil]; | 125 NSFont *substituteFont = [NSFont findFontLike:nsFont forString:string withRa
nge:NSMakeRange(0, codeUnitsLength) inLanguage:nil]; |
126 [string release]; | 126 [string release]; |
127 | 127 |
128 // FIXME: Remove this SPI usage: http://crbug.com/255122 | 128 // FIXME: Remove this SPI usage: http://crbug.com/255122 |
129 if (!substituteFont && codeUnitsLength == 1) | 129 if (!substituteFont && codeUnitsLength == 1) |
130 substituteFont = [NSFont findFontLike:nsFont forCharacter:codeUnits[0] i
nLanguage:nil]; | 130 substituteFont = [NSFont findFontLike:nsFont forCharacter:codeUnits[0] i
nLanguage:nil]; |
131 if (!substituteFont) | 131 if (!substituteFont) |
132 return nullptr; | 132 return nullptr; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 213 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
214 NSFontTraitMask actualTraits = 0; | 214 NSFontTraitMask actualTraits = 0; |
215 if (fontDescription.style()) | 215 if (fontDescription.style()) |
216 actualTraits = [fontManager traitsOfFont:nsFont]; | 216 actualTraits = [fontManager traitsOfFont:nsFont]; |
217 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; | 217 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; |
218 | 218 |
219 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; | 219 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; |
220 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); | 220 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); |
221 bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSF
ontItalicTrait)) || fontDescription.isSyntheticItalic(); | 221 bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSF
ontItalicTrait)) || fontDescription.isSyntheticItalic(); |
222 | 222 |
223 // FontPlatformData::typeface() is null in the case of Chromium out-of-proce
ss font loading failing. | 223 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. |
224 // Out-of-process loading occurs for registered fonts stored in non-system l
ocations. | 224 // In that case, we don't want to use the platformData. |
225 // When loading fails, we do not want to use the returned FontPlatformData s
ince it will not have | |
226 // a valid SkTypeface. | |
227 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); | 225 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); |
228 if (!platformData->typeface()) { | 226 if (!platformData->font()) |
229 return nullptr; | 227 return 0; |
230 } | |
231 return platformData.leakPtr(); | 228 return platformData.leakPtr(); |
232 } | 229 } |
233 | 230 |
234 } // namespace blink | 231 } // namespace blink |
OLD | NEW |