Does CEGUI support bitmap fonts?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Legolas1681
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Fri Jan 28, 2005 00:32

Does CEGUI support bitmap fonts?

Postby Legolas1681 » Sun Jan 30, 2005 03:50

I would like to know if CEGUI supports bitmap fonts, and if so, how would I go about implementing one.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Sun Jan 30, 2005 08:33

Yes, it does support bitmapped fonts. I'm not sure if anybody has actually done one yet though ;)

You need to create an Imageset (image file/xml combo) that defines named images for the bitmapped glyphs that you'll be using.

You then need to create a font xml file that defines a 'static' font which references the above imageset. The rest of the font definition is done via xml <Mapping> elements, these define a UTF32 codepoint (character code), the name of the image from the imageset that will be drawn for the codepoint being mapped, and an optional horizontal advance value.

Once you have all this the font can be loaded and generally used in the same way as ttf 'dynamic' fonts.

Code: Select all

<?xml version="1.0" ?>
<Font Name="myFont" Filename="myFont.imageset" Type="Static" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
   <Mapping Codepoint="49" Image="Num1" />
   <Mapping Codepoint="50" Image="Num2" />
   <Mapping Codepoint="51" Image="Num3" />
   <Mapping Codepoint="52" Image="Num4" />
   <Mapping Codepoint="53" Image="Num5" />
</Font>

In this very simple example, a static (bitmapped) font named "myFont" is being created. It is using images defined in the Imageset file "myFont.imageset", and maps the character codes for the first five numerals to the images named Num1, Num2, Num3, Num4, and Num5.

Hopefully this will give you a start :)

CE.

User avatar
walaber
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Sun Jan 23, 2005 10:20
Contact:

Re: Does CEGUI support bitmap fonts?

Postby walaber » Mon Jan 31, 2005 06:41

is there currently an easy way yo generate the imageset from a standard bitmap font? for example a way to get the output of a program like bitmapfontbuilder to work easily?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Mon Jan 31, 2005 09:17

Unfortunately not :( I've not actually looked into many tools like bitmapfontbuilder, though what would be really cool is a small converter tool or something.

Maybe I'll take a look in a little while and see if I can get something started...

CE.

User avatar
Ayudo
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 14, 2005 23:07
Location: germany, munich
Contact:

Re: Does CEGUI support bitmap fonts?

Postby Ayudo » Tue Feb 15, 2005 01:24

Hi Crazy Eddie!

Thanks for your system!
I am now trying to create and my own font.

But most times it is displayed blured and with other resolutions than 1024/768 it is unreadable.

And something is odd: For some letters, the width of the letter itself is good for correct distance to the next letter, for others I would need to add a pixel.

My goal:
-Just use my letters as they are in the png-file.
-Use them like that at any resolution/renderer - and allways have 1 pixel spacing between them.

Here it is for testing:
http://www.weltenspiegel.de/private/ogr ... futech.zip

Just put/replace these files in the folder /ogre_gui_demo8/Release/ of Demo 8.

Thanks for helping on this issue!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Tue Feb 15, 2005 09:06

Okay, I'll take a look and get back to you later on today.

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Tue Feb 15, 2005 14:39

Right.

To adjust horizontal spacing for glyphs you use the HorzAdvance attribute in your Mapping elements. This does not change the width of the images but changes the amount the 'pen' is moved after rendering a particular codepoint.

I have attached a modified font definition with these attributes in place.

The issue with blurry imagery is present in releases up to and including 0.1.1 (there is nothing 'simple' that can be done to fix that). The issue has long been fixed in CVS and 0.2.0 will be the debut release containing the fix. Comparing how things were with how they are now, I can't believe that certain people had a hard time convincing me there was a problem :lol:

To always have a single pixel between glyphs, use the HorzAdvance as I have demonstrated and keep auto scaling off. With autoscaling on, everything gets scaled depending upon the display resolution so it renders at the same physical size as when the resolution is equal to the native resolution specified in the font/imageset.

HTH

CE

User avatar
Ayudo
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 14, 2005 23:07
Location: germany, munich
Contact:

Re: Does CEGUI support bitmap fonts?

Postby Ayudo » Fri Feb 25, 2005 22:08

Ok, just "upgraded" to Ogre1.0.0 Release / CEGUI0.2.0.

Now the font looks good :-)

But another phenomen occured:
The height of the font doesnt seem to be used proper anymore in lists and dropdowns.

Have a look at:

http://www.weltenspiegel.de/private/ogr ... 0225/0.gif
and
http://www.weltenspiegel.de/private/ogr ... 0225/1.gif

In pic 2 I just added 5 times the same text.

Thanks for help...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Sat Feb 26, 2005 09:50

I haven't loked at the code yet, but I have a good idea of what is wrong. I'll try and get this fixed later today, thanks for the report :)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Sat Feb 26, 2005 16:16

Okay, I have a fix for this issue.

You need this patch (I'll get this into CVS shortly):

Code: Select all

Index: src/CEGUIFont.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/CEGUIFont.cpp,v
retrieving revision 1.29
diff -u -r1.29 CEGUIFont.cpp
--- src/CEGUIFont.cpp   11 Feb 2005 10:48:02 -0000   1.29
+++ src/CEGUIFont.cpp   26 Feb 2005 16:11:40 -0000
@@ -891,8 +891,8 @@
       {
          const Image* img = pos->second.d_image;
 
-         if (img->getOffsetY() > d_max_bearingY)
-            d_max_bearingY = img->getOffsetY();
+         if (-img->getOffsetY() > d_max_bearingY)
+            d_max_bearingY = -img->getOffsetY();
 
          if (img->getHeight() > d_lineHeight)
             d_lineHeight = img->getHeight();
@@ -901,6 +901,7 @@
       d_max_bearingY *= scale;
       d_lineHeight *= scale;
       d_lineSpacing = d_lineHeight;
+        d_maxGlyphHeight = d_lineHeight;
    }
 
 }


And the attached update to the Imageset file. The change was to specify the YOffset, which for a static / bitmapped font tells the system where the 'baseline' is for each glyph.

User avatar
Ayudo
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 14, 2005 23:07
Location: germany, munich
Contact:

Re: Does CEGUI support bitmap fonts?

Postby Ayudo » Sat Feb 26, 2005 19:38

Ok, works now :-)

But this line:
d_maxGlyphHeight = d_lineHeight;

throws in VC7.1:

d:\projects\cegui_mk2\src\CEGUIFont.cpp(904) : warning C4244: '=' : conversion from 'float' to 'CEGUI::uint', possible loss of data


In Debug it is no problem, but in Release it says:

\projects\cegui_mk2\src\CEGUIFont.cpp(904): error C2220: warning treated as error - no object file generated

-> so no Release-dll will be generated
/edit... as it only a small cast and my project being years away from "release" - no hurry ;-)

Thank you for (again) fast responding to this issue!
Thanks for your work!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Sun Feb 27, 2005 10:38

Cool.

The missing cast issue was already fixed in 0.2.0 branch, though it's not fixed in HEAD yet as it mixed in with a whole load of other changes I have not committed yet :)

CE.

User avatar
Ayudo
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 14, 2005 23:07
Location: germany, munich
Contact:

Re: Does CEGUI support bitmap fonts?

Postby Ayudo » Sun Mar 13, 2005 01:34

I encountered another little issue on the pixelated fonts.

In my imageset, I have doublequotes - three pixels wide.
So I defined HorzAdvance="4" - like this the next symbol should have 1 pixel distance.
But it is drawn with 2 pixel. If I change to 3, it is 0 pixel distance.

For testing I just packed it all with my bitmap font and all dlls (CEGUI MK2 0.2.0 (CVS), Ogre1.0.0) and stuff together for testing (7.5 MB):
http://www.weltenspiegel.de/private/ogr ... client.rar

Just edit the file font_futech9.font:
<Mapping Codepoint="34" Image="doublequote" HorzAdvance="3" />
(no space between quotes)
<Mapping Codepoint="34" Image="doublequote" HorzAdvance="4" />
(2 pixel between quotes)




Another thing which is quite strange imo:
YOffset does not have any effekt anymore? (it was strange though, as I had it on negativ values - dont remember why though)

And the only way to change the space between lines (combo-boxes, lists, multiline-textfields) is by changing the height of the symbol. P.e. If I wanted to have 5 pixels between entries in a list-box, I would have leave 5 pixels blank space under my characters in the image-file. (what a waste ;-) )

Another idea: could the HorzAdvance not be default to "image-width + <global attribute char-distance>" of the symbol?

My idea would be something like:

<Font Name="Futech9" Filename="font_futech9.imageset" Type="Static" Size="9" HorzAdvance="1" VertAdvance="5" NativeHorzRes="800" NativeVertRes="600" AutoScaled="false">

HorzAdvance="1" -> Leave 1 pixel space between chars.
VertAdvance="5" -> Leave 5 pixel space between lines in lists a.s.o.

I hope, you got the idea :-)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does CEGUI support bitmap fonts?

Postby CrazyEddie » Sun Mar 13, 2005 10:23

Okay, I'll take a look (probably will not be today though).

The YOffset was to set the baseline position for each glyph; this gives you control over the ascenders and descenders for each glyph. I don't think I've broken anything with regards to this, but I'll have a look at this also. Btw, they're negative because that's just the way the Image/Imageset system works.

The idea about being able to give generic default spacings to be used when these are not specified per-glyph is a good idea; I'll look into getting something in over the next week.

CE.

User avatar
Ayudo
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 14, 2005 23:07
Location: germany, munich
Contact:

Re: Does CEGUI support bitmap fonts?

Postby Ayudo » Sun Mar 13, 2005 11:26

YOffset does not have any effekt anymore? (it was strange though, as I had it on negativ values - dont remember why though)


Thats a mistake on my side... somehow I accidently used old DLLs (also with the client.rar)

So YOffset has to be set to -<height of image> for best results.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 25 guests