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

Unified Diff: src/ports/SkFontHost_win.cpp

Issue 12391045: Use bitmap-based glyph metrics instead of outline-based metrics (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 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 7941)
+++ src/ports/SkFontHost_win.cpp (working copy)
@@ -813,13 +813,21 @@
glyph->fRsbDelta = 0;
glyph->fLsbDelta = 0;
- // Note: need to use GGO_GRAY8_BITMAP instead of GGO_METRICS because GGO_METRICS returns a smaller
- // BlackBlox; we need the bigger one in case we need the image. fAdvance is the same.
- uint32_t ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GRAY8_BITMAP | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
+ // Note 1: Don't use GGO_GRAY8_BITMAP because it always returns outline-based metrics.
+ // When embedded bitmap exists, bitmap-based metrics have to be used.
+ // If not, slightly smaller metrics is returned (anti-alias gap)
+ // so outset is necessary.
+ // Note 2: Don't change glyph shape because in that case GetGlyphOutline always returns
+ // outline-based metrics.
+ fMat22.eM12 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM12));
+ fMat22.eM22 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM22));
+ uint32_t ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
if (GDI_ERROR == ret) {
ensure_typeface_accessible(fRec.fFontID);
- ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GRAY8_BITMAP | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
+ ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
}
+ fMat22.eM12 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM12));
+ fMat22.eM22 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM22));
if (GDI_ERROR != ret) {
if (ret == 0) {
@@ -828,21 +836,16 @@
}
glyph->fWidth = gm.gmBlackBoxX;
glyph->fHeight = gm.gmBlackBoxY;
- glyph->fTop = SkToS16(gm.gmptGlyphOrigin.y - gm.gmBlackBoxY);
+ glyph->fTop = SkToS16(-gm.gmptGlyphOrigin.y);
glyph->fLeft = SkToS16(gm.gmptGlyphOrigin.x);
glyph->fAdvanceX = SkIntToFixed(gm.gmCellIncX);
glyph->fAdvanceY = -SkIntToFixed(gm.gmCellIncY);
// we outset in all dimensions, since the image may bleed outside
// of the computed bounds returned by GetGlyphOutline.
- // This was deduced by trial and error for small text (e.g. 8pt), so there
- // maybe a more precise way to make this adjustment...
- //
- // This test shows us clipping the tops of some of the CJK fonts unless we
- // increase the top of the box by 2, hence the height by 4. This seems to
- // correspond to an embedded bitmap font, but not sure.
- // LayoutTests/fast/text/backslash-to-yen-sign-euc.html
- //
+ // it is because we ignore grayscale or ClearType anti-alias
+ // in getting metrics.
+ // Note: GetGlyphOutline doesn't support ClearType.
if (glyph->fWidth) { // don't outset an empty glyph
glyph->fWidth += 4;
glyph->fHeight += 4;
« 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