| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #include "SkAdvancedTypefaceMetrics.h" | 8 #include "SkAdvancedTypefaceMetrics.h" |
| 10 #include "SkBase64.h" | 9 #include "SkBase64.h" |
| 11 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 249 } |
| 251 | 250 |
| 252 static void EnsureAccessible(const SkTypeface* face) { | 251 static void EnsureAccessible(const SkTypeface* face) { |
| 253 call_ensure_accessible(static_cast<const LogFontTypeface*>(face)->fLogFo
nt); | 252 call_ensure_accessible(static_cast<const LogFontTypeface*>(face)->fLogFo
nt); |
| 254 } | 253 } |
| 255 | 254 |
| 256 protected: | 255 protected: |
| 257 SkStreamAsset* onOpenStream(int* ttcIndex) const override; | 256 SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
| 258 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override; | 257 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override; |
| 259 void onFilterRec(SkScalerContextRec*) const override; | 258 void onFilterRec(SkScalerContextRec*) const override; |
| 260 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 259 SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
| 261 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 260 PerGlyphInfo, const uint32_t*, uint32_t) const o
verride; |
| 262 const uint32_t*, uint32_t) const override; | |
| 263 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; | 261 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; |
| 264 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, | 262 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
| 265 uint16_t glyphs[], int glyphCount) const overrid
e; | 263 uint16_t glyphs[], int glyphCount) const overrid
e; |
| 266 int onCountGlyphs() const override; | 264 int onCountGlyphs() const override; |
| 267 int onGetUPEM() const override; | 265 int onGetUPEM() const override; |
| 268 void onGetFamilyName(SkString* familyName) const override; | 266 void onGetFamilyName(SkString* familyName) const override; |
| 269 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; | 267 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; |
| 270 int onGetTableTags(SkFontTableTag tags[]) const override; | 268 int onGetTableTags(SkFontTableTag tags[]) const override; |
| 271 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 269 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
| 272 size_t length, void* data) const override; | 270 size_t length, void* data) const override; |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 GLYPHMETRICS gm; | 1724 GLYPHMETRICS gm; |
| 1727 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, NULL, &mat2)) { | 1725 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, NULL, &mat2)) { |
| 1728 return false; | 1726 return false; |
| 1729 } | 1727 } |
| 1730 SkASSERT(advance); | 1728 SkASSERT(advance); |
| 1731 *advance = gm.gmCellIncX; | 1729 *advance = gm.gmCellIncX; |
| 1732 return true; | 1730 return true; |
| 1733 } | 1731 } |
| 1734 | 1732 |
| 1735 SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics( | 1733 SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics( |
| 1736 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, | 1734 PerGlyphInfo perGlyphInfo, |
| 1737 const uint32_t* glyphIDs, | 1735 const uint32_t* glyphIDs, |
| 1738 uint32_t glyphIDsCount) const { | 1736 uint32_t glyphIDsCount) const { |
| 1739 LOGFONT lf = fLogFont; | 1737 LOGFONT lf = fLogFont; |
| 1740 SkAdvancedTypefaceMetrics* info = NULL; | 1738 SkAdvancedTypefaceMetrics* info = NULL; |
| 1741 | 1739 |
| 1742 HDC hdc = CreateCompatibleDC(NULL); | 1740 HDC hdc = CreateCompatibleDC(NULL); |
| 1743 HFONT font = CreateFontIndirect(&lf); | 1741 HFONT font = CreateFontIndirect(&lf); |
| 1744 HFONT savefont = (HFONT)SelectObject(hdc, font); | 1742 HFONT savefont = (HFONT)SelectObject(hdc, font); |
| 1745 HFONT designFont = NULL; | 1743 HFONT designFont = NULL; |
| 1746 | 1744 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1775 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; | 1773 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; |
| 1776 // If bit 1 is set, the font may not be embedded in a document. | 1774 // If bit 1 is set, the font may not be embedded in a document. |
| 1777 // If bit 1 is clear, the font can be embedded. | 1775 // If bit 1 is clear, the font can be embedded. |
| 1778 // If bit 2 is set, the embedding is read-only. | 1776 // If bit 2 is set, the embedding is read-only. |
| 1779 if (otm.otmfsType & 0x1) { | 1777 if (otm.otmfsType & 0x1) { |
| 1780 info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>( | 1778 info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>( |
| 1781 info->fFlags, | 1779 info->fFlags, |
| 1782 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); | 1780 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); |
| 1783 } | 1781 } |
| 1784 | 1782 |
| 1785 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { | 1783 if (perGlyphInfo & kToUnicode_PerGlyphInfo) { |
| 1786 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); | 1784 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); |
| 1787 } | 1785 } |
| 1788 | 1786 |
| 1789 if (glyphCount > 0 && | 1787 if (glyphCount > 0 && |
| 1790 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { | 1788 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { |
| 1791 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; | 1789 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; |
| 1792 } else { | 1790 } else { |
| 1793 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; | 1791 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; |
| 1794 info->fItalicAngle = 0; | 1792 info->fItalicAngle = 0; |
| 1795 info->fAscent = 0; | 1793 info->fAscent = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 ABC abcWidths; | 1832 ABC abcWidths; |
| 1835 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | 1833 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { |
| 1836 int16_t width = abcWidths.abcB; | 1834 int16_t width = abcWidths.abcB; |
| 1837 if (width > 0 && width < min_width) { | 1835 if (width > 0 && width < min_width) { |
| 1838 min_width = width; | 1836 min_width = width; |
| 1839 info->fStemV = min_width; | 1837 info->fStemV = min_width; |
| 1840 } | 1838 } |
| 1841 } | 1839 } |
| 1842 } | 1840 } |
| 1843 | 1841 |
| 1844 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { | 1842 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { |
| 1845 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { | 1843 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { |
| 1846 appendRange(&info->fGlyphWidths, 0); | 1844 appendRange(&info->fGlyphWidths, 0); |
| 1847 info->fGlyphWidths->fAdvance.append(1, &min_width); | 1845 info->fGlyphWidths->fAdvance.append(1, &min_width); |
| 1848 finishRange(info->fGlyphWidths.get(), 0, | 1846 finishRange(info->fGlyphWidths.get(), 0, |
| 1849 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1847 SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
| 1850 } else { | 1848 } else { |
| 1851 info->fGlyphWidths.reset( | 1849 info->fGlyphWidths.reset( |
| 1852 getAdvanceData(hdc, | 1850 getAdvanceData(hdc, |
| 1853 glyphCount, | 1851 glyphCount, |
| 1854 glyphIDs, | 1852 glyphIDs, |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 | 2522 |
| 2525 private: | 2523 private: |
| 2526 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2524 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
| 2527 }; | 2525 }; |
| 2528 | 2526 |
| 2529 /////////////////////////////////////////////////////////////////////////////// | 2527 /////////////////////////////////////////////////////////////////////////////// |
| 2530 | 2528 |
| 2531 SkFontMgr* SkFontMgr_New_GDI() { | 2529 SkFontMgr* SkFontMgr_New_GDI() { |
| 2532 return SkNEW(SkFontMgrGDI); | 2530 return SkNEW(SkFontMgrGDI); |
| 2533 } | 2531 } |
| OLD | NEW |