Character width / height in fontdef

Minor issues with the Ogre API that can be trivial to fix
Post Reply
KarenRei
Gnoblar
Posts: 5
Joined: Wed Jan 05, 2011 12:58 am

Character width / height in fontdef

Post by KarenRei »

As described in this thread:

http://www.ogre3d.org/forums/viewtopic.php?f=2&t=53308

And this bug report:

http://www.ogre3d.org/mantis/view.php?id=376

... calligraphy fonts and a number of others generally don't work right in OGRE because OGRE's font loading code makes assumptions about how much a character may overlap its neighbors, and the default is an amount that's too small for the sweeping strokes of calligraphy fonts. That is, in OgreFont.cpp, loadResource() there is a variable named char_spacer which is set to 5. It should be a relatively minor change to allow the value for this variable to be specified in the fontdef file instead of hard-coding it.

If you want to see a rendering disaster, replace a ttf font in the OGRE program of your choice with a calligraphy font like Mutlu Ornamental:

http://www.dafont.com/mutlu-ornamental.font

I'm not sure if this counts as a papercut (this is the first project I've seen use that term), but since it's an issue that should have a pretty simple fix and has been around for a while, I felt it was worth listing.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Character width / height in fontdef

Post by jacmoe »

/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
KarenRei
Gnoblar
Posts: 5
Joined: Wed Jan 05, 2011 12:58 am

Re: Character width / height in fontdef

Post by KarenRei »

Thanks for the link.

For the "average user" test, I encountered this bug in my very first following of an OGRE "Hello World" tutorial (the only difference being that since I didn't have the font they were using, I chose one of my own -- and was left banging my head for a couple days until I figured out what the bug was; it nearly drove me off using OGRE).

As for the simplicity test, I know nothing about OGRE's configuration file management, and even I think I could patch it in less than a day -- probably 2 hours to code and a few for testing. An expert could probably do this in under an hour total. Basically, wherever they set things like mSource (the font name), you need to do the same with a new variable, mCharSpacer (aka, since there's a function "setSource", you need "setCharSpacer", and so forth). And then you just use mCharSpacer instead of char_spacer.
inzero
Kobold
Posts: 33
Joined: Sun Dec 19, 2010 9:55 am

Re: Character width / height in fontdef

Post by inzero »

I posted about this a couple times as well. Everything in that wiki link seems to describe this.. regardless, it's been brought up multiple times in different forums, and it would be nice if someone that knows how to fix it atleast acknowledges it.
KarenRei
Gnoblar
Posts: 5
Joined: Wed Jan 05, 2011 12:58 am

Re: Character width / height in fontdef

Post by KarenRei »

Hmm... I was considering making a patch, since this should be such an easy fix, but the devel version of ogre fails to link:

[ 97%] Built target Sample_ParticleGS
Linking CXX executable ../../bin/SampleBrowser
../../lib/libOgreMain.so.1.8.0: undefined reference to `deflateInit_'
../../lib/libOgreMain.so.1.8.0: undefined reference to `deflate'
../../lib/libOgreMain.so.1.8.0: undefined reference to `deflateEnd'
../../lib/libOgreMain.so.1.8.0: undefined reference to `inflate'
../../lib/libOgreMain.so.1.8.0: undefined reference to `inflateInit_'
../../lib/libOgreMain.so.1.8.0: undefined reference to `inflateEnd'
../../lib/libOgreMain.so.1.8.0: undefined reference to `inflateReset'
collect2: ld returned 1 exit status


Sounds like it's not linking with zlib. :P Blah, I don't have enough time to fix things like a bad build configuration as well :P
KarenRei
Gnoblar
Posts: 5
Joined: Wed Jan 05, 2011 12:58 am

Re: Character width / height in fontdef

Post by KarenRei »

Here we go -- I haven't had a chance to test them beyond a compile, but I've patched the code to support charspacing as a fontdef argument (or as a function call):

http://www.daughtersoftiresias.org/code/OGRE/

The default value is 5. Increasing it should support wide-character fonts, while decreasing (on fonts that can tolerate less) should save memory and improve performance.
Post Reply