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" | 9 #include "SkEndian.h" |
10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 this->onGetFamilyName(name); | 284 this->onGetFamilyName(name); |
285 } | 285 } |
286 | 286 |
287 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( | 287 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( |
288 PerGlyphInfo info, | 288 PerGlyphInfo info, |
289 const uint32_t* glyphIDs, | 289 const uint32_t* glyphIDs, |
290 uint32_t glyphIDsCount) const { | 290 uint32_t glyphIDsCount) const { |
291 SkAdvancedTypefaceMetrics* result = | 291 SkAdvancedTypefaceMetrics* result = |
292 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); | 292 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); |
293 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { | 293 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { |
294 struct SkOTTableOS2 os2table; | 294 SkOTTableOS2::Version::V2::Type::Field fsType; |
295 if (this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), 0, | 295 constexpr SkFontTableTag os2Tag = SkTEndian_SwapBE32(SkOTTableOS2::TAG); |
296 sizeof(os2table), &os2table) > 0) { | 296 constexpr size_t fsTypeOffset = offsetof(SkOTTableOS2::Version::V2, fsTy
pe); |
297 if (os2table.version.v2.fsType.field.Bitmap || | 297 if (this->getTableData(os2Tag, fsTypeOffset, sizeof(fsType), &fsType) ==
sizeof(fsType)) { |
298 (os2table.version.v2.fsType.field.Restricted && | 298 if (fsType.Bitmap || (fsType.Restricted && !(fsType.PreviewPrint ||
fsType.Editable))) { |
299 !(os2table.version.v2.fsType.field.PreviewPrint || | |
300 os2table.version.v2.fsType.field.Editable))) { | |
301 result->fFlags |= SkAdvancedTypefaceMetrics::kNotEmbeddable_Font
Flag; | 299 result->fFlags |= SkAdvancedTypefaceMetrics::kNotEmbeddable_Font
Flag; |
302 } | 300 } |
303 if (os2table.version.v2.fsType.field.NoSubsetting) { | 301 if (fsType.NoSubsetting) { |
304 result->fFlags |= SkAdvancedTypefaceMetrics::kNotSubsettable_Fon
tFlag; | 302 result->fFlags |= SkAdvancedTypefaceMetrics::kNotSubsettable_Fon
tFlag; |
305 } | 303 } |
306 } | 304 } |
307 } | 305 } |
308 return result; | 306 return result; |
309 } | 307 } |
310 | 308 |
311 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count, | 309 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count, |
312 int32_t adjustments[]) const { | 310 int32_t adjustments[]) const { |
313 return false; | 311 return false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(noeffects, desc
, true)); | 348 SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(noeffects, desc
, true)); |
351 if (ctx.get()) { | 349 if (ctx.get()) { |
352 SkPaint::FontMetrics fm; | 350 SkPaint::FontMetrics fm; |
353 ctx->getFontMetrics(&fm); | 351 ctx->getFontMetrics(&fm); |
354 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, | 352 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, |
355 fm.fXMax * invTextSize, fm.fBottom * invTextSize); | 353 fm.fXMax * invTextSize, fm.fBottom * invTextSize); |
356 return true; | 354 return true; |
357 } | 355 } |
358 return false; | 356 return false; |
359 } | 357 } |
OLD | NEW |