How to use custom font size in MobiAccess
The Code:
class : Form
{
private function Init() : Void;
public CI()
{
super();
this.Init();
}
Init
{
var label : Label = Label.CI();
this.AddControl(label);
label.SetText("hello");
var fontSize : Object = 50;
label.SetFont(Font.CI(EFontFace.DEFAULT, [EFontSize]fontSize, false, false, false));
label.SetPosition(LTWHPos.CI(0.0,300.0, 200.0,100.0));
return;
}
}
Instead of using one of the values of the enum EfontSize (MEDIUM, LARGE, SMALL), we can use a little trick to create our own font size object with, let us say, a font size of 50:
var fontSize : Object = 50;
then with this parameter we call the SetFont method, cast on the appropriate type:
label.SetFont(Font.CI(EFontFace.DEFAULT, [EFontSize]fontSize, false, false, false));
The FontSize object has to be drawn into a variable, because the [EFontSize][Object]fontSize casting trick does not work (I also tried it that way first :) )
Anyone finds out about this, I wasn’t the one who told you. :)
Warning: The trick above only works on Android platform
Written by SJ





