Font Display Utility by Anonymous Coder1st Sep 2004 15:50
|
---|
Summary font display utility Description Shows you the string name of all fonts on a system that can be accessed through DarkBASIC. The pitch and RGB value of the font can also be changed. Contains a delay factor to enable easy keyboard operation. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Program Setup & Initialization initialize: set display mode 800,600,32 perform checklist for fonts fontNum = 1 : fontSize = 12 : numFonts = checklist quantity() redState = 192 : greenState = 192 : blueState = 255 delayVal = 29 sync on sync rate 30 setup: ink rgb(0,192,255),0 color backdrop 0 `Program Implementation programStart: while mouseclick()=0 cls gosub showOptions gosub keyboard gosub showFont if scancode()=0 then delayVal = 29 sync endwhile gosub cleanup `Successful Program Completion programFinish: end cleanup: sync off cls return `User Input Control keyboard: ink rgb(255,64,64),0 set text size 12 if keystate(13) or keystate(78) inc fontSize if fontSize=37 then fontSize = 36 text 0,50,"Font size increasing." endif if keystate(12) or keystate(74) dec fontSize if fontSize=0 then fontSize = 1 text 0,50,"Font size decreasing." endif if keystate(28) or keystate(156) fontSize = 12 text 0,50,"Font size reset to 12 pitch." endif if keystate(33) then gosub slideForward if keystate(31) then gosub slideBack if keystate(18) dec redState if redState<0 then redState = 0 endif if keystate(20) inc redState if redState>255 then redState = 255 endif if keystate(32) dec greenState if greenState<0 then greenState = 0 endif if keystate(34) inc greenState if greenState>255 then greenState = 255 endif if keystate(46) dec blueState if blueState<0 then blueState = 0 endif if keystate(48) inc blueState if blueState>255 then blueState = 255 endif return `Font Selection slideForward: inc delayVal if delayVal=30 ink rgb(0,192,192),0 set text size 12 text 0,50,"New font selected." inc fontNum if fontNum>checklist quantity() then fontNum = 1 delayVal = 0 endif return slideBack: inc delayVal if delayVal=30 ink rgb(0,192,192),0 set text size 12 text 0,50,"New font selected." dec fontNum if fontNum=0 then fontNum = checklist quantity() delayVal = 0 endif return `Display Systems showFont: ink rgb(redState,greenState,blueState),0 set text size fontSize set text font checklist string$(fontNum) text 0,100,"~ ! @ # $ % ^ & * ( ) _ +" text 0,(100+text size()+2),"` 1 2 3 4 5 6 7 8 9 0 - =" text 0,(100+text size()*2+2),"Q W E R T Y U I O P { } |" text 0,(100+text size()*3+2),"q w e r t y u i o p [ ] " text 0,(100+text size()*4+2),"A S D F G H J K L : "+chr$(34) text 0,(100+text size()*5+2),"a s d f g h j k l ; '" text 0,(100+text size()*6+2),"Z X C V B N M < > ?" text 0,(100+text size()*7+2),"z x c v b n m , . /" text 0,(100+text size()*8+2),"The quick brown fox jumps over the lazy dog." return showOptions: set text font "Arial" set text size 14 ink rgb(0,192,255),0 text 0,0,"Use + and - to change to size of the font. Pressing ENTER will reset the font size. Use the keys surrounding 'F' to change the RGB factors." text 0,12,"Press 'S' and 'F' to scroll through system fonts DarkBASIC can access. Click the mouse to exit." ink rgb(0,128,255),0 text 340,520,"Font displayed at "+str$(fontSize)+" pitch." text 340,532,"This font is called: "+checklist string$(fontNum) return |