Fix Font::measure_text() to actually compute a bounding box width.

This commit is contained in:
Brian J. Burg 2012-10-16 16:43:22 -07:00
parent 22af9770b8
commit c545dd901b

View file

@ -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