Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sizing text - separate from what the text is.

Featured Replies

We allow users to increase and decrease font size by clicking a + or - sign. Each sign is a button and the button is a "set field" with the field specified and the calculated result:

textSizeChg (field ; "UP" ), where textSizeChg is a custom function written by someone long ago:

***********************************************************************************

// fontSizeChg ( text ; upordown )

Let ( [

sizenow = Filter ( LeftWords ( GetAsCSS( text ) ; 5 ) ; "1234567890" ) ;

sizenow = Case ( IsEmpty ( sizenow ) ; 12 ; sizenow ) ] ;

TextSize ( text ; Case ( PatternCount ( upordown ; "up" ) ; sizenow + 1 ; Max ( 1 ; sizenow - 1 ) ) )

)

*************************************************************************************

however when we have a number in the field to be sized, it grabs that number and things it's the sizenow.

So if we have the field with a default of 12, and it has a Save $49 Today! in it, clicking + takes it to a 50 font size and clicking - takes it to a 48 font size. That's not nearly as bad as when the number 50000 appears!

This happens on Win.

How can I have button sizing when the text includes a number (which is not its font?)

Thanks for any all insights!!

Whoever wrote that custom function made an unwarranted assumption that the text in the field (or more precisely, the first character of the text) has a font-size attribute. When this assumption fails, the function is "lost" and misinterprets any digits in the first 3 words of the text as the font size.

To determine the current size of the text, try =

Let ( [

CSS = GetAsCSS ( Textfield ) ;

pos = Position ( CSS ; "font-size: " ; 1 ; 1 ) ;

start = pos + 11 ;

end = Position ( CSS ; "px;" ; start ; 1 )

] ;

Case ( pos ; Middle ( CSS ; start ; end - start ) ; 12 )

)

Note that this returns the font-size of the first portion of text that has a font-size attribute. If no character in the entire text has a font-size attribute, the default result of 12 is returned.

  • Author

You're awesome! I rewrote the custom function, and it's such a relief to have it work as expected! Thank you so much for your wisdom and help.


// determine font size:

Let ( [

CSS = GetAsCSS ( text ) ;

pos = Position ( CSS ; "font-size: " ; 1 ; 1 ) ;

start = pos + 11 ;

end = Position ( CSS ; "px;" ; start ; 1 ) ;

sizenow = Case ( pos ; Middle ( CSS ; start ; end - start ) ; 12 )

] ;



// resize up or down

TextSize ( text ; Case ( PatternCount ( upordown ; "up" ) ; sizenow + 1 ; Max ( 1 ; sizenow - 1 ) ) )

)

Do you really need the custom function? You could let the script handle the entire logic by setting your field to =

Let ( [

CSS = GetAsCSS ( YourTable::Textfield ) ;

pos = Position ( CSS ; "font-size: " ; 1 ; 1 ) ;

start = pos + 11 ;

end = Position ( CSS ; "px;" ; start ; 1 ) ;

sizeNow = Case ( pos ; Middle ( CSS ; start ; end - start ) ; 12 )

] ;

TextSize ( YourTable::Textfield ; sizeNow + Get ( ScriptParameter ) )

) 

with the script parameter being either 1 (increase) or -1 (decrease).

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.