SetHtml - change font size?

50 views
Skip to first unread message

wheelie tips

unread,
Dec 20, 2021, 2:42:42 AM12/20/21
to DroidScript
Hi,

I'm trying without any success to change the size of two rows in the same text control using HTML code; can someone pls show me what is the correct syntax to change in sample below the 'largeFont' to a large font and the 'smallFont' to a small font?

function OnStart()
{
        lay = app.CreateLayout( "linear", "VCenter,FillXY" );        
        txt = app.CreateText(null, null, null, "Left,Html,Multiline");
       
        var largeFont = '<b>TOP ROW</b>'
        var smallFont = 'lower small font row'
       
        htm = largeFont + '<br>' + smallFont
        txt.SetHtml( htm )
       
        lay.AddChild( txt );        
        app.AddLayout( lay );
}

Many many thanks in advance!
Best,
WT

Alan Hendry

unread,
Dec 20, 2021, 7:37:57 AM12/20/21
to DroidScript
HI,
Most web tutorials/references have moved to using styles so I can't find a good reference
<b>bold</b>
<strong>strong</strong>
<big>big</big>
<small>small</small>
<i>italic</i>
<u>underline</u>
Headings h1 to h6 control size but give a new line before and after.
Also you can embed tags within tags
<b><big>big bold</big></b>
Overall answer
<big>TOP ROW</big><br/><small>lower small font row</small>
Regards, ah

wheelie tips

unread,
Dec 20, 2021, 8:06:11 AM12/20/21
to DroidScript
Hey Alan!
Thank you for your answer, with that, and with the SetTextSize together, I've reached my desired result.
Thanks again mate!

wheelie tips

unread,
Dec 20, 2021, 8:17:15 AM12/20/21
to DroidScript
BTW, for future users, if one wanna make the font even smaller or larger then use more tags, for ex:

function OnStart()
{
        lay = app.CreateLayout( "linear", "VCenter,FillXY" );        
        txt = app.CreateText(null, null, null, "Left,Html,Multiline");
       
        var largeFont = '<b><big><big><big>big bold</big></big></big></b>'
        var smallFont = '<small><small><small>lower small font row</small></small></small>'

       
        htm = largeFont + '<br>' + smallFont
        txt.SetHtml( htm )
       
        lay.AddChild( txt );        
        app.AddLayout( lay );
}  
Reply all
Reply to author
Forward
0 new messages