trolly | Re:Font editor for q-step 3it's in freebasic
fonts are monospaced and 8pixel width,the code supports both 8x8 and 8x16 fonts
type Font
fontheight as integer
fontdata(0 TO 255, 0 TO 15) AS STRING * 1
declare sub Load(filename as string)
declare sub Save(filename as string)
declare sub DrawText(text as string,x as integer,y as integer,fcolor as integer,bcolor as integer)
end type
sub Font.DrawText(text as string,x1 as integer,y1 as integer,fcolor as integer,bcolor as integer)
dim i as integer,x as integer,y as integer, a as integer
IF bcolor > -1 THEN LINE (x1, y1 )-(x1 + len(text)*8-1, y1 + this.FontHeight-1), bcolor,bf
FOR i = 1 TO LEN(Text)
a = ASC(MID$(Text, i, 1))
FOR y = 0 TO this.FontHeight
LINE (x1+((i-1)*8), y1 + y)-(x1 + 8+((i-1)*8), y1 + y), fcolor, , (ASC(fontdata(a, y)) * 128)
NEXT y
NEXT i
end sub
sub Font.Load(filename as string)
dim fic as integer,i as integer,y as integer
fic = FREEFILE
OPEN filename FOR BINARY AS fic
this.FontHeight=lof(fic)/256
FOR i = 0 TO 255
FOR y = 0 TO this.FontHeight-1
GET #fic, , fontdata(i, y)
NEXT y
NEXT i
CLOSE fic
end sub
| 2010-05-12 | 2:04 AM |