Test to check width value of Default font returned from "getOneLineWidth".
You can modify the width value by a fudge factor to increase the size of the box
Change font size - Up and Down buttons. (goes from 1 to whatever, starts at 35)
Change font face - Left and Right buttons. (normal,bold,italic,bold-italic)
Change Fudge Factor = REW and FF buttons. (bumps fudge +- 0.01)
* If you don't get
BOLD, change the value of 75 to 63 in the font string at button of code.
Function Font_Test_2()
reg = CreateObject("roFontRegistry")
face = ["Normal","Italic","Bold","Bold-Italic"]
scr = CreateObject("roImageCanvas")
port = CreateObject( "roMessagePort" )
scr.SetMessagePort( port )
scr.SetLayer( 0, { color: "#FF808080" } )
scr.Show()
usage = "Left/Right chg Face, Up/Dn chg Size, FF/REW chg Fudge Factor"
size = 35
s = "Hello foo foo enjoy"
loop = true
mode = 0
fudge = 1.0
while loop
bold = Int(mode/2)
italic = Mod( mode, 2 )
f = reg.GetDefaultFont( size, bold, italic )
w = Int( f.GetOneLineWidth( s, 10000 ) * fudge )
h = f.GetOneLineHeight()
font = reg.Get( "", size, bold, italic )
if Int(mode/2) = 1
font = Set_Bold( font )
end if
a = Int(fudge / 1.0).ToStr()
b = Mod( Int(fudge*10), 10 ).ToStr()
c = Mod( Int(fudge*100), 10 ).ToStr()
val = a+"."+b+c
txt = face[mode]+" Fudge Factor = "+val+Chr(10)
txt = txt + "w = "+w.ToStr()+" h = "+h.ToStr()+Chr(10)
txt = txt + font + " font string"
items = CreateObject( "roArray", 100, 1 )
items.Push( { color: "#FFFFFFFF", TargetRect:{x:100,y:200,w:w,h:h}} )
items.Push( { Text:s,
TextAttrs:{ Color:"#FFFF0000", Font:font, HAlign:"Left", VAlign:"Middle" },
TargetRect:{ x:100,y:200,w:w,h:h }} )
items.Push( { Text:txt,
TextAttrs:{ Color:"#FF000000", Font:"Large", HAlign:"Left", VAlign:"Top" },
TargetRect:{ x:100,y:10,w:600,h:200 }} )
items.Push( { Text:usage,
TextAttrs:{ Color:"#FF000000", Font:"Medium", HAlign:"Left", VAlign:"Middle" },
TargetRect:{ x:100,y:300,w:720,h:40 }} )
scr.SetLayer( 1, items )
while true
msg = wait( 1000, port )
if msg <> invalid AND msg.GetType() = 7
i = msg.GetIndex()
if i = 2 ' up
size = size + 1
exit while
elseif i = 3 ' down
size = size - 1
exit while
elseif i = 4 ' left
mode = Mod(mode+1, 4)
exit while
elseif i = 5 ' right
mode = Mod(mode-1, 4)
exit while
elseif i = 6 ' select
exit while
elseif i = 8 ' reverse
fudge = fudge * 0.99
exit while
elseif i = 9 ' forward
fudge = fudge * 1.01
exit while
else
loop = false
exit while
end if
end if
end while
items.Clear()
scr.ClearLayer( 1 )
sleep( 200 )
end while
End Function
Sub Set_Bold( in as object ) as object
p = in.Tokenize( "," )
p[3] = "75" ' <<<<<<<<<<< ********* Set this to "63" on some boxes
out = ""
for i=0 to p.Count()-1
out = out + "," + p[i]
end for
return out
End Sub