Generating fixed width font

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Regret
Prole
Posts: 8
Joined: Sun Nov 29, 2009 12:37 am

Generating fixed width font

Post by Regret »

I wrote this in an attempt to generate a fixed width font from the default love font. It prints given letters one by one on a black background, screenshoting / cutting out each one and then assembling it into a new imageFont.

I have encountered the following problems:
a) Saving the font in .tga format does not save the transparency which is needed to create an imageFont
b) [FIXED] The zipped version (.love) of this code generates a different (bad) imageFont while when unzipped (ran from a folder) the generated font is as intended. Occurs under WinXP, didn't test on other OS.

Problem a) could theoretically be solved by saving in a different data format, f.e. pixel data as opposed to using image formats.

I have no idea why b) occurs though, any ideas?


Screenshot of b)
screen.png
screen.png (40.83 KiB) Viewed 3819 times

The code
fixedwidthfont.love
(3.74 KiB) Downloaded 216 times
Last edited by Regret on Tue Jul 13, 2010 7:24 pm, edited 1 time in total.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Generating fixed width font

Post by kikito »

1. PNG > TGA. (Looks over the internet for facts) It's smaller, also lossless, also has alpha channel, and allows more color depth (TGA's max is 8bpc, PNG is 16). More importantly, it is usually better supported on graphic libraries.

2. The "uncompressed works, compressed it gives me an error" is 90% times due to uppercase/lowercase differences between the filenames used in the source code and the real file names. For example, image.png vs image.PNG . Look for those typos.
When I write def I mean function.
Regret
Prole
Posts: 8
Joined: Sun Nov 29, 2009 12:37 am

Re: Generating fixed width font

Post by Regret »

kikito wrote:1. PNG > TGA. (Looks over the internet for facts) It's smaller, also lossless, also has alpha channel, and allows more color depth (TGA's max is 8bpc, PNG is 16). More importantly, it is usually better supported on graphic libraries.
Love does not support saving into .png format using love.image.newEncodedImageData.
kikito wrote:2. The "uncompressed works, compressed it gives me an error" is 90% times due to uppercase/lowercase differences between the filenames used in the source code and the real file names. For example, image.png vs image.PNG . Look for those typos.
There are no images used, no typos in filenames as it is only main.lua and conf.lua.


EDIT: Problem b) was my fault due to running .love files with an older version, ran it with newest and it worked ;/
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Generating fixed width font

Post by Robin »

So, ehm, why not use a normal fixed width font?
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest