
-----------------------------------
copthesaint
Sun Feb 15, 2009 3:25 pm

All Font Program
-----------------------------------
This 19 line attachment will let make using Font.Draw Alot Shorter.
With this you won't have to name fonts, and  Free them.

%  Program will let you draw all font types and all sizes for the font.
var fontName : array 1 .. 234 of string
var FontNumSet, FontViewChange : int := 0
var FontSetAll : array 1 .. 234 of int
function FontSelect (FontNum : int, Size : int) : int
    FontNumSet := 0
    Font.StartName
    loop
        FontNumSet += 1
        fontName (FontNumSet) := Font.GetName
        exit when fontName (FontNumSet) = ""
    end loop
    fontName (FontNum) := fontName (FontNum) + ":" + (intstr (Size))
    FontSetAll (FontNum) := Font.New (fontName (FontNum))
    result FontSetAll (FontNum)
end FontSelect
Font.Draw ("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz", 5, 25, FontSelect (98, 13), black)



-----------------------------------
SNIPERDUDE
Tue Feb 17, 2009 12:52 pm

RE:All Font Program
-----------------------------------
Why didn't I think of this?

Good add.

-----------------------------------
copthesaint
Tue Feb 17, 2009 1:55 pm

RE:All Font Program
-----------------------------------
Thank you

-----------------------------------
BigBear
Wed Mar 04, 2009 3:17 pm

RE:All Font Program
-----------------------------------
so that 234 is that the amount of fonts you have on your computer?

Should you use Font.GetName to determine how many fonts a given computer has. 

Or is 234 the max amount of fonts that turing supports?

With Vista Home Premium I have 209 fonts.

-----------------------------------
copthesaint
Wed Mar 04, 2009 6:13 pm

Re: All Font Program
-----------------------------------
Here Is a WAY better version of it. 


unit
module FONT
    export DrawFont
    class AllFont
        export FontSelect
        type FontsRec :
            record
                FontNew : int
            end record
        var FontSET : FontsRec
        function FontSelect (FontName : string, Size : int) : int
            FontSET.FontNew := Font.New (FontName + ":" + intstr (Size))
            result FontSET.FontNew
        end FontSelect
    end AllFont
    var ForwardAllFont : pointer to AllFont
    procedure DrawFont (StringValue : string, Xvalue, Yvalue, Color, FontSIZE : int, FontNAME : string)
        new AllFont, ForwardAllFont
        Font.Draw (StringValue, Xvalue, Yvalue, ForwardAllFont -> FontSelect ("Arial", FontSIZE), Color)
    end DrawFont
end FONT

This is to load it:

import ( FONT in "FONT.tu" )
loop
    FONT.DrawFont ("Hello", 56, 76, green, 17, "Arial")
    View.Update
    delay (10)
    cls
end loop

There It is. The problem with the first program i that the fonts change with every computer so that isn't very good for a program.

-----------------------------------
The_Bean
Wed Mar 04, 2009 7:00 pm

Re: All Font Program
-----------------------------------
So all that is basically removing the need of making a new variable to hold the font, so wouldn't it be easier to:

proc FontDraw (text : string, x, y : int, fontName : string, fontSize, c : int)
    var font := Font.New (fontName + ":" + intstr (fontSize))
    Font.Draw (text, x, y, font, c)
end FontDraw
FontDraw ("Hello", 56, 76, "Arial", 17, green)


-----------------------------------
copthesaint
Wed Mar 04, 2009 7:27 pm

RE:All Font Program
-----------------------------------
Yea but at the same time I'm teaching myself classes and exporting/importing so I decided to do it that way so later I could add too it. (GUI)

-----------------------------------
BigBear
Fri May 01, 2009 7:34 pm

RE:All Font Program
-----------------------------------
http://compsci.ca/v3/viewtopic.php?t=17295&highlight=
