TGC Codebase Backup



Font Tester [BlueGUI Version] by 00bk

7th Apr 2005 12:06
Summary

Locate the best font for your needs!



Description

Locate the best font for your needs!
Either type in the name of your font or browse to select it; then type in the size you wish to view (optional) and voila! Perfect for finding the ideal font and size for your program.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    remstart
#################
# FONT TESTER - #
#BLUEGUI VERSION#
#Created by Ben #
#     Kahan     #
#################

:!PLEASE NOTE PLEASE NOTE PLEASE NOTE PLEASE NOTE PLEASE NOTE PLEASE NOTE PLEASE NOTE!:
I WILL soon be creating a tutorial to help you with creating a menu - people always seem
to have a load of trouble with that!
remend

startblue "ID","PASS"

`Create globals and constants for the menu
global menu
#constant menu_file 1
global menufile
#constant menu_file_testfont 2
#constant menu_file_testfontandsize 3
#constant menu_file_exit 4
#constant menu_about 5
global menuhelp
#constant menu_help_about 6

`Set the window settings at the start
settings()

`Insert the function (see below for the full function)
createmainmenu()

`Start the loop
do

`Wait until the user presses a menu item
getevent

`Input what will happen if the user presses "Test Font Only"
if eventdata()=menu_file_testfont
settings2()
print "Please select what font you would like to test or type in SELECT to choose one yourself:"
input selectfont$
if selectfont$="SELECT" then selectfont()
set text font selectfont$
print "the quick brown fox jumps over the lazy dog"
print "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
endif

`Input what will happen if the user presses "Test Font and Size"
if eventdata()=menu_file_testfontandsize
settings2()
print "Please select what font you would like to test or type in SELECT to choose one yourself:"
input selectfont$
if selectfont$="SELECT" then selectfont()
input "What size do you wish to test: ",fontsize$
set text font selectfont$
set text size val(fontsize$)
print "the quick brown fox jumps over the lazy dog"
print "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
endif

`Input what will happen if the user presses "Exit"
if eventdata()=menu_file_exit
end
endif

`Input what will happen if the user presses "About Font Tester"
if eventdata()=menu_help_about
message "About Font Tester","Created by Ben Kahan. Also available without BlueGUI plugin."
endif

`End the loop
loop

`Create the menu function
function selectfont()
selectfont$=opendialog("Select a font...","True Type Font (*.ttf)|*.ttf|All Files (*.*)|*.*")
endfunction

function settings()
cls -1
ink 0,-1
set window size 1,1
maximize window
set window title "Font Tester - BlueGUI Version"
set text font "Arial Narrow"
set text size 16
endfunction

function settings2()
cls -1
set text font "Arial Narrow"
endfunction

function createmainmenu()
menu=createmenu(0)
addmenuitem menu,"File",1
menufile=createsubmenu(menu,1)
addmenuitem menufile,"Test Font Only",2
addmenuitem menufile,"Test Font and size",3
addmenusplitter menufile
addmenuitem menufile,"Exit",4
addmenuitem menu,"Help",5
menuhelp=createsubmenu(menu,5)
addmenuitem menuhelp,"About Font Tester",6
endfunction