一个应用字体变为点阵字

这两天在用omegat翻译东西,发现界面所有字体变成了点阵字。在选项菜单中是可以设置字体的,默认是noto sans cjk regular,但无论设置什么字体,UI都是点阵字。

其它应用很正常,唯独omegat是点阵字。

(不确认是不是点阵字,但渲染效果特别差)

如果使用命令启动omegat: java -jar OmegaT.jar,UI会有乱码。

我尝试从官方[omegat.org]重新下载,仍然无效。

这个应该怎么排查?

ps:

以前一直在gnome环境中使用omegat,没有任何字体问题。最近换kde后,第一次使用omegat。

我又在虚拟机KDE环境中做了测试,结果仍是字体有问题。这可以排除我的主机系统问题,因为虚拟机是没经过任何配置的。

你是从Debian正式储存库安装的omegat吗?你从选项->字体对话框指定了字体吗?

omegat不是从debian官方仓库安装的,而是从omegat.org下载的,解压后直接运行~

已经从选项->字体对话框指定了字体为noto sans cjk sc regular~

我建议从Debian正式储存库安装它。
从启动选项中指定-Dswing.plaf.metal.controlFont-Dswing.plaf.metal.userFont可能会有所帮助。

我刚从“发现”里安装了一下,安装好后打开也是点阵字效果(v3.6)~

我在terminal里执行omegat,后面分别加上 -Dswing.plaf.metal.controlFont-Dswing.plaf.metal.userFont启动两次,还是点阵字效果~

保险起见,我在buster+gnome虚拟机中试了一下,从omegat.org下载(v4.3.2),解压,安装default-jre,然后执行java -jar OmegaT.jar,界面字体非常好,没有问题~

参照Arch Wiki的JRE Font页面:
https://wiki.archlinux.org/index.php/Java_Runtime_Environment_fonts#Font_selection
参照线程:
https://omegat.sourceforge.io/user-support-archive/2019-January/043336.html
使用启动参数-Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel以使用GTK界面会有效吗?

你应该同时使用这两个启动选项,而不是分别使用。
观察以下线程
https://omegat.sourceforge.io/user-support-archive/2019-January/043335.html
https://omegat.sourceforge.io/user-support-archive/2019-January/043337.html
https://omegat.sourceforge.io/user-support-archive/2019-January/043338.html
该报告声称,他的设置对其他Java程序有效,而对omega无效;一个反馈建议他使用其他窗口管理器,而另一个反馈声称他能够让程序在GNOME上工作。
这可能是一个上游错误。我建议调整Java的字体设置,然后试着以GTK界面启动它,如果仍然无效……可能它现在无法在KDE下良好工作。

https://omega.sourceforge.io/user-support-archive/2019-January/043335.html

上面这一类的链接,我居然全部是404~

两个参数一起上,字体仍然是点阵效果~

估计KDE plasma环境omegat就只能这样了,我先将就着用,回头有时间看能不能把omegat改成lokalize~

是omegat不兼容Qt么?

我修复了相关链接,你再看看……
建议:调整Java的字体设置,然后试着以GTK界面启动它。
根据邮件列表中的说明,我估计是由于omegat不兼容KDE的fontconfig设置造成的。

我在terminal里输入omegat,后面加上上面的参数,启动后界面字体还是点阵字体的效果,没有改善~
然后,我把前面三个参数全部一次性加上,启动后还是没有改善~

这种做法是错误的,你应该使用命令java [options] -jar OmegaT.jar为其添加启动选项。

我试了一下,用java -jar OmegaT.jar 后面加上最后一个参数,以及三个参数全部加上,启动两次,结果都是如我上面的第二张截图,UI部分文字是点阵效果,另外部分是方块~

java [三个参数] -jar OmegaT.jar,结果相同~

Debian软件包中的/usr/bin/omegat文件内容为:

#!/bin/sh

JAVA_OPTIONS='-Djava.library.path=/usr/lib/jni'

JAVA=$(which java | xargs readlink -f)

echo "$JAVA" | grep -q -e '\(openjdk\|sun\)'
if [ $? -eq 0 ]
then
    JAVABIN=$JAVA
elif [ -x /usr/lib/jvm/java-6-openjdk/bin/java ]
then
    JAVABIN="/usr/lib/jvm/java-6-openjdk/bin/java"
elif [ -x /usr/lib/jvm/java-6-sun/bin/java ]
then
    JAVABIN="/usr/lib/jvm/java-6-sun/bin/java"
elif [ -x /usr/lib/jvm/java-1.5.0-sun/bin/java ]
then
    JAVABIN="/usr/lib/jvm/java-1.5.0-sun/bin/java"
else
    echo "Suitable java binary not found."
    exit 1
fi

exec $JAVABIN $JAVA_OPTIONS -jar /usr/share/omegat/OmegaT.jar $*

注意:Debian的/bin/sh链接到/usr/bin/dash而非/usr/bin/bash
因此,如果在终端使用omegat命令,其参数会被覆盖。

Arch Wiki的建议有帮助吗?
对于 Plasma还有别的错误报告:
OmegaT - multiplatform CAT tool / Bugs / #929 Built-in Help not starting when clicking on the menu entry (sourceforge.net)
OmegaT - multiplatform CAT tool / Bugs / #999 External opening/browsing not supported on some Linux environments (sourceforge.net)
java - Desktop API is not supported on the current platform - Stack Overflow

Basically, the problem is that Java Desktop integration doesn’t work well on Linux.
It was designed to work good with Windows; something works on other systems, but nobody really cared to add proper support for those. Even if you install the required ‘gnome libraries’, the results will be poor.

因此,或许应该避免使用Java GUI程序。

arch wiki的两个方法,我试了一下:

第一个方法,改/etc/environment,我试了JAVA_FONTS=/usr/share/fonts/truetype和/usr/share/fonts/truetype/noto以及/home/peter/.fonts三个方式,每次都重启,重启后启动omegat,没有效果~

第二个方法,把字体拷贝到/usr/lib/jvm/java-8-openjdk/jre/lib/fonts/fallback/,我系统不存在这个目录,我自己创建,也没有效果~

我觉得,避免使用java GUI也许是正确的,不知道omegat开发团队有没有想过这个问题~

Arch Wiki上说:

Substitute the /usr/lib/jvm/java-8-openjdk for the $JAVA_HOME of the JRE you are actually using.

我怀疑你使用的不是Java 8。建议检查环境变量$JAVA_HOME和命令java -version的输出。

openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, mixed mode, sharing)

我在创建目录时,中间的java-8-openjdk我改成了java-11-openjdk-amd64(因为这个目录是存在的)~
java-11-openjdk-amd64目录存在,但下面没有jre,后续就都是现创建了~

所以结论是,试图在omegat启动时为其指定字体的努力全部失败了。
我阅读了omegat的用户手册
https://omegat.sourceforge.io/manual-standard/zh_CN/index.html
它与Oracle Java兼容而不是与OpenJDK兼容,这是第一个问题;第二个问题是,通常Java GUI的API与GNOME兼容而不是与FreeDesktop标准兼容,因此它在基于Qt的桌面环境(甚至包括Openbox)上会出现问题。
因此,几乎可以肯定这是一个上游错误,应该把它报告给该软件包的维护者。
但是无论如何,Java GUI在KDE上很糟糕,应该避免使用它。

看来在KDE上应该把omegat换成lokalize。

报告给维护者,是报告给debian,还是omegat团队?

按照分发的惯例,报告给Debian。如果Debian的软件包维护者认为不能解决它,就会将其报告给上游。

Usually program messages and documentation are written in English. Using a framework made of a set of tools and libraries, it is possible to have your favorite applications speak your native non-English language. This process of adapting an application to a specific language is known as localization. The localization process includes translating the program’s interfaces and documentation to the various languages users need and, in some countries or regions, making the inputs and outputs conform to particular conventions. Lokalize is a tool which will assist you in the localization process to make an application’s interface speaks many languages.
Every internationalization-aware program makes available for translation one or more message-catalog files. The extension of these files is .pot. POT is an acronym for “Portable Object Template”. Lokalize is an advanced and easy to use PO file (GNU gettext message catalogs) editor. It is a computer-aided translation system for translators, written from scratch using the KDE Platform 4 framework. Aside from basic editing of PO files with nifty auxiliary details, it integrates support for glossary, translation memory, diff-modes for QA, project managing, etc. It has many features like full navigation capabilities, extensive editing functionality, search functions, syntax checking and statistics functions.
Portable Object (.po) files: Each translator takes a copy of one of these POT templates and begins to fill in the blanks: each message is translated into the language desired. The file containing the translated text is referred to as a PO (Portable Object) file.

不幸的是,看起来lokalize并不完全是omegat的替代品。

昨天晚上我发现了localize不适用的这个问题,所以,目前还是暂时将就着用omegat~

其实我想知道你有什么lokalize不能满足的需求……