LINUX.ORG.RU

Кернинг в Java приложениях

 , , , ,


0

1

Помогите, пожалуйста, разобраться со шрифтами.

Дано: Fedora 37, KDE 5.27.4, X11. В Java приложениях некоторые буквы в шрифте липнут друг к другу.

Беглый гуглеж дал такую же проблему на SO. Цитата решения:

It is not a problem of JavaFX but a configuration issue on my Linux system. JavaFX needs subpixel rendering to position the glyphs correctly.

JavaFX like CoreText + DirectWrite, and unlike GDI + Swing uses unhinted glyphs with floating point accumulation of the positions. But the raster problem is that you need to align the glyph to discrete pixels In the subpixel case you have 3x the resolution to play with and the rounding to the raster grid is not obvious. If your linux system were configured to support LCD subpixel text I’d expect it to be similar to Mac .. modulo the fact that retina is hi-res and that the fonts will be different. So it is probably not something FX has control over .. you need to look at your settings. If freetype from your vendor is configured without LCD text support you may be out of luck

Я в шрифтах вообще на шарю, поэтому единственное что уловил из всего этого, что счастье наступит при включении LCD subpixel rendering.

В настройках шрифта KDE такой опции нет.

Попробовал сходить на арчевики и добавить вручную в ~/.config/fontconfig/fonts.conf

<match target="font">
  <edit name="lcdfilter" mode="assign">
    <const>lcddefault</const>
  </edit>
</match>

Также пробовал создать файлик ~/.Xresources с содержимым:

Xft.lcdfilter: lcddefault

Ни то, ни другое не помогло.

Из freetype удалось вытащить только это:

❯ freetype-config --cflags
-I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -pthread

~
❯ freetype-config --version
24.3.18

Ответ на: комментарий от andreyu

Вроде, да. Опять же я не сильно спец по опциям компилятора. Вот исходники сборки.

+ echo 'Patch #0 (freetype-2.3.0-enable-spr.patch):'
Patch #0 (freetype-2.3.0-enable-spr.patch):
+ /usr/bin/patch --no-backup-if-mismatch -f -p1 -b --suffix .enable-spr --fuzz=0
patching file include/freetype/config/ftoption.h
Hunk #1 succeeded at 123 (offset 31 lines).

Это содержимое патча:

--- freetype-2.3.0/include/freetype/config/ftoption.h.spf	2007-01-18 14:27:34.000000000 -0500
+++ freetype-2.3.0/include/freetype/config/ftoption.h	2007-01-18 14:27:48.000000000 -0500
@@ -92,7 +92,7 @@
    * When this macro is not defined, FreeType offers alternative LCD
    * rendering technology that produces excellent output.
    */
-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
emcode
() автор топика

В JavaFx был свой рендерер вроде, если тебя именно fx интересует , в том же вопросе и связанных упомянуты разные опции для контроля. В обычных swing приложениях вроде поддержку «системного» рендеринга добавляли, можешь в к-л intellij ide/jre проверить дополнительно, там точно работало.

e1nste1n ★★★★★
()