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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp

Issue 2392033002: Correcting text baseline for tiny fonts (Closed)
Patch Set: Rebaseline. Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Alexey Proskuryakov 3 * Copyright (C) 2006 Alexey Proskuryakov
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 isVDMXValid = true; 124 isVDMXValid = true;
125 WTF::Partitions::fastFree(vdmxTable); 125 WTF::Partitions::fastFree(vdmxTable);
126 } 126 }
127 } 127 }
128 #endif 128 #endif
129 129
130 float ascent; 130 float ascent;
131 float descent; 131 float descent;
132 132
133 // Beware those who step here: This code is designed to match Win32 font 133 // Beware those who step here: This code is designed to match Win32 font
134 // metrics *exactly* (except the adjustment of ascent/descent on 134 // metrics *exactly* except:
135 // Linux/Android). 135 // - the adjustment of ascent/descent on Linux/Android
136 // - metrics.fAscent and metrics.fDesscent are not rounded to int
136 if (isVDMXValid) { 137 if (isVDMXValid) {
137 ascent = vdmxAscent; 138 ascent = vdmxAscent;
138 descent = -vdmxDescent; 139 descent = -vdmxDescent;
139 } else { 140 } else {
140 ascent = SkScalarRoundToInt(-metrics.fAscent); 141 ascent = -metrics.fAscent;
141 descent = SkScalarRoundToInt(metrics.fDescent); 142 descent = metrics.fDescent;
142 #if OS(LINUX) || OS(ANDROID) 143 #if OS(LINUX) || OS(ANDROID)
143 // When subpixel positioning is enabled, if the descent is rounded down, the 144 // When subpixel positioning is enabled, if the descent is rounded down, the
144 // descent part of the glyph may be truncated when displayed in a 'overflow: 145 // descent part of the glyph may be truncated when displayed in a 'overflow:
145 // hidden' container. To avoid that, borrow 1 unit from the ascent when 146 // hidden' container. To avoid that, borrow 1 unit from the ascent when
146 // possible. 147 // possible.
147 // FIXME: This can be removed if sub-pixel ascent/descent is supported. 148 // FIXME: This can be removed if sub-pixel ascent/descent is supported.
148 if (platformData().getFontRenderStyle().useSubpixelPositioning && 149 if (platformData().getFontRenderStyle().useSubpixelPositioning &&
149 descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) { 150 descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) {
150 ++descent; 151 ++descent;
151 --ascent; 152 --ascent;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (glyphs[i]) { 428 if (glyphs[i]) {
428 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); 429 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
429 haveGlyphs = true; 430 haveGlyphs = true;
430 } 431 }
431 } 432 }
432 433
433 return haveGlyphs; 434 return haveGlyphs;
434 } 435 }
435 436
436 } // namespace blink 437 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698