Font derivation, plus ConcurrentModificationException on font load

Jeff Hain jeffhain at
Sun Dec 7 22:54:45 UTC 2014


Currently discovering JavaFX (using 1.8.0_25-b18),I saw that there is no way to "derive" a font, as could be done in AWT.
In AWT, if you load "FreeMono.ttf", you get a non-bold font by default, but using
font.deriveFont(font.BOLD, 1.0f) you can obtain a bold version of it.
In JavaFX, there is no way to obtain a bold version of "FreeMono.ttf".The best you can do is to load "FreeMonoBold.ttf" and then callFont.load("FreeMono", FontWeight.BOLD, 1.0), but the resulting lookis quite different than AWT's bold FreeMono.ttf.
===> Are there plans to add font derivation in JavaFX, so that fonts of various         styles can be obtained from a same ".ttf" file, or will it stay as this?

Now code to reproduce a bug :
import javafx.scene.text.Font;

public class JavaFXCMEOnFontReload {
    public static void main(String[] args) {
         * java.runtime.version=1.8.0_25-b18
        // download:
        final String urlStr = "file:src/bugz/FreeMono.ttf";
        final String initialFontFamily = "AngsanaUPC";
        System.out.println("font(" + initialFontFamily + ")...");
        for (int k=0;k<2;k++) {
            System.out.println("loadFont(" + urlStr + ")...");
            final Font font = Font.loadFont(urlStr, 1.0);
            if (font == null) {
                throw new AssertionError("could not load " + urlStr);
            System.out.println("font(" + font.getFamily() + ")...");
### END

Exception in thread "main" java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(
    at java.util.HashMap$
    at com.sun.javafx.font.PrismFontFactory.removeEmbeddedFont(
    at com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(
    at com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(
    at com.sun.javafx.font.PrismFontLoader.loadFont(
    at javafx.scene.text.Font.loadFont(
    at bugz.JavaFXCMEOnFontReload.main(


More information about the openjfx-dev mailing list