Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start implementing text in layout 2020 #24822

Merged
merged 6 commits into from Nov 25, 2019
Prev

Support line_height better in layout 2020

  • Loading branch information
nox committed Nov 25, 2019
commit 85b2a4dc6466cc2136f0caa5867803dcee253c8a
@@ -292,6 +292,7 @@ impl TextRun {
use gfx::font::{ShapingFlags, ShapingOptions};
use style::computed_values::text_rendering::T as TextRendering;
use style::computed_values::word_break::T as WordBreak;
use style::values::generics::text::LineHeight;

let font_style = self.parent_style.clone_font();
let inherited_text_style = self.parent_style.get_inherited_text();
@@ -375,10 +376,11 @@ impl TextRun {
break;
}
}
// https://www.w3.org/TR/CSS2/visudet.html#propdef-line-height
// 'normal':
// “set the used value to a "reasonable" value based on the font of the element.”
let line_height = font_size * 1.2;
let line_height = match self.parent_style.get_inherited_text().line_height {
LineHeight::Normal => font_line_gap.into(),
LineHeight::Number(n) => font_size * n.0,
LineHeight::Length(l) => l.0,
};
let content_rect = Rect {
start_corner: Vec2 {
block: Length::zero(),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.