| 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" |
| 11 #include "SkFontMgr.h" | 11 #include "SkFontMgr.h" |
| 12 #include "SkLazyPtr.h" | 12 #include "SkLazyPtr.h" |
| 13 #include "SkOTTable_OS_2.h" | 13 #include "SkOTTable_OS_2.h" |
| 14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
| 16 | 16 |
| 17 SkTypeface::SkTypeface(const SkFontStyle& style, SkFontID fontID, bool isFixedPi
tch) | 17 SkTypeface::SkTypeface(const SkFontStyle& style, SkFontID fontID, bool isFixedPi
tch) |
| 18 : fUniqueID(fontID), fStyle(style), fIsFixedPitch(isFixedPitch) { } | 18 : fUniqueID(fontID), fStyle(style), fIsFixedPitch(isFixedPitch) { } |
| 19 | 19 |
| 20 SkTypeface::~SkTypeface() { } | 20 SkTypeface::~SkTypeface() { } |
| 21 | 21 |
| 22 |
| 23 SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = NULL
; |
| 24 |
| 22 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
| 23 | 26 |
| 24 class SkEmptyTypeface : public SkTypeface { | 27 class SkEmptyTypeface : public SkTypeface { |
| 25 public: | 28 public: |
| 26 static SkEmptyTypeface* Create() { | 29 static SkEmptyTypeface* Create() { |
| 27 return SkNEW(SkEmptyTypeface); | 30 return SkNEW(SkEmptyTypeface); |
| 28 } | 31 } |
| 29 protected: | 32 protected: |
| 30 SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } | 33 SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } |
| 31 | 34 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return face->uniqueID(); | 106 return face->uniqueID(); |
| 104 } | 107 } |
| 105 | 108 |
| 106 bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { | 109 bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { |
| 107 return SkTypeface::UniqueID(facea) == SkTypeface::UniqueID(faceb); | 110 return SkTypeface::UniqueID(facea) == SkTypeface::UniqueID(faceb); |
| 108 } | 111 } |
| 109 | 112 |
| 110 /////////////////////////////////////////////////////////////////////////////// | 113 /////////////////////////////////////////////////////////////////////////////// |
| 111 | 114 |
| 112 SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) { | 115 SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) { |
| 116 if (gCreateTypefaceDelegate) { |
| 117 SkTypeface* result = (*gCreateTypefaceDelegate)(name, style); |
| 118 if (result) { |
| 119 return result; |
| 120 } |
| 121 } |
| 113 if (NULL == name) { | 122 if (NULL == name) { |
| 114 return RefDefault(style); | 123 return RefDefault(style); |
| 115 } | 124 } |
| 116 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 125 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 117 return fm->legacyCreateTypeface(name, style); | 126 return fm->legacyCreateTypeface(name, style); |
| 118 } | 127 } |
| 119 | 128 |
| 120 SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) { | 129 SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) { |
| 121 if (!family) { | 130 if (!family) { |
| 122 return SkTypeface::RefDefault(s); | 131 return SkTypeface::RefDefault(s); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 if (ctx.get()) { | 364 if (ctx.get()) { |
| 356 SkPaint::FontMetrics fm; | 365 SkPaint::FontMetrics fm; |
| 357 ctx->getFontMetrics(&fm); | 366 ctx->getFontMetrics(&fm); |
| 358 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, | 367 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, |
| 359 fm.fXMax * invTextSize, fm.fBottom * invTextSize); | 368 fm.fXMax * invTextSize, fm.fBottom * invTextSize); |
| 360 return true; | 369 return true; |
| 361 } | 370 } |
| 362 return false; | 371 return false; |
| 363 } | 372 } |
| 364 | 373 |
| OLD | NEW |