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: FourthWorld, heatherlaine, Klaus, kevinmiller

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

Text Character Width?

Post by cmhjon » Wed May 26, 2021 6:49 pm

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: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Text Character Width?

Post by richmond62 » Wed May 26, 2021 7:35 pm

unequalscaling.png
-
I suspect you'll have to use font substitution.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Text Character Width?

Post by Klaus » Wed May 26, 2021 7:37 pm

Hi Jon,

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


Best

Klaus

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

Re: Text Character Width?

Post by cmhjon » Wed May 26, 2021 8:04 pm

Well poop!

Thank you,
Jon

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Text Character Width?

Post by kdjanz » Wed May 26, 2021 8:47 pm

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: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Text Character Width?

Post by cmhjon » Wed May 26, 2021 10:02 pm

Hi kdjanz,

Unfortunately, the text changes :(

Thank you though!
Jon :)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Text Character Width?

Post by richmond62 » Thu May 27, 2021 8:09 am

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: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Text Character Width?

Post by richmond62 » Thu May 27, 2021 9:21 am

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 104 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Text Character Width?

Post by richmond62 » Thu May 27, 2021 10:58 am

Screen Shot 2021-05-27 at 12.57.44 PM.png
-
mary_poppins_r18-1024x575.jpg

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

Re: Text Character Width?

Post by cmhjon » Thu May 27, 2021 1:02 pm

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

Return to “Getting Started with LiveCode - Complete Beginners”