JavaFX always choose monospace font - possible bug?

Adam Granger adam at adamish.com
Fri Apr 24 08:30:33 UTC 2015


I'm using a redhat 6 system with jdk 1.8u40 where the only font available
is "Liberation" in all its variants, bold, italic, mono, serif, sans-serif
etc.

/usr/share/fonts/liberation
/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
/usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
/usr/share/fonts/liberation/fonts.dir
/usr/share/fonts/liberation/LiberationMono-Italic.ttf
/usr/share/fonts/liberation/LiberationSans-Bold.ttf
/usr/share/fonts/liberation/LiberationSerif-Bold.ttf
/usr/share/fonts/liberation/LiberationMono-Regular.ttf
/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
/usr/share/fonts/liberation/LiberationSerif-BoldItalic.ttf
/usr/share/fonts/liberation/fonts.scale
/usr/share/fonts/liberation/LiberationSans-Regular.ttf
/usr/share/fonts/liberation/LiberationSans-Italic.ttf
/usr/share/fonts/liberation/LiberationMono-Bold.ttf

When I run up a app, even without custom CSS, all the controls,
textfields, buttons etc are displayed in monospaced liberation.

I've debugged this using -Dprism.debugFonts

Loading FontFactory com.sun.javafx.font.freetype.FTFactory
Subpixel: enabled
Freetype2 Loaded (version 2.3.11)
LCD support Enabled
Time spent accessing fontconfig=4ms.
FC font sans:regular:roman maps to Liberation Mono in file
/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 0) Family=Liberation Mono, Style=Regular, Fullname=Liberation Mono,
File=/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 1) Family=Liberation Sans, Style=Regular, Fullname=Liberation Sans,
File=/usr/share/fonts/liberation/LiberationSans-Regular.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font sans:bold:roman maps to Liberation Mono Bold in file
/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 0) Family=Liberation Mono, Style=Bold, Fullname=Liberation Mono Bold,
File=/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 1) Family=Liberation Sans, Style=Bold, Fullname=Liberation Sans Bold,
File=/usr/share/fonts/liberation/LiberationSans-Bold.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font sans:regular:italic maps to Liberation Mono Italic in file
/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 0) Family=Liberation Mono, Style=Italic, Fullname=Liberation Mono Italic,
File=/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 1) Family=Liberation Sans, Style=Italic, Fullname=Liberation Sans Italic,
File=/usr/share/fonts/liberation/LiberationSans-Italic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC font sans:bold:italic maps to Liberation Sans Bold Italic in file
/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 0) Family=Liberation Sans, Style=Bold Italic, Fullname=Liberation Sans
Bold Italic,
File=/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 1) Family=Liberation Mono, Style=Bold Italic, Fullname=Liberation Mono
Bold Italic,
File=/usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC font serif:regular:roman maps to Liberation Mono in file
/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 0) Family=Liberation Mono, Style=Regular, Fullname=Liberation Mono,
File=/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 1) Family=Liberation Sans, Style=Regular, Fullname=Liberation Sans,
File=/usr/share/fonts/liberation/LiberationSans-Regular.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font serif:bold:roman maps to Liberation Mono Bold in file
/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 0) Family=Liberation Mono, Style=Bold, Fullname=Liberation Mono Bold,
File=/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 1) Family=Liberation Sans, Style=Bold, Fullname=Liberation Sans Bold,
File=/usr/share/fonts/liberation/LiberationSans-Bold.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font serif:regular:italic maps to Liberation Mono Italic in file
/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 0) Family=Liberation Mono, Style=Italic, Fullname=Liberation Mono Italic,
File=/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 1) Family=Liberation Sans, Style=Italic, Fullname=Liberation Sans Italic,
File=/usr/share/fonts/liberation/LiberationSans-Italic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC font serif:bold:italic maps to Liberation Sans Bold Italic in file
/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 0) Family=Liberation Sans, Style=Bold Italic, Fullname=Liberation Sans
Bold Italic,
File=/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 1) Family=Liberation Mono, Style=Bold Italic, Fullname=Liberation Mono
Bold Italic,
File=/usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC font monospace:regular:roman maps to Liberation Mono in file
/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 0) Family=Liberation Mono, Style=Regular, Fullname=Liberation Mono,
File=/usr/share/fonts/liberation/LiberationMono-Regular.ttf
 1) Family=Liberation Sans, Style=Regular, Fullname=Liberation Sans,
File=/usr/share/fonts/liberation/LiberationSans-Regular.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font monospace:bold:roman maps to Liberation Mono Bold in file
/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 0) Family=Liberation Mono, Style=Bold, Fullname=Liberation Mono Bold,
File=/usr/share/fonts/liberation/LiberationMono-Bold.ttf
 1) Family=Liberation Sans, Style=Bold, Fullname=Liberation Sans Bold,
File=/usr/share/fonts/liberation/LiberationSans-Bold.ttf
 2) Family=Liberation Serif, Style=Regular, Fullname=Liberation Serif,
File=/usr/share/fonts/liberation/LiberationSerif-Regular.ttf
FC font monospace:regular:italic maps to Liberation Mono Italic in file
/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 0) Family=Liberation Mono, Style=Italic, Fullname=Liberation Mono Italic,
File=/usr/share/fonts/liberation/LiberationMono-Italic.ttf
 1) Family=Liberation Sans, Style=Italic, Fullname=Liberation Sans Italic,
File=/usr/share/fonts/liberation/LiberationSans-Italic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC font monospace:bold:italic maps to Liberation Sans Bold Italic in file
/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 0) Family=Liberation Sans, Style=Bold Italic, Fullname=Liberation Sans
Bold Italic,
File=/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
 1) Family=Liberation Mono, Style=Bold Italic, Fullname=Liberation Mono
Bold Italic,
File=/usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
 2) Family=Liberation Serif, Style=Italic, Fullname=Liberation Serif
Italic, File=/usr/share/fonts/liberation/LiberationSerif-Italic.ttf
FC name=sans style=0 uses Liberation Mono in file:
/usr/share/fonts/liberation/LiberationMono-Regular.ttf

It seems that JavaFX makes mappings which I believe to be incorrect, for
example "sans:regular:roman" maps to Liberation Mono rather than
LiberationSans-Regular.

Firstly can anyone explain the 1) 2) 3) output that -Dprism.debugFonts
gives. What does this mean??

Secondly, is this a bug or not? Can anyone advise? Surely JavaFX should
map the logical font to it's "physical" equivalent, i.e. sans regular =>
<font name> sans regular, mono bold => <font name> mono bold etc.

I've read over https://wiki.openjdk.java.net/display/OpenJFX/Font+Setup
but this doesn't help to explain this situation. I saw support for private
font font directory with -Dprism.fontdir however I'd prefer for JavaFX to
map to existing fonts in /usr/shar/fonts "correctly"

I also wrote this up at
http://stackoverflow.com/questions/29828681/javafx-uses-monospaced-font-for-all-controls
also, but had zero interest.

Regards,

Adam.







More information about the openjfx-dev mailing list