| 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
| 10 | 10 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16; | 412 info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16; |
| 413 | 413 |
| 414 info->fAscent = SkToS16(dwfm.ascent); | 414 info->fAscent = SkToS16(dwfm.ascent); |
| 415 info->fDescent = SkToS16(dwfm.descent); | 415 info->fDescent = SkToS16(dwfm.descent); |
| 416 info->fCapHeight = SkToS16(dwfm.capHeight); | 416 info->fCapHeight = SkToS16(dwfm.capHeight); |
| 417 | 417 |
| 418 info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->xMin), | 418 info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->xMin), |
| 419 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->yMax), | 419 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->yMax), |
| 420 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->xMax), | 420 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->xMax), |
| 421 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->yMin)); | 421 (int32_t)SkEndian_SwapBE16((uint16_t)headTab
le->yMin)); |
| 422 | |
| 423 //TODO: is this even desired? It seems PDF only wants this value for Type1 | |
| 424 //fonts, and we only get here for TrueType fonts. | |
| 425 info->fStemV = 0; | |
| 426 /* | |
| 427 // Figure out a good guess for StemV - Min width of i, I, !, 1. | |
| 428 // This probably isn't very good with an italic font. | |
| 429 int16_t min_width = SHRT_MAX; | |
| 430 info->fStemV = 0; | |
| 431 char stem_chars[] = {'i', 'I', '!', '1'}; | |
| 432 for (size_t i = 0; i < SK_ARRAY_COUNT(stem_chars); i++) { | |
| 433 ABC abcWidths; | |
| 434 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | |
| 435 int16_t width = abcWidths.abcB; | |
| 436 if (width > 0 && width < min_width) { | |
| 437 min_width = width; | |
| 438 info->fStemV = min_width; | |
| 439 } | |
| 440 } | |
| 441 } | |
| 442 */ | |
| 443 | |
| 444 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { | |
| 445 if (fixedWidth) { | |
| 446 SkAdvancedTypefaceMetrics::WidthRange range(0); | |
| 447 int16_t advance; | |
| 448 getWidthAdvance(fDWriteFontFace.get(), 1, &advance); | |
| 449 range.fAdvance.append(1, &advance); | |
| 450 SkAdvancedTypefaceMetrics::FinishRange( | |
| 451 &range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault); | |
| 452 info->fGlyphWidths.emplace_back(std::move(range)); | |
| 453 } else { | |
| 454 IDWriteFontFace* borrowedFontFace = fDWriteFontFace.get(); | |
| 455 info->setGlyphWidths( | |
| 456 glyphCount, | |
| 457 glyphIDs, | |
| 458 glyphIDsCount, | |
| 459 SkAdvancedTypefaceMetrics::GetAdvance([borrowedFontFace](int gId
, int16_t* data) { | |
| 460 return getWidthAdvance(borrowedFontFace, gId, data); | |
| 461 }) | |
| 462 ); | |
| 463 } | |
| 464 } | |
| 465 | |
| 466 return info; | 422 return info; |
| 467 } | 423 } |
| 468 #endif//defined(SK_BUILD_FOR_WIN32) | 424 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |