Issues

Issue #672 resolved

Making image font spacer area insignificant

hahawoo
created an issue

I reckon it might make sense if the spacer color area of an image font wasn't significant in the actual font, I think it would be better if it was like "insignificant whitespace".

It seems like the spacer area is appended as transparent space on the right side of the character, but if you wanted transparent space on the right side of character, you could, y'know, just put transparent space on the right side of the character. :P

(Possibly perhaps maybe kinda somewhat related: #466. If the spacer color area wasn't significant, 0 pixel spacing would be possible.)

Comments (5)

  1. Minh Ngo

    I do not like that the spacing is encoded into the image. I propose that a third parameter be added which accepts a number for spacing. This would make the images be typical sprite sheets and allow for other uses without any special formatting.

    font = love.graphics.newImageFont( ..., glyphs, spacing )
    

    EDIT:

    Another parameter would be needed to specify the width of each character to compensate for removal of spacing data. If multi row fonts are to be supported, a height parameter should be added as well.

    font = love.graphics.newImageFont( ..., glyphs, width, height, spacing )
    
  2. hahawoo reporter

    The way I see it, I kinda think that the image font format should be as simple as possible, and you can pre-process whatever image you want to use into that format (I made a pre-processing thing in #190, which doesn't have a spacing parameter, but it could easily be added). Here's why I think this:

    1. It keeps the mechanism as simple as possible, and leaves how you want to use it up to you, so it's easy to understand and generally in line with LÖVE's philosophy.
    2. Images could be in any number of formats, and you might want to do any number of transformations to them. You might have a multi-line sprite sheet and the characters have varying widths, so you'd use the separator color for the widths, but you'd use a parameter for the height. Or would you use a vertical separate color too? What if it's an optimised sprite sheet and the coordinates of the characters aren't aligned to a grid? And what about specifying line height?

    Alex Szpakowski mentioned thinking about adding the Angel Code font format, which I reckon is kinda cool, because it doesn't add any complexity the API (I guess it's just like a new font format, like TTF or OTF), and if you want to do cool stuff with image fonts like kerning or negative spacing, you can.

  3. hahawoo reporter

    Another issue with having a spacing state for image fonts is that there should be methods to set/get this state, which would require either a subclass of Font for image fonts or TTF/OTF fonts having a spacing state as well. Edit: Or maybe not.

    Just thinking out loud, but I wonder if the initial reason for significant spacer area was for scaling up font images and keeping equivalent letter spacing. I guess this wouldn't be necessary now due to "nearest" Font filtering.

    I wonder if image fonts would be still necessary with Angel Code bitmap fonts? Because a converter could surely be written to convert current LÖVE image fonts (or any other format) into that format.

  4. Log in to comment