diff --git a/crates/gpui_wgpu/src/cosmic_text_system.rs b/crates/gpui_wgpu/src/cosmic_text_system.rs index 775067518c6..7d738affa57 100644 --- a/crates/gpui_wgpu/src/cosmic_text_system.rs +++ b/crates/gpui_wgpu/src/cosmic_text_system.rs @@ -816,7 +816,10 @@ impl CosmicTextSystemState { let shaped_glyph = ShapedGlyph { id: GlyphId(glyph.glyph_id as u32), - position: point(glyph.x.into(), glyph.y.into()), + position: point( + (glyph.x + glyph.x_offset * f32::from(font_size)).into(), + (glyph.y - glyph.y_offset * f32::from(font_size)).into(), + ), index: glyph.start, is_emoji, }; @@ -1369,6 +1372,29 @@ mod tests { Ok(text_system.layout_line(text, gpui::px(14.0), &runs)) } + #[test] + fn combining_marks_are_positioned_over_their_base() -> Result<()> { + let text_system = text_system()?; + let layout = layout_text(&text_system, "v\u{0304}v")?; + let glyphs = layout + .runs + .iter() + .flat_map(|run| run.glyphs.iter()) + .collect::>(); + assert_eq!(glyphs.len(), 3); + let base = glyphs[0].position; + let mark = glyphs[1].position; + let next = glyphs[2].position; + assert!(mark.x > base.x); + assert!( + mark.x < next.x, + "combining mark positioned after its base: mark.x={:?}, next.x={:?}", + mark.x, + next.x + ); + Ok(()) + } + /// Mirrors the original crash: mixed-direction text reaching the shaper /// through `shape_text`, which only splits lines on `\n`. #[test]