Discussion:
Bad character spacing (kerning?) in Linux
o***@arne-augenstein.de
2018-03-07 16:51:42 UTC
Permalink
Hello all,

I've recently started a project in JavaFX and had some trouble with
inconsistent widths of spaces between characters in Linux. I haven't
been able to find much useful information and therefore posted a
stackoverflow question with a screenshot illustrating the problem and
some simple example code to reproduce the issue. I think it's better
explained with the picture, that's why I won't repeat myself here and
point you instead to my question on that page:

https://stackoverflow.com/questions/49136131/bad-character-spacing-kerning-in-javafxs-font-rendering-in-linux

One of the members of stackoverflow advised me to ask this question on
your mailing list. My question is if this behavior is inherent to the
way JavaFX renders text on Linux. And if there is some
workaround/setting which I could use to circumvent this issue.

Thanks in advance and regards
Arne Augenstein
Phil Race
2018-03-07 17:10:49 UTC
Permalink
The Linux image shows greyscale text.
The Mac image shows subpixel LCD text.
The latter can be positioned with sub-pixel (1/3 pixel) resolution.

Why does this make a difference ?
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

-phil.
Post by o***@arne-augenstein.de
Hello all,
I've recently started a project in JavaFX and had some trouble with
inconsistent widths of spaces between characters in Linux. I haven't
been able to find much useful information and therefore posted a
stackoverflow question with a screenshot illustrating the problem and
some simple example code to reproduce the issue. I think it's better
explained with the picture, that's why I won't repeat myself here and
https://stackoverflow.com/questions/49136131/bad-character-spacing-kerning-in-javafxs-font-rendering-in-linux
One of the members of stackoverflow advised me to ask this question on
your mailing list. My question is if this behavior is inherent to the
way JavaFX renders text on Linux. And if there is some
workaround/setting which I could use to circumvent this issue.
Thanks in advance and regards
Arne Augenstein
Arne Augenstein
2018-03-07 20:20:59 UTC
Permalink
Thanks Phil, I think you've put me on the right track. I'm using
Manjaro, which is a very close derivative of Archlinux. Looking at
https://wiki.archlinux.org/index.php/font_configuration#Subpixel_rendering
it seems this really could be the underlying problem. Subpixel
rendering is disabled by default on Archlinux systems.

I probably will need a few days to verify that this is in fact the
issue. I will report back as soon as I've found out more.

Arne
Post by Phil Race
The Linux image shows greyscale text.
The Mac image shows subpixel LCD text.
The latter can be positioned with sub-pixel (1/3 pixel) resolution.
Why does this make a difference ?
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
-phil.
Post by o***@arne-augenstein.de
Hello all,
I've recently started a project in JavaFX and had some trouble with
inconsistent widths of spaces between characters in Linux. I
haven't been able to find much useful information and therefore
posted a stackoverflow question with a screenshot illustrating the
problem and some simple example code to reproduce the issue. I
think it's better explained with the picture, that's why I won't
repeat myself here and point you instead to my question on that
https://stackoverflow.com/questions/49136131/bad-character-spacing-kerning-in-javafxs-font-rendering-in-linux

One of the members of stackoverflow advised me to ask this question
on your mailing list. My question is if this behavior is inherent
to the way JavaFX renders text on Linux. And if there is some
workaround/setting which I could use to circumvent this issue.
Thanks in advance and regards
Arne Augenstein
Arne Augenstein
2018-03-07 21:14:44 UTC
Permalink
Ok, it went faster than expected. I can confirm that missing subpixel
rendering was the issue.

Archlinux has some alternative freetype packages which provide
Cleartype rendering. I found one that works on my machine and now the
text is rendered correctly.

Thanks a lot. I've searched for a solution to this behaviour for quite
a couple of days and you provided me with the correct answer within an
hour.

For reference (if someone else has the same problem): I've installed
the package freetype2-ultimate5 from the AUR repository.
freetype2-cleartype would've probably been the better choice as it is
advised to use this one in the wiki article from my previous mail. But
that package currently doesn't compile on my PC.

Arne



On Mi, Mär 7, 2018 at 9:20 PM, Arne Augenstein
Post by Arne Augenstein
Thanks Phil, I think you've put me on the right track. I'm using
Manjaro, which is a very close derivative of Archlinux. Looking at
https://wiki.archlinux.org/index.php/font_configuration#Subpixel_rendering
it seems this really could be the underlying problem. Subpixel
rendering is disabled by default on Archlinux systems.
I probably will need a few days to verify that this is in fact the
issue. I will report back as soon as I've found out more.
Arne
Post by Phil Race
The Linux image shows greyscale text.
The Mac image shows subpixel LCD text.
The latter can be positioned with sub-pixel (1/3 pixel) resolution.
Why does this make a difference ?
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
-phil.
Post by o***@arne-augenstein.de
Hello all,
I've recently started a project in JavaFX and had some trouble with
inconsistent widths of spaces between characters in Linux. I
haven't been able to find much useful information and therefore
posted a stackoverflow question with a screenshot illustrating
the problem and some simple example code to reproduce the issue.
I think it's better explained with the picture, that's why I
won't repeat myself here and point you instead to my question on
https://stackoverflow.com/questions/49136131/bad-character-spacing-kerning-in-javafxs-font-rendering-in-linux

One of the members of stackoverflow advised me to ask this question
on your mailing list. My question is if this behavior is
inherent to the way JavaFX renders text on Linux. And if there
is some workaround/setting which I could use to circumvent this
issue.
Thanks in advance and regards
Arne Augenstein
Loading...