From c545dd901b2ff54ac8d200962834ce06791a3f23 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Tue, 16 Oct 2012 16:43:22 -0700 Subject: [PATCH] Fix Font::measure_text() to actually compute a bounding box width. --- src/servo/text/font.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/servo/text/font.rs b/src/servo/text/font.rs index da75d040348..f0671e55758 100644 --- a/src/servo/text/font.rs +++ b/src/servo/text/font.rs @@ -55,12 +55,11 @@ pub impl Font : FontMethods { // TODO: alter advance direction for RTL // TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text let mut advance = au(0); - let mut bounds = Rect(Point2D(au(0), -self.metrics.ascent), - Size2D(au(0), self.metrics.ascent + self.metrics.descent)); do run.glyphs.iter_glyphs_for_range(offset, length) |_i, glyph| { advance += glyph.advance(); - bounds = bounds.translate(&Point2D(glyph.advance(), au(0))); } + let mut bounds = Rect(Point2D(au(0), -self.metrics.ascent), + Size2D(advance, self.metrics.ascent + self.metrics.descent)); // TODO(Issue #125): support loose and tight bounding boxes; using the // ascent+descent and advance is sometimes too generous and