summaryrefslogtreecommitdiffstats
path: root/webkit/port/platform/graphics
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-01 14:56:39 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-01 14:56:39 +0000
commit2dec58a1e2770208e9eba8300c52a82af8b8df0b (patch)
tree65f610edcc122d307fc9bab9b531bb8edc75903d /webkit/port/platform/graphics
parent3c06d5c5c16948627c5a1c27a6db263f87c84b98 (diff)
downloadchromium_src-2dec58a1e2770208e9eba8300c52a82af8b8df0b.zip
chromium_src-2dec58a1e2770208e9eba8300c52a82af8b8df0b.tar.gz
chromium_src-2dec58a1e2770208e9eba8300c52a82af8b8df0b.tar.bz2
Fix font regression. I was using ascent() instead of font->ascent(), which
I think doesn't take into account fallback fonts and small caps, so those characters would be incorrectly vertically aligned. This also fixes an old bug I noticed where if the run is more than 1024 pixels, it will start being drawn over itself since we never used the updated x coordinate. Review URL: http://codereview.chromium.org/9206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform/graphics')
-rw-r--r--webkit/port/platform/graphics/FontWin.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/webkit/port/platform/graphics/FontWin.cpp b/webkit/port/platform/graphics/FontWin.cpp
index 0166763..6428bcb 100644
--- a/webkit/port/platform/graphics/FontWin.cpp
+++ b/webkit/port/platform/graphics/FontWin.cpp
@@ -77,13 +77,17 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext,
Vector<WORD, kDefaultBufferLength> glyphs;
Vector<int, kDefaultBufferLength> advances;
+ // Compute the coordinate. The 'origin' represents the baseline, so we need
+ // to move it up to the top of the bounding square.
+ int x = static_cast<int>(point.x());
+ int lineTop = static_cast<int>(point.y()) - font->ascent();
+
// We draw the glyphs in chunks to avoid having to do a heap allocation for
// the arrays of characters and advances. Since ExtTextOut is the
// lowest-level text output function on Windows, there should be little
// penalty for splitting up the text. On the other hand, the buffer cannot
// be bigger than 4094 or the function will fail.
int glyphIndex = 0;
- int chunkX = 0; // x offset of this span from the point
while (glyphIndex < numGlyphs) {
// how many chars will be in this chunk?
int curLen = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
@@ -99,16 +103,9 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext,
curWidth += advances[i];
}
- SkPoint origin2 = point;
- origin2.fX += chunkX;
-
bool success = false;
for (int executions = 0; executions < 2; ++executions) {
- // The 'origin' represents the baseline, so we need to move it up
- // to the top of the bounding square by subtracting the ascent
- success = !!ExtTextOut(hdc, static_cast<int>(origin2.fX),
- static_cast<int>(origin2.fY) - ascent(),
- ETO_GLYPH_INDEX, NULL,
+ success = !!ExtTextOut(hdc, x, lineTop, ETO_GLYPH_INDEX, NULL,
reinterpret_cast<const wchar_t*>(&glyphs[0]),
curLen,
&advances[0]);
@@ -123,7 +120,7 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext,
ASSERT(success);
- chunkX += curWidth;
+ x += curWidth;
}
SelectObject(hdc, oldFont);