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

Side by Side 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, 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 /* 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 apply_outset(glyph, fOutset); 806 apply_outset(glyph, fOutset);
807 return; 807 return;
808 } 808 }
809 809
810 GLYPHMETRICS gm; 810 GLYPHMETRICS gm;
811 sk_bzero(&gm, sizeof(gm)); 811 sk_bzero(&gm, sizeof(gm));
812 812
813 glyph->fRsbDelta = 0; 813 glyph->fRsbDelta = 0;
814 glyph->fLsbDelta = 0; 814 glyph->fLsbDelta = 0;
815 815
816 // Note: need to use GGO_GRAY8_BITMAP instead of GGO_METRICS because GGO_MET RICS returns a smaller 816 // Note 1: Don't use GGO_GRAY8_BITMAP because it always returns outline-base d metrics.
817 // BlackBlox; we need the bigger one in case we need the image. fAdvance is the same. 817 // When embedded bitmap exists, bitmap-based metrics have to be used .
818 uint32_t ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GRAY8_BITMAP | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22); 818 // If not, slightly smaller metrics is returned (anti-alias gap)
819 // so outset is necessary.
820 // Note 2: Don't change glyph shape because in that case GetGlyphOutline alw ays returns
821 // outline-based metrics.
822 fMat22.eM12 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM12));
823 fMat22.eM22 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM22));
824 uint32_t ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
819 if (GDI_ERROR == ret) { 825 if (GDI_ERROR == ret) {
820 ensure_typeface_accessible(fRec.fFontID); 826 ensure_typeface_accessible(fRec.fFontID);
821 ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GRAY8_BITMAP | GG O_GLYPH_INDEX, &gm, 0, NULL, &fMat22); 827 ret = GetGlyphOutlineW(fDDC, glyph->getGlyphID(0), GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
822 } 828 }
829 fMat22.eM12 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM12));
830 fMat22.eM22 = SkFixedToFIXED(-SkFIXEDToFixed(fMat22.eM22));
823 831
824 if (GDI_ERROR != ret) { 832 if (GDI_ERROR != ret) {
825 if (ret == 0) { 833 if (ret == 0) {
826 // for white space, ret is zero and gmBlackBoxX, gmBlackBoxY are 1 i ncorrectly! 834 // for white space, ret is zero and gmBlackBoxX, gmBlackBoxY are 1 i ncorrectly!
827 gm.gmBlackBoxX = gm.gmBlackBoxY = 0; 835 gm.gmBlackBoxX = gm.gmBlackBoxY = 0;
828 } 836 }
829 glyph->fWidth = gm.gmBlackBoxX; 837 glyph->fWidth = gm.gmBlackBoxX;
830 glyph->fHeight = gm.gmBlackBoxY; 838 glyph->fHeight = gm.gmBlackBoxY;
831 glyph->fTop = SkToS16(gm.gmptGlyphOrigin.y - gm.gmBlackBoxY); 839 glyph->fTop = SkToS16(-gm.gmptGlyphOrigin.y);
832 glyph->fLeft = SkToS16(gm.gmptGlyphOrigin.x); 840 glyph->fLeft = SkToS16(gm.gmptGlyphOrigin.x);
833 glyph->fAdvanceX = SkIntToFixed(gm.gmCellIncX); 841 glyph->fAdvanceX = SkIntToFixed(gm.gmCellIncX);
834 glyph->fAdvanceY = -SkIntToFixed(gm.gmCellIncY); 842 glyph->fAdvanceY = -SkIntToFixed(gm.gmCellIncY);
835 843
836 // we outset in all dimensions, since the image may bleed outside 844 // we outset in all dimensions, since the image may bleed outside
837 // of the computed bounds returned by GetGlyphOutline. 845 // of the computed bounds returned by GetGlyphOutline.
838 // This was deduced by trial and error for small text (e.g. 8pt), so the re 846 // it is because we ignore grayscale or ClearType anti-alias
839 // maybe a more precise way to make this adjustment... 847 // in getting metrics.
840 // 848 // Note: GetGlyphOutline doesn't support ClearType.
841 // This test shows us clipping the tops of some of the CJK fonts unless we
842 // increase the top of the box by 2, hence the height by 4. This seems t o
843 // correspond to an embedded bitmap font, but not sure.
844 // LayoutTests/fast/text/backslash-to-yen-sign-euc.html
845 //
846 if (glyph->fWidth) { // don't outset an empty glyph 849 if (glyph->fWidth) { // don't outset an empty glyph
847 glyph->fWidth += 4; 850 glyph->fWidth += 4;
848 glyph->fHeight += 4; 851 glyph->fHeight += 4;
849 glyph->fTop -= 2; 852 glyph->fTop -= 2;
850 glyph->fLeft -= 2; 853 glyph->fLeft -= 2;
851 854
852 apply_outset(glyph, fOutset); 855 apply_outset(glyph, fOutset);
853 } 856 }
854 857
855 if (fHiResFont) { 858 if (fHiResFont) {
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 rec->fMaskFormat = SkMask::kA8_Format; 1761 rec->fMaskFormat = SkMask::kA8_Format;
1759 } 1762 }
1760 #endif 1763 #endif
1761 1764
1762 LogFontTypeface* logfontTypeface = static_cast<LogFontTypeface*>(typeface); 1765 LogFontTypeface* logfontTypeface = static_cast<LogFontTypeface*>(typeface);
1763 if (!logfontTypeface->fCanBeLCD && isLCD(*rec)) { 1766 if (!logfontTypeface->fCanBeLCD && isLCD(*rec)) {
1764 rec->fMaskFormat = SkMask::kA8_Format; 1767 rec->fMaskFormat = SkMask::kA8_Format;
1765 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; 1768 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag;
1766 } 1769 }
1767 } 1770 }
OLDNEW
« 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