Author Topic: Width of text: RESOLVED  (Read 602 times)

garry23

  • Hero Member
  • *****
  • Posts: 1310
Width of text: RESOLVED
« 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

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3204
  • 60Da / 1100D / EOSM
Re: Width of text
« Reply #1 on: May 19, 2017, 03:15:56 PM »
Code: [Select]
FONT.LARGE:width("test")
See also editor.lua

garry23

  • Hero Member
  • *****
  • Posts: 1310
Re: Width of text
« Reply #2 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)

garry23

  • Hero Member
  • *****
  • Posts: 1310
Re: Width of text
« Reply #3 on: May 19, 2017, 03:51:19 PM »
@dmilligan

David: BTW here's the screen dump.


garry23

  • Hero Member
  • *****
  • Posts: 1310
Re: Width of text
« Reply #4 on: May 19, 2017, 04:10:39 PM »
SORTED!

Looked in ML source and realised should MED not MEDIUM

:-)