mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #11032 - mbrubeck:no-whitespace, r=pcwalton
Filter out whitespace glyphs from display list Fixes #10244. r? @glennw <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11032) <!-- Reviewable:end -->
This commit is contained in:
commit
df8008cfe6
3 changed files with 26 additions and 18 deletions
|
@ -1800,6 +1800,7 @@ impl ScaledFontExtensionMethods for ScaledFont {
|
||||||
for slice in run.natural_word_slices_in_visual_order(range) {
|
for slice in run.natural_word_slices_in_visual_order(range) {
|
||||||
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
|
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
|
||||||
let glyph_advance = glyph.advance();
|
let glyph_advance = glyph.advance();
|
||||||
|
if !slice.glyphs.is_whitespace() {
|
||||||
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
||||||
let azglyph = struct__AzGlyph {
|
let azglyph = struct__AzGlyph {
|
||||||
mIndex: glyph.id() as u32,
|
mIndex: glyph.id() as u32,
|
||||||
|
@ -1808,8 +1809,9 @@ impl ScaledFontExtensionMethods for ScaledFont {
|
||||||
y: (origin.y + glyph_offset.y).to_f32_px(),
|
y: (origin.y + glyph_offset.y).to_f32_px(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
origin = Point2D::new(origin.x + glyph_advance, origin.y);
|
|
||||||
azglyphs.push(azglyph)
|
azglyphs.push(azglyph)
|
||||||
|
}
|
||||||
|
origin.x = origin.x + glyph_advance;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ impl GlyphEntry {
|
||||||
Au(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as i32)
|
Au(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as i32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn id(&self) -> GlyphId {
|
fn id(&self) -> GlyphId {
|
||||||
self.value & GLYPH_ID_MASK
|
self.value & GLYPH_ID_MASK
|
||||||
}
|
}
|
||||||
|
@ -361,6 +362,7 @@ impl<'a> GlyphInfo<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn offset(self) -> Option<Point2D<Au>> {
|
pub fn offset(self) -> Option<Point2D<Au>> {
|
||||||
match self {
|
match self {
|
||||||
GlyphInfo::Simple(_, _) => None,
|
GlyphInfo::Simple(_, _) => None,
|
||||||
|
@ -436,10 +438,12 @@ impl<'a> GlyphStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn len(&self) -> ByteIndex {
|
pub fn len(&self) -> ByteIndex {
|
||||||
ByteIndex(self.entry_buffer.len() as isize)
|
ByteIndex(self.entry_buffer.len() as isize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_whitespace(&self) -> bool {
|
pub fn is_whitespace(&self) -> bool {
|
||||||
self.is_whitespace
|
self.is_whitespace
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,14 +394,16 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
for slice in item.text_run.natural_word_slices_in_visual_order(&item.range) {
|
for slice in item.text_run.natural_word_slices_in_visual_order(&item.range) {
|
||||||
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
|
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
|
||||||
let glyph_advance = glyph.advance();
|
let glyph_advance = glyph.advance();
|
||||||
|
if !slice.glyphs.is_whitespace() {
|
||||||
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
||||||
let glyph = webrender_traits::GlyphInstance {
|
let glyph = webrender_traits::GlyphInstance {
|
||||||
index: glyph.id(),
|
index: glyph.id(),
|
||||||
x: (origin.x + glyph_offset.x).to_f32_px(),
|
x: (origin.x + glyph_offset.x).to_f32_px(),
|
||||||
y: (origin.y + glyph_offset.y).to_f32_px(),
|
y: (origin.y + glyph_offset.y).to_f32_px(),
|
||||||
};
|
};
|
||||||
origin = Point2D::new(origin.x + glyph_advance, origin.y);
|
|
||||||
glyphs.push(glyph);
|
glyphs.push(glyph);
|
||||||
|
}
|
||||||
|
origin.x = origin.x + glyph_advance;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue