JavaFX字体渲染中的字符间距(字距调整)错误(在Linux中) [英] Bad character spacing (kerning) in JavaFX's font rendering (in Linux)

查看:1166
本文介绍了JavaFX字体渲染中的字符间距(字距调整)错误(在Linux中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始在JavaFX中开发一个应用程序而且我遇到了一个问题,我发现很少有用的信息:Linux中字符之间的间距非常不均匀。我不是在谈论不同角色的宽度,而是在讨论角色之间的空格。

I've started developing an application in JavaFX and I've run in an issue, I could find very little helpful information about: The spacing of between characters in Linux is very uneven. I'm not talking about the width of different characters but of the spaces between the characters.

它在普通文本中可见,但下面的例子比正常情况更好地说明了效果文本。看看第一行。前两个字符之间的空格小于第二个和第三个字符之间的空格。这也发生在第六和第七个角色之间以及其他几个角色:

It's visible in normal text, but the following example illustrates the effect better than normal text. Take a look at the first row. The space between the first two characters is smaller than between the second and third. This also happens between the sixth and seventh character and several others:

Swing没有这个问题,JavaFX在Windows中没有这个问题,或者在该操作系统上几乎看不到。它似乎也不是Mac上的主要问题。为了比较,这是Mac Retina MacBook Pro的一个示例输出,2014年中,运行OS X 10.12.6和Java 9.0.4:

Swing does not have this problem and JavaFX doesn't have this problem in Windows or it is barely visible on that OS. Neither does it appear to be a major issue on Mac. For comparison, here is a sample output on a Mac Retina MacBook Pro, mid-2014, running OS X 10.12.6 and Java 9.0.4:

有人知道这是否是JavaFX字体渲染引擎中的错误?如果有,是否有解决方法?

Does anyone know if this is a bug in JavaFX's font rendering engine? If so, is there a workaround?

我真的开始怀疑我是否应该更改框架,因为在我看来这样糟糕的字体渲染是不可接受的。

I'm really starting to wonder if I should change the framework as in my opinion such bad font rendering is not acceptable.

关于这个问题还有另外一个问题,但还没有得到答案:
为什么JavaFX在使用Text组件时在字母之间添加额外的间距以及如何修复它?

There is another question regarding this issue but it hasn't been answered, yet: Why does JavaFX add extra spacing between letters when using the Text component and how do I fix it?

我已经能够在运行Manjaro的两台不同Linux机器上以及运行Debian的虚拟机中使用以下代码重现此问题:

I have been able reproduce this issue on two different Linux machines running Manjaro and in a virtual machine running Debian with the following code:

package de.localtoast.fonttest;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class FontTest extends Application {

    @Override
    public void start(Stage primaryStage) {
        VBox root = new VBox();
        Label label1 = new Label("0000000000000000000000");
        Label label2 = new Label("OOOOOOOOOOOOOOOOOOOOOO");
        Label label3 = new Label("oooooooooooooooooooooo");

        root.getChildren().add(label1);
        root.getChildren().add(label2);
        root.getChildren().add(label3);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Font Test");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


推荐答案

jewelsea建议我把我的问题放在 openjfx-dex邮件列表上。 那边的人可以解释发生了什么

jewelsea advised me to put my question on the openjfx-dex mailing list. The guys over there could explain what's going on:

是JavaFX的问题,但是我的Linux系统上存在配置问题。 JavaFX需要子像素渲染才能正确定位字形。我正在使用Manjaro,它是Archlinux的衍生物。在Archlinux中,子像素渲染是默认禁用,这与专利有关微软承保。

It is not a problem of JavaFX but a configuration issue on my Linux system. JavaFX needs subpixel rendering to position the glyphs correctly. I'm using Manjaro, which is a derivative of Archlinux. In Archlinux, subpixel rendering is disabled by default, which has to do with patents covered by Microsoft.

在我的情况下,问题可以通过从AUR安装freetype2-ultimate5软件包来解决,尽管在wiki中提到的freetype2-cleartype软件包可能是更好的选择。但由于另一个问题,后者目前无法在我的系统上编译。

In my case the problem could be solved by installing the freetype2-ultimate5 package from AUR, although the in the wiki mentioned freetype2-cleartype package is probably the better choice. But the latter one currently doesn't compile on my system because of another issue.

这篇关于JavaFX字体渲染中的字符间距(字距调整)错误(在Linux中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆