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!
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 » Sun Jul 11, 2010 7:30 pm

Nitrogen, are you sure this is the correct way to render the glyphs?

Code: Select all

For Each Character:
    cursorx = cursorx + character.A  
    render(character at cursorx);
    cursorx = cursorx + character.C;
When I use this approach I get the following:

Image

I would have thought the character Width needs to be incorporated. However I painfully found that the "Width" that you list in your exported files refers not to the width of the character, but the width of the glyph as rendered into the font bitmap. You can see the width when you turn on the guidelines:

Image

I imagined my code to be more like this:

Code: Select all

For Each Character:
    cursorx = cursorx + character.A  
    render(character at cursorx);
    cursorx = cursorx + character.width + character.C;
However since the width is basically the same for every character (about 26-28 pixels wide for each character in this particular font), the output looks like this..

Image

It seems odd to me that you only consider A and C and not the width. :?
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 » Sun Jul 11, 2010 8:57 pm

Mixing A and C values can make a big difference. I read them in swapped! :oops:

Looks like your pseudo code is the right way to go. Still kind of weird you don't need to know the character's width at all.. I didn't realize the C values consider the glyph width.
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 » Fri Jul 16, 2010 8:26 am

Ok I think I have a legit problem now. I'm able to print the characters just fine, but I'm not able to center them. The problem is that the very first character will always be offset, because the only data we have is the glyph bounding area, and not where the glyph actually starts. Let me explain with a picture:

Image

The box outlines the given bounds for the 'B' character. To render 'B' we just take this box and write it exactly to a render target. However we don't know know how much space is to the left of 'B'. (shown by the red line) After we write this first letter, we can use the HorzAdvance and XOffset data to determine where to write the following characters. The following characters will fall into place correctly, but the first character will always have a magical offset, dependent on the glyph.

Programmatically I'm able to determine the length of a given set of characters, and determine where it should be drawn. But when drawing the characters, there is an initial offset that I don't know how to take into consideration:

Image

Is there some way people are able to center text that I'm not aware of? If so, please let me know. Otherwise, I think we need another piece of data to really achieve centering. I need to know the distance from the left bounding box edge to the start of the glyph.

Nitrogen, hope you're reading this and can give input. :mrgreen:
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 » Fri Jul 16, 2010 8:48 am

Awesome, I found a way. I just need to include the full width of the last character as part of the text width, and centering works. :D

Code: Select all

	unsigned int TextLine::getWidth()
	{
		if(mCharacters.empty())
			return 0;

		// Find the last non-NULL, non-whitespace character.
		std::vector<Character*>::reverse_iterator it = mCharacters.rbegin();
		while((it != mCharacters.rend()) && ((Text::isNullCharacter((*it)->getCodePoint())) || (Text::isWhiteSpace((*it)->getCodePoint()))))
		{
			++it;
		}

		// If entire line of text is filled with whitespace or NULL character, return 0.
		if(it == mCharacters.rend())
			return 0;

		unsigned int width = ((*it)->getXPosition() + (*it)->getWidth()) - mCharacters.front()->getXPosition();

		return width;
	}
I get the X position of the last non-whitespace character and add its width.
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 Aug 04, 2010 6:58 am

Wow, this is actually really tough! Now I'm trying to Implement a TextBox using XML font definitions produced from Font Studio, and not seeing how to position the Text Cursor. The problem is illustrated by this image:

Image

Since each character has a different width, and the "width" of the character describes the texture area containing the glyph (which is never a minimal bounding box), it seems impossible to know where to place the cursor.

When generating the png images, is the glyph data provided with these oversized bounding boxes? Life would be so much easier if the width of the character was the actual width of the character, from its left most pixel to its right most. :(

[Edit]
So we have A, C, and "width". However the Width is not correct. The correct width I'm looking for is described here:
http://msdn.microsoft.com/en-us/library ... S.85).aspx

We need this width!
[/Edit]
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 Aug 04, 2010 7:21 am

From MSDN:

Image
The A spacing is the width to add to the current position before placing the character. The B spacing is the width of the character itself. The C spacing is the white space to the right of the character. The total advance width is determined by calculating the sum of A+B+C. The character cell is an imaginary rectangle that surrounds each character or symbol in a font. Because characters can overhang or underhang the character cell, either or both of the A and C increments can be a negative number.
I wonder if I can get the width I want?

Code: Select all

glyphWidth = (Imaginary Rectangle Width) - A - C;
I'll have to try this tomorrow. This would be awesome if it worked!
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 » Thu Aug 05, 2010 6:52 am

arg, it doesn't work. :cry:

Code: Select all

B != wid - A - C;
Has anybody else implemented TextBox style functionality with these fonts? Overall, everything would be so much simpler if each character contained the following data:

1. Cell width
2. minimum Horizontal Distance from Cell left edge to nearest pixel of glyph
3. minimum Horizontal Distance from Cell right edge to nearest pixel of glyph
4. HorzAdvance, or the amount of pixels to move the pen before writing this glyph
5. XOffset, or the amount of pixels to move the pen after writing this glyph

We're missing data on 2 and 3 here. Since glyphs are drawn as cells, there is no real way to align the text cursor so that it appears just after the glyph. Instead, the cursor always appears after the cell, which looks odd. Things also get really funky with spaces, because the spaces just represent the number of pixels to move the pen, before it draws another cell. Often times a Cell preceding a space will extend farther than the space. (this also makes calculating text length very difficult)
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 » Thu Aug 12, 2010 10:23 pm

Wow, you been busy KungFoo!

Okay, so I've updated Font Studio to provide the missing bits of data that you need.
https://bitbucket.org/michael_pote/font ... /downloads

Each character in the XML output now has:

- A,B,C values as per your MSDN document
- Wid and Hgt of the cell
- Ox and Oy - Offset in pixels from the top left edge of the cell to where the actual glyph is drawn.

So the values you require should be something like:

2. minimum Horizontal Distance from Cell left edge to nearest pixel of glyph = Ox
3. minimum Horizontal Distance from Cell right edge to nearest pixel of glyph = Wid - (Ox + B)

Hope that helps...
Last edited by Nitrogen on Sun Feb 17, 2013 5:16 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 » Fri Aug 27, 2010 6:52 am

Wanted to give a lot of thanks to Nitrogen for responding to my requests and modifying his tool so I could use it for real time text manipulation! (ie TextBox and the like)
0 x
Creator of QuickGUI!

User avatar
ekt
Greenskin
Posts: 149
Joined: Thu Apr 01, 2004 5:55 pm
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by ekt » Sun Nov 28, 2010 5:50 pm

to me the 'Drop Shadow' functionality is not working. it enlarges the spaces occupied by each character, but i can't see any shadow dropped.
do anyone have it working?
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 » Tue Jan 25, 2011 8:33 am

The Drop Shadow function uses the "BG" Colour (Background colour) as the colour for the drop shadow, so if your background is set to white, you will get a white drop shadow.

You can change the BG colour by clicking it's colour box in the top right corner of the app.

You can see the actual alpha values by switching to the Mask tab. This will show you the drop shadow alpha transparency values which will always appear as white (100% opaque) on black (0% opaque).

You can change the preview window's background colour by doubleclicking the preview area.
0 x

User avatar
ekt
Greenskin
Posts: 149
Joined: Thu Apr 01, 2004 5:55 pm
Contact:

Re: Font Studio bitmap font generator supports CEGUI

Post by ekt » Tue Jan 25, 2011 10:37 pm

thanks for the info nitrogen, it works. i didn't pay enough attention :)
You can change the preview window's background colour by doubleclicking the preview area.
nothing happens double clicking on the preview window, but the main issue is solved.
0 x

zootlewurdle
Halfling
Posts: 91
Joined: Sat Aug 06, 2011 8:38 am
Location: United Kingdom

Re: Font Studio bitmap font generator supports CEGUI

Post by zootlewurdle » Sat Sep 17, 2011 8:38 am

I'm guessing this tool is dead as the downlod link no longer works and the domain seems dead too. :(

Are there any other tools for getting a ttf font to a bitmap/fontdef combo for Ogre?

Thanks.

As a side note: I was following the Outline Font guide elsewhere on the site, it's clearly completely out of date as it refers to another tool which doesn't seem to be included with Ogre now, BitmapFontBuilder. I'd suggest the article is removed or updated to state its out of date (http://www.ogre3d.org/tikiwiki/Outlined+Fonts).
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 » Sun Sep 18, 2011 5:40 pm

Then what are you waiting for? :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

wagenheimer
Gnoblar
Posts: 1
Joined: Thu Dec 08, 2011 1:51 am

Re: Font Studio bitmap font generator supports CEGUI

Post by wagenheimer » Thu Dec 08, 2011 1:54 am

FontStudio - Bug with Chinese
Hi Nitrogen!

Are you still over there? =)

I do use fontstudio and have created a lot of games with it, but now I'm having some problem with Chinese letters.

By example.... 开始游戏 .... This text have always 2 missings letters on FontStudio, its never render two of these letters. Font studio only renders 始游.

I think it should be some problem with "Load Range from Text File"...

I'm using this font http://www.wagenheimer.com/temp/HDZB_35.TTF and I'm sure this font supports all the characters.

Is there a new version or If possible, could you please fix this and release a new version?

Thanks! =)
0 x

mislawik
Gnoblar
Posts: 11
Joined: Sun Jan 09, 2011 9:09 am

Re: Font Studio bitmap font generator supports CEGUI

Post by mislawik » Sat Apr 14, 2012 12:31 am

The URL doesn't work.
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 Apr 14, 2012 1:22 am

0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

mislawik
Gnoblar
Posts: 11
Joined: Sun Jan 09, 2011 9:09 am

Re: Font Studio bitmap font generator supports CEGUI

Post by mislawik » Sat Apr 14, 2012 1:26 pm

Thank you, jacmoe!
0 x

zadirion
Kobold
Posts: 35
Joined: Sat May 14, 2011 11:08 am

Re: Font Studio bitmap font generator supports CEGUI

Post by zadirion » Sat Feb 16, 2013 8:25 am

The CEGUI plugin that comes by default with Font Studio 4.2 is broken.

I bit the bullet and have ported the Delphi (yuck) plugin into C++ and improved it to work properly.
Feedback and discussion about it will be over at the CEGUI forum:
http://www.cegui.org.uk/phpBB2/viewtopic.php?f=7&t=6367

Repo is here:
https://bitbucket.org/zadirion/zadirion ... /wiki/Home
Code contributions are welcome and definitely most encouraged.
Excuse the messy code, I did this on a tiresome Friday night in a quick and dirty fashion.

Font Studio 4.2 is also available for download in the repo's Downloads sections.

Enjoy.
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 Feb 17, 2013 4:52 pm

Haha dont knock Delphi too much zadirion, it was my first love :P

Anyways, I've open sourced the app, check out the (Delphi) repository at
https://bitbucket.org/michael_pote/font-studio

There is also a Windows Binary download.
0 x

zadirion
Kobold
Posts: 35
Joined: Sat May 14, 2011 11:08 am

Re: Font Studio bitmap font generator supports CEGUI

Post by zadirion » Sun Feb 17, 2013 6:51 pm

Hey! That's awesome news open sourcing it :D !!! Definitely crossed my mind to ask if you were willing, but I thought you might just say no :oops:

Would you be opened to the possibility of letting me and other people port it to C++ then reintegrate the port in your main repo? That might help it gain some more use and support.

Also, Pascal was my first programming language (definitely not love though :P ) so we are much alike in that sense you and I :lol:

I'll refine the plugin a bit more in the meantime and then check and see how much work would be needed for porting.

EDIT: Just looked over 4.2.1, and saw the new Ox and Oy values, that's hillarious. You won't believe what I had to do to get things working without those two buggers :lol: I actually had to bypass the plugin interface and enumerate the windows and get the values directly from the associated controls in FontStudio. Glad there's an easier way now :lol:
0 x

zadirion
Kobold
Posts: 35
Joined: Sat May 14, 2011 11:08 am

Re: Font Studio bitmap font generator supports CEGUI

Post by zadirion » Sun Feb 17, 2013 7:36 pm

New version is out:
Release notes 1.2:
- Fixed glyphs in certain larger fonts with a large border sometimes overlap
- Plugin now exports .imageset file too

Download Zadirion's CEGUI Font Exporter for Font Studio v1.2
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 Feb 17, 2013 7:37 pm

Damn man, should have just asked ;)

Yeah I dont mind what you do with it, I havent touched it in 3 years, I doubt I would have done any more work on it myself, so I'm very happy to release it and port it.

I'd be very interested if you could get a cross platform version of it running, but not sure how the plugin situation would work and it does use a LOT of Windows API calls to get the glyph and character information...
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 Feb 17, 2013 7:46 pm

Oh and there's an easter egg in the app itself, see if you can find it :)
It's something to do with having bad taste in fonts ;)
0 x

zadirion
Kobold
Posts: 35
Joined: Sat May 14, 2011 11:08 am

Re: Font Studio bitmap font generator supports CEGUI

Post by zadirion » Sun Feb 17, 2013 7:53 pm

Well I was just thinking that.
I was thinking do the UI with CEGUI (duh) xD and abstract away the calls to Windows APIs, meaning make Linux and Windows wrappers. We'd implement the Windows wrappers, and someone else the Linux (I have literally 0 experience in Linux programming), Mac, whatnot.

It sounds easy enough on paper, but it's quite a fair bit of work I'm sure.

Edit: was about to press 'Submit' for this post when I saw your new post. Let me guess, something about Comic Sans?
Edit2: yep, found it! :D nice touch
0 x

Post Reply