Page 1 of 1

A custom font for FB I want some feed back on

Posted: Wed Sep 17, 2008 11:13 pm
by T'lon Nanaki
Hey everyone...
I wrote a custom font code i wanted some feed back on
before i past it, i need to make some info clear on how it works

first I use a simple bitmap (.BMP) to hold the characters along with a little data in the bitmap about the font

at point 0,0 in the bitmap is a pixil representation of the width in pixils the space character is(it would be silly to have this value over 10), and at point 1,0 (there should be at most 70-90 characters in a full alpha-numeric list, inlcuding punctuations and mathmatic symbols) is the number of characters that are in the font +1 (I know theres a flaw in the codes somewhere or this number would just be a count of characters)

now there needs to be a support file that also has all characters used in the font surrounded by double perentheses ("), such as " ABC" in the order that it appears in the bitmap...

now that I've explained the setup here are the subs and what they do

SUBS
setfontfile( file as string)- this will change the fontlist to what is placed in file
load(file as string)- loads the font bitmap for file
fontcolor( r as integer, g as integer, b as integer)- sets color to rgb
fontcolor( c as integer) - makes font color of c
txt( t as string, x as single,y as single) - puts t at x,y on screen

screen 19,,,1

DIM as fonts font
font.setfontfile( <FONTLIST> )
font.load( <BITMAP> )
font.txt( "Your text goes here", 0,100)

-----------"FONT.FNT"-------------------
" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.!?,':-+*/=()"

----------TO MAKE A QUICK FONT BITMAP---------
I use a paint program called ultimate paint which has a palette function on it and saves in 8 bit formats using the palette chart which makes this really easy, I type the characters down first in note pad and then in the paint editor using palette color 255 (the color i've reserved for font) on a black (0) background, then i figure out howmany pixils are from the start of the bitmap to the first character and place the color of that value (10 pixiles= color 10) at coor(0,0) followed by the number of characters+1 at coor(1,0), i save the note pad file as "FONT.FNT" and save the bitmap as "FONT.BMP"


well here's the code, I know there's probably better codes somewhere but
I prefer to write my own personal include files for what i code so dont bother telling me otherwise... :)

-----------START OF "font.bi"------------
TYPE fint
DIM AS INTEGER wide,offset
DIM AS BYTE ascii
END TYPE

TYPE fonts
PRIVATE:
DIM AS STRING fontfile
DIM AS ANY PTR gph
DIM AS STRING fontlist
DIM AS fint PTR list
DIM AS INTEGER count,tall

PUBLIC:
DECLARE constructor
DECLARE SUB LOAD(file AS STRING)
DECLARE SUB txt(l AS STRING,x AS SINGLE,y AS SINGLE)
DECLARE SUB setfontfile(file AS STRING)
DECLARE SUB fontcolor(c AS INTEGER)
DECLARE SUB fontcolor(r AS INTEGER,g AS INTEGER,b AS INTEGER)
END TYPE

constructor fonts
this.fontfile="font.wdu"
END constructor

SUB fonts.fontcolor(c AS INTEGER)
DIM AS INTEGER r,g,b
PALETTE GET 255,r,g,b
PALETTE 255,r,g,b
END SUB

SUB fonts.fontcolor(r AS INTEGER,g AS INTEGER,b AS INTEGER)
PALETTE 255,r,g,b
END SUB

SUB fonts.setfontfile(file AS STRING)
this.fontfile=file
END SUB

SUB fonts.txt(l AS STRING,x AS SINGLE,y AS SINGLE)
l=ucase(l)
DIM AS INTEGER scan,s2
DIM AS INTEGER c
FOR scan=1 TO LEN(l)
c=ASC(MID(l,scan,1))
FOR s2=0 TO LEN(this.fontlist)-1
IF c=this.list[s2].ascii THEN EXIT FOR
NEXT
PUT(x,y),this.gph,(this.list[s2].offset,0)-STEP(this.list[s2].wide,this.tall),TRANS
x+=this.list[s2].wide+1
NEXT
'PUT (15,15),this.gph,(this.list[curchar].offset,0)-STEP(this.list[curchar].wide,ysize),TRANS
END SUB

SUB fonts.LOAD(file AS STRING)
'set screen mode if not currently set
LOCATE 1,1
PRINT "LOADING FONT FROM: ";file
SLEEP 2500
DIM AS STRING drive
SCREENINFO ,,,,,,drive
IF drive="" THEN SCREEN 19,,,1

'load list of characters in font
DIM AS INTEGER h = FREEFILE
OPEN this.fontfile FOR INPUT AS #h
INPUT #h,this.fontlist
CLOSE h

'open bitmap as a file and get sizeof picture
DIM AS INTEGER xsize,ysize
OPEN file FOR BINARY AS #h
GET #h,19,xsize
GET #h,23,ysize
CLOSE #h
'load file into a bitmap pointer,extract startpoint,and number of characters
this.gph=IMAGECREATE(xsize,ysize)
DIM AS INTEGER sp,nc
BLOAD file,this.gph
sp=POINT(0,0,this.gph):nc=POINT(1,0,this.gph)
'allocate enough memory to hold fontinfo for all characters for width,offset,asciicode
this.list=CALLOCATE(nc,SIZEOF(fint))
'begin setting info into list array...

DIM AS INTEGER curchar,xpos,yscan,scan,wide,offset
DIM AS BYTE flag,ischar

'scanning graphics...

curchar=1
wide=1
offset=sp

FOR xpos=sp TO xsize-1
FOR yscan=0 TO ysize-1
ischar=0
IF POINT(xpos,yscan,this.gph) THEN
ischar=1:EXIT FOR
END IF
NEXT
LOCATE 1,1

IF ischar=1 AND flag=0 THEN
curchar+=1:flag=1
wide=0:offset=xpos
END IF
IF ischar=1 AND flag=1 THEN
wide+=1:
END IF
IF ischar=0 THEN
this.list[curchar].wide=wide
this.list[curchar].ascii=ASC(MID(this.fontlist,curchar,1))
this.list[curchar].offset=offset
flag=0
END IF

'
NEXT

this.list[0].wide=sp-3
this.list[0].ascii=ASC(" ")
this.list[0].offset=2

this.tall=ysize

PALETTE 255,255,255,255

END SUB


well that's it, go ahead and check it out and get back to me with any advice/pointers/or comments you have, I don't mind criticism but unless you can say it in a way that can get me to laugh, try to be polite

thank you.

Re: A custom font for FB I want some feed back on

Posted: Fri Sep 19, 2008 1:55 am
by T'lon Nanaki
T'lon Nanaki wrote: ----------TO MAKE A QUICK FONT BITMAP---------
I use a paint program called ultimate paint which has a palette function on it and saves in 8 bit formats using the palette chart which makes this really easy, I type the characters down first in note pad and then in the paint editor using palette color 255 (the color i've reserved for font) on a black (0) background, then i figure out howmany pixils are from the start of the bitmap to the first character and place the color of that value (10 pixiles= color 10) at coor(0,0) followed by the number of characters+1 at coor(1,0), i save the note pad file as "FONT.FNT" and save the bitmap as "FONT.BMP"
I was doing a little re-reading and I noticed that I left out a piece of information out by accident

in the bitmap there needs to be a one pixil space between each character or the code will scan multiple characters as a single character.

I don't know if it's possible to put graphics from my computer into these post but if someone could explain how to do that i could just show what my font looks like and obviously eleminate every thing i got quoted above.

Posted: Wed Sep 24, 2008 11:08 am
by T'lon Nanaki
Well, looks like no one cares to leave any comments so I guess there's no point in making any more posts of this nature. anyway i had an idea, does anyone want to help me orginize a competition, it's for both FB and QB, I don't want to go into any details over the forums yet but anyone intrested can contact me at my email "talon_nanaki [AT] yahoo.com"

Posted: Wed Sep 24, 2008 1:26 pm
by burger2227
Sorry for sending you here! The FB people are kind of clanish. Try FB.COM if you can tolerate the rules.

You could post a competition in the Discussions areas of this forum.

Good Luck,

Ted

Posted: Wed Sep 24, 2008 5:22 pm
by Lachie Dazdarian
Yeah, try the official forum for more feedback.

But I think you won't get much far with this type of approach. You know. "Uh, I have this cool idea about this or that, but I won't go into details until you email me and send me a postcard."

Really.

Just lay it out.

Also, for the font routines. How about compiling that in a package and shipping it with 2-3 fonts? Then you can actually expect some feedback. Don't see point in us first commenting your snippets of code. Like I said, wrong approach.

Posted: Thu Sep 25, 2008 1:44 pm
by T'lon Nanaki
your right, I should have my code in a zip along with what it needs to run right. I'll keep that in mind when and if I decide to post another.