Only apply leading adjustment on newlines.
This results in ALL height adjustments being off by 2px, regardless of leading or font size. Tantalizing!
This commit is contained in:
parent
2ab85c32e2
commit
2858c09b6e
|
@ -88,7 +88,18 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
|
||||||
self.font
|
self.font
|
||||||
.map(|f| f.get_leading_for_height(self.max_font_size))
|
.map(|f| f.get_leading_for_height(self.max_font_size))
|
||||||
.unwrap_or_else(|| Twips::new(0)),
|
.unwrap_or_else(|| Twips::new(0)),
|
||||||
) + Twips::from_pixels(self.current_line_span.leading)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calculate the line-to-line leading present on ths line, including the
|
||||||
|
/// font-leading above.
|
||||||
|
fn line_leading_adjustment(&self) -> Twips {
|
||||||
|
round_down_to_pixel(
|
||||||
|
self.font
|
||||||
|
.map(|f| f.get_leading_for_height(self.max_font_size))
|
||||||
|
.unwrap_or_else(|| Twips::new(0))
|
||||||
|
+ Twips::from_pixels(self.current_line_span.leading),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply all indents and alignment to the current line, if necessary.
|
/// Apply all indents and alignment to the current line, if necessary.
|
||||||
|
@ -180,7 +191,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
|
||||||
self.cursor.set_x(Twips::from_pixels(0.0));
|
self.cursor.set_x(Twips::from_pixels(0.0));
|
||||||
self.cursor += (
|
self.cursor += (
|
||||||
Twips::from_pixels(0.0),
|
Twips::from_pixels(0.0),
|
||||||
self.max_font_size + self.font_leading_adjustment(),
|
self.max_font_size + self.line_leading_adjustment(),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue