Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 All Font Program
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Sun Feb 15, 2009 3:25 pm   Post subject: 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.

code:
%  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)

Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Tue Feb 17, 2009 12:52 pm   Post subject: RE:All Font Program

Why didn't I think of this?

Good add.
copthesaint




PostPosted: Tue Feb 17, 2009 1:55 pm   Post subject: RE:All Font Program

Thank you
BigBear




PostPosted: Wed Mar 04, 2009 3:17 pm   Post subject: 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




PostPosted: Wed Mar 04, 2009 6:13 pm   Post subject: Re: All Font Program

Here Is a WAY better version of it.


Turing:
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:

Turing:
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




PostPosted: Wed Mar 04, 2009 7:00 pm   Post subject: 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:
Turing:

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




PostPosted: Wed Mar 04, 2009 7:27 pm   Post subject: 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




PostPosted: Fri May 01, 2009 7:34 pm   Post subject: RE:All Font Program

http://compsci.ca/v3/viewtopic.php?t=17295&highlight=
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: