bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Indic font rendering incorrectly

Open neevany opened this issue 1 year ago • 1 comments

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

  • what were you expecting? to render font correctly like in the screenshot from google fonts site Screenshot 2024-04-18 at 8 01 54 AM

  • what actually happened? it did not render font correctly like in this screenshot Screenshot 2024-04-18 at 8 00 53 AM

neevany avatar Apr 18 '24 02:04 neevany

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.

jordanhalase avatar Apr 25 '24 01:04 jordanhalase

Looks like this was fixed by #10193

image

rparrett avatar Aug 22 '24 22:08 rparrett