Home | Reviews | GUIpedia | Forum | Fun500
Brandon | My Font Routinehttp://www.sixbynine.net/filequick/379 That's the font routine I use witha little demo app to test speed improvements. Please try to make it run faster! Who ever optimizes the most will get their name in the Fun500 6 credits. | 2010-04-11 | 4:28 PM |
HorvatM | Re:My Font RoutineHere is my version: SUB JFont (Text$, TextColor%, PosX%, PosY%, Size%) IF Size% > 10 THEN Size% = 10 'Check and fix invalid size calls IF Size% < 1 THEN Size% = 1 'likewise for <. '(Why does an upper limit even exist?) PosY% = PosY% \ Size% FOR Cursor% = 1 TO LEN(Text$) CharAscVal% = ASC(MID$(Text$, Cursor%, 1)) 'get ASCII value of each char FOR X% = 1 TO 8 StartX% = PosX% 'reset the starting position FOR Y% = 1 TO 6 IF CharSet%(CharAscVal%, X%, Y%) THEN 'Draw a pixel, stretched if needed LINE (StartX% + PixelsRight%, (X% + PosY%) * Size%)-(StartX% + PixelsRight% + Size% - 1, ((X% + PosY%) * Size%) + Size% - 1), TextColor%, BF END IF StartX% = StartX% + Size% 'Set starting X-value for next pixel NEXT Y% NEXT X% PixelsRight% = PixelsRight% + Size% * 6 'add pixels for next character NEXT Cursor% END SUB In addition, I modified the font loading code: OPEN "fontdata.dat" FOR INPUT AS #1 FOR Char% = 1 TO 126 FOR X% = 1 TO 8 FOR Y% = 1 TO 6 INPUT #1, CharSet%(Char%, X%, Y%) CharSet%(Char%, X%, Y%) = -CharSet%(Char%, X%, Y%) 'QB uses -1 for NEXT Y% 'true, so we NEXT X% 'flip its sign NEXT Char% CLOSE #1 I tested my version against yours, and in the following test... mytimer = TIMER FOR i = 1 TO 1000 JFont "AAAAAAAAAA", 0, 1, 1, 10 NEXT i COLOR 7: PRINT TIMER - mytimer ...my version took 21.91016 seconds and yours took 27.90234. I don't think I can do much more. | 2010-04-12 | 11:42 AM |
Dick | Re:My Font RoutineCheck this one out. Reduced your font file down to 1KB and the entire font routine is only like 1-2 lines of code. http://qbasic.orgfree.com/jfont.zip | 2010-04-14 | 11:08 PM |
Brandon | Re:My Font RoutineYour code doesn't support scaling, correct? | 2010-04-15 | 1:49 PM |
Dick | Re:My Font RoutineNo. Not really a serious attempt, just playing with asm, but you can take this code as yours. I believe that most of your speed decrease comes from the LINE BF statement and also because you're using a three dimensional array. | 2010-04-15 | 10:06 PM |
Brandon | My Font Routine FliesUsing HorvatM's code and adding a little mod based on Dick's advice about LINE BF slowing it down, I've really sped up the font, with 10 About apps on my 233MHz P2 development laptop the screen redraws instantly. This week I have no school, so I'm going to be working on Fun500 more. | 2010-04-16 | 5:46 PM |
trolly | Re:My Font Routinethere is mine routine,
sub Font.DrawString(texte as string,x as integer,y as integer,couleur as long,)
dim zy as integer,i as integer,a as integer,masque as long
FOR i = 1 TO LEN(texte)
a = ASC(MID$(texte, i, 1))
FOR zy = 0 TO this.height - 1
masque = FontData(a, zy)
LINE (x+((i-1)*8), y +zy)-(x+((i-1)*8)+8, y + zy), couleur, , masque* 128
NEXT zy
NEXT i
end sub
the font file using only one byte per character's line. I use the mask of lines to display the characters more quickly (instead of dot byt dot) | 2010-04-21 | 2:05 AM |
2021 Brandon Cornell