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

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

Issue 370463002: Remove vertical/horizontal metrics selection. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Mac. Created 6 years, 5 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
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkScalerContext_win_dw.h » ('j') | 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // initializations (which may include calling GDI). 552 // initializations (which may include calling GDI).
553 bool isValid() const; 553 bool isValid() const;
554 554
555 protected: 555 protected:
556 virtual unsigned generateGlyphCount() SK_OVERRIDE; 556 virtual unsigned generateGlyphCount() SK_OVERRIDE;
557 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 557 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
558 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 558 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
559 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 559 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
560 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 560 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
561 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 561 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
562 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, 562 virtual void generateFontMetrics(SkPaint::FontMetrics*) SK_OVERRIDE;
563 SkPaint::FontMetrics* mY) SK_OVERRIDE;
564 563
565 private: 564 private:
566 DWORD getGDIGlyphPath(const SkGlyph& glyph, UINT flags, 565 DWORD getGDIGlyphPath(const SkGlyph& glyph, UINT flags,
567 SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf); 566 SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf);
568 567
569 HDCOffscreen fOffscreen; 568 HDCOffscreen fOffscreen;
570 /** fGsA is the non-rotational part of total matrix without the text height scale. 569 /** fGsA is the non-rotational part of total matrix without the text height scale.
571 * Used to find the magnitude of advances. 570 * Used to find the magnitude of advances.
572 */ 571 */
573 MAT2 fGsA; 572 MAT2 fGsA;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 if (GDI_ERROR != status) { 970 if (GDI_ERROR != status) {
972 SkPoint advance; 971 SkPoint advance;
973 fG_inv.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIn cY), &advance); 972 fG_inv.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIn cY), &advance);
974 glyph->fAdvanceX = SkScalarToFixed(advance.fX); 973 glyph->fAdvanceX = SkScalarToFixed(advance.fX);
975 glyph->fAdvanceY = SkScalarToFixed(advance.fY); 974 glyph->fAdvanceY = SkScalarToFixed(advance.fY);
976 } 975 }
977 } 976 }
978 } 977 }
979 978
980 static const MAT2 gMat2Identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; 979 static const MAT2 gMat2Identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}};
981 void SkScalerContext_GDI::generateFontMetrics(SkPaint::FontMetrics* mx, SkPaint: :FontMetrics* my) { 980 void SkScalerContext_GDI::generateFontMetrics(SkPaint::FontMetrics* metrics) {
982 if (!(mx || my)) { 981 if (NULL == metrics) {
983 return; 982 return;
984 } 983 }
985 984 sk_bzero(metrics, sizeof(*metrics));
986 if (mx) {
987 sk_bzero(mx, sizeof(*mx));
988 }
989 if (my) {
990 sk_bzero(my, sizeof(*my));
991 }
992 985
993 SkASSERT(fDDC); 986 SkASSERT(fDDC);
994 987
995 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS 988 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
996 if (fType == SkScalerContext_GDI::kBitmap_Type || fType == SkScalerContext_G DI::kLine_Type) { 989 if (fType == SkScalerContext_GDI::kBitmap_Type || fType == SkScalerContext_G DI::kLine_Type) {
997 #endif 990 #endif
998 if (mx) { 991 metrics->fTop = SkIntToScalar(-fTM.tmAscent);
999 mx->fTop = SkIntToScalar(-fTM.tmAscent); 992 metrics->fAscent = SkIntToScalar(-fTM.tmAscent);
1000 mx->fAscent = SkIntToScalar(-fTM.tmAscent); 993 metrics->fDescent = SkIntToScalar(fTM.tmDescent);
1001 mx->fDescent = SkIntToScalar(fTM.tmDescent); 994 metrics->fBottom = SkIntToScalar(fTM.tmDescent);
1002 mx->fBottom = SkIntToScalar(fTM.tmDescent); 995 metrics->fLeading = SkIntToScalar(fTM.tmExternalLeading);
1003 mx->fLeading = SkIntToScalar(fTM.tmExternalLeading); 996 metrics->fAvgCharWidth = SkIntToScalar(fTM.tmAveCharWidth);
1004 } 997 metrics->fMaxCharWidth = SkIntToScalar(fTM.tmMaxCharWidth);
1005 998 metrics->fXMin = 0;
1006 if (my) { 999 metrics->fXMax = metrics->fMaxCharWidth;
1007 my->fTop = SkIntToScalar(-fTM.tmAscent); 1000 //metrics->fXHeight = 0;
1008 my->fAscent = SkIntToScalar(-fTM.tmAscent);
1009 my->fDescent = SkIntToScalar(fTM.tmDescent);
1010 my->fBottom = SkIntToScalar(fTM.tmDescent);
1011 my->fLeading = SkIntToScalar(fTM.tmExternalLeading);
1012 my->fAvgCharWidth = SkIntToScalar(fTM.tmAveCharWidth);
1013 my->fMaxCharWidth = SkIntToScalar(fTM.tmMaxCharWidth);
1014 my->fXMin = 0;
1015 my->fXMax = my->fMaxCharWidth;
1016 //my->fXHeight = 0;
1017 }
1018 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS 1001 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
1019 return; 1002 return;
1020 } 1003 }
1021 #endif 1004 #endif
1022 1005
1023 OUTLINETEXTMETRIC otm; 1006 OUTLINETEXTMETRIC otm;
1024 1007
1025 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); 1008 uint32_t ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm);
1026 if (0 == ret) { 1009 if (0 == ret) {
1027 LogFontTypeface::EnsureAccessible(this->getTypeface()); 1010 LogFontTypeface::EnsureAccessible(this->getTypeface());
1028 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm); 1011 ret = GetOutlineTextMetrics(fDDC, sizeof(otm), &otm);
1029 } 1012 }
1030 if (0 == ret) { 1013 if (0 == ret) {
1031 return; 1014 return;
1032 } 1015 }
1033 1016
1034 if (mx) { 1017 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
1035 mx->fTop = SkIntToScalar(-otm.otmrcFontBox.left); 1018 metrics->fTop = SkIntToScalar(-otm.otmrcFontBox.top);
1036 mx->fAscent = SkIntToScalar(-otm.otmAscent); 1019 metrics->fAscent = SkIntToScalar(-otm.otmAscent);
1037 mx->fDescent = SkIntToScalar(-otm.otmDescent); 1020 metrics->fDescent = SkIntToScalar(-otm.otmDescent);
1038 mx->fBottom = SkIntToScalar(otm.otmrcFontBox.right); 1021 metrics->fBottom = SkIntToScalar(-otm.otmrcFontBox.bottom);
1039 mx->fLeading = SkIntToScalar(otm.otmLineGap); 1022 metrics->fLeading = SkIntToScalar(otm.otmLineGap);
1040 mx->fUnderlineThickness = SkIntToScalar(otm.otmsUnderscoreSize); 1023 metrics->fAvgCharWidth = SkIntToScalar(otm.otmTextMetrics.tmAveCharWidth);
1041 mx->fUnderlinePosition = -SkIntToScalar(otm.otmsUnderscorePosition); 1024 metrics->fMaxCharWidth = SkIntToScalar(otm.otmTextMetrics.tmMaxCharWidth);
1025 metrics->fXMin = SkIntToScalar(otm.otmrcFontBox.left);
1026 metrics->fXMax = SkIntToScalar(otm.otmrcFontBox.right);
1027 #endif
1028 metrics->fUnderlineThickness = SkIntToScalar(otm.otmsUnderscoreSize);
1029 metrics->fUnderlinePosition = -SkIntToScalar(otm.otmsUnderscorePosition);
1042 1030
1043 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; 1031 metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1044 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; 1032 metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1045 }
1046 1033
1047 if (my) { 1034 metrics->fXHeight = SkIntToScalar(otm.otmsXHeight);
1048 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS 1035 GLYPHMETRICS gm;
1049 my->fTop = SkIntToScalar(-otm.otmrcFontBox.top); 1036 sk_bzero(&gm, sizeof(gm));
1050 my->fAscent = SkIntToScalar(-otm.otmAscent); 1037 DWORD len = GetGlyphOutlineW(fDDC, 'x', GGO_METRICS, &gm, 0, 0, &gMat2Identi ty);
1051 my->fDescent = SkIntToScalar(-otm.otmDescent); 1038 if (len != GDI_ERROR && gm.gmBlackBoxY > 0) {
1052 my->fBottom = SkIntToScalar(-otm.otmrcFontBox.bottom); 1039 metrics->fXHeight = SkIntToScalar(gm.gmBlackBoxY);
1053 my->fLeading = SkIntToScalar(otm.otmLineGap);
1054 my->fAvgCharWidth = SkIntToScalar(otm.otmTextMetrics.tmAveCharWidth);
1055 my->fMaxCharWidth = SkIntToScalar(otm.otmTextMetrics.tmMaxCharWidth);
1056 my->fXMin = SkIntToScalar(otm.otmrcFontBox.left);
1057 my->fXMax = SkIntToScalar(otm.otmrcFontBox.right);
1058 #endif
1059 my->fUnderlineThickness = SkIntToScalar(otm.otmsUnderscoreSize);
1060 my->fUnderlinePosition = -SkIntToScalar(otm.otmsUnderscorePosition);
1061
1062 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1063 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1064
1065 my->fXHeight = SkIntToScalar(otm.otmsXHeight);
1066
1067 GLYPHMETRICS gm;
1068 sk_bzero(&gm, sizeof(gm));
1069 DWORD len = GetGlyphOutlineW(fDDC, 'x', GGO_METRICS, &gm, 0, 0, &gMat2Id entity);
1070 if (len != GDI_ERROR && gm.gmBlackBoxY > 0) {
1071 my->fXHeight = SkIntToScalar(gm.gmBlackBoxY);
1072 }
1073 } 1040 }
1074 } 1041 }
1075 1042
1076 //////////////////////////////////////////////////////////////////////////////// //////// 1043 //////////////////////////////////////////////////////////////////////////////// ////////
1077 1044
1078 #define SK_SHOW_TEXT_BLIT_COVERAGE 0 1045 #define SK_SHOW_TEXT_BLIT_COVERAGE 0
1079 1046
1080 static void build_power_table(uint8_t table[], float ee) { 1047 static void build_power_table(uint8_t table[], float ee) {
1081 for (int i = 0; i < 256; i++) { 1048 for (int i = 0; i < 256; i++) {
1082 float x = i / 255.f; 1049 float x = i / 255.f;
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 } 2369 }
2403 2370
2404 void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const { 2371 void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const {
2405 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || 2372 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag ||
2406 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) 2373 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag)
2407 { 2374 {
2408 rec->fMaskFormat = SkMask::kA8_Format; 2375 rec->fMaskFormat = SkMask::kA8_Format;
2409 rec->fFlags |= SkScalerContext::kGenA8FromLCD_Flag; 2376 rec->fFlags |= SkScalerContext::kGenA8FromLCD_Flag;
2410 } 2377 }
2411 2378
2412 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag | 2379 unsigned flagsWeDontSupport = SkScalerContext::kVertical_Flag |
2380 SkScalerContext::kDevKernText_Flag |
2413 SkScalerContext::kForceAutohinting_Flag | 2381 SkScalerContext::kForceAutohinting_Flag |
2414 SkScalerContext::kEmbeddedBitmapText_Flag | 2382 SkScalerContext::kEmbeddedBitmapText_Flag |
2415 SkScalerContext::kEmbolden_Flag | 2383 SkScalerContext::kEmbolden_Flag |
2416 SkScalerContext::kLCD_BGROrder_Flag | 2384 SkScalerContext::kLCD_BGROrder_Flag |
2417 SkScalerContext::kLCD_Vertical_Flag; 2385 SkScalerContext::kLCD_Vertical_Flag;
2418 rec->fFlags &= ~flagsWeDontSupport; 2386 rec->fFlags &= ~flagsWeDontSupport;
2419 2387
2420 SkPaint::Hinting h = rec->getHinting(); 2388 SkPaint::Hinting h = rec->getHinting();
2421 switch (h) { 2389 switch (h) {
2422 case SkPaint::kNo_Hinting: 2390 case SkPaint::kNo_Hinting:
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 2587
2620 private: 2588 private:
2621 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2589 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2622 }; 2590 };
2623 2591
2624 /////////////////////////////////////////////////////////////////////////////// 2592 ///////////////////////////////////////////////////////////////////////////////
2625 2593
2626 SkFontMgr* SkFontMgr_New_GDI() { 2594 SkFontMgr* SkFontMgr_New_GDI() {
2627 return SkNEW(SkFontMgrGDI); 2595 return SkNEW(SkFontMgrGDI);
2628 } 2596 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkScalerContext_win_dw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698