There is no easy way.
At first you know that java provides only five logical font families. All other fonts are not guaranteed to be present on the system that you run the program.
Then no, there is no automatic mapping of font properties on your system. You will need to download them all and program the search for the desired measure.
with this code you can encode available fonts:
import java.awt.Font; import java.awt.GraphicsEnvironment; public class MainClass { public static void main(String[] a) { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts();
and then choose the one that suits your needs. Change the code to display the information you want: weight, for example.
Edit: Pay attention to They are merely font-type names recognized by the Java runtime which must be mapped to some physical font that is installed on your system observation at http://download.oracle.com/javase/1.3/docs/guide /intl/addingfonts.html .
Even logical fonts are not guaranteed to be always the same. What you can do is get the size 10pt and calculate the font size. how
font_size_in_points = ((10 * desidered_measure) / analog_measure_of_the_10pt)
source share