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

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

Issue 152073003: Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is us… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Updating files as per HEAD Created 6 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
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontHost_win_dw.cpp » ('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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 if (0 == ret) { 1054 if (0 == ret) {
1055 return; 1055 return;
1056 } 1056 }
1057 1057
1058 if (mx) { 1058 if (mx) {
1059 mx->fTop = SkIntToScalar(-otm.otmrcFontBox.left); 1059 mx->fTop = SkIntToScalar(-otm.otmrcFontBox.left);
1060 mx->fAscent = SkIntToScalar(-otm.otmAscent); 1060 mx->fAscent = SkIntToScalar(-otm.otmAscent);
1061 mx->fDescent = SkIntToScalar(-otm.otmDescent); 1061 mx->fDescent = SkIntToScalar(-otm.otmDescent);
1062 mx->fBottom = SkIntToScalar(otm.otmrcFontBox.right); 1062 mx->fBottom = SkIntToScalar(otm.otmrcFontBox.right);
1063 mx->fLeading = SkIntToScalar(otm.otmLineGap); 1063 mx->fLeading = SkIntToScalar(otm.otmLineGap);
1064 mx->fUnderlineThickness = SkIntToScalar(otm.otmsUnderscoreSize);
1065 mx->fUnderlinePosition = -SkIntToScalar(otm.otmsUnderscorePosition);
1066
1067 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1068 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1064 } 1069 }
1065 1070
1066 if (my) { 1071 if (my) {
1067 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS 1072 #ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
1068 my->fTop = SkIntToScalar(-otm.otmrcFontBox.top); 1073 my->fTop = SkIntToScalar(-otm.otmrcFontBox.top);
1069 my->fAscent = SkIntToScalar(-otm.otmAscent); 1074 my->fAscent = SkIntToScalar(-otm.otmAscent);
1070 my->fDescent = SkIntToScalar(-otm.otmDescent); 1075 my->fDescent = SkIntToScalar(-otm.otmDescent);
1071 my->fBottom = SkIntToScalar(-otm.otmrcFontBox.bottom); 1076 my->fBottom = SkIntToScalar(-otm.otmrcFontBox.bottom);
1072 my->fLeading = SkIntToScalar(otm.otmLineGap); 1077 my->fLeading = SkIntToScalar(otm.otmLineGap);
1073 my->fAvgCharWidth = SkIntToScalar(otm.otmTextMetrics.tmAveCharWidth); 1078 my->fAvgCharWidth = SkIntToScalar(otm.otmTextMetrics.tmAveCharWidth);
1074 my->fMaxCharWidth = SkIntToScalar(otm.otmTextMetrics.tmMaxCharWidth); 1079 my->fMaxCharWidth = SkIntToScalar(otm.otmTextMetrics.tmMaxCharWidth);
1075 my->fXMin = SkIntToScalar(otm.otmrcFontBox.left); 1080 my->fXMin = SkIntToScalar(otm.otmrcFontBox.left);
1076 my->fXMax = SkIntToScalar(otm.otmrcFontBox.right); 1081 my->fXMax = SkIntToScalar(otm.otmrcFontBox.right);
1082 my->fUnderlineThickness = SkIntToScalar(otm.otmsUnderscoreSize);
1083 my->fUnderlinePosition = -SkIntToScalar(otm.otmsUnderscorePosition);
1084
1085 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1086 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1077 #endif 1087 #endif
1078 my->fXHeight = SkIntToScalar(otm.otmsXHeight); 1088 my->fXHeight = SkIntToScalar(otm.otmsXHeight);
1079 1089
1080 GLYPHMETRICS gm; 1090 GLYPHMETRICS gm;
1081 sk_bzero(&gm, sizeof(gm)); 1091 sk_bzero(&gm, sizeof(gm));
1082 DWORD len = GetGlyphOutlineW(fDDC, 'x', GGO_METRICS, &gm, 0, 0, &gMat2Id entity); 1092 DWORD len = GetGlyphOutlineW(fDDC, 'x', GGO_METRICS, &gm, 0, 0, &gMat2Id entity);
1083 if (len != GDI_ERROR && gm.gmBlackBoxY > 0) { 1093 if (len != GDI_ERROR && gm.gmBlackBoxY > 0) {
1084 my->fXHeight = SkIntToScalar(gm.gmBlackBoxY); 1094 my->fXHeight = SkIntToScalar(gm.gmBlackBoxY);
1085 } 1095 }
1086 } 1096 }
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 2639
2630 private: 2640 private:
2631 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2641 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2632 }; 2642 };
2633 2643
2634 /////////////////////////////////////////////////////////////////////////////// 2644 ///////////////////////////////////////////////////////////////////////////////
2635 2645
2636 SkFontMgr* SkFontMgr_New_GDI() { 2646 SkFontMgr* SkFontMgr_New_GDI() {
2637 return SkNEW(SkFontMgrGDI); 2647 return SkNEW(SkFontMgrGDI);
2638 } 2648 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontHost_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698