1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

fonts: shaper: also handle <wideglyph><spacer><spacer> ligatures

The Cascadia Code font has ligatures for `---` that consist of
a triple wide glyph followed by two zero-width glyphs.  Rewrite
that into a single glyph that spans three cells and remove the
zero-width glyphs from the shaped info.

refs: https://github.com/wez/wezterm/issues/478
This commit is contained in:
Wez Furlong 2021-02-25 21:16:10 -08:00
parent 4e27607615
commit 8009863f9b

View File

@ -48,10 +48,18 @@ where
infos: &[GlyphInfo],
glyphs: &[Rc<CachedGlyph<T>>],
) -> Vec<ShapedInfo<T>> {
let mut pos = vec![];
let mut pos: Vec<ShapedInfo<T>> = vec![];
let mut run = None;
for (info, glyph) in infos.iter().zip(glyphs.iter()) {
if !info.is_space && glyph.texture.is_none() {
if let Some(shaped) = pos.last_mut() {
if shaped.pos.bitmap_pixel_width as f32 > shaped.pos.bearing_x {
// This space-like glyph belongs to the preceding glyph
shaped.pos.num_cells += 1;
continue;
}
}
if run.is_none() {
run.replace(ShapedInfo {
pos: GlyphPosition {
@ -121,6 +129,14 @@ where
});
}
}
if let Some(run) = run.take() {
log::warn!(
"leftovers when shaping {:#?} {:#?} -> {:?}",
infos,
glyphs,
run
);
}
pos
}
}