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

Unified Diff: src/ports/SkFontHost_win.cpp

Issue 14759021: Use more fields from OutlineFontMEtrics: linegap, bbox. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win.cpp
===================================================================
--- src/ports/SkFontHost_win.cpp (revision 9035)
+++ src/ports/SkFontHost_win.cpp (working copy)
@@ -99,8 +99,11 @@
* and since we have a cache of LOGFONTs for our tyepfaces, we always set the
* lfHeight to a canonical size, and then we use the 2x2 matrix to achieve the
* actual requested size.
+ *
+ * Not critical to match the font's upem, but we want it big enough to avoid
+ * precision loss for GDI calls that return ints (e.g. GetOutlineFontMetrics).
*/
-static const int gCanonicalTextSize = 64;
+static const int gCanonicalTextSize = 2048;
static void tchar_to_skstring(const TCHAR t[], SkString* s) {
#ifdef UNICODE
@@ -835,11 +838,17 @@
}
void SkScalerContext_Windows::generateFontMetrics(SkPaint::FontMetrics* mx, SkPaint::FontMetrics* my) {
-// Note: This code was borrowed from generateLineHeight, which has a note
-// stating that it may be incorrect.
- if (!(mx || my))
+ if (!(mx || my)) {
return;
+ }
+ if (mx) {
+ sk_bzero(mx, sizeof(*mx));
+ }
+ if (my) {
+ sk_bzero(my, sizeof(*my));
+ }
+
SkASSERT(fDDC);
if (fType == SkScalerContext_Windows::kBitmap_Type) {
@@ -848,8 +857,7 @@
mx->fAscent = SkIntToScalar(-fTM.tmAscent);
mx->fDescent = -SkIntToScalar(fTM.tmDescent);
mx->fBottom = SkIntToScalar(fTM.tmDescent);
- mx->fLeading = SkIntToScalar(fTM.tmInternalLeading
- + fTM.tmExternalLeading);
+ mx->fLeading = SkIntToScalar(fTM.tmExternalLeading);
}
if (my) {
@@ -857,8 +865,7 @@
my->fAscent = SkIntToScalar(-fTM.tmAscent);
my->fDescent = SkIntToScalar(-fTM.tmDescent);
my->fBottom = SkIntToScalar(fTM.tmDescent);
- my->fLeading = SkIntToScalar(fTM.tmInternalLeading
- + fTM.tmExternalLeading);
+ my->fLeading = SkIntToScalar(fTM.tmExternalLeading);
bungeman-skia 2013/05/08 02:40:40 tmAveCharWidth is also available here. There is no
}
return;
}
@@ -875,21 +882,21 @@
}
if (mx) {
- mx->fTop = -fScale * otm.otmTextMetrics.tmAscent;
+ mx->fTop = -fScale * otm.otmrcFontBox.left;
mx->fAscent = -fScale * otm.otmAscent;
mx->fDescent = -fScale * otm.otmDescent;
- mx->fBottom = fScale * otm.otmTextMetrics.tmDescent;
- mx->fLeading = fScale * (otm.otmTextMetrics.tmInternalLeading
- + otm.otmTextMetrics.tmExternalLeading);
+ mx->fBottom = fScale * otm.otmrcFontBox.right;
+ mx->fLeading = fScale * otm.otmLineGap;
}
if (my) {
- my->fTop = -fScale * otm.otmTextMetrics.tmAscent;
+ my->fTop = -fScale * otm.otmrcFontBox.top;
my->fAscent = -fScale * otm.otmAscent;
my->fDescent = -fScale * otm.otmDescent;
- my->fBottom = fScale * otm.otmTextMetrics.tmDescent;
- my->fLeading = fScale * (otm.otmTextMetrics.tmInternalLeading
- + otm.otmTextMetrics.tmExternalLeading);
+ my->fBottom = fScale * otm.otmrcFontBox.bottom;
+ my->fLeading = fScale * otm.otmLineGap;
+ my->fAvgCharWidth = fScale * otm.otmTextMetrics.tmAveCharWidth;
+ my->fXHeight = fScale * otm.otmsXHeight;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698