Computer Science Canada

[Source] Font Formatting

Author:  Asok [ Wed Jun 04, 2003 12:03 pm ]
Post subject:  [Source] Font Formatting

ok after looking at some hideous projects because people attempt to make something "look" alligned, I felt compelled to take 3 seconds to create some functions that will align ur text for you, because I will vomit if I see any more ugly ugly programs. If you don't know what I'm talking about look at JSBN's Razz j/k

anyways here it is:

code:
function center (text : string, y, fontID, Color : int) : string
Font.Draw (text,(maxx div 2) - (Font.Width(text,fontID) div 2),y, fontID, Color)
result ""
end center
function right (text : string,y,fontID, Color : int) : string
Font.Draw (text,(maxx - Font.Width(text,fontID)),y,fontID,Color)
result ""
end right
function left (text : string, y , fontID, Color : int) : string
Font.Draw (text,0,y, fontID, Color)
result ""
end left


a demo of it is:

code:
var font1 : int := Font.New ("Arial:20")
var font2 : int := Font.New ("Arial:12")
put center ("Big Centered Text",300,font1,black)..
put center ("Small Centered Text",250,font2,black)..
put right ("Big Right Text",200,font1,black)..
put right ("Small Right Text",150,font2,black)..
put left ("Big Left Text",100,font1,black)..
put left ("Small Left Text",50,font2,black)..


yea I know the demo blows but hopefully it's enough to stop people from using text that is all over the place. If you think your program looks ugly, it probably does.

Later next week I'll post my ass kicking ISP, keep checking the forums, more info on the way!


: