Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on May 19, 2017, 02:39:41 PM

Title: Width of text: RESOLVED
Post by: garry23 on May 19, 2017, 02:39:41 PM
@dmilligan

David I hope you can put me out of my misery.

I'm needing to right justify some text and need to the width of a string.

I've tried using font:width(text) but I'm obviously using it wrong.

Could you help me please, ie how do I get the pixel width of a piece of text.

Sorry to be a pain.

Cheers

Garry
Title: Re: Width of text
Post by: dmilligan on May 19, 2017, 03:15:56 PM
Code: [Select]
FONT.LARGE:width("test")
See also editor.lua
Title: Re: Width of text
Post by: garry23 on May 19, 2017, 03:24:27 PM
@dmilligan

Thanks: tried that but get nil value medium error.

Here is the code I used, message is a string.

Code: [Select]
  local qq = FONT.MEDIUM:width(message)
Title: Re: Width of text
Post by: garry23 on May 19, 2017, 03:51:19 PM
@dmilligan

David: BTW here's the screen dump.

(http://thumb.ibb.co/futv8F/VRAM0.jpg) (http://ibb.co/futv8F)
Title: Re: Width of text
Post by: garry23 on May 19, 2017, 04:10:39 PM
SORTED!

Looked in ML source and realised should MED not MEDIUM

:-)