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 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 protected: | 29 protected: |
30 SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } | 30 SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } |
31 | 31 |
32 SkStreamAsset* onOpenStream(int* ttcIndex) const override { return NULL; } | 32 SkStreamAsset* onOpenStream(int* ttcIndex) const override { return NULL; } |
33 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override { | 33 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override { |
34 return NULL; | 34 return NULL; |
35 } | 35 } |
36 void onFilterRec(SkScalerContextRec*) const override { } | 36 void onFilterRec(SkScalerContextRec*) const override { } |
37 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 37 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
38 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 38 PerGlyphInfo, |
39 const uint32_t*, uint32_t) const override { retu
rn NULL; } | 39 const uint32_t*, uint32_t) const override { retu
rn NULL; } |
40 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { } | 40 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { } |
41 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, | 41 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
42 uint16_t glyphs[], int glyphCount) const overrid
e { | 42 uint16_t glyphs[], int glyphCount) const overrid
e { |
43 if (glyphs && glyphCount > 0) { | 43 if (glyphs && glyphCount > 0) { |
44 sk_bzero(glyphs, glyphCount * sizeof(glyphs[0])); | 44 sk_bzero(glyphs, glyphCount * sizeof(glyphs[0])); |
45 } | 45 } |
46 return 0; | 46 return 0; |
47 } | 47 } |
48 int onCountGlyphs() const override { return 0; }; | 48 int onCountGlyphs() const override { return 0; }; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 SkTypeface::LocalizedStrings* SkTypeface::createFamilyNameIterator() const { | 258 SkTypeface::LocalizedStrings* SkTypeface::createFamilyNameIterator() const { |
259 return this->onCreateFamilyNameIterator(); | 259 return this->onCreateFamilyNameIterator(); |
260 } | 260 } |
261 | 261 |
262 void SkTypeface::getFamilyName(SkString* name) const { | 262 void SkTypeface::getFamilyName(SkString* name) const { |
263 SkASSERT(name); | 263 SkASSERT(name); |
264 this->onGetFamilyName(name); | 264 this->onGetFamilyName(name); |
265 } | 265 } |
266 | 266 |
267 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( | 267 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( |
268 SkAdvancedTypefaceMetrics::PerGlyphInfo info, | 268 PerGlyphInfo info, |
269 const uint32_t* glyphIDs, | 269 const uint32_t* glyphIDs, |
270 uint32_t glyphIDsCount) const { | 270 uint32_t glyphIDsCount) const { |
271 SkAdvancedTypefaceMetrics* result = | 271 SkAdvancedTypefaceMetrics* result = |
272 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); | 272 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); |
273 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { | 273 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { |
274 struct SkOTTableOS2 os2table; | 274 struct SkOTTableOS2 os2table; |
275 if (this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), 0, | 275 if (this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), 0, |
276 sizeof(os2table), &os2table) > 0) { | 276 sizeof(os2table), &os2table) > 0) { |
277 if (os2table.version.v2.fsType.field.Bitmap || | 277 if (os2table.version.v2.fsType.field.Bitmap || |
278 (os2table.version.v2.fsType.field.Restricted && | 278 (os2table.version.v2.fsType.field.Restricted && |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (ctx.get()) { | 343 if (ctx.get()) { |
344 SkPaint::FontMetrics fm; | 344 SkPaint::FontMetrics fm; |
345 ctx->getFontMetrics(&fm); | 345 ctx->getFontMetrics(&fm); |
346 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, | 346 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, |
347 fm.fXMax * invTextSize, fm.fBottom * invTextSize); | 347 fm.fXMax * invTextSize, fm.fBottom * invTextSize); |
348 return true; | 348 return true; |
349 } | 349 } |
350 return false; | 350 return false; |
351 } | 351 } |
352 | 352 |
OLD | NEW |