Need help formatting imageFonts

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
vine
Prole
Posts: 5
Joined: Sun Dec 02, 2012 4:59 pm

Need help formatting imageFonts

Post by vine »

I need help getting an imageFont to format correctly;
Capture2.PNG
Capture2.PNG (4.67 KiB) Viewed 1736 times
The first line is how you'd organize your font so it can be read by Love, from what I understand of https://love2d.org/wiki/ImageFontFormat.
The second line shows how Love would render the font after a love.graphics.print('ABCDE')
The last line is how I'd like the font to be rendered.

How would I go about doing this, or is it even possible without some ridiculous workaround?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Need help formatting imageFonts

Post by bartbes »

It is, indeed, currently impossible to have a spacing of 0 with ImageFonts, I remember there being a ticket on the tracker, but I couldn't find it in the minute of searching I just did.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Need help formatting imageFonts

Post by Jasoco »

bartbes wrote:It is, indeed, currently impossible to have a spacing of 0 with ImageFonts, I remember there being a ticket on the tracker, but I couldn't find it in the minute of searching I just did.
Correction, in order to make it look like the last (Which is something I also want to be able to do) it would need a spacing of -1.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Need help formatting imageFonts

Post by Inny »

This might help:

Code: Select all

local font = love.graphics.newFont(...)
local offset = 1
function draw_text(x, y, str)
  for c in str:gmatch('.') do
    love.graphics.print(c, x, y)
    x = x + font:getWidth(c) - offset
  end
end
It needs tweaking to handle newlines and such.
Post Reply

Who is online

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