Re: Text without AWT?
Posted by
Xerxes Rånby on
Mar 01, 2017; 2:55pm
URL: https://forum.jogamp.org/Text-without-AWT-tp4037684p4037713.html
adi wrote
I have seen it. But there are only two fonts therein, JAVA and UBUNTU.
To load a custom Font you simply need to know where you have your true type .ttf files stored, in a jar or on disk, and then implement your own FontSet.
Indeed the JogAmp JOGL source tree contains only two FontSet's however you can look at the source code to load your own font!
*
http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java;hb=HEAD *
http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/jogamp/graph/font/JavaFontLoader.java;hb=HEADYou may also use FontFactory.get to load a Font from a InputStream that supports random-access.
Font f= FontFactory.get ( stream /*InputStream*/, true /* close stream */) ;
or use FontFactory to load a Font from a File
Font f= FontFactory.get ( file /*File*/) ;
Example on my Linux system I can use:
font = FontFactory.get(new File("/usr/share/fonts/truetype/freefont/FreeMono.ttf"));

adi wrote
And why is 'weight' used with volatile?
In the original junit demo weight was changed at runtime from keyboard input that is running on a differnt thread compared to rendering.
It is volatile as a leftover from the junit test demo code when i flattened it into only one class.