PS .. the ConcurrentModificationException is one we fixed for 8u40.
You should test that out with a current EA build.
-phil.
On 12/7/14 8:56 PM, Phil Race wrote:
There's probably an RFE or bug that mentions the omission of deriveFont
Its the most direct way to say many things such there this font
with all these properties - some of which I may not be aware of -
and I just want it to be bigger/smaller/bolder but otherwise the same
So deriveFont should be added, and JDK 9 would seem a reasonable
target here.
One thing to note is that 2D (actually AWT has no part in this),
has built-in support for doing some things that the platforms
may not support. FX delegates to the platform and if the platform
can't oblique a font for you it won't happen even with a deriveFont API.
This is "vice-versa" of course, so there are likely to be things you get
from the platform you won't from cross-platform built-in support,
notably platform-specific rendering.
-phil.
On 12/7/14 2:54 PM, Jeff Hain wrote:
Hello.
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 :
### BEGIN
import javafx.scene.text.Font;
public class JavaFXCMEOnFontReload {
public static void main(String[] args) {
/*
* java.runtime.version=1.8.0_25-b18
*/
// download:
http://www.fonts2u.com/download/free-monospaced.font
final String urlStr = "file:src/bugz/FreeMono.ttf";
final String initialFontFamily = "AngsanaUPC";
System.out.println("font(" + initialFontFamily + ")...");
Font.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() + ")...");
Font.font(font.getFamily());
}
}
}
### END
Output:font(AngsanaUPC)...
loadFont(file:src/bugz/FreeMono.ttf)...
font(FreeMono)...
loadFont(file:src/bugz/FreeMono.ttf)...
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
at
com.sun.javafx.font.PrismFontFactory.removeEmbeddedFont(PrismFontFactory.java:1550)
at
com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(PrismFontFactory.java:1644)
at
com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(PrismFontFactory.java:1525)
at
com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:99)
at javafx.scene.text.Font.loadFont(Font.java:400)
at bugz.JavaFXCMEOnFontReload.main(JavaFXCMEOnFontReload.java:18)
-Jeff