Hope this helps.
' roFont String
'---------------------------------------------------------------------------------------------------------
' p[0] = () = family
' p[1] = (38) size = font size
' p[2] = (-1) pixel-size
' p[3] = (5) style-hint
' p[4] = (2) weight 75 was 63 = bold
' p[5] = (1) style = italic
' p[6] = (0) underline
' p[7] = (0) strikeout
' p[8] = (0) fixed-pitch
' p[9] = (0) raw-mode
'---------------------------------------------------------------------------------------------------------
' This function attempts to size the input text string to the provided width
' It will use the F as the max size. The font size will keep going lower until 1/2 the height
. then if max is set, will split the line and start over.
. It returns an object with the roFont(string as above), the text(may have been split) and the font index
Function Get_Font( text as string, F as object, W as integer, H as integer,
bold as boolean, italic as boolean, max as integer ) as object
font = [ face, txt, x ]
return font
'---------------------------------------------------------------------------------------------------------
--------------------- Call to size string ---------------------
if obj.font = invalid
obj.font = Get_Font( Decode(data), "Medium", XR(W-55), YR(H), true, false, 2 )
end if
--------------------- Usage - f[1] = text, f[0] = roFont String ---------------------
f = obj.font
itm.Push( { Text:f[1]
TextAttrs:{Color:"#A0000000", Font:f[0], HAlign:"Left", VAlign:"Middle", TextDirection:"LeftToRight"}
TargetRect:{x:xa+1,y:ya+1,w:W-55,h:H}} )
The XR and YR calls are because all my screens are SD and extrapolated to HD
I don't know if you noticed but there isn't a Mini or Big font size ! I defined them.
m.Mini_Font = reg.Get( font, x[0], false, false ) ' x[0] is variable depending on SD HD and external font
m.Mini_Font_Bold = Bold_Font( m.Mini_Font ) ' Bold_Font Is a subroutine to set the weight to 75
itm.Push( { Text:str
TextAttrs:{Color:"#FFFFFFFF", Font:m.Mini_Font_Bold, HAlign:"Left", VAlign:"Middle", TextDirection:"LeftToRight"}
TargetRect:{x:40,y:ya,w:m.X_Size,h:60}} )