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

Side by Side Diff: Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp

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 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 private: 73 private:
74 RefPtr<SharedBuffer> m_buffer; 74 RefPtr<SharedBuffer> m_buffer;
75 size_t m_offset; 75 size_t m_offset;
76 }; 76 };
77 #endif 77 #endif
78 78
79 FontCustomPlatformData::~FontCustomPlatformData() 79 FontCustomPlatformData::~FontCustomPlatformData()
80 { 80 {
81 #if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
82 if (m_atsContainer)
83 ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault);
84 #endif
85 #if USE(SKIA_ON_MAC_CHROMIUM) 81 #if USE(SKIA_ON_MAC_CHROMIUM)
86 SkSafeUnref(m_typeface); 82 SkSafeUnref(m_typeface);
87 #endif 83 #endif
88 CGFontRelease(m_cgFont); 84 CGFontRelease(m_cgFont);
89 } 85 }
90 86
91 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b ool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRend eringMode) 87 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b ool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRend eringMode)
92 { 88 {
93 return FontPlatformData(m_cgFont, size, bold, italic, orientation, widthVari ant); 89 return FontPlatformData(m_cgFont, size, bold, italic, orientation, widthVari ant);
94 } 90 }
(...skipping 17 matching lines...) Expand all
112 108
113 sfntBuffer = SharedBuffer::adoptVector(sfnt); 109 sfntBuffer = SharedBuffer::adoptVector(sfnt);
114 buffer = sfntBuffer.get(); 110 buffer = sfntBuffer.get();
115 } 111 }
116 #endif 112 #endif
117 113
118 ATSFontContainerRef containerRef = 0; 114 ATSFontContainerRef containerRef = 0;
119 115
120 RetainPtr<CGFontRef> cgFontRef; 116 RetainPtr<CGFontRef> cgFontRef;
121 117
122 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
123 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData()); 118 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData());
124 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithC FData(bufferData.get())); 119 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithC FData(bufferData.get()));
125 120
126 cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get())); 121 cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
127 if (!cgFontRef) 122 if (!cgFontRef)
128 return 0; 123 return 0;
129 #else
130 // Use ATS to activate the font.
131
132 // The value "3" means that the font is private and can't be seen by anyone else.
133 ATSFontActivateFromMemory((void*)buffer->data(), buffer->size(), 3, kATSFont FormatUnspecified, NULL, kATSOptionFlagsDefault, &containerRef);
134 if (!containerRef)
135 return 0;
136 ItemCount fontCount;
137 ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 0, NULL, &fon tCount);
138
139 // We just support the first font in the list.
140 if (fontCount == 0) {
141 ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
142 return 0;
143 }
144
145 ATSFontRef fontRef = 0;
146 ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL);
147 if (!fontRef) {
148 ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
149 return 0;
150 }
151
152 cgFontRef.adoptCF(CGFontCreateWithPlatformFont(&fontRef));
153 // Workaround for <rdar://problem/5675504>.
154 if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef.get()))
155 cgFontRef = 0;
156 if (!cgFontRef) {
157 ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
158 return 0;
159 }
160 #endif // PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
161 124
162 FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData( containerRef, cgFontRef.leakRef()); 125 FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData( containerRef, cgFontRef.leakRef());
163 #if USE(SKIA_ON_MAC_CHROMIUM) 126 #if USE(SKIA_ON_MAC_CHROMIUM)
164 RemoteFontStream* stream = new RemoteFontStream(buffer); 127 RemoteFontStream* stream = new RemoteFontStream(buffer);
165 fontCustomPlatformData->m_typeface = SkTypeface::CreateFromStream(stream); 128 fontCustomPlatformData->m_typeface = SkTypeface::CreateFromStream(stream);
166 stream->unref(); 129 stream->unref();
167 #endif 130 #endif
168 return fontCustomPlatformData; 131 return fontCustomPlatformData;
169 } 132 }
170 133
171 bool FontCustomPlatformData::supportsFormat(const String& format) 134 bool FontCustomPlatformData::supportsFormat(const String& format)
172 { 135 {
173 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || equalIgnoringCase(format, "woff"); 136 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || equalIgnoringCase(format, "woff");
174 } 137 }
175 138
176 } 139 }
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/mac/FontCacheMac.mm ('k') | Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698