Get widest character of 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.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Get widest character of font?

Post by zorg »

To be absolutely sure, i'd go over either the 26 basic latin letters and compare all to the first, for example; or if possible, i'd check for the ones the user(s) actually used.

Then again, instead of rejecting non-monospaced fonts, you could still do the route i mentioned above, even if it would be a tad more wasteful... or you could use a canvas; depending on a few things, with that, even non-monospaced symbol placement can be "optimized". (Only drawing everything once / when a symbol changes in a specific location; at all other times, you'd just have one draw call to draw the whole canvas... and this would also be useable with monospaced fonts as well.)
Me and my stuff :3True 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.
User avatar
TheOddByte
Prole
Posts: 35
Joined: Sun Dec 15, 2013 7:15 pm

Re: Get widest character of font?

Post by TheOddByte »

zorg wrote: Tue Feb 21, 2017 10:19 pm ...
How would I do this with a canvas? I'm not very familiar with that.
By the way, here's the code I'm currently using: http://pastebin.com/sEzk7SWx
As you can see I'm currently drawing each character individually, which I realize isn't very optimal.
What's the object-oriented way to get wealthy? Inheritance.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Get widest character of font?

Post by Positive07 »

Non monospaced fonts will probably look horrible in a grid... The shorter solution should be enough to detect if it's monospaced
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: No registered users and 205 guests