JavaFX中阿拉伯文本中的奇怪间隙

huangapple go评论48阅读模式
英文:

JavaFX weird gaps in arabic text

问题

使用JavaFX版本18.0.1来显示阿拉伯文本。在Ubuntu上进行测试。在一些机器上,但不是所有机器,字母之间会出现一些奇怪的间隙。我说奇怪,因为文本整体不会变宽。似乎字母的重叠部分变成了白色而不是黑色。这里是间隙和正确的渲染:

JavaFX中阿拉伯文本中的奇怪间隙

我发现一个区别是,在正确渲染的机器上,JavaFX会下载两个额外的库到其缓存目录中:libdecora_sse.so和libprism_sw.so。据我最好的了解,prism是字体渲染引擎的名称,所以我猜后者肯定与此有关。但我不知道是什么导致JavaFX在某台机器上使用它而在另一台机器上不使用它。

任何帮助将不胜感激。

英文:

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:

JavaFX中阿拉伯文本中的奇怪间隙

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.

答案1

得分: 1

强制使用命令行选项来使用软件渲染器。

-Dprism.order=sw

我没有尝试过这个,但提问者在之前的评论中独立确认这个解决方案有效。

背景信息

JavaFX 渲染器(或者 JavaFX 使用的相关开源字体库或本地操作系统字体实现)可能存在某种限制,阻止它在某些平台上正确渲染某些字体(可能是那些带有显著字距的字体)。强制渲染引擎不使用硬件加速并在软件中进行计算可以解决这个问题。

Prism 是 JavaFX 的渲染引擎。我认为使用的字体引擎可能不同,它可能(或者可能不)委托 prism 来进行实际渲染,但我认为所有的字体计算都来自某个由本地操作系统辅助的开源库。

我猜想问题与字距支持有关。字体假设支持字距,但在不正确的渲染中,没有使用字距。这可能是 JavaFX、JavaFX 用于渲染的开源库,或者底层操作系统渲染能力的限制。

这个关于Linux 上 JavaFX 字符间距的问题可能会给你更多的见解。明确一点,你的问题与那个问题不同。向邮件列表提问的建议是明智的。

Oracle 曾经在他们的发行版中提供了一些闭源渲染,但我不知道它是否还存在,你可以尝试包含 JavaFX 的 Oracle Java 8 版本,虽然已经过时,但可能有效。

我认为 Decora 可能执行一些效果(尽管可能还有其他功能)。我认为 SSE 版本使用了x86 处理器上的 SSE 扩展指令,而不是使用 GPU 着色器。它可能作为软件渲染的一部分使用。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月29日 02:18:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76352973.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定