mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
layout: Resolve word_spacing ahead of time.
It's not possible anymore, in the presence of min() / max(), to split a <length-percentage> value into a <length> and a <percentage> component. Tweak word_spacing to do what Gecko does (resolving it in advance).
This commit is contained in:
parent
e227715aee
commit
f03026b869
8 changed files with 45 additions and 24 deletions
|
@ -601,13 +601,6 @@ impl TextRun {
|
|||
flags.insert(ShapingFlags::KEEP_ALL_FLAG);
|
||||
}
|
||||
|
||||
let shaping_options = gfx::font::ShapingOptions {
|
||||
letter_spacing,
|
||||
word_spacing: inherited_text_style.word_spacing.to_hash_key(),
|
||||
script: unicode_script::Script::Common,
|
||||
flags,
|
||||
};
|
||||
|
||||
crate::context::with_thread_local_font_context(layout_context, |font_context| {
|
||||
let font_group = font_context.font_group(font_style);
|
||||
let font = font_group
|
||||
|
@ -616,6 +609,25 @@ impl TextRun {
|
|||
.expect("could not find font");
|
||||
let mut font = font.borrow_mut();
|
||||
|
||||
let word_spacing = &inherited_text_style.word_spacing;
|
||||
let word_spacing = word_spacing
|
||||
.to_length()
|
||||
.map(|l| l.into())
|
||||
.unwrap_or_else(|| {
|
||||
let space_width = font
|
||||
.glyph_index(' ')
|
||||
.map(|glyph_id| font.glyph_h_advance(glyph_id))
|
||||
.unwrap_or(gfx::font::LAST_RESORT_GLYPH_ADVANCE);
|
||||
word_spacing.to_used_value(Au::from_f64_px(space_width))
|
||||
});
|
||||
|
||||
let shaping_options = gfx::font::ShapingOptions {
|
||||
letter_spacing,
|
||||
word_spacing,
|
||||
script: unicode_script::Script::Common,
|
||||
flags,
|
||||
};
|
||||
|
||||
let (runs, break_at_start) = gfx::text::text_run::TextRun::break_and_shape(
|
||||
&mut font,
|
||||
&self.text,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue