Custom fonts from an already created image.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Custom fonts from an already created image.

Post by Cube_ »

Ok so I have a font image (the font is Chairo Bold, there is not *.ttf or simmilar available, just this one png file, this font (for those who are interested) was used in Oacrina of Time (THE ORIGINAL, have no clue about the 3ds version))
how would I go by when making an xml file for the font?
"this is not the bottleneck you are looking for"
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Custom fonts from an already created image.

Post by hybrid »

You can't. well, you could count pixels and create an XML manually. But I doubt that it's easier than finding this font somewhere as a proper font file.
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Custom fonts from an already created image.

Post by CuteAlien »

Maybe you could get it working as bitmap font. I think our bitmap fonts find the characters by a yellow pixel on top-left of each character and a red pixel on bottom-right. Order probably also has to be the same as in other bitmap fonts. Take a look at one of the existing ones in the media-folder like "fonthaettenschweiler.bmp" in a graphic-program (paintbrush will do).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Custom fonts from an already created image.

Post by hybrid »

Yeah, but of course this requires the characters to be aligned with a fixed spacing IIRC, and also requires certain height of the lines and the bitmap. Moreover, you lose all extra information about kerning and whatever is stored in the XML as well.
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Custom fonts from an already created image.

Post by CuteAlien »

Well, he already has a bitmap font (.png) if I got that right. So yeah - depends on that stuff, but chances are not too bad all that's there already.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Custom fonts from an already created image.

Post by Cube_ »

well, if I can't do it this way, does anyone know of some software that can convert a bitmapped font into a ttf file so I can use the irrlicht font tool to convert it (if you want I can upload the image)
I have no clue if the letters are in the 'right' order. I assume they are.
"this is not the bottleneck you are looking for"
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Custom fonts from an already created image.

Post by Radikalizm »

aaammmsterdddam wrote:well, if I can't do it this way, does anyone know of some software that can convert a bitmapped font into a ttf file so I can use the irrlicht font tool to convert it (if you want I can upload the image)
I have no clue if the letters are in the 'right' order. I assume they are.
It's not just about letters being in the right order, it's more about how a tool can identify and separate letters from eachother
You seem to assume that all bitmap fonts are the same, or that all bitmap fonts could be read by any tool, which is absolutely not the case

Also, TrueType font glyphs are not stored as rasterized data, but as curves. The conversion from these curves to rasterized data with certain specified qualities can be done easily using a rasterization engine, but rebuilding clean curve data from rasterized data is not something you can do
I'm not saying that it's impossible to get curve data back from your bitmaps, but the resulting data in your truetype font would look pretty horrible
Your bitmap probably also does not include all characters included in the original truetype font by the way
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Custom fonts from an already created image.

Post by CuteAlien »

aaammmsterdddam wrote:I have no clue if the letters are in the 'right' order. I assume they are.
That's why I wrote to take a look at fonthaettenschweiler in the media folder. Obviously the fonts coming with Irrlicht have the right order. So you can directly compare to those.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Custom fonts from an already created image.

Post by Cube_ »

ok... so I should remap the font according to that image (I actually started with that yesterday ;) )
Your bitmap probably also does not include all characters included in the original truetype font by the way
Of course it doesn't. there is no TrueType font. This is a font dump I made. (dumped directly from the game!)
^^*
"this is not the bottleneck you are looking for"
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Custom fonts from an already created image.

Post by Radikalizm »

aaammmsterdddam wrote:ok... so I should remap the font according to that image (I actually started with that yesterday ;) )
Your bitmap probably also does not include all characters included in the original truetype font by the way
Of course it doesn't. there is no TrueType font. This is a font dump I made. (dumped directly from the game!)
^^*
Well, you were the one talking about recreating a TTF out of your bitmap ;)

Also, it's not exactly legal to use copyrighted resources you extracted from some game and use it in your own
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Custom fonts from an already created image.

Post by Cube_ »

it is for a fan project.
And I don't care about the law.
**hey nintendo! Sue me, bitchez!**

Back to the question.
there is really no way of doing this?
I tried using incscape and some program (Fontforge I think)
But it didn't want to work :(
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Custom fonts from an already created image.

Post by CuteAlien »

aaammmsterdddam wrote:ok... so I should remap the font according to that image (I actually started with that yesterday ;) )
Didn't that work? Don't forget the colored pixels I mentioned.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
docWild
Posts: 38
Joined: Wed Nov 30, 2011 4:29 pm

Re: Custom fonts from an already created image.

Post by docWild »

aaammmsterdddam wrote:it is for a fan project.
there is really no way of doing this?
I tried using incscape and some program (Fontforge I think)
But it didn't want to work :(
It can be done. Those coloured control characters can be found within a loop which will "scan" the bitmap data of the image. From that you can define the rectangles which irrlicht will be able to read, then you can take the characters you want and generate another bitmap using those control characters as delineators for each individual character (this can also be done with some skill, patience and frustration in an image program). The problem is that each position is probably hardcoded into irrlicht to represent a specific character as it has no meta data from an XML file to identify it, so it will take lots of tinkering and a fair amount of bug testing to make sure the engine is loading the correct character as a computer has no concept of what an "A" looks like. If you have done your job correctly you will have a bitmap which can be read as a font file.

I wouldn't recommend it though. Sounds like a mission with very little reward.
Post Reply