bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
34.94k stars 3.41k forks source link

Indic font rendering incorrectly #13010

Closed neevany closed 1 week ago

neevany commented 4 months ago

Bevy version

11afe160791cdc8c043afb7a7c68cfd8ae1c6a87 / master

Relevant system information

SystemInfo { os: "MacOS 14.4.1 ", kernel: "23.4.0", cpu: "Apple M2 Pro"}
AdapterInfo { name: "Apple M2 Pro", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

What you did

https://fonts.google.com/noto/specimen/Noto+Sans+Telugu

let text_style = TextStyle {
    font: asset_server.load("fonts/NotoSansTelugu-Medium.ttf"),
    font_size: 60.0,
    ..default()
};
parent.spawn(TextBundle {
  text: Text {
      sections: vec![TextSection::new("రాష్ట్రముల మధ్య", text_style.clone())],
      ..default()
  },
  ..default()
});

What went wrong

the font is not rendering correctly

jordanhalase commented 4 months ago

I do not know how to fix this but I decomposed the string into its code points.

రాష్ట్రముల మధ్య

Code points:

U+0C30      ర
U+0C3E      ా
U+0C37      ష
U+0C4D      ్
U+0C1F      ట
U+0C4D      ్
U+0C30      ర
U+0C2E      మ
U+0C41      ు
U+0C32      ల
U+0020       
U+0C2E      మ
U+0C27      ధ
U+0C4D      ్
U+0C2F      య

The first character looks like a ర with a ◌ా nonspacing mark (U+0C3E) appended. The combining mark is tacked on, but the glyph should render differently when it is applied. They should combine as a రా.

The next visual glyph appears to be made up of five code points, which render completely differently if any are removed. This is me pressing backspace on the second glyph:

ష్ట్ర ష్ట్ ష్ట ష్ ష

For this glyph, the first two code points U+0C37 U+0C4D combine to make ష్ but the second and third code point U+0C4D U+0C1F combine to make ట్, yet the fourth and fifth code point combine to make ్ర. Maybe something is parsing the TTF wrong with the grapheme clusters?

Is this a limitation of the ab_glyph crate that bevy_text uses internally?

Does anyone have any thoughts?

EDIT: I wonder if down the line we could make use of something like rustybuzz as a text shaping engine for complex scripts like Indic or Hebrew. Bevy doesn't seem to support right-to-left languages either at the moment.

rparrett commented 1 week ago

Looks like this was fixed by #10193

image