OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 "SkTypes.h" | 8 #include "SkTypes.h" |
9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
10 | 10 |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | 1811 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { |
1812 int16_t width = abcWidths.abcB; | 1812 int16_t width = abcWidths.abcB; |
1813 if (width > 0 && width < min_width) { | 1813 if (width > 0 && width < min_width) { |
1814 min_width = width; | 1814 min_width = width; |
1815 info->fStemV = min_width; | 1815 info->fStemV = min_width; |
1816 } | 1816 } |
1817 } | 1817 } |
1818 } | 1818 } |
1819 | 1819 |
1820 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { | 1820 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { |
1821 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { | 1821 info->setGlyphWidths( |
1822 SkAdvancedTypefaceMetrics::WidthRange range(0); | 1822 glyphCount, |
1823 range.fAdvance.append(1, &min_width); | 1823 glyphIDs, |
1824 SkAdvancedTypefaceMetrics::FinishRange( | 1824 glyphIDsCount, |
1825 &range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1825 SkAdvancedTypefaceMetrics::GetAdvance([hdc](int gId, int16_t* advanc
e) { |
1826 info->fGlyphWidths.emplace_back(std::move(range)); | 1826 // Initialize the MAT2 structure to |
1827 } else { | 1827 // the identify transformation matrix. |
1828 info->setGlyphWidths( | 1828 static const MAT2 mat2 = { |
1829 glyphCount, | 1829 SkScalarToFIXED(1), SkScalarToFIXED(0), |
1830 glyphIDs, | 1830 SkScalarToFIXED(0), SkScalarToFIXED(1)}; |
1831 glyphIDsCount, | 1831 int flags = GGO_METRICS | GGO_GLYPH_INDEX; |
1832 SkAdvancedTypefaceMetrics::GetAdvance([hdc](int gId, int16_t* ad
vance) { | 1832 GLYPHMETRICS gm; |
1833 // Initialize the MAT2 structure to | 1833 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, nullpt
r, &mat2)) { |
1834 // the identify transformation matrix. | 1834 return false; |
1835 static const MAT2 mat2 = { | 1835 } |
1836 SkScalarToFIXED(1), SkScalarToFIXED(0), | 1836 SkASSERT(advance); |
1837 SkScalarToFIXED(0), SkScalarToFIXED(1)}; | 1837 *advance = gm.gmCellIncX; |
1838 int flags = GGO_METRICS | GGO_GLYPH_INDEX; | 1838 return true; |
1839 GLYPHMETRICS gm; | 1839 }) |
1840 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, nu
llptr, &mat2)) { | 1840 ); |
1841 return false; | |
1842 } | |
1843 SkASSERT(advance); | |
1844 *advance = gm.gmCellIncX; | |
1845 return true; | |
1846 }) | |
1847 ); | |
1848 } | |
1849 } | 1841 } |
1850 | 1842 |
1851 Error: | 1843 Error: |
1852 ReturnInfo: | 1844 ReturnInfo: |
1853 SelectObject(hdc, savefont); | 1845 SelectObject(hdc, savefont); |
1854 DeleteObject(designFont); | 1846 DeleteObject(designFont); |
1855 DeleteObject(font); | 1847 DeleteObject(font); |
1856 DeleteDC(hdc); | 1848 DeleteDC(hdc); |
1857 | 1849 |
1858 return info; | 1850 return info; |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 | 2505 |
2514 private: | 2506 private: |
2515 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2507 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2516 }; | 2508 }; |
2517 | 2509 |
2518 /////////////////////////////////////////////////////////////////////////////// | 2510 /////////////////////////////////////////////////////////////////////////////// |
2519 | 2511 |
2520 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } | 2512 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } |
2521 | 2513 |
2522 #endif//defined(SK_BUILD_FOR_WIN32) | 2514 #endif//defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |