Convert a pixel-perfect ImageFont to a TrueType font?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Convert a pixel-perfect ImageFont to a TrueType font?
Does anyone know a way to convert an ImageFont to a TrueType font? I've tried FontStruct and FontForge, but neither of them give me any good options other than "recreate the entire thing".
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Convert a pixel-perfect ImageFont to a TrueType font?
Why do you need to do the conversion?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Convert a pixel-perfect ImageFont to a TrueType font?
Re: Convert a pixel-perfect ImageFont to a TrueType font?
Gah, should have looked that up first. Thanks.
Re: Convert a pixel-perfect ImageFont to a TrueType font?
There are online font generators that can create fonts from images. So, you can try generating a font image from your image font, and then feed it to one of those font generators.
Re: Convert a pixel-perfect ImageFont to a TrueType font?
2020 Edit: Seems Fontcutter is down. You should use this recently-released tool instead. Much easier to use.
TL;DR: http://fontcutter.fbksoft.com/ is useful, mess around with values in the resulting .fnt file using this, everything before the "Binary file layout" header
Unfinished garbage tutorial draft below:
Whoops, I abandoned this thread after making it. Good news though: I found a basic workflow that's pretty good! Gonna write this blog-style, starting from the top.
So, a lot of game engines support "Bitmap Fonts", which are made up of an image file and a .fnt file. Bitmap fonts are typically made from existing fonts you have installed to your font folder, generated using this tool. However, there is a way to make your own Bitmap font. And no, it won't force you to waste hours recreating it in FontForge. (I didn't know you can't overlap points until I went to export it... )
There's an open-source tool called "Fontcutter". It's a bit old, and it has quite a few bugs, but it's a great starting point. It takes in image files that are somewhat like the Love2D image fonts, and slices them and outputs a .fnt file. I say "somewhat like" because there's a catch: you can't just throw in a normal Love2D and expect it to immediately work. There's two catches actually. First: the program only supports monospace fonts. Second: you're gonna have to remove the background color that separates each glyph. (If you don't have a monospace font, keep a backup!)
Don't be discouraged by either of these! A little tweaking and it will work. Set the text lines to one, dump in your glyph string, (don't forget to correct the escaped characters!) and make sure that the glyph string neither begins or ends with a space, as that space will get removed! Then, adjust the char width and char height parameters to fit at least one of your characters.
Now, check the preview tab. If you didn't make a monospace font, keep moving and try not to throw up. Don't worry, we'll fix this in a second. Even if your font looks good in the preview tab, there's a few things we'll have to change. Check the Ouput [sic] tab and select all the text. Copy it into a new text editor window. Save it as whatever you want, just don't forget to give it the .fnt extension. Wait a sec-- did we just make a .fnt file? Yep. Internally, it's that simple.
Now, this is the hard part. If you have a monospace font and your font looks good, skip the next paragraph.
You're gonna have to open a good pixel-perfect image editor like Aseprite or Paint.Net, and go through, glyph by glyph, correcting each of the parameters. todo finish draft
Unfinished garbage tutorial draft below:
Whoops, I abandoned this thread after making it. Good news though: I found a basic workflow that's pretty good! Gonna write this blog-style, starting from the top.
So, a lot of game engines support "Bitmap Fonts", which are made up of an image file and a .fnt file. Bitmap fonts are typically made from existing fonts you have installed to your font folder, generated using this tool. However, there is a way to make your own Bitmap font. And no, it won't force you to waste hours recreating it in FontForge. (I didn't know you can't overlap points until I went to export it... )
There's an open-source tool called "Fontcutter". It's a bit old, and it has quite a few bugs, but it's a great starting point. It takes in image files that are somewhat like the Love2D image fonts, and slices them and outputs a .fnt file. I say "somewhat like" because there's a catch: you can't just throw in a normal Love2D and expect it to immediately work. There's two catches actually. First: the program only supports monospace fonts. Second: you're gonna have to remove the background color that separates each glyph. (If you don't have a monospace font, keep a backup!)
Don't be discouraged by either of these! A little tweaking and it will work. Set the text lines to one, dump in your glyph string, (don't forget to correct the escaped characters!) and make sure that the glyph string neither begins or ends with a space, as that space will get removed! Then, adjust the char width and char height parameters to fit at least one of your characters.
Now, check the preview tab. If you didn't make a monospace font, keep moving and try not to throw up. Don't worry, we'll fix this in a second. Even if your font looks good in the preview tab, there's a few things we'll have to change. Check the Ouput [sic] tab and select all the text. Copy it into a new text editor window. Save it as whatever you want, just don't forget to give it the .fnt extension. Wait a sec-- did we just make a .fnt file? Yep. Internally, it's that simple.
Now, this is the hard part. If you have a monospace font and your font looks good, skip the next paragraph.
You're gonna have to open a good pixel-perfect image editor like Aseprite or Paint.Net, and go through, glyph by glyph, correcting each of the parameters. todo finish draft
Last edited by V360 on Mon May 11, 2020 8:04 pm, edited 1 time in total.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Convert a pixel-perfect ImageFont to a TrueType font?
You still managed to not explain why you are not satisfied with löve's style of imagefonts...
THEN AGAIN, the wiki clearly states that löve ALSO supports the bmfont format, so i'm unsure what you're on about with the fontcutter thing, since i feel like that's also useless in this context.
THEN AGAIN, the wiki clearly states that löve ALSO supports the bmfont format, so i'm unsure what you're on about with the fontcutter thing, since i feel like that's also useless in this context.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Convert a pixel-perfect ImageFont to a TrueType font?
Yeah I have that feeling that this a case of seeking help with an extremely convoluted solution for a problem that should be simpler to solve.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests