Lisp HUG Maillist Archive

Measuring text size

Hi,

Using GP, is it possible to measure text extent with high precision? get-string-extent et. al rounds to whole pixels used, which is often nice, but sometimes I find myself needing a more exact number.

I've been using a workaround, scaling the font size by some factor, measuring, and then dividing the result by the same factor. But besides being a clumsy way of doing things, it is also quite inefficient: a factor of 10 only increases the precision by one digit, while the resources needed to do the calculation in theory increases a 100 times. In practice, it is nearly not as bad, but it's still slower. A new font object also needs to be allocated, which can be a bottleneck in code running many times.

Regards
Erik


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:34 UTC