OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkAdvancedTypefaceMetrics.h" | 8 #include "SkAdvancedTypefaceMetrics.h" |
9 #include "SkEndian.h" | |
10 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
11 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
12 #include "SkOTTable_OS_2.h" | |
13 #include "SkStream.h" | 11 #include "SkStream.h" |
14 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
15 | 13 |
16 //#define TRACE_LIFECYCLE | 14 //#define TRACE_LIFECYCLE |
17 | 15 |
18 #ifdef TRACE_LIFECYCLE | 16 #ifdef TRACE_LIFECYCLE |
19 static int32_t gTypefaceCounter; | 17 static int32_t gTypefaceCounter; |
20 #endif | 18 #endif |
21 | 19 |
22 SkTypeface::SkTypeface(Style style, SkFontID fontID, bool isFixedPitch) | 20 SkTypeface::SkTypeface(Style style, SkFontID fontID, bool isFixedPitch) |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 bool isLocal = false; | 252 bool isLocal = false; |
255 SkFontDescriptor desc(this->style()); | 253 SkFontDescriptor desc(this->style()); |
256 this->onGetFontDescriptor(&desc, &isLocal); | 254 this->onGetFontDescriptor(&desc, &isLocal); |
257 name->set(desc.getFamilyName()); | 255 name->set(desc.getFamilyName()); |
258 } | 256 } |
259 | 257 |
260 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( | 258 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( |
261 SkAdvancedTypefaceMetrics::PerGlyphInfo info, | 259 SkAdvancedTypefaceMetrics::PerGlyphInfo info, |
262 const uint32_t* glyphIDs, | 260 const uint32_t* glyphIDs, |
263 uint32_t glyphIDsCount) const { | 261 uint32_t glyphIDsCount) const { |
264 SkAdvancedTypefaceMetrics* result = | 262 return this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); |
265 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); | |
266 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { | |
267 struct SkOTTableOS2 os2table; | |
268 if (this->getTableData(SkEndian_SwapBE32(SkOTTableOS2::TAG), 0, | |
269 sizeof(os2table), &os2table) > 0) { | |
270 if (os2table.version.v2.fsType.field.Restricted || | |
271 os2table.version.v2.fsType.field.Bitmap) { | |
272 result->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>( | |
273 result->fFlags, | |
274 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); | |
275 } | |
276 if (os2table.version.v2.fsType.field.NoSubsetting) { | |
277 result->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>( | |
278 result->fFlags, | |
279 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag); | |
280 } | |
281 } | |
282 } | |
283 return result; | |
284 } | 263 } |
285 | 264 |
286 /////////////////////////////////////////////////////////////////////////////// | 265 /////////////////////////////////////////////////////////////////////////////// |
287 | 266 |
288 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count, | 267 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count, |
289 int32_t adjustments[]) const { | 268 int32_t adjustments[]) const { |
290 return false; | 269 return false; |
291 } | 270 } |
OLD | NEW |