Hints for changing jME/GBUI font

I'm using GBUI for my GUI, but I want to use a font other than the default.  I see that jME uses a png file, and I see people mentioning using AngelCode to generate a new png, but I also see Text2D.  Overall, I'm just very confused about how to substitute fonts, and I'm wondering if someone could either point me to an example of using an alternate font, or at least give me some tips on where to look?



Thanks,

  Mike

Let me look…I thought I'd used different fonts in other projects with GBUI…I know I've done it with JME, but I think I actually manipulated OpenGL directly to do the font changes in JME…I can't remember tho, it's been a while since I've had to change fonts…

Thanks,

I dug into this more yesterday and got as far as the ResourceProvider creating an AWTTextFactory (? - I don't have the code in front of me).  It's creating a java.awt.Font with the family passed from the bss.  I'm trying to figure out how to point it to a "customer" ttf (True-Type Font) file that exists in my rsrc directory, but isn't installed on the system.  I'm hoping I can do that without changing the GBUI code.



I'll let you know once I find a solution.

Ok,…I finally had a look at GBUI cause I found your questions very interesting.



First answer: You don't have to change anything at GBUI's sourcecode. In order to use a custom ttf-file you only have to register the font to the system and then you can use it in your style.bss



Here is a cool repository for free ttf-fonts: fontpool.de - Kostenlose Fonts und TrueType-Schriften zum Download



I downloaded one ttf (adventure.ttf) and placed it in my rsrc/fonts/-directory (of course you can use any location in your classpath)



To register the font and output the family-name that you have to use in your style:

       try {
         Font t = Font.createFont(Font.TRUETYPE_FONT, ComboBoxTest.class.getClassLoader().getResource("rsrc/fonts/adventure.ttf").openStream());
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         ge.registerFont(t);
         System.out.println("FONTFAMILY:"+t.getFamily());
      } catch (Exception e) {
         e.printStackTrace();
      }  



Only thing to do is to add a label like this:

        BLabel label = new BLabel("Test: Fortuna Duesseldorf");
        label.setBounds(10,10,700,30);



That code as to be executed bfore using the font the first time.

Now you can use the font in your style.bss (or as I use the GBUI-Test style2.bss). Here in the example I changed the font for labels.

label {
  font: "Adventure" bold 32;
  color: #ab0f0f;
}



Here is the result and I attached all needed files in a zip. Hope that helped.



Sweet!

I got it working by changing the code to treat the name as a path if it wasn't an installed font, but I like your solution better.  The less I have to change the base code, the better!



Thanks again!

I'm going to add this to the list of things that we should add to the code as like BFontLoader or something