javafxarabicarabic-support

JavaFX weird gaps in arabic text


Using JavaFX version 18.0.1 to display Arabic text. Testing on Ubuntu. On some machines, but not all, there are some weird gaps between the letters. I say weird because the text does not get wider overall. Seems like the overlapping parts of the letters become white instead of black. Here is both the gaps and the correct render:

Arabic text gap and correct

One difference I discovered is that on the machine where it is rendered correctly, JavaFX downloads two extra libraries into its cache dir: libdecora_sse.so and libprism_sw.so. To my best knowledge, prism is the name of the font rendering engine, so my guess is the latter has to do with this for sure. But I have no idea what makes JavaFX to use it on one machine but not on the other.

Any help would be appreciated.


Solution

  • Force the software renderer to be used via command line options.

    -Dprism.order=sw
    

    I did not try this, but the asker independently confirmed that this solution works in prior comments.

    Background Info

    There must be a limitation in the JavaFX renderer (or an associated open-source font lib used by JavaFX or native OS font implementation) that prevents it from correctly rendering certain fonts (probably those with significant kerning) on some platforms using the hardware-accelerated pipelines. Forcing the rendering engine to not use hardware acceleration and to make the calculations in software fixes this issue.

    Prism is the JavaFX rendering engine. I think the font engine used is something different, it may (or may not) delegate to prism for the actual rendering but I think all the font calculations come from some open-source library assisted by the native OS.

    My guess is the problem is related to kerning support. The font is assuming that kerning is supported, but in the incorrect rendering, kerning is not used. That could be a limitation of JavaFX, the open-source lib JavaFX uses for rendering, or the underlying OS rendering capabilities.

    This question on JavaFX character spacing on Linux might give you more insights. To be clear, your issue is different than the one in that question. The recommendation to ask the mailing list is sound.

    Oracle did have some closed-source rendering on their distribution, but I don’t know if that exists anymore, you could try an Oracle Java 8 version that includes JavaFX, though obsolete it might work.

    Decora I think does effects (though it might do other things). I think the sse version uses SSE extension instructions on the x86 chips rather than using a GPU shader. It is probably used as part of the software rendering.