| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 The Android Open Source Project | 3 * Copyright 2011 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkAdvancedTypefaceMetrics.h" | 10 #include "SkAdvancedTypefaceMetrics.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 size_t SkTypeface::getTableSize(SkFontTableTag tag) const { | 116 size_t SkTypeface::getTableSize(SkFontTableTag tag) const { |
| 117 return SkFontHost::GetTableSize(fUniqueID, tag); | 117 return SkFontHost::GetTableSize(fUniqueID, tag); |
| 118 } | 118 } |
| 119 | 119 |
| 120 size_t SkTypeface::getTableData(SkFontTableTag tag, size_t offset, size_t length
, | 120 size_t SkTypeface::getTableData(SkFontTableTag tag, size_t offset, size_t length
, |
| 121 void* data) const { | 121 void* data) const { |
| 122 return SkFontHost::GetTableData(fUniqueID, tag, offset, length, data); | 122 return SkFontHost::GetTableData(fUniqueID, tag, offset, length, data); |
| 123 } | 123 } |
| 124 | 124 |
| 125 SkStream* SkTypeface::openStream(int* ttcIndex) const { | 125 SkStream* SkTypeface::openStream(int* ttcIndex) const { |
| 126 if (ttcIndex) { | 126 int ttcIndexStorage; |
| 127 int32_t ndx = 0; | 127 if (NULL == ttcIndex) { |
| 128 (void)SkFontHost::GetFileName(fUniqueID, NULL, 0, &ndx); | 128 // So our subclasses don't need to check for null param |
| 129 *ttcIndex = (int)ndx; | 129 ttcIndex = &ttcIndexStorage; |
| 130 } | 130 } |
| 131 return SkFontHost::OpenStream(fUniqueID); | 131 return this->onOpenStream(ttcIndex); |
| 132 } | 132 } |
| 133 | 133 |
| 134 int SkTypeface::getUnitsPerEm() const { | 134 int SkTypeface::getUnitsPerEm() const { |
| 135 // should we try to cache this in the base-class? | 135 // should we try to cache this in the base-class? |
| 136 return this->onGetUPEM(); | 136 return this->onGetUPEM(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /////////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////////// |
| 140 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
| 141 | 141 |
| 142 #include "SkFontDescriptor.h" | 142 #include "SkFontDescriptor.h" |
| 143 | 143 |
| 144 int SkTypeface::onGetUPEM() const { | 144 int SkTypeface::onGetUPEM() const { |
| 145 int upem = 0; | 145 int upem = 0; |
| 146 | 146 |
| 147 SkAdvancedTypefaceMetrics* metrics; | 147 SkAdvancedTypefaceMetrics* metrics; |
| 148 metrics = this->getAdvancedTypefaceMetrics( | 148 metrics = this->getAdvancedTypefaceMetrics( |
| 149 SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo, | 149 SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo, |
| 150 NULL, 0); | 150 NULL, 0); |
| 151 if (metrics) { | 151 if (metrics) { |
| 152 upem = metrics->fEmSize; | 152 upem = metrics->fEmSize; |
| 153 metrics->unref(); | 153 metrics->unref(); |
| 154 } | 154 } |
| 155 return upem; | 155 return upem; |
| 156 } | 156 } |
| 157 | 157 |
| 158 SkStream* SkTypeface::onOpenStream(int* ttcIndex) const { |
| 159 if (ttcIndex) { |
| 160 int32_t ndx = 0; |
| 161 (void)SkFontHost::GetFileName(fUniqueID, NULL, 0, &ndx); |
| 162 *ttcIndex = (int)ndx; |
| 163 } |
| 164 return SkFontHost::OpenStream(fUniqueID); |
| 165 } |
| 166 |
| 158 int SkTypeface::onGetTableTags(SkFontTableTag tags[]) const { return 0; } | 167 int SkTypeface::onGetTableTags(SkFontTableTag tags[]) const { return 0; } |
| 159 size_t SkTypeface::onGetTableData(SkFontTableTag, size_t offset, | 168 size_t SkTypeface::onGetTableData(SkFontTableTag, size_t offset, |
| 160 size_t length, void* data) const { return 0; } | 169 size_t length, void* data) const { return 0; } |
| 161 void SkTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { | 170 void SkTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { |
| 162 desc->setStyle(this->style()); | 171 desc->setStyle(this->style()); |
| 163 } | 172 } |
| 164 | 173 |
| OLD | NEW |