Font Studio bitmap font generator supports CEGUI

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Tue Feb 10, 2009 9:18 pm

Hello to the Ogre3D community!
I've been recently playing around with Ogre3D, and hence CEGUI, and I saw the lack of a nice bitmap font generator for use with CEGUI.

Well, it just so happens that I have a nice bitmap font generator, with a convenient plugin system, so I spent a short while writing a CEGUI exporter for FontStudio my bitmap font generator.

Specifically, This exports the three files needed to describe a bitmap font: .font, .imageset and .png . After trawling the CEGUI messageboards and wikis I managed to get kerning information into the font description, so fonts are rendered as accurately as normal OS fonts would be.

I see that CEGUI already renders out ttf files, so users will probably use Font Studio for the effects it can add to your fonts.
Though it can also handle small fonts just as accurately as ttf rendered fonts, Largeish image after the link.

Font Studio can be downloaded from here:
Font Studio Bitmap Font Generator



EDIT (08/2010):
I've sorted out my hosting issues,
Font Studio is now back online at the link above.
Also, Version 4.2.1 now allows exports with more data for each character to allow much greater control over the positioning and rendering of the font.
Currently only the XML plugin has been updated to take advantage of this.

EDIT (02/2013):
I've open sourced Font Studio, you can check out Delphi source code in a repository on bitbucket:
https://bitbucket.org/michael_pote/font-studio
Last edited by Nitrogen on Sun Feb 17, 2013 5:14 pm, edited 4 times in total.
0 x

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel

Re: Font Studio bitmap font generator supports CEGUI

Post by Assaf Raman » Tue Feb 10, 2009 11:03 pm

Nice work!
0 x
Watch out for my OGRE related tweets here.

User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by Jabberwocky » Tue Feb 10, 2009 11:16 pm

Woo, outlined text! This can be extremely useful for cases where you don't always know what background colour the text will be placed over, e.g. floating selection text.
Well done!
0 x
Image

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Wed Feb 11, 2009 1:47 am

PPS. I decided not to export into Ogre3D's native fontdesc. files since they didnt seem to have support for kerning information. If there is enough demand for it, it could be added though.
I think a lot of people would like this. If your work resulted in .fontdef files, all GUI library could benefit from your tool. I know I'd use it, outlined text is pretty cool.
0 x
Creator of QuickGUI!

User avatar
my.name
Goblin
Posts: 222
Joined: Tue Aug 08, 2006 2:58 pm
Location: Moscow

Re: Font Studio bitmap font generator supports CEGUI

Post by my.name » Wed Feb 11, 2009 3:49 am

Image

Image

Code: Select all

		MyGUI::xml::Document outdoc;
		outdoc.createDeclaration();
		MyGUI::xml::ElementPtr root = outdoc.createRoot("Font");

		std::string filename = "Default.imageset";
		MyGUI::xml::Document indoc;
		indoc.open(filename);

		root->addAttribute("name", indoc.getRoot()->findAttribute("Name"));
		root->addAttribute("source", indoc.getRoot()->findAttribute("Imagefile"));
		int default_height = 0;

		MyGUI::xml::ElementEnumerator iter = indoc.getRoot()->getElementEnumerator();
		while (iter.next("Image"))
		{
			int height = MyGUI::utility::parseInt(iter->findAttribute("Height"));
			MyGUI::IntCoord coord(
				MyGUI::utility::parseInt(iter->findAttribute("XPos")) - MyGUI::utility::parseInt(iter->findAttribute("XOffset")),
				MyGUI::utility::parseInt(iter->findAttribute("YPos")),
				MyGUI::utility::parseInt(iter->findAttribute("Width")),
				height );

			if (default_height == 0 && height != 0) default_height = height;

			MyGUI::xml::ElementPtr child = root->createChild("Code");
			child->addAttribute("index", iter->findAttribute("Name"));
			child->addAttribute("coord", coord.print());
		}

		root->addAttribute("default_height", default_height);

		outdoc.save(filename + ".xml");
=)
0 x
Image
Image

User avatar
Evak
Orc Shaman
Posts: 707
Joined: Sun Apr 02, 2006 7:51 pm
Location: Sacramento, CA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by Evak » Wed Feb 11, 2009 8:19 am

heh very nice :) there is one other bitmap font editor I know of but its a lot more basic than this one. Thanks for sharing :)
0 x

Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Wed Feb 11, 2009 10:50 am

Hehe cool guys..

Glad to see you using it :P

That MyGUI implementation looks cool, but does it support kerning?

You see each character has two extra values (aside from the usual x,y,w,h), in CEGUI they are called XOffset (in the .imageset file) and HorzAdvance (in the .font file).

XOffset is the amount to move the pen forwards or backwards before drawing the character. So it can move closer or further from the last character.
HorzAdvance is the amount to move the pen after drawing the character, and it's normally the width of the character, added to another value which moves the following characters either closer or further from the current character.

In fact, give me the layout of the font format for MyGUI and I'll try add an exporter for it. But I strongly suggest adding support for these two values. it's so easy to implement!
0 x

User avatar
altren
Gnome
Posts: 317
Joined: Tue Oct 24, 2006 9:02 am
Location: Moscow, Russa
x 1
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by altren » Wed Feb 11, 2009 3:16 pm

Nitrogen wrote:That MyGUI implementation looks cool, but does it support kerning?
Yes - my.name just exported it wrong way.
Nitrogen wrote:In fact, give me the layout of the font format for MyGUI and I'll try add an exporter for it. But I strongly suggest adding support for these two values. it's so easy to implement!
Here's example

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Font name="ComicSansMS" source="ComicSansMS.png" default_height="36">
    <Code index="0032" coord="0 0 10 36"/>
    <Code index="0033" coord="0 36 6 36"/>
    <Code index="0034" coord="0 72 11 36"/>
    <Code index="0035" coord="16 0 23 36"/>
    <Code index="0036" coord="39 0 17 36"/>
    <!--...more characters...-->
  </Font>
</MyGUI>

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Font">
  <Font name="Internal_font_name" default_height="default_height_in_pixels" source="texture_file_name">
    <Code index="character_code" coord="left top width height"/>
  </Font>
</MyGUI>
Also look at my.name's code above.

I also found bug in your app: when show guides enabled result texture contain this guides.Imagelook at capital U and Z
0 x
Image

Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Wed Feb 11, 2009 7:00 pm

Yes, the guides are actually painted over the font! I'll fix that in the next version..

Okay with the MyGui font description, I see the coordinates for each character, but no kerning information... You cant do proper kerning with those 4 coordinates alone. You need those other two values I described...
0 x

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Wed Feb 11, 2009 8:28 pm

I forget exactly how I render glyphs in QuickGUI, but I think I use Ogre to get the UV coords of the glyph, and I use them to draw a quad to the render target. Basically I treat the font texture as a grid of character cells, and I display cells next to each other. I think I understand your explanation of the xOffset and HorzAdvanced, although I think that implementation would go into the Ogre::Font class, right? Kerning is used to produce the texture correctly, after the UV coords are determined, I can just use them. Or maybe Kerning is about overlapping characters, in which case I'd need to have the xOffset/HorzAdvanced in QuickGUI, so I can draw the characters correctly. But really it should be an addition to the Ogre::Font class, so that information is available to me by default. This wouldn't be difficult to add in to Ogre, would it? You probably wouldn't get any push back to add this into the core Ogre::Font class.
0 x
Creator of QuickGUI!

Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Wed Feb 11, 2009 9:26 pm

Yes, Kerning is about overlapping the characters. You still need the UV coordinates to draw the correct characters, the other two values are just to position the characters correctly on the screen.

Because you are all using XML files, it'll be easy to add these two attributes to each character element.

It would be an extremely easy fix to load these additional attributes into the Ogre::Font class, then in the rendering code, instead of something like

Code: Select all

For Each Character:
    render(character at cursorx);
    cursorx = cursorx + character.width;
You'd have something like:

Code: Select all

For Each Character:
    cursorx = cursorx + character.A  
    render(character at cursorx);
    cursorx = cursorx + character.C;
A and C are the names used by windows internally for Xoffset and HorzAdvance respectively. Have a look at http://msdn.microsoft.com/en-us/library ... S.85).aspx for more information.

I'd do it, but I've never worked with CVS systems before, I wouldnt know how to check in/check out the files :oops:
Last edited by Nitrogen on Wed Feb 11, 2009 9:33 pm, edited 1 time in total.
0 x

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Wed Feb 11, 2009 9:33 pm

I'm not the most familiar with the process either, but here is how you can get started:

- install TortoiseSVN
- check out Ogre from SVN (in file explorer right click, SVN -> Check out Repository, or something like that)
-- Add in location of Ogre SVN, make sure you get HEAD revision
- modify files
- right click in file explorer, SVN -> Make Patch, or something like that
- Submit patch to SourceForge
0 x
Creator of QuickGUI!


User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by jacmoe » Mon Apr 05, 2010 8:18 pm

Oh, no: the site is down. :(

Anyone has a copy of the program?
I didn't get around to grabbing it.

Yet another good reason for hosted open source projects.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by jacmoe » Tue Apr 20, 2010 9:38 pm

Nitrogren wrote:Hey Jacob,

Here’s a BRAND NEW font studio! Never before seen ;)

- Plugins now support long file extensions (more than 3 characters)
- The Character Range can be automatically selected from opening a text file. (Unicode text files should be supported.)

It’s version 4.2 now and I’ve changed the plugin architecture a bit.

This does mean that current plugins made for Font Studio 4.1xx wont work in this version.

However, I’ve included the source code to all the plugins included with this version, and I can write a guide on how to upgrade any plugins that need upgrading if you like.

It’s very easy:

- Replace your plugin’s FontExportPlugin.pas with this most recent version.
- Add a function GetPluginVersion():integer to your plugin’s exports
- Inside the function should be one line: “ Result := fntPluginVersion2;”
- Compile and go!

Have fun!

- Mike
Download FontStudio 4.20 here:
FontStudio 4.20
Last edited by jacmoe on Sat Apr 14, 2012 1:21 am, edited 1 time in total.
Reason: Download link fixed
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Tue Apr 27, 2010 6:40 pm

Jacmoe thanks a ton for sharing this, I revisited this thread and none of the links at the top worked.. thankfully you posted a download. :D

So I played around with this tool, not sure I understand what some of the UI fields are, for example "Trail" or "L" (is the TextBox covering the label?), but I was able to create some fonts with outlines, pretty cool.

There is one thing I'm wondering. If for example the UI supports multiple fonts in the same line, we need a variable to store the y component that letters sit on. I forgot the technical term, but its the imaginary line that all characters sit on, for example this should illustrate:

j j j j

All of the j's are resting on the same line. I need this info exported into the raw data format. If this information was provide, I think I'd have all I need to be able to display these fonts, including support for mixing fonts.

By the way, I can't use the CEGUI or .fnt formats, but I think the raw data/graphic export is nice and simple. (although missing the vertical component I mentioned :P )

Jacmoe, if you're in touch with Nitrogen can you share this post with him?
0 x
Creator of QuickGUI!

Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Wed Apr 28, 2010 10:03 am

Hmm, not sure whats going on with the display of the UI, it should look like this:
fntStudio.jpg
Leading and Trailing are the amount of pixels that pad either side of the character inside it's texture rectangle..

As for the vertical placement, thats a valid point.. I think that value would be something like 'baseline'? Anyways, I didnt even consider that when I was making it...
I'll look into it for the next version, which may be a while off since work is hectic!
0 x

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Wed Apr 28, 2010 5:49 pm

The Panel inside "Character Placement" grouping does not fit the Bounds in my version, it is always 4/5 the size of the "Character Placement" region. I'm not sure if this Panel affects the Up/Down Value boxes, but all of them are offset. Actually now that I think about it, I think its the text labels that are in the wrong places, not the Up/Down Value boxes.

Are you sharing the source for this tool? Its almost perfect, aside from the baseline value and minor UI defects. :P
0 x
Creator of QuickGUI!

User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by KungFooMasta » Wed May 19, 2010 12:16 am

Another reason why the baseline is important is due to centering the text. Take the screenshots in this other Ogre projec to illustrate:

http://www.ogre3d.org/forums/viewtopic. ... 58&start=0

In the second Label, it seems as though the text is vertically centered according to the full height of the text, from the top of the 'H', to the bottom of th 'p'. But wouldn't it look better if the text was centered according to the height of the text, from the baseline to the top? (I would post a picture but I'm at work) What do people expect, when it comes to vertically centering Text? (I believe I center text in QuickGUI from glyph top to glyph bottom, and people have commented that it looks incorrect, especially when you have a label with text where there are no underhanging parts, like 'j', 'p', 'y', 'q', etc. Just want to confirm if this is correct or not)

The good thing is that even if you don't officially support this, I can figure out the baseline for any generated font, modify the xml file, and then use it accordingly. But it would be cooler if I could write my own plugin, as my GUI lib doesn't have any built in xml parsers.. I'd have to add it just to be able to understand the default output of Font Studio. :(
0 x
Creator of QuickGUI!

mono2k
Gnoblar
Posts: 19
Joined: Mon Mar 15, 2010 8:02 am

Re: Font Studio bitmap font generator supports CEGUI

Post by mono2k » Sat May 22, 2010 5:38 pm

any chance to get a working link to FontStudio420.zip? Ogitor's wiki doesn't work for me...
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by jacmoe » Sat May 22, 2010 5:44 pm

Try now - I moved it to a directory which is part of the backup routine. :)
FontStudio420.zip
Last edited by jacmoe on Sat Apr 14, 2012 1:21 am, edited 1 time in total.
Reason: Download link fixed
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

mono2k
Gnoblar
Posts: 19
Joined: Mon Mar 15, 2010 8:02 am

Re: Font Studio bitmap font generator supports CEGUI

Post by mono2k » Sat May 22, 2010 6:39 pm

Thnx a lot!
0 x

Nitrogen
Gnoblar
Posts: 13
Joined: Tue Feb 10, 2009 7:23 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by Nitrogen » Sun Jun 13, 2010 8:51 pm

Hmm, thinking about those misaligned textboxes in Font Studio, it could be caused by running at a non-72dpi resolution...
Delphi has an "autoscale" option on which tries to reposition your controls on a non-72dpi resolution display and it causes all sorts of problems like this..
I'll have a look at it...
0 x

acb1010
Gnoblar
Posts: 1
Joined: Tue Jun 15, 2010 12:21 pm

Re: Font Studio bitmap font generator supports CEGUI

Post by acb1010 » Tue Jun 15, 2010 12:31 pm

It is really nice tool. However, it is not optimize arrangement on image & it is not export bmp with alpha BRAND NAME.
Bitmap Font Generator of www.AngelCode.com can export tga type and file fnt contains position of characters it is very easy to map it In Addition it has fontable. I am really eager to join Font Studio to improve its functions. Where can I check source to develop it ?
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by jacmoe » Tue Jun 15, 2010 12:51 pm

Give Nitrogen a ping - I don't think he's interested in open sourcing it.
It's written in Delphi by the way. :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

Post Reply