Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Java to map a logical font (e.g. SansSerif) to a specific font on my system?

Tags:

java

fonts

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?

like image 919
Epaga Avatar asked Oct 14 '08 09:10

Epaga


People also ask

How do you achieve special fonts for your text in Java?

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.

Which fonts can I use in Java?

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.

Which class encapsulates various information about font in Java?

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);


1 Answers

Look in $JAVA_HOME/jre/lib/fontconfig.properties for everything (well, almost) you'd ever want to know about font mapping in Java. :-)

like image 173
Chris Jester-Young Avatar answered Sep 23 '22 02:09

Chris Jester-Young