Computer Science Canada

Check for Availible Fonts

Author:  BigBear [ Sun Feb 10, 2008 1:29 pm ]
Post subject:  Check for Availible Fonts

This is just a simple program to check for available fonts on your computer and Font.Draw them useful when deciding what font to use for menus etc.

Turing:

%Screen is set to large because then you can scroll.
var fontName : string
var y : int := 0
var font : int
var winID : int := Window.Open ("graphics:1280;1280")
Font.StartName
loop
    fontName := Font.GetName
    exit when fontName = ""
    font := Font.New (fontName + ":12")
    y += 20
    Font.Draw (fontName, 100, 10 + y, font, black)
end loop


Also found this program in Turing's F10 Help which displays all the fonts, styles and sizes available on the system. However they are not Font.Drawed so i find it is sort of useless.

Turing:

%Setscreen very large to have the ability to scroll and read it
var winID : int := Window.Open ("graphics:2080;2080")
        var fontName : string
        var bold, italic, underline : boolean
        var size : int
        var styles : array boolean, boolean, boolean of string :=
            init ("", "underline", "italic", "italic, underline", "bold", "bold,underline", "bold,italic", "bold,italic,underline")
        Font.StartName
        loop
            fontName := Font.GetName
            exit when fontName = ""
            Font.GetStyle (fontName, bold, italic, underline)
            for b : false .. bold
                for i : false .. italic
                    for u : false .. underline
                        put fontName : 30, styles (b, i, u) : 22 ..
                        Font.StartSize (fontName, styles (b, i, u) )
                        loop
                            size := Font.GetSize
                            exit when size = 0
                            if size = 1 then put "scalable  " ..
                            else put size, " " ..
                            end if
                        end loop
                        put ""
                    end for
                end for
            end for
        end loop


: