Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Side by Side Diff: Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm

Issue 13905007: Remove the last remaining PLATFORM() bits from WebCore. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fffffffffff Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * This file is part of the internal font implementation. 2 * This file is part of the internal font implementation.
3 * 3 *
4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
5 * Copyright (c) 2010 Google Inc. All rights reserved. 5 * Copyright (c) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 10 matching lines...) Expand all
21 * 21 *
22 */ 22 */
23 23
24 #import "config.h" 24 #import "config.h"
25 #import "FontPlatformData.h" 25 #import "FontPlatformData.h"
26 26
27 #import "WebCoreSystemInterface.h" 27 #import "WebCoreSystemInterface.h"
28 #import <AppKit/NSFont.h> 28 #import <AppKit/NSFont.h>
29 #import <wtf/text/WTFString.h> 29 #import <wtf/text/WTFString.h>
30 30
31 #if PLATFORM(CHROMIUM) && OS(DARWIN) 31 #if OS(DARWIN)
32 #import "HarfBuzzFace.h" 32 #import "HarfBuzzFace.h"
33 #endif 33 #endif
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 // These CoreText Text Spacing feature selectors are not defined in CoreText. 37 // These CoreText Text Spacing feature selectors are not defined in CoreText.
38 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth }; 38 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
39 39
40 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFon t, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontW idthVariant widthVariant) 40 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFon t, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontW idthVariant widthVariant)
41 : m_syntheticBold(syntheticBold) 41 : m_syntheticBold(syntheticBold)
42 , m_syntheticOblique(syntheticOblique) 42 , m_syntheticOblique(syntheticOblique)
43 , m_orientation(orientation) 43 , m_orientation(orientation)
44 , m_size(size) 44 , m_size(size)
45 , m_widthVariant(widthVariant) 45 , m_widthVariant(widthVariant)
46 , m_font(nsFont) 46 , m_font(nsFont)
47 , m_isColorBitmapFont(false) 47 , m_isColorBitmapFont(false)
48 , m_isCompositeFontReference(false) 48 , m_isCompositeFontReference(false)
49 , m_isPrinterFont(isPrinterFont) 49 , m_isPrinterFont(isPrinterFont)
50 { 50 {
51 ASSERT_ARG(nsFont, nsFont); 51 ASSERT_ARG(nsFont, nsFont);
52 52
53 CGFontRef cgFont = 0; 53 CGFontRef cgFont = 0;
54 loadFont(nsFont, size, m_font, cgFont); 54 loadFont(nsFont, size, m_font, cgFont);
55 55
56 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 56 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
57 // FIXME: Chromium: The following code isn't correct for the Chromium port s ince the sandbox might 57 // FIXME: Chromium: The following code isn't correct for the Chromium port s ince the sandbox might
58 // have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont(). 58 // have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont().
59 { 59 {
60 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font )); 60 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font ));
61 m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait; 61 m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
62 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 62 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
63 m_isCompositeFontReference = traits & kCTFontCompositeTrait; 63 m_isCompositeFontReference = traits & kCTFontCompositeTrait;
64 #endif 64 #endif
65 } 65 }
66 #endif 66 #endif
67 67
68 if (m_font) 68 if (m_font)
69 CFRetain(m_font); 69 CFRetain(m_font);
70 70
71 m_cgFont.adoptCF(cgFont); 71 m_cgFont.adoptCF(cgFont);
72 } 72 }
73 73
74 FontPlatformData:: ~FontPlatformData() 74 FontPlatformData:: ~FontPlatformData()
75 { 75 {
76 if (m_font && m_font != reinterpret_cast<NSFont *>(-1)) 76 if (m_font && m_font != reinterpret_cast<NSFont *>(-1))
77 CFRelease(m_font); 77 CFRelease(m_font);
78 } 78 }
79 79
80 void FontPlatformData::platformDataInit(const FontPlatformData& f) 80 void FontPlatformData::platformDataInit(const FontPlatformData& f)
81 { 81 {
82 m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? const_cast <NSFont *>(static_cast<const NSFont *>(CFRetain(f.m_font))) : f.m_font; 82 m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? const_cast <NSFont *>(static_cast<const NSFont *>(CFRetain(f.m_font))) : f.m_font;
83 83
84 m_cgFont = f.m_cgFont; 84 m_cgFont = f.m_cgFont;
85 m_CTFont = f.m_CTFont; 85 m_CTFont = f.m_CTFont;
86 86
87 #if PLATFORM(CHROMIUM) && OS(DARWIN) 87 #if OS(DARWIN)
88 m_inMemoryFont = f.m_inMemoryFont; 88 m_inMemoryFont = f.m_inMemoryFont;
89 m_harfBuzzFace = f.m_harfBuzzFace; 89 m_harfBuzzFace = f.m_harfBuzzFace;
90 #endif 90 #endif
91 } 91 }
92 92
93 const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformD ata& f) 93 const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformD ata& f)
94 { 94 {
95 m_cgFont = f.m_cgFont; 95 m_cgFont = f.m_cgFont;
96 if (m_font == f.m_font) 96 if (m_font == f.m_font)
97 return *this; 97 return *this;
98 if (f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1)) 98 if (f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1))
99 CFRetain(f.m_font); 99 CFRetain(f.m_font);
100 if (m_font && m_font != reinterpret_cast<NSFont *>(-1)) 100 if (m_font && m_font != reinterpret_cast<NSFont *>(-1))
101 CFRelease(m_font); 101 CFRelease(m_font);
102 m_font = f.m_font; 102 m_font = f.m_font;
103 m_CTFont = f.m_CTFont; 103 m_CTFont = f.m_CTFont;
104 #if PLATFORM(CHROMIUM) && OS(DARWIN) 104 #if OS(DARWIN)
105 m_inMemoryFont = f.m_inMemoryFont; 105 m_inMemoryFont = f.m_inMemoryFont;
106 m_harfBuzzFace = f.m_harfBuzzFace; 106 m_harfBuzzFace = f.m_harfBuzzFace;
107 #endif 107 #endif
108 return *this; 108 return *this;
109 } 109 }
110 110
111 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const 111 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
112 { 112 {
113 if (m_font || other.m_font) 113 if (m_font || other.m_font)
114 return m_font == other.m_font; 114 return m_font == other.m_font;
(...skipping 11 matching lines...) Expand all
126 CFRetain(font); 126 CFRetain(font);
127 if (m_font) 127 if (m_font)
128 CFRelease(m_font); 128 CFRelease(m_font);
129 m_font = font; 129 m_font = font;
130 m_size = [font pointSize]; 130 m_size = [font pointSize];
131 131
132 CGFontRef cgFont = 0; 132 CGFontRef cgFont = 0;
133 NSFont* loadedFont = 0; 133 NSFont* loadedFont = 0;
134 loadFont(m_font, m_size, loadedFont, cgFont); 134 loadFont(m_font, m_size, loadedFont, cgFont);
135 135
136 #if PLATFORM(CHROMIUM) && OS(DARWIN) 136 #if OS(DARWIN)
137 // If loadFont replaced m_font with a fallback font, then release the 137 // If loadFont replaced m_font with a fallback font, then release the
138 // previous font to counter the retain above. Then retain the new font. 138 // previous font to counter the retain above. Then retain the new font.
139 if (loadedFont != m_font) { 139 if (loadedFont != m_font) {
140 CFRelease(m_font); 140 CFRelease(m_font);
141 CFRetain(loadedFont); 141 CFRetain(loadedFont);
142 m_font = loadedFont; 142 m_font = loadedFont;
143 } 143 }
144 #endif 144 #endif
145 145
146 m_cgFont.adoptCF(cgFont); 146 m_cgFont.adoptCF(cgFont);
147 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 147 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
148 { 148 {
149 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font )); 149 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font ));
150 m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait; 150 m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
151 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 151 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
152 m_isCompositeFontReference = traits & kCTFontCompositeTrait; 152 m_isCompositeFontReference = traits & kCTFontCompositeTrait;
153 #endif 153 #endif
154 } 154 }
155 #endif 155 #endif
156 m_CTFont = 0; 156 m_CTFont = 0;
157 } 157 }
158 158
159 bool FontPlatformData::roundsGlyphAdvances() const 159 bool FontPlatformData::roundsGlyphAdvances() const
160 { 160 {
161 return [m_font renderingMode] == NSFontAntialiasedIntegerAdvancementsRenderi ngMode; 161 return [m_font renderingMode] == NSFontAntialiasedIntegerAdvancementsRenderi ngMode;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocat orDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 230 RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocat orDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
231 231
232 descriptor = CTFontDescriptorCreateCopyWithAttributes(cascadeToLastResortFon tDescriptor(), attributes.get()); 232 descriptor = CTFontDescriptorCreateCopyWithAttributes(cascadeToLastResortFon tDescriptor(), attributes.get());
233 233
234 return descriptor; 234 return descriptor;
235 } 235 }
236 236
237 // Adding a cascade list breaks the font on Leopard 237 // Adding a cascade list breaks the font on Leopard
238 static bool canSetCascadeListForCustomFont() 238 static bool canSetCascadeListForCustomFont()
239 { 239 {
240 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 240 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
241 return true; 241 return true;
242 #else 242 #else
243 return false; 243 return false;
244 #endif 244 #endif
245 } 245 }
246 246
247 CTFontRef FontPlatformData::ctFont() const 247 CTFontRef FontPlatformData::ctFont() const
248 { 248 {
249 if (m_CTFont) 249 if (m_CTFont)
250 return m_CTFont.get(); 250 return m_CTFont.get();
(...skipping 25 matching lines...) Expand all
276 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et())); 276 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et()));
277 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_size, 0)); 277 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_size, 0));
278 278
279 if (newFont) 279 if (newFont)
280 m_CTFont = newFont; 280 m_CTFont = newFont;
281 } 281 }
282 282
283 return m_CTFont.get(); 283 return m_CTFont.get();
284 } 284 }
285 285
286 #if PLATFORM(CHROMIUM) && OS(DARWIN) 286 #if OS(DARWIN)
287 static bool isAATFont(CTFontRef ctFont) 287 static bool isAATFont(CTFontRef ctFont)
288 { 288 {
289 CFDataRef table = CTFontCopyTable(ctFont, kCTFontTableMort, 0); 289 CFDataRef table = CTFontCopyTable(ctFont, kCTFontTableMort, 0);
290 if (table) { 290 if (table) {
291 CFRelease(table); 291 CFRelease(table);
292 return true; 292 return true;
293 } 293 }
294 table = CTFontCopyTable(ctFont, kCTFontTableMorx, 0); 294 table = CTFontCopyTable(ctFont, kCTFontTableMorx, 0);
295 if (table) { 295 if (table) {
296 CFRelease(table); 296 CFRelease(table);
(...skipping 20 matching lines...) Expand all
317 #ifndef NDEBUG 317 #ifndef NDEBUG
318 String FontPlatformData::description() const 318 String FontPlatformData::description() const
319 { 319 {
320 RetainPtr<CFStringRef> cgFontDescription(AdoptCF, CFCopyDescription(cgFont() )); 320 RetainPtr<CFStringRef> cgFontDescription(AdoptCF, CFCopyDescription(cgFont() ));
321 return String(cgFontDescription.get()) + " " + String::number(m_size) 321 return String(cgFontDescription.get()) + " " + String::number(m_size)
322 + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ? " synthetic oblique" : "") + (m_orientation ? " vertical orientation" : ""); 322 + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ? " synthetic oblique" : "") + (m_orientation ? " vertical orientation" : "");
323 } 323 }
324 #endif 324 #endif
325 325
326 } // namespace WebCore 326 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698