Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: src/ports/SkFontHost_win.cpp

Issue 12938004: Use function-ptr instead of SkFontHost api to allow client to handle (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_sandbox_none.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include <tchar.h> 28 #include <tchar.h>
29 #include <usp10.h> 29 #include <usp10.h>
30 #include <objbase.h> 30 #include <objbase.h>
31 31
32 static void (*gEnsureLOGFONTAccessibleProc)(const LOGFONT&); 32 static void (*gEnsureLOGFONTAccessibleProc)(const LOGFONT&);
33 33
34 void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*proc)(const LOGFONT&)) { 34 void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*proc)(const LOGFONT&)) {
35 gEnsureLOGFONTAccessibleProc = proc; 35 gEnsureLOGFONTAccessibleProc = proc;
36 } 36 }
37 37
38 static void call_ensure_accessible(const LOGFONT& lf) {
39 if (gEnsureLOGFONTAccessibleProc) {
40 gEnsureLOGFONTAccessibleProc(lf);
41 }
42 }
43
44 ///////////////////////////////////////////////////////////////////////////////
45
38 // always packed xxRRGGBB 46 // always packed xxRRGGBB
39 typedef uint32_t SkGdiRGB; 47 typedef uint32_t SkGdiRGB;
40 48
41 template <typename T> T* SkTAddByteOffset(T* ptr, size_t byteOffset) { 49 template <typename T> T* SkTAddByteOffset(T* ptr, size_t byteOffset) {
42 return (T*)((char*)ptr + byteOffset); 50 return (T*)((char*)ptr + byteOffset);
43 } 51 }
44 52
45 // define this in your Makefile or .gyp to enforce AA requests 53 // define this in your Makefile or .gyp to enforce AA requests
46 // which GDI ignores at small sizes. This flag guarantees AA 54 // which GDI ignores at small sizes. This flag guarantees AA
47 // for rotated text, regardless of GDI's notions. 55 // for rotated text, regardless of GDI's notions.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 SkTypeface(style, fontID, false), fLogFont(lf), fSerializeAsStream(seria lizeAsStream) { 169 SkTypeface(style, fontID, false), fLogFont(lf), fSerializeAsStream(seria lizeAsStream) {
162 170
163 // If the font has cubic outlines, it will not be rendered with ClearTyp e. 171 // If the font has cubic outlines, it will not be rendered with ClearTyp e.
164 HFONT font = CreateFontIndirect(&lf); 172 HFONT font = CreateFontIndirect(&lf);
165 173
166 HDC deviceContext = ::CreateCompatibleDC(NULL); 174 HDC deviceContext = ::CreateCompatibleDC(NULL);
167 HFONT savefont = (HFONT)SelectObject(deviceContext, font); 175 HFONT savefont = (HFONT)SelectObject(deviceContext, font);
168 176
169 TEXTMETRIC textMetric; 177 TEXTMETRIC textMetric;
170 if (0 == GetTextMetrics(deviceContext, &textMetric)) { 178 if (0 == GetTextMetrics(deviceContext, &textMetric)) {
171 SkFontHost::EnsureTypefaceAccessible(*this); 179 call_ensure_accessible(lf);
172 if (0 == GetTextMetrics(deviceContext, &textMetric)) { 180 if (0 == GetTextMetrics(deviceContext, &textMetric)) {
173 textMetric.tmPitchAndFamily = TMPF_TRUETYPE; 181 textMetric.tmPitchAndFamily = TMPF_TRUETYPE;
174 } 182 }
175 } 183 }
176 if (deviceContext) { 184 if (deviceContext) {
177 ::SelectObject(deviceContext, savefont); 185 ::SelectObject(deviceContext, savefont);
178 ::DeleteDC(deviceContext); 186 ::DeleteDC(deviceContext);
179 } 187 }
180 if (font) { 188 if (font) {
181 ::DeleteObject(font); 189 ::DeleteObject(font);
182 } 190 }
183 191
184 // Used a logfont on a memory context, should never get a device font. 192 // Used a logfont on a memory context, should never get a device font.
185 // Therefore all TMPF_DEVICE will be PostScript (cubic) fonts. 193 // Therefore all TMPF_DEVICE will be PostScript (cubic) fonts.
186 fCanBeLCD = !((textMetric.tmPitchAndFamily & TMPF_VECTOR) && 194 fCanBeLCD = !((textMetric.tmPitchAndFamily & TMPF_VECTOR) &&
187 (textMetric.tmPitchAndFamily & TMPF_DEVICE)); 195 (textMetric.tmPitchAndFamily & TMPF_DEVICE));
188 } 196 }
189 197
190 LOGFONT fLogFont; 198 LOGFONT fLogFont;
191 bool fSerializeAsStream; 199 bool fSerializeAsStream;
192 bool fCanBeLCD; 200 bool fCanBeLCD;
193 201
194 static LogFontTypeface* Create(const LOGFONT& lf) { 202 static LogFontTypeface* Create(const LOGFONT& lf) {
195 SkTypeface::Style style = get_style(lf); 203 SkTypeface::Style style = get_style(lf);
196 SkFontID fontID = SkTypefaceCache::NewFontID(); 204 SkFontID fontID = SkTypefaceCache::NewFontID();
197 return new LogFontTypeface(style, fontID, lf); 205 return new LogFontTypeface(style, fontID, lf);
198 } 206 }
199 207
208 static void EnsureAccessible(const SkTypeface* face) {
209 call_ensure_accessible(static_cast<const LogFontTypeface*>(face)->fLogFo nt);
210 }
211
200 protected: 212 protected:
201 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE; 213 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE;
202 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; 214 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
203 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( 215 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
204 SkAdvancedTypefaceMetrics::PerGlyphInfo, 216 SkAdvancedTypefaceMetrics::PerGlyphInfo,
205 const uint32_t*, uint32_t) const SK_OVERRIDE; 217 const uint32_t*, uint32_t) const SK_OVERRIDE;
206 }; 218 };
207 219
208 class FontMemResourceTypeface : public LogFontTypeface { 220 class FontMemResourceTypeface : public LogFontTypeface {
209 public: 221 public:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 299 }
288 } 300 }
289 301
290 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) { 302 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) {
291 // Zero means that we don't have any fallback fonts for this fontID. 303 // Zero means that we don't have any fallback fonts for this fontID.
292 // This function is implemented on Android, but doesn't have much 304 // This function is implemented on Android, but doesn't have much
293 // meaning here. 305 // meaning here.
294 return NULL; 306 return NULL;
295 } 307 }
296 308
297 static void ensure_typeface_accessible(SkFontID fontID) {
298 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID));
299 if (face) {
300 SkFontHost::EnsureTypefaceAccessible(*face);
301 }
302 }
303
304 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) { 309 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) {
305 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID)); 310 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID));
306 if (face) { 311 if (face) {
307 *lf = face->fLogFont; 312 *lf = face->fLogFont;
308 } else { 313 } else {
309 sk_bzero(lf, sizeof(LOGFONT)); 314 sk_bzero(lf, sizeof(LOGFONT));
310 } 315 }
311 } 316 }
312 317
313 // Construct Glyph to Unicode table. 318 // Construct Glyph to Unicode table.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 return CLEARTYPE_QUALITY; 560 return CLEARTYPE_QUALITY;
556 default: 561 default:
557 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) { 562 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) {
558 return CLEARTYPE_QUALITY; 563 return CLEARTYPE_QUALITY;
559 } else { 564 } else {
560 return ANTIALIASED_QUALITY; 565 return ANTIALIASED_QUALITY;
561 } 566 }
562 } 567 }
563 } 568 }
564 569
565 SkScalerContext_Windows::SkScalerContext_Windows(SkTypeface* typeface, 570 SkScalerContext_Windows::SkScalerContext_Windows(SkTypeface* rawTypeface,
566 const SkDescriptor* desc) 571 const SkDescriptor* desc)
567 : SkScalerContext(typeface, desc), fDDC(0), fFont(0), fSavefont(0), fSC( 0) 572 : SkScalerContext(rawTypeface, desc)
573 , fDDC(0)
574 , fFont(0)
575 , fSavefont(0)
576 , fSC(0)
568 , fGlyphCount(-1) { 577 , fGlyphCount(-1) {
569 SkAutoMutexAcquire ac(gFTMutex); 578 SkAutoMutexAcquire ac(gFTMutex);
570 579
580 LogFontTypeface* typeface = reinterpret_cast<LogFontTypeface*>(rawTypeface);
581
571 fDDC = ::CreateCompatibleDC(NULL); 582 fDDC = ::CreateCompatibleDC(NULL);
572 SetGraphicsMode(fDDC, GM_ADVANCED); 583 SetGraphicsMode(fDDC, GM_ADVANCED);
573 SetBkMode(fDDC, TRANSPARENT); 584 SetBkMode(fDDC, TRANSPARENT);
574 585
575 // Scaling by the DPI is inconsistent with how Skia draws elsewhere 586 // Scaling by the DPI is inconsistent with how Skia draws elsewhere
576 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72); 587 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72);
577 LOGFONT lf; 588 LOGFONT lf = typeface->fLogFont;
578 GetLogFontByID(fRec.fFontID, &lf);
579 lf.lfHeight = -gCanonicalTextSize; 589 lf.lfHeight = -gCanonicalTextSize;
580 lf.lfQuality = compute_quality(fRec); 590 lf.lfQuality = compute_quality(fRec);
581 fFont = CreateFontIndirect(&lf); 591 fFont = CreateFontIndirect(&lf);
582 592
583 // if we're rotated, or want fractional widths, create a hires font 593 // if we're rotated, or want fractional widths, create a hires font
584 fHiResFont = 0; 594 fHiResFont = 0;
585 if (needHiResMetrics(fRec.fPost2x2)) { 595 if (needHiResMetrics(fRec.fPost2x2)) {
586 lf.lfHeight = -HIRES_TEXTSIZE; 596 lf.lfHeight = -HIRES_TEXTSIZE;
587 fHiResFont = CreateFontIndirect(&lf); 597 fHiResFont = CreateFontIndirect(&lf);
588 598
589 fMat22Identity.eM11 = fMat22Identity.eM22 = SkFixedToFIXED(SK_Fixed1); 599 fMat22Identity.eM11 = fMat22Identity.eM22 = SkFixedToFIXED(SK_Fixed1);
590 fMat22Identity.eM12 = fMat22Identity.eM21 = SkFixedToFIXED(0); 600 fMat22Identity.eM12 = fMat22Identity.eM21 = SkFixedToFIXED(0);
591 601
592 // construct a matrix to go from HIRES logical units to our device units 602 // construct a matrix to go from HIRES logical units to our device units
593 fRec.getSingleMatrix(&fHiResMatrix); 603 fRec.getSingleMatrix(&fHiResMatrix);
594 SkScalar scale = SkScalarInvert(SkIntToScalar(HIRES_TEXTSIZE)); 604 SkScalar scale = SkScalarInvert(SkIntToScalar(HIRES_TEXTSIZE));
595 fHiResMatrix.preScale(scale, scale); 605 fHiResMatrix.preScale(scale, scale);
596 } 606 }
597 fSavefont = (HFONT)SelectObject(fDDC, fFont); 607 fSavefont = (HFONT)SelectObject(fDDC, fFont);
598 608
599 if (0 == GetTextMetrics(fDDC, &fTM)) { 609 if (0 == GetTextMetrics(fDDC, &fTM)) {
600 ensure_typeface_accessible(fRec.fFontID); 610 call_ensure_accessible(lf);
601 if (0 == GetTextMetrics(fDDC, &fTM)) { 611 if (0 == GetTextMetrics(fDDC, &fTM)) {
602 fTM.tmPitchAndFamily = TMPF_TRUETYPE; 612 fTM.tmPitchAndFamily = TMPF_TRUETYPE;
603 } 613 }
604 } 614 }
605 // Used a logfont on a memory context, should never get a device font. 615 // Used a logfont on a memory context, should never get a device font.
606 // Therefore all TMPF_DEVICE will be PostScript fonts. 616 // Therefore all TMPF_DEVICE will be PostScript fonts.
607 617
608 // If TMPF_VECTOR is set, one of TMPF_TRUETYPE or TMPF_DEVICE must be set, 618 // If TMPF_VECTOR is set, one of TMPF_TRUETYPE or TMPF_DEVICE must be set,
609 // otherwise we have a vector FON, which we don't support. 619 // otherwise we have a vector FON, which we don't support.
610 // This was determined by testing with Type1 PFM/PFB and OpenTypeCFF OTF, 620 // This was determined by testing with Type1 PFM/PFB and OpenTypeCFF OTF,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 fMat22.eM21 = SkScalarToFIXED(-fRec.fPost2x2[0][1]); 667 fMat22.eM21 = SkScalarToFIXED(-fRec.fPost2x2[0][1]);
658 fMat22.eM22 = SkScalarToFIXED(fRec.fPost2x2[1][1]); 668 fMat22.eM22 = SkScalarToFIXED(fRec.fPost2x2[1][1]);
659 669
660 lf.lfHeight = -SkScalarCeilToInt(fRec.fTextSize); 670 lf.lfHeight = -SkScalarCeilToInt(fRec.fTextSize);
661 HFONT bitmapFont = CreateFontIndirect(&lf); 671 HFONT bitmapFont = CreateFontIndirect(&lf);
662 SelectObject(fDDC, bitmapFont); 672 SelectObject(fDDC, bitmapFont);
663 ::DeleteObject(fFont); 673 ::DeleteObject(fFont);
664 fFont = bitmapFont; 674 fFont = bitmapFont;
665 675
666 if (0 == GetTextMetrics(fDDC, &fTM)) { 676 if (0 == GetTextMetrics(fDDC, &fTM)) {
667 ensure_typeface_accessible(fRec.fFontID); 677 call_ensure_accessible(lf);
668 //if the following fails, we'll just draw at gCanonicalTextSize. 678 //if the following fails, we'll just draw at gCanonicalTextSize.
669 GetTextMetrics(fDDC, &fTM); 679 GetTextMetrics(fDDC, &fTM);
670 } 680 }
671 } 681 }
672 682
673 fOffscreen.init(fFont, xform); 683 fOffscreen.init(fFont, xform);
674 } 684 }
675 685
676 SkScalerContext_Windows::~SkScalerContext_Windows() { 686 SkScalerContext_Windows::~SkScalerContext_Windows() {
677 if (fDDC) { 687 if (fDDC) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return; 763 return;
754 } 764 }
755 765
756 UINT glyphId = glyph->getGlyphID(0); 766 UINT glyphId = glyph->getGlyphID(0);
757 767
758 GLYPHMETRICS gm; 768 GLYPHMETRICS gm;
759 sk_bzero(&gm, sizeof(gm)); 769 sk_bzero(&gm, sizeof(gm));
760 770
761 DWORD status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX , &gm, 0, NULL, &fMat22); 771 DWORD status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX , &gm, 0, NULL, &fMat22);
762 if (GDI_ERROR == status) { 772 if (GDI_ERROR == status) {
763 ensure_typeface_accessible(fRec.fFontID); 773 LogFontTypeface::EnsureAccessible(this->getTypeface());
764 status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22); 774 status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
765 if (GDI_ERROR == status) { 775 if (GDI_ERROR == status) {
766 glyph->zeroMetrics(); 776 glyph->zeroMetrics();
767 return; 777 return;
768 } 778 }
769 } 779 }
770 780
771 bool empty = false; 781 bool empty = false;
772 // The black box is either the embedded bitmap size or the outline extent. 782 // The black box is either the embedded bitmap size or the outline extent.
773 // It is 1x1 if nothing is to be drawn, but will also be 1x1 if something ve ry small 783 // It is 1x1 if nothing is to be drawn, but will also be 1x1 if something ve ry small
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 my->fLeading = SkIntToScalar(fTM.tmInternalLeading 848 my->fLeading = SkIntToScalar(fTM.tmInternalLeading
839 + fTM.tmExternalLeading); 849 + fTM.tmExternalLeading);
840 } 850 }
841 return; 851 return;
842 } 852 }
843 853
844 OUTLINETEXTMETRIC otm; 854 OUTLINETEXTMETRIC otm;
845 855
846 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); 856 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm);
847 if (GDI_ERROR == ret) { 857 if (GDI_ERROR == ret) {
848 ensure_typeface_accessible(fRec.fFontID); 858 LogFontTypeface::EnsureAccessible(this->getTypeface());
849 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); 859 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm);
850 } 860 }
851 if (sizeof(otm) != ret) { 861 if (sizeof(otm) != ret) {
852 return; 862 return;
853 } 863 }
854 864
855 if (mx) { 865 if (mx) {
856 mx->fTop = -fScale * otm.otmTextMetrics.tmAscent; 866 mx->fTop = -fScale * otm.otmTextMetrics.tmAscent;
857 mx->fAscent = -fScale * otm.otmAscent; 867 mx->fAscent = -fScale * otm.otmAscent;
858 mx->fDescent = -fScale * otm.otmDescent; 868 mx->fDescent = -fScale * otm.otmDescent;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 void SkScalerContext_Windows::generateImage(const SkGlyph& glyph) { 1091 void SkScalerContext_Windows::generateImage(const SkGlyph& glyph) {
1082 SkAutoMutexAcquire ac(gFTMutex); 1092 SkAutoMutexAcquire ac(gFTMutex);
1083 SkASSERT(fDDC); 1093 SkASSERT(fDDC);
1084 1094
1085 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat; 1095 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat;
1086 const bool isAA = !isLCD(fRec); 1096 const bool isAA = !isLCD(fRec);
1087 1097
1088 size_t srcRB; 1098 size_t srcRB;
1089 const void* bits = fOffscreen.draw(glyph, isBW, &srcRB); 1099 const void* bits = fOffscreen.draw(glyph, isBW, &srcRB);
1090 if (NULL == bits) { 1100 if (NULL == bits) {
1091 ensure_typeface_accessible(fRec.fFontID); 1101 LogFontTypeface::EnsureAccessible(this->getTypeface());
1092 bits = fOffscreen.draw(glyph, isBW, &srcRB); 1102 bits = fOffscreen.draw(glyph, isBW, &srcRB);
1093 if (NULL == bits) { 1103 if (NULL == bits) {
1094 sk_bzero(glyph.fImage, glyph.computeImageSize()); 1104 sk_bzero(glyph.fImage, glyph.computeImageSize());
1095 return; 1105 return;
1096 } 1106 }
1097 } 1107 }
1098 1108
1099 if (!isBW) { 1109 if (!isBW) {
1100 const uint8_t* table; 1110 const uint8_t* table;
1101 //The offscreen contains a GDI blit if isAA and kGenA8FromLCD_Flag is no t set. 1111 //The offscreen contains a GDI blit if isAA and kGenA8FromLCD_Flag is no t set.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 SkAutoMutexAcquire ac(gFTMutex); 1184 SkAutoMutexAcquire ac(gFTMutex);
1175 1185
1176 SkASSERT(&glyph && path); 1186 SkASSERT(&glyph && path);
1177 SkASSERT(fDDC); 1187 SkASSERT(fDDC);
1178 1188
1179 path->reset(); 1189 path->reset();
1180 1190
1181 GLYPHMETRICS gm; 1191 GLYPHMETRICS gm;
1182 uint32_t total_size = GetGlyphOutlineW(fDDC, glyph.fID, GGO_NATIVE | GGO_GLY PH_INDEX, &gm, BUFFERSIZE, glyphbuf, &fMat22); 1192 uint32_t total_size = GetGlyphOutlineW(fDDC, glyph.fID, GGO_NATIVE | GGO_GLY PH_INDEX, &gm, BUFFERSIZE, glyphbuf, &fMat22);
1183 if (GDI_ERROR == total_size) { 1193 if (GDI_ERROR == total_size) {
1184 ensure_typeface_accessible(fRec.fFontID); 1194 LogFontTypeface::EnsureAccessible(this->getTypeface());
1185 total_size = GetGlyphOutlineW(fDDC, glyph.fID, GGO_NATIVE | GGO_GLYPH_IN DEX, &gm, BUFFERSIZE, glyphbuf, &fMat22); 1195 total_size = GetGlyphOutlineW(fDDC, glyph.fID, GGO_NATIVE | GGO_GLYPH_IN DEX, &gm, BUFFERSIZE, glyphbuf, &fMat22);
1186 if (GDI_ERROR == total_size) { 1196 if (GDI_ERROR == total_size) {
1187 SkASSERT(false); 1197 SkASSERT(false);
1188 return; 1198 return;
1189 } 1199 }
1190 } 1200 }
1191 1201
1192 const uint8_t* cur_glyph = glyphbuf; 1202 const uint8_t* cur_glyph = glyphbuf;
1193 const uint8_t* end_glyph = glyphbuf + total_size; 1203 const uint8_t* end_glyph = glyphbuf + total_size;
1194 1204
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 SkFontDescriptor descriptor(face->style()); 1283 SkFontDescriptor descriptor(face->style());
1274 1284
1275 // Get the actual name of the typeface. The logfont may not know this. 1285 // Get the actual name of the typeface. The logfont may not know this.
1276 HFONT font = CreateFontIndirect(&face->fLogFont); 1286 HFONT font = CreateFontIndirect(&face->fLogFont);
1277 1287
1278 HDC deviceContext = ::CreateCompatibleDC(NULL); 1288 HDC deviceContext = ::CreateCompatibleDC(NULL);
1279 HFONT savefont = (HFONT)SelectObject(deviceContext, font); 1289 HFONT savefont = (HFONT)SelectObject(deviceContext, font);
1280 1290
1281 int fontNameLen; //length of fontName in TCHARS. 1291 int fontNameLen; //length of fontName in TCHARS.
1282 if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) { 1292 if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
1283 SkFontHost::EnsureTypefaceAccessible(*rawFace); 1293 LogFontTypeface::EnsureAccessible(rawFace);
1284 if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) { 1294 if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
1285 fontNameLen = 0; 1295 fontNameLen = 0;
1286 } 1296 }
1287 } 1297 }
1288 1298
1289 SkAutoSTArray<LF_FULLFACESIZE, TCHAR> fontName(fontNameLen+1); 1299 SkAutoSTArray<LF_FULLFACESIZE, TCHAR> fontName(fontNameLen+1);
1290 if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) { 1300 if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) {
1291 SkFontHost::EnsureTypefaceAccessible(*rawFace); 1301 LogFontTypeface::EnsureAccessible(rawFace);
1292 if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) { 1302 if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) {
1293 fontName[0] = 0; 1303 fontName[0] = 0;
1294 } 1304 }
1295 } 1305 }
1296 1306
1297 if (deviceContext) { 1307 if (deviceContext) {
1298 ::SelectObject(deviceContext, savefont); 1308 ::SelectObject(deviceContext, savefont);
1299 ::DeleteDC(deviceContext); 1309 ::DeleteDC(deviceContext);
1300 } 1310 }
1301 if (font) { 1311 if (font) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1374
1365 const char stem_chars[] = {'i', 'I', '!', '1'}; 1375 const char stem_chars[] = {'i', 'I', '!', '1'};
1366 int16_t min_width; 1376 int16_t min_width;
1367 unsigned glyphCount; 1377 unsigned glyphCount;
1368 1378
1369 // To request design units, create a logical font whose height is specified 1379 // To request design units, create a logical font whose height is specified
1370 // as unitsPerEm. 1380 // as unitsPerEm.
1371 OUTLINETEXTMETRIC otm; 1381 OUTLINETEXTMETRIC otm;
1372 unsigned int otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); 1382 unsigned int otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm);
1373 if (0 == otmRet) { 1383 if (0 == otmRet) {
1374 ensure_typeface_accessible(this->uniqueID()); 1384 call_ensure_accessible(lf);
1375 otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); 1385 otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm);
1376 } 1386 }
1377 if (!otmRet || !GetTextFace(hdc, LF_FACESIZE, lf.lfFaceName)) { 1387 if (!otmRet || !GetTextFace(hdc, LF_FACESIZE, lf.lfFaceName)) {
1378 goto Error; 1388 goto Error;
1379 } 1389 }
1380 lf.lfHeight = -SkToS32(otm.otmEMSquare); 1390 lf.lfHeight = -SkToS32(otm.otmEMSquare);
1381 designFont = CreateFontIndirect(&lf); 1391 designFont = CreateFontIndirect(&lf);
1382 SelectObject(hdc, designFont); 1392 SelectObject(hdc, designFont);
1383 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { 1393 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) {
1384 goto Error; 1394 goto Error;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 1596
1587 HDC hdc = ::CreateCompatibleDC(NULL); 1597 HDC hdc = ::CreateCompatibleDC(NULL);
1588 HFONT font = CreateFontIndirect(&lf); 1598 HFONT font = CreateFontIndirect(&lf);
1589 HFONT savefont = (HFONT)SelectObject(hdc, font); 1599 HFONT savefont = (HFONT)SelectObject(hdc, font);
1590 1600
1591 SkMemoryStream* stream = NULL; 1601 SkMemoryStream* stream = NULL;
1592 DWORD tables[2] = {kTTCTag, 0}; 1602 DWORD tables[2] = {kTTCTag, 0};
1593 for (int i = 0; i < SK_ARRAY_COUNT(tables); i++) { 1603 for (int i = 0; i < SK_ARRAY_COUNT(tables); i++) {
1594 size_t bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0); 1604 size_t bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0);
1595 if (bufferSize == GDI_ERROR) { 1605 if (bufferSize == GDI_ERROR) {
1596 ensure_typeface_accessible(uniqueID); 1606 call_ensure_accessible(lf);
1597 bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0); 1607 bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0);
1598 } 1608 }
1599 if (bufferSize != GDI_ERROR) { 1609 if (bufferSize != GDI_ERROR) {
1600 stream = new SkMemoryStream(bufferSize); 1610 stream = new SkMemoryStream(bufferSize);
1601 if (GetFontData(hdc, tables[i], 0, (void*)stream->getMemoryBase(), 1611 if (GetFontData(hdc, tables[i], 0, (void*)stream->getMemoryBase(),
1602 bufferSize)) { 1612 bufferSize)) {
1603 break; 1613 break;
1604 } else { 1614 } else {
1605 delete stream; 1615 delete stream;
1606 stream = NULL; 1616 stream = NULL;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 if (isLCD(*rec) && !isAxisAligned(*rec)) { 1701 if (isLCD(*rec) && !isAxisAligned(*rec)) {
1692 rec->fMaskFormat = SkMask::kA8_Format; 1702 rec->fMaskFormat = SkMask::kA8_Format;
1693 } 1703 }
1694 #endif 1704 #endif
1695 1705
1696 if (!fCanBeLCD && isLCD(*rec)) { 1706 if (!fCanBeLCD && isLCD(*rec)) {
1697 rec->fMaskFormat = SkMask::kA8_Format; 1707 rec->fMaskFormat = SkMask::kA8_Format;
1698 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; 1708 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag;
1699 } 1709 }
1700 } 1710 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_sandbox_none.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698