linebender / parley

Rich text layout library
Apache License 2.0
228 stars 28 forks source link

Arabic font fallback not working on linux #174

Closed richardhozak closed 2 days ago

richardhozak commented 6 days ago

Hello, I wanted to test out this library, so I've run the swash_render example on my system and the font fallback for arabic text does not work as expected.

Here is rendered swash_output.png from the example: swash_render

Is there anything I can test to debug this issue?

xorgy commented 5 days ago

Welcome, @richardhozak. If you could be a little more specific that'd be helpful. This will depend on which fonts you have installed, and how your FontConfig is set up. Which distro are you on, and which version of that distro? Also, does Arabic text normally display on your system, but not in this example?

richardhozak commented 4 days ago

I am on PopOS 22.04 I have not messed with FontConfig so it should be in default configuration. Arabic text renders in Firefox and I've also tested cosmic text, which also works FWIW. I looked into installed fonts and can see that there are arabic variants that are chosen in Firefox.

I've also tested swash_render example on Ubuntu 24.04 and it works there, I am not sure what could be different between those two systems.

richardhozak commented 3 days ago

I've investigated a bit more, tried default installation of PopOS 22.04 and Ubuntu 24.04 in VMs and can see that in Ubuntu 24.04 fontique correctly chooses fallback family "Noto Sans Arabic" but on PopOS 22.04 it figures out two fallback families: "Noto Sans" and "Noto Serif" both not being correct.

richardhozak commented 3 days ago

I've found the issue. For some reason fontconfig's lang map reports "Noto Sans" and "Noto Serif" as default families to use for Arabic even though we can find font families with better coverage.

dfrg commented 2 days ago

Thanks for investigating this. We currently blindly trust fontconfig’s language mappings but it seems like we should do a minimal coverage check on those and trigger the fallback path if it fails.

richardhozak commented 2 days ago

I do have a fix you are describing, will publish PR later today, it got a bit late yesterday 😴...