MyGUI in OpenMW: font problem


30-01-2009 10:25:35

Hey, we're planning on possibly using MyGUI in OpenMW, an OGRE-based open source reimplementation of Morrowind.

Of course, we want to use the existing built-in Morrowind fonts to make the look and feel as close as possible to the original game. The existing fonts are stored in a proprietary format, but we've manage to decode it. The fonts are bitmap fonts, consisting of an image and a set of coordinates for each character. The image is completely white (r/g/b are all 255), and the actual letters are defined by the alpha value only. The letters have varying height and width, etc.

So here are my questions, which I hope someone here can answer:

1. Is it possible to use these kind of fonts in MyGUI?
2. I found this thread which suggests it IS possible: viewtopic.php?f=17&t=8753 . However, it mentions that you need the SVN sources. Is this still true? (I've got 2.2.0_RC1 right now.)
3. Is it possible to do this through API calls? I mean, if I know the data at runtime (the image and the coordinates), can I insert it into the FontManager somehow without actually writing it out to a png / xml file first?

Thanks for your time


30-01-2009 16:08:25

1. Yes, but it seems, that you won't see the text. MyGUI use such format: white coloured letters and other space is alpha.
2. SVN trunk is enough stable. It's recommends to update from SVN, because too many changes had been done since 2.2.0_RC1 released.
3. Yes. But you have to emulate that you load xml :).// From MyGUI::FontManager
void _load(xml::ElementPtr _node, const std::string & _file, Version _version);
See Demo_Font for more details.


30-01-2009 21:03:32

Ok, thanks for the quick answer. Looks like I might not need to do it this way after all though, since we found some ttf versions of the fonts.

So with this obstacle gone, I think I'm going to go for MyGUI. Next up is skinning the GUI so it looks Morrowind-ish. Hopefully I'll post some screenshots here in the not to distant future :)


02-02-2009 10:19:45

Ok, here's an early screenshot:

As you see I'm still using the Comic font. I am having a few problems with the font system in MyGUI:

1. The truetype font I want to use doesn't work! The font can be found here: Here's the section from the .font file:

<Font name="cards" source="magiccards.ttf" size="18" resolution="72" antialias_colour="false" space_width="a" tab_count="4" spacer="5">
<Code range="33 98"/>
<Code range="1026 1039"/>
<Code hide="1026 1039"/>
<Code hide="1104"/>

I had to cut the ranges a little bit or else it would complain about missing characters. Could someone else please try it? The font works in any other program I've tried.

2. MyGUI doesn't seem to want to render spaces. The button above (Pressthisbutton) was given the string "Press this button". The same seems to be true for all captions and all fonts.

3. I tried using bitmap fonts as well, but the letters all end up stretched and out of proportion with each other (when in fact I want them rendered exactly as they appear in the bitmap texture.) Is there any guide for doing this? Perhaps there's more options I should specify in the xml file? (I only had coords and index.)

I'm using the latest svn from tags/MyGUI_2.2.

A couple of questions come to mind:
1. Is there a guide or tutorial for using fonts in MyGUI?
2. Why doesn't MyGUI use the Ogre font system? It seems like the systems have the same functionality, so I would guess it's a bit redundant to have both.
3. Why do you have to specify the ranges etc in the xml file? Can't this information be extracted from the ttf files?

I ask these because I'm curious, I know very little about font rendering. They're not meant as criticism :)

02-02-2009 10:35:52

update from svn.
and run Demo_Font with you font.


02-02-2009 11:01:02

1. You can use Demo_Font to see your font "in action", also you can change some parameters of your font and save automatically generated texture for the future use.
2. MyGUI uses Ogre font system, but it was expanded and some additional functions were added.
3. When you specify the ranges, you can control the size of the font texture, because there are some fonts with a lot of encodings and without the range this textures will be very huge. ( this textures will have an unreal size (c) ).


02-02-2009 12:37:06

Thanks for the quick reply. It still doesn't work right though.

I changed to the latest svn (trunk) and tried Demo_Font, and used the saved output in my xml files. It prints something, but it seems it prints the wrong characters (for example, the text "Skin test" just becomes a single 'o'.) Here's a screenshot from Demo_Font:

The texture preview looks ok to me, but the font preview doesn't seem quite right. Any ideas?

03-02-2009 15:11:03

wait ...


03-02-2009 16:00:00

1. Is there a guide or tutorial for using fonts in MyGUI?No. :( We slightly improved font format since 2.2_RC1 and now it's a bit more configurable. You should work with new code and remove all old MyGUI media to avoid wrong behaviour.2. Why doesn't MyGUI use the Ogre font system? It seems like the systems have the same functionality, so I would guess it's a bit redundant to have both.You don't need to use Ogre fonts at all while using MyGUI :) .
3. Why do you have to specify the ranges etc in the xml file? Can't this information be extracted from the ttf files?ttf file may have lots of characters for many different characters, for example Chineese, Russian, English, Arabic and so on, but I'm sure that you don't need all of them. We render all selected characters into texture and use only this texture in runtime.


05-02-2009 11:01:50

wait ...
So what's the status on this? Is it a bug?



05-02-2009 11:52:56

Give us your font file. May be it's problem in font mapping and libfreetype.


05-02-2009 13:26:35

Give us your font file. May be it's problem in font mapping and libfreetype.
Here it is:

06-02-2009 09:38:56

truetype version : freetype230


06-02-2009 11:32:29

That's weird - still no luck on this end. And:

$ freetype-config --ftversion

Could you please send me the resulting .font file, just in case? Thanks.

10-02-2009 15:48:14

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Font">
<Font name="FontName" default_height="22" source="magiccards.ttf" size="23" resolution="50" antialias_colour="false" space_width="4" tab_width="8" cursor_width="2" distance="5" offset_height="0">
<Code range="33 126"/>

11-02-2009 03:41:18



20-02-2009 07:53:00

Thanks, I'll check out FontStudio.

In the mean time, here's a very early video of MyGUI in Morrowind / OpenMW (with the old font):

I use MyGUI both for the windows and the HUD elements. The life bars etc are of course real progress bars that can be set to any value.

20-02-2009 11:11:48

WOW :wink:


16-02-2011 10:06:01

First of all: sorry for the huge bump :)

We're currently working on getting the original Morrowind font format to work with OpenMW. The lead developer was working on this but he isn't active anymore and OpenMW got completely rewritten to C++. It's currently working with ManualFont, but with one problem: characters shorter than FontHeight get stretched.

To get a better idea of what I'm talking about, here's how it should look:

And here's how it looks right now:

Here's what my font xml file looks like:
<Font name="Magic_Cards_Regular" type="ManualFont" default_height="16" source="magic_cards_regular.png">
<!-- values read from Magic_Cards_Regular.fnt -->
<Code index="33" coord="0 116 4 15" ascent="14"/>
<Code index="34" coord="109 0 5 15" ascent="14"/>
<Code index="35" coord="84 26 10 15" ascent="14"/>
<Code index="36" coord="83 41 9 15" ascent="14"/>
<Code index="37" coord="13 115 13 15" ascent="14"/>
<Code index="38" coord="68 58 13 15" ascent="14"/>
<Code index="39" coord="47 88 4 15" ascent="14"/>
<Code index="40" coord="34 103 7 15" ascent="14"/>

It's the most obvious with the letter 'w' and the zero. You can also see that the characters are too big in comparison with the original.

Question: Is there any way to get MyGUI to support different heights for each character?


PS: The topic on the OpenMW forum can be found here:
PPS: A showcase of the "stable" release of OpenMW can be seen here: