Is there a way to map a logical font (e.g. SansSerif) to a different font when running a Java program? If so, does the method differ between Java VM versions?
You can use the getFamily() method to find out the family name, while getFontName() returns the face name of the font. Finally, to actually use a Font object, you can simply specify it as an argument to the setFont() method of a Component or Graphics2D object.
All implementations of the Java Platform must support TrueType fonts; support for other font technologies is implementation dependent. Physical fonts may use names such as Helvetica, Palatino, HonMincho, or any number of other font names.
The Font class encapsulates information about a font. A new font is produced by creating an instance of the Font class with a name, style, and point size. Font f = new Font("Dialog", Font. PLAIN, 12);
Look in $JAVA_HOME/jre/lib/fontconfig.properties
for everything (well, almost) you'd ever want to know about font mapping in Java. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With