OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 269 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; |
270 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 270 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
271 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 271 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
272 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 272 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
273 const uint32_t*, uint32_t) const SK_OVERRIDE; | 273 const uint32_t*, uint32_t) const SK_OVERRIDE; |
274 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; | 274 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; |
275 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, | 275 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
276 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; | 276 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; |
277 virtual int onCountGlyphs() const SK_OVERRIDE; | 277 virtual int onCountGlyphs() const SK_OVERRIDE; |
278 virtual int onGetUPEM() const SK_OVERRIDE; | 278 virtual int onGetUPEM() const SK_OVERRIDE; |
| 279 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; |
279 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 280 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; |
280 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 281 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
281 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 282 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
282 size_t length, void* data) const SK_OVERRIDE; | 283 size_t length, void* data) const SK_OVERRIDE; |
283 }; | 284 }; |
284 | 285 |
285 class FontMemResourceTypeface : public LogFontTypeface { | 286 class FontMemResourceTypeface : public LogFontTypeface { |
286 public: | 287 public: |
287 /** | 288 /** |
288 * The created FontMemResourceTypeface takes ownership of fontMemResource. | 289 * The created FontMemResourceTypeface takes ownership of fontMemResource. |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 wideFamilyName, str_len); | 1755 wideFamilyName, str_len); |
1755 ::wcsncpy(lf->lfFaceName, wideFamilyName, LF_FACESIZE - 1); | 1756 ::wcsncpy(lf->lfFaceName, wideFamilyName, LF_FACESIZE - 1); |
1756 delete [] wideFamilyName; | 1757 delete [] wideFamilyName; |
1757 lf->lfFaceName[LF_FACESIZE-1] = L'\0'; | 1758 lf->lfFaceName[LF_FACESIZE-1] = L'\0'; |
1758 #else | 1759 #else |
1759 ::strncpy(lf->lfFaceName, familyName, LF_FACESIZE - 1); | 1760 ::strncpy(lf->lfFaceName, familyName, LF_FACESIZE - 1); |
1760 lf->lfFaceName[LF_FACESIZE - 1] = '\0'; | 1761 lf->lfFaceName[LF_FACESIZE - 1] = '\0'; |
1761 #endif | 1762 #endif |
1762 } | 1763 } |
1763 | 1764 |
1764 void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 1765 void LogFontTypeface::onGetFamilyName(SkString* familyName) const { |
1765 bool* isLocalStream) const { | |
1766 // Get the actual name of the typeface. The logfont may not know this. | 1766 // Get the actual name of the typeface. The logfont may not know this. |
1767 HFONT font = CreateFontIndirect(&fLogFont); | 1767 HFONT font = CreateFontIndirect(&fLogFont); |
1768 | 1768 |
1769 HDC deviceContext = ::CreateCompatibleDC(NULL); | 1769 HDC deviceContext = ::CreateCompatibleDC(NULL); |
1770 HFONT savefont = (HFONT)SelectObject(deviceContext, font); | 1770 HFONT savefont = (HFONT)SelectObject(deviceContext, font); |
1771 | 1771 |
1772 SkString familyName; | 1772 dcfontname_to_skstring(deviceContext, fLogFont, familyName); |
1773 dcfontname_to_skstring(deviceContext, fLogFont, &familyName); | |
1774 | 1773 |
1775 if (deviceContext) { | 1774 if (deviceContext) { |
1776 ::SelectObject(deviceContext, savefont); | 1775 ::SelectObject(deviceContext, savefont); |
1777 ::DeleteDC(deviceContext); | 1776 ::DeleteDC(deviceContext); |
1778 } | 1777 } |
1779 if (font) { | 1778 if (font) { |
1780 ::DeleteObject(font); | 1779 ::DeleteObject(font); |
1781 } | 1780 } |
| 1781 } |
1782 | 1782 |
| 1783 void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 1784 bool* isLocalStream) const { |
| 1785 SkString familyName; |
| 1786 this->onGetFamilyName(&familyName); |
1783 desc->setFamilyName(familyName.c_str()); | 1787 desc->setFamilyName(familyName.c_str()); |
1784 *isLocalStream = this->fSerializeAsStream; | 1788 *isLocalStream = this->fSerializeAsStream; |
1785 } | 1789 } |
1786 | 1790 |
1787 static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) { | 1791 static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) { |
1788 // Initialize the MAT2 structure to the identify transformation matrix. | 1792 // Initialize the MAT2 structure to the identify transformation matrix. |
1789 static const MAT2 mat2 = {SkScalarToFIXED(1), SkScalarToFIXED(0), | 1793 static const MAT2 mat2 = {SkScalarToFIXED(1), SkScalarToFIXED(0), |
1790 SkScalarToFIXED(0), SkScalarToFIXED(1)}; | 1794 SkScalarToFIXED(0), SkScalarToFIXED(1)}; |
1791 int flags = GGO_METRICS | GGO_GLYPH_INDEX; | 1795 int flags = GGO_METRICS | GGO_GLYPH_INDEX; |
1792 GLYPHMETRICS gm; | 1796 GLYPHMETRICS gm; |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2587 | 2591 |
2588 private: | 2592 private: |
2589 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2593 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2590 }; | 2594 }; |
2591 | 2595 |
2592 /////////////////////////////////////////////////////////////////////////////// | 2596 /////////////////////////////////////////////////////////////////////////////// |
2593 | 2597 |
2594 SkFontMgr* SkFontMgr_New_GDI() { | 2598 SkFontMgr* SkFontMgr_New_GDI() { |
2595 return SkNEW(SkFontMgrGDI); | 2599 return SkNEW(SkFontMgrGDI); |
2596 } | 2600 } |
OLD | NEW |