Jamieh
Topic Author
Posts: 70
Joined: 12 Apr 2019, 00:30

Can you change the Unity Noesis default FontSize at runtime?

24 Jul 2020, 08:01

Running under Unity, I've set my Noesis default fontsize to 15px. This works good for our WebAssembly builds, but for tablets we'd like the default fontsize to be bigger.

Maybe a better way to do this would be to just create different styles for tablet/mobile, but I was wondering if there was some way to alter the default fontsize programmatically? Then I could detect the Android or iOS builds and set the default fontsize to 18 in those cases and leave it 15 for our WebAssembly build.

Thanks--if this isn't possible, any other suggestions on how to accomplish this are welcome. Otherwise, I'll just code the default fontsize into every page and alter it in the viewmodel.
 
User avatar
sfernandez
Site Admin
Posts: 3154
Joined: 22 Dec 2011, 19:20

Re: Can you change the Unity Noesis default FontSize at runtime?

24 Jul 2020, 11:22

You can call the following code at your application startup to change default font properties.
Noesis.GUI.SetFontDefaultProperties(30.0f, FontWeight.Normal, FontStretch.Normal, FontStyle.Normal);
If a xaml was loaded before executing that code, then that xaml will keep using the values set in Noesis settings.

Another approach could be to use DynamicResources in your control styles to set FontSize, then add to the root xaml the value you want to use depending on the platform:
view.Content.Resources["DefaultFontSize"] = 30.0f;
 
Jamieh
Topic Author
Posts: 70
Joined: 12 Apr 2019, 00:30

Re: Can you change the Unity Noesis default FontSize at runtime?

24 Jul 2020, 18:39

Cool, I will try these suggestions. Thanks!

Who is online

Users browsing this forum: No registered users and 4 guests