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

Side by Side Diff: src/ports/SkFontHost_win_dw.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: Fixing comments for Underline patch Created 6 years, 10 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
« src/ports/SkFontHost_win.cpp ('K') | « src/ports/SkFontHost_win.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTypes.h" 8 #include "SkTypes.h"
9 #undef GetGlyphIndices 9 #undef GetGlyphIndices
10 10
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 fTypeface->fDWriteFontFace->GetMetrics(&dwfm); 867 fTypeface->fDWriteFontFace->GetMetrics(&dwfm);
868 868
869 SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm); 869 SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm);
870 if (mx) { 870 if (mx) {
871 mx->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem; 871 mx->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem;
872 mx->fAscent = mx->fTop; 872 mx->fAscent = mx->fTop;
873 mx->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem; 873 mx->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem;
874 mx->fBottom = mx->fDescent; 874 mx->fBottom = mx->fDescent;
875 mx->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem; 875 mx->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem;
876 mx->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem; 876 mx->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem;
877 mx->fUnderlineThickness = fRec.fTextSize * SkIntToScalar(dwfm.underlineP osition) / upem;
878 mx->fUnderlinePosition = fRec.fTextSize * SkIntToScalar(dwfm.underlineTh ickness) / upem;
879
880 if(!mx->fUnderlineThickness)
bungeman-skia 2014/02/19 15:39:17 Here and below: I don't believe that DirectWrite s
h.joshi 2014/02/19 17:12:03 Okey, Added these checks below as "face->underline
881 mx->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIs Valid_FontMetricFlag);
882 else
883 mx->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsVa lid_FontMetricFlag);
884
885 if(!mx->fUnderlinePosition)
886 mx->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsV alid_FontMetricsflag);
887 else
888 mx->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsVal id_FontMetricsflag);
877 } 889 }
878 890
879 if (my) { 891 if (my) {
880 my->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem; 892 my->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem;
881 my->fAscent = my->fTop; 893 my->fAscent = my->fTop;
882 my->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem; 894 my->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem;
883 my->fBottom = my->fDescent; 895 my->fBottom = my->fDescent;
884 my->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem; 896 my->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem;
885 my->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem; 897 my->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem;
898 my->fUnderlineThickness = fRec.fTextSize * SkIntToScalar(dwfm.underlineP osition) / upem;
899 my->fUnderlinePosition = fRec.fTextSize * SkIntToScalar(dwfm.underlineTh ickness) / upem;
900
901 if(!my->fUnderlineThickness)
902 my->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIs Valid_FontMetricFlag);
903 else
904 my->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsVa lid_FontMetricFlag);
905
906 if(!my->fUnderlinePosition)
907 my->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsV alid_FontMetricsflag);
908 else
909 my->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsVal id_FontMetricsflag);
886 } 910 }
887 } 911 }
888 912
889 /////////////////////////////////////////////////////////////////////////////// 913 ///////////////////////////////////////////////////////////////////////////////
890 914
891 #include "SkColorPriv.h" 915 #include "SkColorPriv.h"
892 916
893 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph) { 917 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph) {
894 const int width = glyph.fWidth; 918 const int width = glyph.fWidth;
895 const size_t dstRB = (width + 7) >> 3; 919 const size_t dstRB = (width + 7) >> 3;
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); 1936 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
1913 } else { 1937 } else {
1914 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N AME_MAX_LENGTH); 1938 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N AME_MAX_LENGTH);
1915 if (localeNameLen) { 1939 if (localeNameLen) {
1916 localeName = localeNameStorage; 1940 localeName = localeNameStorage;
1917 }; 1941 };
1918 } 1942 }
1919 1943
1920 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam e, localeNameLen)); 1944 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam e, localeNameLen));
1921 } 1945 }
OLDNEW
« src/ports/SkFontHost_win.cpp ('K') | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698