Part IX
Variable Font Sizing
SUB SetMaxFontHeight
'determine max font size that can fit into kid grid
'k is static variable for kid grid
XuiGetSize (grid, #GetSize, @x, @y, @width, @height, k, 0)
XuiGetFont (grid, #GetFont, @size, @weight, @italic, @angle, k, @typeface$)
XuiGetTextString(grid, #GetTextString, 0, 0, 0, 0, k, @text$)
h = 0
size = 40
DO WHILE h < height
size = size + 80
XuiSetFont (grid, #SetFont, size, weight, italic, angle, k, typeface$)
XuiGetFontNumber (grid, #GetFontNumber, @font, 0, 0, 0, k, 0 )
XgrGetTextImageSize (font, text$, @dx, @dy, @w, @h, @topGap, @flags)
LOOP
XuiSetFont (grid, #SetFont, size-80, weight, italic, angle, k, typeface$)
END SUB
The code for our program up to this point can be found in Calendar10.x.
Next
(c) 2000 David SZAFRANSKI