Text Character Width?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
cmhjon
Posts: 199
Joined: Tue Aug 04, 2015 11:55 am

Text Character Width?

Post by cmhjon »

Hi all,

Does LC have any way of changing the width of text characters in a text box? In page layout applications, this is called horizontal scale. The following image shows what I mean:

https://creativepro.com/wp-content/uplo ... caling.png

I'm already using a condensed font in the text field but need to squeeze the width of the characters a little more.

I checked the dictionary and didn't find anything that seemed to fit my needs.

Thank you,
Jon
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Text Character Width?

Post by richmond62 »

unequalscaling.png
-
I suspect you'll have to use font substitution.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text Character Width?

Post by Klaus »

Hi Jon,

no, sorry, LC does not provide any of these pleasantries that dedicated layout application supply!


Best

Klaus
cmhjon
Posts: 199
Joined: Tue Aug 04, 2015 11:55 am

Re: Text Character Width?

Post by cmhjon »

Well poop!

Thank you,
Jon
kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm

Re: Text Character Width?

Post by kdjanz »

If the field is just a label for a control that does not need to change, you could take a snapshot to turn it into a graphic and then squeeze the graphic rectangle right down to unintelligibility. That won't work for a field where the text is changing however.
cmhjon
Posts: 199
Joined: Tue Aug 04, 2015 11:55 am

Re: Text Character Width?

Post by cmhjon »

Hi kdjanz,

Unfortunately, the text changes :(

Thank you though!
Jon :)
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Text Character Width?

Post by richmond62 »

Of course if the text is subject to change . . .

Every time the text changes the stack could take a snapshot of the field, scale it and position it as appropriate;

this is really quite straightforward.
-
Screen Shot 2021-05-27 at 10.25.09 AM.png
-
Code in the wider field:

Code: Select all

on textChanged
   put fld "ff" into fld "ff2"
   set the width of fld "ff2" to the formattedWidth of fld "ff2"
   set the location of fld "ff2" to 200,32
   import snapshot from fld "ff2"
   set the name of the last control to "SNAPP"
   set the width of img "SNAPP" to 380
end textChanged
Stack removed as improved version in the next posting.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Text Character Width?

Post by richmond62 »

Ouch: I realised that as one typed a new word one ended up with a 'pile' of intermediate images all called "SNAPP"
which was a load of "bollo"!

So, here's an improved version:
-

Code: Select all

on textChanged
   if exists(img "SNAPP") then
      delete img "SNAPP"
   end if
   put fld "ff" into fld "ff2"
   set the width of fld "ff2" to the formattedWidth of fld "ff2"
   set the location of fld "ff2" to 200,32
   import snapshot from fld "ff2"
   set the name of the last control to "SNAPP"
   set the width of img "SNAPP" to 380
end textChanged
It should be clear why I have added lines 2-4
Attachments
TEXT SQUIDGER.livecode.zip
Here's the stack.
(1.19 KiB) Downloaded 253 times
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Text Character Width?

Post by richmond62 »

Screen Shot 2021-05-27 at 12.57.44 PM.png
-
mary_poppins_r18-1024x575.jpg
cmhjon
Posts: 199
Joined: Tue Aug 04, 2015 11:55 am

Re: Text Character Width?

Post by cmhjon »

Hi richmond62,

Although I am trying different condensed fonts to find one that will work, that import snapshot function is VERY cool! I didn't know that LC could do anything like that! I have filed that one away for future use. Thank you for sharing! :)

Best regards,
Jon :)
Post Reply