Buttonlabel/Textfield Size of text on Tablet is different

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Buttonlabel/Textfield Size of text on Tablet is different

Post by Texter » Thu Jun 21, 2018 7:23 am

Hi

I need help once again

Why is the size of text in Livecode like this
Lifecode.JPG


and in Tablet like this
Tablet.jpg
Is this a different font? Do the tablet do not use the font from livecode?

Texter

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by jacque » Thu Jun 21, 2018 4:36 pm

If you have not assigned a font to the stack or to individual controls, LC uses the system font which is different on every OS. If you did assign a font and the OS doesn't have that font, then it also falls back to the system font.

You can either assign a font that exists on all platforms (there are only a few) or include the font file with the app. See "start using" in the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by bogs » Thu Jun 21, 2018 7:32 pm

As well as what Jacque pointed out, different OSes display the same fonts differently to some degree (i.e. Mac/Windows/Linux, not sure about mobile), so even using those same few fonts may not give you exactly the same appearance, requiring you to make sure the final appearance is correct on the devices OS.
Image

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by Texter » Fri Jun 22, 2018 12:58 pm

Hi

Thanks jacque and bogs

I will search which fonts are equal to livecode on Win10 and Android.

But is there a code to use this font for the whole stack? Or do I have to set this font to all fields and labels?

Texter

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

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by Klaus » Fri Jun 22, 2018 1:04 pm

Hi Texter,

the magic word is "inheritance", no code needed!

If you set the textfont (or any other property) for a stack and
not for every card and objects, then all cards and object "inherit"
this textfont property. This applies to ALL properties!

So if you did not set the textfont explicitely for any card or control,
just set it for the stack and you are done!

Best

Klaus

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by Texter » Mon Jun 25, 2018 5:24 pm

Hi Klaus,

Thanks for all your help.

I managed it to set the textfont for the whole stack.

Can I also set the textfont for all fields (only fields) of the stack?

I tried it but get only Errors. How is the syntax for this?

Texter

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

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by Klaus » Mon Jun 25, 2018 5:58 pm

Hi Texter,

of course you can set the textfont (and any property!) for each control in LC separately.
That will overwrite the inherited property.

To do so for all fields in your stack you need to script a nested repeat loop like:

Code: Select all

...
lock screen
put "Comic Sans OH NO!" into tFont
repeat with i = 1 to the num of cds
  put the num of flds of cd i into tFields
  repeat with k = 1 to tFields
    set the textfont of fld k of cd i to tFont
  end repeat
end repeat
unlock screen
...
Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by jmburnod » Mon Jun 25, 2018 6:02 pm

Hi Texter,
Can I also set the textfont for all fields (only fields) of the stack?
Yes, something like that:

Code: Select all

on doChangeMyFont pFont
 set the  lockmessages to true
   lock screen
   repeat with i = 1 to the num of cds
      open cd i
      repeat with z = 1 to the num of flds
         set the textFont of char 1 to -1 of fld z to pFont
      end repeat
   end repeat
   open cd 1
end doChangeMyFont
Best regards
Jean-Marc
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by jacque » Mon Jun 25, 2018 7:45 pm

There's a difference between setting the font of a field and setting it for the characters in the field. The first applies to any text, whether new or not, and the latter applies only to the current text. If is deleted and replaced, it will use the font inherited from a control farther along the hierarchy.

Inheritance goes from character text, field, card, stack. The first one that has the property set is the setting that's used.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by Texter » Mon Jun 25, 2018 8:27 pm

Hi Klaus, Jean-Marc, Jacque

Thank you for your help

Thought it is easier to set the textfont because set the textfont of stack "Test" to "Arial" worked fine.

and I tried set the textfont of all fields of stack "Test" to "Arial"

Never imagine I need a loop for this

Texter

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by jacque » Mon Jun 25, 2018 9:01 pm

You can shift-click all the fields on a card using the edit tool, then double-click any one of them to open the property inspector. In the text pane (looks like an "A") you can select the font and size and it will be applied to all the selected objects. Unless you need to change fonts dynamically in script, you only need to do this once during development.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buttonlabel/Textfield Size of text on Tablet is different

Post by bogs » Tue Jun 26, 2018 4:17 pm

As you might imagine, depending on your ultimate goals, there are a few ways to tackle what your describing. All of the above will do what you asked about, in particular to expound on Klaus's answer to this:
Texter wrote:
Fri Jun 22, 2018 12:58 pm
But is there a code to use this font for the whole stack? Or do I have to set this font to all fields and labels?
Here is a picture with the defaults in place and 3 controls.
Selection_003.png
Default stack text property...
Selection_003.png (8.88 KiB) Viewed 6673 times
Once you set the text formatting of the stack, all of the controls automatically inherit that as Klaus pointed out, as well as any new controls you add. The exception will be the Title bar for the window, it will have the font and the size is determined by the OS setting.
Selection_004.png
Changed stack text, added other controls...
Next, let us say that you wanted to make the field text bold, but retain the font of the stack. Clicking on the control, in the text formatting area, simply click on bold.
Selection_005.png
Changed field to bold, then cntrl/click/move retaining change...
When I am setting up my design, I normally just drag one of each control out and make sure it looks how I think it should, then if I need more of that control, I ctrl/click/drag it to where it is needed, or copy/paste it, however if you wanted something like that you could just make a template control with the changes desired as well.

None of the above requires any coding, although there is certainly nothing wrong with the loops described above, I save those for cases where I can't achieve my goals through layout. For example, as Jacque mentioned, if you needed to change text dynamically in one (or more) field(s), or if you needed to change the color of one (or more) button(s), then using case/select (for a few controls) or a loop for a large number of controls becomes a more viable option.
Texter wrote:
Mon Jun 25, 2018 8:27 pm
and I tried set the textfont of all fields of stack "Test" to "Arial"
You may also want to look up childControl in the dictionary, in using loops this will allow you to target specific types of controls instead of looping through all the controls on a card or in a group, the output will give you the short name or ids.
Image
Image

Post Reply

Return to “Android Deployment”