Increase font mixed sizes

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Increase font mixed sizes

Post by paulclaude » Tue Jun 23, 2015 12:49 pm

Someone knows a quicker way to increase or decrease (+1, -1) the font size of the whole text of a field that contains many different font sizes, rather than increasing textSize char by char?

Code: Select all

set the textsize of char a to (the textsize of char a) + 1
Thanks...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Increase font mixed sizes

Post by dunbarx » Tue Jun 23, 2015 2:19 pm

Hi.

I could be wrong, but if a field contains mixed textSizes, or mixed anyTextProperties, I think there is no way to set a single property to change the whole in a "piecemeal" way. If the mixed styles drill down to the char level, then the changes will have to be at that level as well, in a loop. Make sure you do all this in a variable, and not in the field itself, for speed. Use the htmlText to retain style properties.

Craig Newman

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Increase font mixed sizes

Post by paulclaude » Tue Jun 23, 2015 2:33 pm

Yes, Craig, this is my problem. I would only know if there is a quicker solution.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Increase font mixed sizes

Post by FourthWorld » Tue Jun 23, 2015 2:35 pm

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Increase font mixed sizes

Post by paulclaude » Tue Jun 23, 2015 3:16 pm

Thanks, Richard, I have a range of sizes from 10 to 25, so I've made this simple example script:

Code: Select all

   
put the htmlText of fld "Song" of cd (output&&"Song") of stack "Print" into sg
put "size="&quote&"x"&quote into toSearch
    repeat with w=25 down to 10
               put toSearch into actSearch
               put toSearch into incrSearch
               replace "x" with w in actSearch
               replace "x" with w+1 in incrSearch
               replace actSearch with incrSearch in sg
    end repeat
set the htmlText of fld "Song" of cd (output&&"Song") of stack "Print" to sg

Post Reply