|
|
|
07-19-2018, 10:04 AM
|
#1
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Q: Width of text string, in pixels?
If I am using a proportional font, e.g. 'Calibri'', in a lua script is there a way to determine the width of a string, in pixels (not characters)?
I have tried using various "average character width" values but none are fully satisfactory.
Perhaps there is a gfx.function that updates gfx.x and gfx.y? gfx.printf() must be able to deal with character widths, so why can't it tell tell me?
Why do I need it: i want to position a graphic 10 pixels after the end of the string.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
07-19-2018, 10:10 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
There is gfx.measurestr to get the width/height of a string with the current font without drawing it (if you're using gfx.printf you'll have to switch to Lua's string.format).
gfx.drawstr, gfx.drawchar an gfx.printf all modify gfx.x andgfx.y.
Last edited by cfillion; 07-19-2018 at 10:16 AM.
|
|
|
07-19-2018, 10:14 AM
|
#3
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Thank you - I tried all sorts of search terms, but not "measure"
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
07-19-2018, 05:19 PM
|
#4
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
|
|
|
07-20-2018, 02:38 AM
|
#5
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Yep, thank you - that is similar to what I had done.
(Maybe I should read all of your thread. )
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 01:33 AM.
|