HTML font size in percentages
Paul Dupuis
paul at researchware.com
Wed May 25 07:36:43 EDT 2022
On 5/20/2022 4:30 PM, J. Landman Gay via use-livecode wrote:
> Thanks for verifying it Paul, that's what I was thinking too. I'm
> looking at replacing the sizes via the style runs, I have a handler
> Mark Waddingham gave me/us on the list last year that I think I can
> modify.
>
> But I'd be grateful to see yours too. No big hurry, I just need to get
> an idea of how to estimate my time at this point. Thank you very much.
>
>
Sorry for the delay. By some weird email glitch I only saw this list
post today.
Anyway, here is the routine, While it works, if I was rewriting it, I
would probably just do a loop with a match to the html font size
attribute. This code does ensure that the size can't go below a minimum
where LC's legacy font size values actually make the text bigger.
on ChangeTextSize pBiggerOrSmaller, pObj
-- usage: ChangeTextSize "bigger"|"smaller",the long ID of field X of
stack Y
lock screen
if len(the text of pObj) > 5000 then
set cursor to watch
end if
-- Get current scaling. The textSize will be set to the effectove
textSize + tCurScale (+1|-1)
-- uTextScaling is defauted to 0 in the object (field) custom properties
put the uTextScaling of pObj into tScale
if tScale is empty then put 0 into tScale
if pBiggerOrSmaller is "bigger" then
add 1 to tScale
put 1 into tCurScale
else
subtract 1 from tScale
put -1 into tCurScale
end if
set the uTextScaling of pObj to tScale
--
put the htmlText of pObj into tHtml
--
set the textHeight of pObj to empty
set the textSize of pObj to max(8,the effective textSize of
pObj+tCurScale)
--
replace "size=""e with "size="&numToChar(1500) in tHtml
set the itemdel to numToChar(1500)
if the number of items of tHtml <> 1 then
put 0 into testItem
repeat for each item theItem in tHtml
add 1 to testItem
if testItem<>1 then
put offset(quote,theitem) into counter
put char 1 to counter-1 of theItem into theSize
put max(8,theSize+tCurScale) into theSize
put theSize into char 1 to counter-1 of theItem
put quote&theItem after newHTML
else
put theItem into newHTML
next repeat
end if
end repeat
set the htmlText of pObj to newHTML
--
end if
unlock screen
end ChangeTextSize
More information about the use-livecode
mailing list