aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/text.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-11 23:05:37 -0500
committerGitHub <noreply@github.com>2020-02-11 23:05:37 -0500
commit6d6d16f7f492e6346f0391e352015226a4444806 (patch)
treed991c986a7f83be25157934e93c248ea86ee4b00 /components/layout/text.rs
parentbaac1e2c69d3b6e840ced2be4b5e03bb39bd40d5 (diff)
parentd1f8d576f83714fe674a36c5b718341c236312e6 (diff)
downloadservo-6d6d16f7f492e6346f0391e352015226a4444806.tar.gz
servo-6d6d16f7f492e6346f0391e352015226a4444806.zip
Auto merge of #25717 - emilio:gecko-sync, r=emilio,nox
style: Sync changes from mozilla-central. See individual commits for details. https://bugzilla.mozilla.org/show_bug.cgi?id=1614394
Diffstat (limited to 'components/layout/text.rs')
-rw-r--r--components/layout/text.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/components/layout/text.rs b/components/layout/text.rs
index ef9515b0726..1d9fae80297 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -10,7 +10,7 @@ use crate::fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTe
use crate::inline::{InlineFragmentNodeFlags, InlineFragments};
use crate::linked_list::split_off_head;
use app_units::Au;
-use gfx::font::{FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions};
+use gfx::font::{self, FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions};
use gfx::text::glyph::ByteIndex;
use gfx::text::text_run::TextRun;
use gfx::text::util::{self, CompressionMode};
@@ -195,7 +195,24 @@ impl TextRunScanner {
};
text_transform = inherited_text_style.text_transform;
letter_spacing = inherited_text_style.letter_spacing;
- word_spacing = inherited_text_style.word_spacing.to_hash_key();
+ word_spacing = inherited_text_style
+ .word_spacing
+ .to_length()
+ .map(|l| l.into())
+ .unwrap_or_else(|| {
+ let space_width = font_group
+ .borrow_mut()
+ .find_by_codepoint(&mut font_context, ' ')
+ .and_then(|font| {
+ let font = font.borrow();
+ font.glyph_index(' ')
+ .map(|glyph_id| font.glyph_h_advance(glyph_id))
+ })
+ .unwrap_or(font::LAST_RESORT_GLYPH_ADVANCE);
+ inherited_text_style
+ .word_spacing
+ .to_used_value(Au::from_f64_px(space_width))
+ });
text_rendering = inherited_text_style.text_rendering;
word_break = inherited_text_style.word_break;
}