Bug in justify alignment?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Bug in justify alignment?

Post by pgimeno »

Test code:

Code: Select all

love.window.setMode(140, 100)
function love.draw()
  love.graphics.printf('This is a simple sample text which is long enough.', 
    0, 0, 140, 'justify')
end
Love 0.9.2:
justify-0.9.png
justify-0.9.png (3.31 KiB) Viewed 1246 times
Love 0.10.2 and 11.4:
justify-0.10.png
justify-0.10.png (3.31 KiB) Viewed 1246 times
In 0.10 and 11.4, besides the fact that the last line gets justified in this case (not in others, not sure what triggers it), there's the problem that lines don't fill the width like they do in 0.9. It's like about half of the spacing that distributes the words goes to the right of the last word.

It also looks like the spacing isn't even in the latter case, but I can't assure it.

Edit: I wrote my own justifier and made a mistake at first. If there are N words, there are N-1 spaces between them, so the difference between the left-justified line and the whole width of the line needs to be divided by N-1, not by N, to calculate the spacing to add between words. When I divided it by N by mistake, the result was quite similar to this bug. I wonder if that's related to the issue.
User avatar
slime
Solid Snayke
Posts: 3129
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Bug in justify alignment?

Post by slime »

Thanks for the report, we'll fix this for 12.0. :)
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Bug in justify alignment?

Post by pgimeno »

slime wrote: Mon Jan 09, 2023 11:49 pm Thanks for the report, we'll fix this for 12.0. :)
Thanks a lot! Would it be possible to include a justification mode where also the last line is justified? That would help with unusual layouts like the one in the request that made me discover this bug, see viewtopic.php?f=4&t=94163
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Bug in justify alignment?

Post by pgimeno »

oops, dupe
User avatar
slime
Solid Snayke
Posts: 3129
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Bug in justify alignment?

Post by slime »

pgimeno wrote: Tue Jan 10, 2023 6:42 pm Thanks a lot! Would it be possible to include a justification mode where also the last line is justified?
Maybe! I wouldn't know what to call it though. Does it have a commonly used name?
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Bug in justify alignment?

Post by pgimeno »

I'm not aware of any name, but 'justifyall' sounds OK to me, with the support of documentation. CSS uses "text-align-last" for the property that defines what happens to the last line, but I don't think that helps.
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests