mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Fix Font::measure_text() to actually compute a bounding box width.
This commit is contained in:
parent
22af9770b8
commit
c545dd901b
1 changed files with 2 additions and 3 deletions
|
@ -55,12 +55,11 @@ pub impl Font : FontMethods {
|
||||||
// TODO: alter advance direction for RTL
|
// TODO: alter advance direction for RTL
|
||||||
// TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text
|
// TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text
|
||||||
let mut advance = au(0);
|
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| {
|
do run.glyphs.iter_glyphs_for_range(offset, length) |_i, glyph| {
|
||||||
advance += glyph.advance();
|
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
|
// TODO(Issue #125): support loose and tight bounding boxes; using the
|
||||||
// ascent+descent and advance is sometimes too generous and
|
// ascent+descent and advance is sometimes too generous and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue