OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 rec->setHinting(SkPaint::kNo_Hinting); | 143 rec->setHinting(SkPaint::kNo_Hinting); |
144 } | 144 } |
145 | 145 |
146 SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics( | 146 SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics( |
147 PerGlyphInfo , | 147 PerGlyphInfo , |
148 const uint32_t* glyphIDs, | 148 const uint32_t* glyphIDs, |
149 uint32_t glyphIDsCount) const { | 149 uint32_t glyphIDsCount) const { |
150 // pdf only | 150 // pdf only |
151 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; | 151 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; |
152 info->fFontName.set(fTestFont->fName); | 152 info->fFontName.set(fTestFont->fName); |
153 info->fLastGlyphID = SkToU16(onCountGlyphs() - 1); | 153 int glyphCount = this->onCountGlyphs(); |
| 154 info->fLastGlyphID = SkToU16(glyphCount - 1); |
| 155 |
| 156 SkTDArray<SkUnichar>& toUnicode = info->fGlyphToUnicode; |
| 157 toUnicode.setCount(glyphCount); |
| 158 SkASSERT(glyphCount == SkToInt(fTestFont->fCharCodesCount)); |
| 159 for (int gid = 0; gid < glyphCount; ++gid) { |
| 160 toUnicode[gid] = SkToS32(fTestFont->fCharCodes[gid]); |
| 161 } |
154 return info; | 162 return info; |
155 } | 163 } |
156 | 164 |
157 void SkTestTypeface::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal)
const { | 165 void SkTestTypeface::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal)
const { |
158 desc->setFamilyName(fTestFont->fName); | 166 desc->setFamilyName(fTestFont->fName); |
159 desc->setStyle(this->fontStyle()); | 167 desc->setStyle(this->fontStyle()); |
160 *isLocal = false; | 168 *isLocal = false; |
161 } | 169 } |
162 | 170 |
163 int SkTestTypeface::onCharsToGlyphs(const void* chars, Encoding encoding, | 171 int SkTestTypeface::onCharsToGlyphs(const void* chars, Encoding encoding, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 290 |
283 private: | 291 private: |
284 SkTestTypeface* fFace; | 292 SkTestTypeface* fFace; |
285 SkMatrix fMatrix; | 293 SkMatrix fMatrix; |
286 }; | 294 }; |
287 | 295 |
288 SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkScalerContextEffe
cts& effects, | 296 SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkScalerContextEffe
cts& effects, |
289 const SkDescriptor* desc)
const { | 297 const SkDescriptor* desc)
const { |
290 return new SkTestScalerContext(const_cast<SkTestTypeface*>(this), effects, d
esc); | 298 return new SkTestScalerContext(const_cast<SkTestTypeface*>(this), effects, d
esc); |
291 } | 299 } |
OLD | NEW |