Page 2 of 2

Re: Get widest character of font?

Posted: Tue Feb 21, 2017 10:19 pm
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.)

Re: Get widest character of font?

Posted: Tue Feb 21, 2017 10:31 pm
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.

Re: Get widest character of font?

Posted: Wed Feb 22, 2017 12:17 am
by Positive07
Non monospaced fonts will probably look horrible in a grid... The shorter solution should be enough to detect if it's monospaced