blob: ce9ffd41774df047c93f6de276a9be57269ea2e0 [file] [log] [blame]
bungeman51daa252014-06-05 13:38:45 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
bungemandf2ec352014-08-20 12:21:32 -07008#include "SkTypes.h"
Mike Klein8f11d4d2018-01-24 12:42:55 -05009#if defined(SK_BUILD_FOR_WIN)
mtklein1ee76512015-11-02 10:20:27 -080010
bungemandf2ec352014-08-20 12:21:32 -070011// SkTypes will include Windows.h, which will pull in all of the GDI defines.
12// GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but
13// IDWriteFontFace has a method called GetGlyphIndices. Since this file does
14// not use GDI, undefing GetGlyphIndices makes things less confusing.
15#undef GetGlyphIndices
16
bungemanb374d6a2014-09-17 07:48:59 -070017#include "SkDWrite.h"
bungeman51daa252014-06-05 13:38:45 -070018#include "SkDWriteFontFileStream.h"
19#include "SkFontDescriptor.h"
20#include "SkFontStream.h"
Ben Wagnerf1bc5e82017-04-07 16:07:46 -040021#include "SkOTTable_fvar.h"
bungeman51daa252014-06-05 13:38:45 -070022#include "SkOTTable_head.h"
23#include "SkOTTable_hhea.h"
24#include "SkOTTable_OS_2.h"
25#include "SkOTTable_post.h"
bungemanf0527152015-08-18 09:34:07 -070026#include "SkOTUtils.h"
bungeman51daa252014-06-05 13:38:45 -070027#include "SkScalerContext.h"
28#include "SkScalerContext_win_dw.h"
29#include "SkTypeface_win_dw.h"
bungeman51daa252014-06-05 13:38:45 -070030#include "SkUtils.h"
31
bungemanb374d6a2014-09-17 07:48:59 -070032void DWriteFontTypeface::onGetFamilyName(SkString* familyName) const {
33 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
34 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames));
35
halcanary96fcdcc2015-08-27 07:41:13 -070036 sk_get_locale_string(familyNames.get(), nullptr/*fMgr->fLocaleName.get()*/, familyName);
bungemanb374d6a2014-09-17 07:48:59 -070037}
38
bungeman51daa252014-06-05 13:38:45 -070039void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
40 bool* isLocalStream) const {
41 // Get the family name.
bungeman5e7b4f92014-08-25 10:16:01 -070042 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
43 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames));
bungeman51daa252014-06-05 13:38:45 -070044
bungeman51daa252014-06-05 13:38:45 -070045 SkString utf8FamilyName;
halcanary96fcdcc2015-08-27 07:41:13 -070046 sk_get_locale_string(familyNames.get(), nullptr/*fMgr->fLocaleName.get()*/, &utf8FamilyName);
bungeman51daa252014-06-05 13:38:45 -070047
48 desc->setFamilyName(utf8FamilyName.c_str());
bungemanb8113782016-07-25 16:54:59 -070049 desc->setStyle(this->fontStyle());
bungeman51daa252014-06-05 13:38:45 -070050 *isLocalStream = SkToBool(fDWriteFontFileLoader.get());
51}
52
53static SkUnichar next_utf8(const void** chars) {
54 return SkUTF8_NextUnichar((const char**)chars);
55}
56
57static SkUnichar next_utf16(const void** chars) {
58 return SkUTF16_NextUnichar((const uint16_t**)chars);
59}
60
61static SkUnichar next_utf32(const void** chars) {
62 const SkUnichar** uniChars = (const SkUnichar**)chars;
63 SkUnichar uni = **uniChars;
64 *uniChars += 1;
65 return uni;
66}
67
68typedef SkUnichar (*EncodingProc)(const void**);
69
70static EncodingProc find_encoding_proc(SkTypeface::Encoding enc) {
71 static const EncodingProc gProcs[] = {
72 next_utf8, next_utf16, next_utf32
73 };
74 SkASSERT((size_t)enc < SK_ARRAY_COUNT(gProcs));
75 return gProcs[enc];
76}
77
78int DWriteFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding,
79 uint16_t glyphs[], int glyphCount) const
80{
halcanary96fcdcc2015-08-27 07:41:13 -070081 if (nullptr == glyphs) {
bungeman51daa252014-06-05 13:38:45 -070082 EncodingProc next_ucs4_proc = find_encoding_proc(encoding);
83 for (int i = 0; i < glyphCount; ++i) {
84 const SkUnichar c = next_ucs4_proc(&chars);
85 BOOL exists;
86 fDWriteFont->HasCharacter(c, &exists);
87 if (!exists) {
88 return i;
89 }
90 }
91 return glyphCount;
92 }
93
94 switch (encoding) {
95 case SkTypeface::kUTF8_Encoding:
96 case SkTypeface::kUTF16_Encoding: {
97 static const int scratchCount = 256;
98 UINT32 scratch[scratchCount];
99 EncodingProc next_ucs4_proc = find_encoding_proc(encoding);
100 for (int baseGlyph = 0; baseGlyph < glyphCount; baseGlyph += scratchCount) {
101 int glyphsLeft = glyphCount - baseGlyph;
102 int limit = SkTMin(glyphsLeft, scratchCount);
103 for (int i = 0; i < limit; ++i) {
104 scratch[i] = next_ucs4_proc(&chars);
105 }
106 fDWriteFontFace->GetGlyphIndices(scratch, limit, &glyphs[baseGlyph]);
107 }
108 break;
109 }
110 case SkTypeface::kUTF32_Encoding: {
111 const UINT32* utf32 = reinterpret_cast<const UINT32*>(chars);
112 fDWriteFontFace->GetGlyphIndices(utf32, glyphCount, glyphs);
113 break;
114 }
115 default:
djsollenf2b340f2016-01-29 08:51:04 -0800116 SK_ABORT("Invalid Text Encoding");
bungeman51daa252014-06-05 13:38:45 -0700117 }
118
119 for (int i = 0; i < glyphCount; ++i) {
120 if (0 == glyphs[i]) {
121 return i;
122 }
123 }
124 return glyphCount;
125}
126
127int DWriteFontTypeface::onCountGlyphs() const {
128 return fDWriteFontFace->GetGlyphCount();
129}
130
131int DWriteFontTypeface::onGetUPEM() const {
132 DWRITE_FONT_METRICS metrics;
133 fDWriteFontFace->GetMetrics(&metrics);
134 return metrics.designUnitsPerEm;
135}
136
137class LocalizedStrings_IDWriteLocalizedStrings : public SkTypeface::LocalizedStrings {
138public:
139 /** Takes ownership of the IDWriteLocalizedStrings. */
140 explicit LocalizedStrings_IDWriteLocalizedStrings(IDWriteLocalizedStrings* strings)
141 : fIndex(0), fStrings(strings)
142 { }
143
mtklein36352bf2015-03-25 18:17:31 -0700144 bool next(SkTypeface::LocalizedString* localizedString) override {
bungeman51daa252014-06-05 13:38:45 -0700145 if (fIndex >= fStrings->GetCount()) {
146 return false;
147 }
148
149 // String
bungeman5e7b4f92014-08-25 10:16:01 -0700150 UINT32 stringLen;
151 HRBM(fStrings->GetStringLength(fIndex, &stringLen), "Could not get string length.");
bungeman51daa252014-06-05 13:38:45 -0700152
bungeman5e7b4f92014-08-25 10:16:01 -0700153 SkSMallocWCHAR wString(stringLen+1);
154 HRBM(fStrings->GetString(fIndex, wString.get(), stringLen+1), "Could not get string.");
bungeman51daa252014-06-05 13:38:45 -0700155
bungeman5e7b4f92014-08-25 10:16:01 -0700156 HRB(sk_wchar_to_skstring(wString.get(), stringLen, &localizedString->fString));
bungeman51daa252014-06-05 13:38:45 -0700157
158 // Locale
bungeman5e7b4f92014-08-25 10:16:01 -0700159 UINT32 localeLen;
160 HRBM(fStrings->GetLocaleNameLength(fIndex, &localeLen), "Could not get locale length.");
bungeman51daa252014-06-05 13:38:45 -0700161
bungeman5e7b4f92014-08-25 10:16:01 -0700162 SkSMallocWCHAR wLocale(localeLen+1);
163 HRBM(fStrings->GetLocaleName(fIndex, wLocale.get(), localeLen+1), "Could not get locale.");
bungeman51daa252014-06-05 13:38:45 -0700164
bungeman5e7b4f92014-08-25 10:16:01 -0700165 HRB(sk_wchar_to_skstring(wLocale.get(), localeLen, &localizedString->fLanguage));
bungeman51daa252014-06-05 13:38:45 -0700166
167 ++fIndex;
168 return true;
169 }
170
171private:
172 UINT32 fIndex;
173 SkTScopedComPtr<IDWriteLocalizedStrings> fStrings;
174};
175
176SkTypeface::LocalizedStrings* DWriteFontTypeface::onCreateFamilyNameIterator() const {
bungemanf0527152015-08-18 09:34:07 -0700177 SkTypeface::LocalizedStrings* nameIter =
178 SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this);
halcanary96fcdcc2015-08-27 07:41:13 -0700179 if (nullptr == nameIter) {
bungemanf0527152015-08-18 09:34:07 -0700180 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
181 HRNM(fDWriteFontFamily->GetFamilyNames(&familyNames), "Could not obtain family names.");
182 nameIter = new LocalizedStrings_IDWriteLocalizedStrings(familyNames.release());
183 }
184 return nameIter;
bungeman51daa252014-06-05 13:38:45 -0700185}
186
187int DWriteFontTypeface::onGetTableTags(SkFontTableTag tags[]) const {
188 DWRITE_FONT_FACE_TYPE type = fDWriteFontFace->GetType();
189 if (type != DWRITE_FONT_FACE_TYPE_CFF &&
190 type != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
191 type != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
192 {
193 return 0;
194 }
195
196 int ttcIndex;
Ben Wagner145dbcd2016-11-03 14:40:50 -0400197 std::unique_ptr<SkStream> stream(this->openStream(&ttcIndex));
198 return stream.get() ? SkFontStream::GetTableTags(stream.get(), ttcIndex, tags) : 0;
bungeman51daa252014-06-05 13:38:45 -0700199}
200
201size_t DWriteFontTypeface::onGetTableData(SkFontTableTag tag, size_t offset,
202 size_t length, void* data) const
203{
204 AutoDWriteTable table(fDWriteFontFace.get(), SkEndian_SwapBE32(tag));
205 if (!table.fExists) {
206 return 0;
207 }
208
209 if (offset > table.fSize) {
210 return 0;
211 }
212 size_t size = SkTMin(length, table.fSize - offset);
bsalomon49f085d2014-09-05 13:34:00 -0700213 if (data) {
bungeman51daa252014-06-05 13:38:45 -0700214 memcpy(data, table.fData + offset, size);
215 }
216
217 return size;
218}
219
bungeman5f213d92015-01-27 05:39:10 -0800220SkStreamAsset* DWriteFontTypeface::onOpenStream(int* ttcIndex) const {
bungeman51daa252014-06-05 13:38:45 -0700221 *ttcIndex = fDWriteFontFace->GetIndex();
222
223 UINT32 numFiles;
halcanary96fcdcc2015-08-27 07:41:13 -0700224 HRNM(fDWriteFontFace->GetFiles(&numFiles, nullptr),
bungeman51daa252014-06-05 13:38:45 -0700225 "Could not get number of font files.");
226 if (numFiles != 1) {
halcanary96fcdcc2015-08-27 07:41:13 -0700227 return nullptr;
bungeman51daa252014-06-05 13:38:45 -0700228 }
229
230 SkTScopedComPtr<IDWriteFontFile> fontFile;
231 HRNM(fDWriteFontFace->GetFiles(&numFiles, &fontFile), "Could not get font files.");
232
233 const void* fontFileKey;
234 UINT32 fontFileKeySize;
235 HRNM(fontFile->GetReferenceKey(&fontFileKey, &fontFileKeySize),
236 "Could not get font file reference key.");
237
238 SkTScopedComPtr<IDWriteFontFileLoader> fontFileLoader;
239 HRNM(fontFile->GetLoader(&fontFileLoader), "Could not get font file loader.");
240
241 SkTScopedComPtr<IDWriteFontFileStream> fontFileStream;
242 HRNM(fontFileLoader->CreateStreamFromKey(fontFileKey, fontFileKeySize,
243 &fontFileStream),
244 "Could not create font file stream.");
245
halcanary385fe4d2015-08-26 13:07:48 -0700246 return new SkDWriteFontFileStream(fontFileStream.get());
bungeman51daa252014-06-05 13:38:45 -0700247}
248
reeda9322c22016-04-12 06:47:05 -0700249SkScalerContext* DWriteFontTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
250 const SkDescriptor* desc) const {
bungeman7cfd46a2016-10-20 16:06:52 -0400251 return new SkScalerContext_DW(sk_ref_sp(const_cast<DWriteFontTypeface*>(this)), effects, desc);
bungeman51daa252014-06-05 13:38:45 -0700252}
253
Ben Wagner3e45a2f2017-11-01 11:47:39 -0400254void DWriteFontTypeface::onFilterRec(SkScalerContextRec* rec) const {
bungeman12f03122015-03-19 13:57:36 -0700255 if (rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) {
bungeman51daa252014-06-05 13:38:45 -0700256 rec->fMaskFormat = SkMask::kA8_Format;
Ben Wagner22253062017-03-16 12:38:46 -0400257 rec->fFlags |= SkScalerContext::kGenA8FromLCD_Flag;
bungeman51daa252014-06-05 13:38:45 -0700258 }
259
bungeman41078062014-07-07 08:16:37 -0700260 unsigned flagsWeDontSupport = SkScalerContext::kVertical_Flag |
261 SkScalerContext::kDevKernText_Flag |
bungeman51daa252014-06-05 13:38:45 -0700262 SkScalerContext::kForceAutohinting_Flag |
263 SkScalerContext::kEmbolden_Flag |
bungeman51daa252014-06-05 13:38:45 -0700264 SkScalerContext::kLCD_Vertical_Flag;
265 rec->fFlags &= ~flagsWeDontSupport;
266
267 SkPaint::Hinting h = rec->getHinting();
Ben Wagner22253062017-03-16 12:38:46 -0400268 // DirectWrite2 allows for hinting to be turned off. Force everything else to normal.
269 if (h != SkPaint::kNo_Hinting || !fFactory2 || !fDWriteFontFace2) {
270 h = SkPaint::kNormal_Hinting;
271 }
bungeman51daa252014-06-05 13:38:45 -0700272 rec->setHinting(h);
273
bungemanb3ed65e2016-05-17 12:24:24 -0700274#if defined(SK_FONT_HOST_USE_SYSTEM_SETTINGS)
275 IDWriteFactory* factory = sk_get_dwrite_factory();
halcanary96fcdcc2015-08-27 07:41:13 -0700276 if (factory != nullptr) {
bungeman51daa252014-06-05 13:38:45 -0700277 SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams;
278 if (SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams))) {
279 float gamma = defaultRenderingParams->GetGamma();
280 rec->setDeviceGamma(gamma);
281 rec->setPaintGamma(gamma);
282
283 rec->setContrast(defaultRenderingParams->GetEnhancedContrast());
284 }
285 }
286#endif
287}
288
289///////////////////////////////////////////////////////////////////////////////
290//PDF Support
291
bungeman51daa252014-06-05 13:38:45 -0700292// Construct Glyph to Unicode table.
293// Unicode code points that require conjugate pairs in utf16 are not
294// supported.
bungeman51daa252014-06-05 13:38:45 -0700295// TODO(bungeman): This never does what anyone wants.
296// What is really wanted is the text to glyphs mapping
297static void populate_glyph_to_unicode(IDWriteFontFace* fontFace,
298 const unsigned glyphCount,
299 SkTDArray<SkUnichar>* glyphToUnicode) {
bungeman51daa252014-06-05 13:38:45 -0700300 //Do this like free type instead
Hal Canary3390cdf2017-04-06 22:26:56 -0400301 SkAutoTMalloc<SkUnichar> glyphToUni(
302 (SkUnichar*)sk_calloc_throw(sizeof(SkUnichar) * glyphCount));
bungemandf2ec352014-08-20 12:21:32 -0700303 int maxGlyph = -1;
Hal Canary266dcb02017-04-07 11:49:20 -0400304 unsigned remainingGlyphCount = glyphCount;
305 for (UINT32 c = 0; c < 0x10FFFF && remainingGlyphCount != 0; ++c) {
wfhf7b54cd2015-07-07 18:06:19 -0700306 UINT16 glyph = 0;
307 HRVM(fontFace->GetGlyphIndices(&c, 1, &glyph),
308 "Failed to get glyph index.");
309 // Intermittent DW bug on Windows 10. See crbug.com/470146.
310 if (glyph >= glyphCount) {
311 return;
312 }
Hal Canary266dcb02017-04-07 11:49:20 -0400313 if (0 < glyph && glyphToUni[glyph] == 0) {
bungemandf2ec352014-08-20 12:21:32 -0700314 maxGlyph = SkTMax(static_cast<int>(glyph), maxGlyph);
Hal Canary266dcb02017-04-07 11:49:20 -0400315 glyphToUni[glyph] = c; // Always use lowest-index unichar.
316 --remainingGlyphCount;
bungeman51daa252014-06-05 13:38:45 -0700317 }
318 }
bungemanaace9972014-08-25 07:14:02 -0700319 SkTDArray<SkUnichar>(glyphToUni, maxGlyph + 1).swap(*glyphToUnicode);
bungeman51daa252014-06-05 13:38:45 -0700320}
321
Hal Canary209e4b12017-05-04 14:23:55 -0400322std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetrics() const {
bungeman51daa252014-06-05 13:38:45 -0700323
Hal Canary209e4b12017-05-04 14:23:55 -0400324 std::unique_ptr<SkAdvancedTypefaceMetrics> info(nullptr);
bungeman51daa252014-06-05 13:38:45 -0700325
326 HRESULT hr = S_OK;
327
328 const unsigned glyphCount = fDWriteFontFace->GetGlyphCount();
329
330 DWRITE_FONT_METRICS dwfm;
331 fDWriteFontFace->GetMetrics(&dwfm);
332
Hal Canary209e4b12017-05-04 14:23:55 -0400333 info.reset(new SkAdvancedTypefaceMetrics);
bungeman51daa252014-06-05 13:38:45 -0700334
bungeman0b775822016-09-13 14:03:54 -0700335 info->fAscent = SkToS16(dwfm.ascent);
336 info->fDescent = SkToS16(dwfm.descent);
337 info->fCapHeight = SkToS16(dwfm.capHeight);
338
bungeman6d867d42014-06-17 10:48:04 -0700339 // SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
340 // the PostScript name of the font. However, due to the way it is currently
341 // used, it must actually be a family name.
bungeman51daa252014-06-05 13:38:45 -0700342 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
bungeman51daa252014-06-05 13:38:45 -0700343 hr = fDWriteFontFamily->GetFamilyNames(&familyNames);
bungeman51daa252014-06-05 13:38:45 -0700344
bungeman5e7b4f92014-08-25 10:16:01 -0700345 UINT32 familyNameLen;
346 hr = familyNames->GetStringLength(0, &familyNameLen);
bungeman51daa252014-06-05 13:38:45 -0700347
bungeman5e7b4f92014-08-25 10:16:01 -0700348 SkSMallocWCHAR familyName(familyNameLen+1);
349 hr = familyNames->GetString(0, familyName.get(), familyNameLen+1);
bungeman51daa252014-06-05 13:38:45 -0700350
bungeman5e7b4f92014-08-25 10:16:01 -0700351 hr = sk_wchar_to_skstring(familyName.get(), familyNameLen, &info->fFontName);
bungeman51daa252014-06-05 13:38:45 -0700352
Hal Canary209e4b12017-05-04 14:23:55 -0400353 populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGlyphToUnicode));
bungeman51daa252014-06-05 13:38:45 -0700354
355 DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
bungeman0b775822016-09-13 14:03:54 -0700356 if (fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
357 fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
358 {
bungeman51daa252014-06-05 13:38:45 -0700359 return info;
360 }
361
bungeman0b775822016-09-13 14:03:54 -0700362 // Simulated fonts aren't really TrueType fonts.
363 if (fDWriteFontFace->GetSimulations() == DWRITE_FONT_SIMULATIONS_NONE) {
364 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
365 }
366
bungeman51daa252014-06-05 13:38:45 -0700367 AutoTDWriteTable<SkOTTableHead> headTable(fDWriteFontFace.get());
368 AutoTDWriteTable<SkOTTablePostScript> postTable(fDWriteFontFace.get());
369 AutoTDWriteTable<SkOTTableHorizontalHeader> hheaTable(fDWriteFontFace.get());
370 AutoTDWriteTable<SkOTTableOS2> os2Table(fDWriteFontFace.get());
371 if (!headTable.fExists || !postTable.fExists || !hheaTable.fExists || !os2Table.fExists) {
bungeman51daa252014-06-05 13:38:45 -0700372 return info;
373 }
374
Hal Canarya865d252017-11-09 16:16:09 -0500375 SkOTUtils::SetAdvancedTypefaceFlags(os2Table->version.v4.fsType, info.get());
Hal Canary4a851ca2017-11-09 11:09:34 -0500376
Ben Wagnerf1bc5e82017-04-07 16:07:46 -0400377 // There are versions of DirectWrite which support named instances for system variation fonts,
378 // but no means to indicate that such a typeface is a variation.
379 AutoTDWriteTable<SkOTTableFontVariations> fvarTable(fDWriteFontFace.get());
380 if (fvarTable.fExists) {
381 info->fFlags |= SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag;
382 }
383
bungeman51daa252014-06-05 13:38:45 -0700384 //There exist CJK fonts which set the IsFixedPitch and Monospace bits,
385 //but have full width, latin half-width, and half-width kana.
386 bool fixedWidth = (postTable->isFixedPitch &&
387 (1 == SkEndian_SwapBE16(hheaTable->numberOfHMetrics)));
388 //Monospace
389 if (fixedWidth) {
390 info->fStyle |= SkAdvancedTypefaceMetrics::kFixedPitch_Style;
391 }
392 //Italic
393 if (os2Table->version.v0.fsSelection.field.Italic) {
394 info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style;
395 }
bungeman51daa252014-06-05 13:38:45 -0700396 //Serif
bungeman4f81caf2016-08-17 10:59:30 -0700397 using SerifStyle = SkPanose::Data::TextAndDisplay::SerifStyle;
398 SerifStyle serifStyle = os2Table->version.v0.panose.data.textAndDisplay.bSerifStyle;
399 if (SkPanose::FamilyType::TextAndDisplay == os2Table->version.v0.panose.bFamilyType) {
400 if (SerifStyle::Cove == serifStyle ||
401 SerifStyle::ObtuseCove == serifStyle ||
402 SerifStyle::SquareCove == serifStyle ||
403 SerifStyle::ObtuseSquareCove == serifStyle ||
404 SerifStyle::Square == serifStyle ||
405 SerifStyle::Thin == serifStyle ||
406 SerifStyle::Bone == serifStyle ||
407 SerifStyle::Exaggerated == serifStyle ||
408 SerifStyle::Triangle == serifStyle)
409 {
410 info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style;
411 }
412 //Script
413 } else if (SkPanose::FamilyType::Script == os2Table->version.v0.panose.bFamilyType) {
414 info->fStyle |= SkAdvancedTypefaceMetrics::kScript_Style;
bungeman51daa252014-06-05 13:38:45 -0700415 }
416
417 info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16;
418
bungeman51daa252014-06-05 13:38:45 -0700419 info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMin),
420 (int32_t)SkEndian_SwapBE16((uint16_t)headTable->yMax),
421 (int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMax),
422 (int32_t)SkEndian_SwapBE16((uint16_t)headTable->yMin));
bungeman51daa252014-06-05 13:38:45 -0700423 return info;
424}
Mike Klein8f11d4d2018-01-24 12:42:55 -0500425#endif//defined(SK_BUILD_FOR_WIN)