Posted: 4th Nov 2002 18:37
Here is a collection of routines that allow the loading, displaying of, and putting into bitmaps of bitmapped fonts (ie fonts that are stored in a bitmap)

+ Code Snippet
function putCharIntoBitmap(bm as integer,_
                           img as integer,_
                           width as integer,_
                           string$ as string)
   if string$""
      create bitmap bm, len(string$)*width, width
      set current bitmap bm
      writeFontChars(string$,0,0,width)
      get image img,0,0,len(string$)*width,width,1
      set current bitmap 0
      delete bitmap bm
   endif
endfunction

function writeFontChars(str as string,_
                        x as integer,_
                        y as integer,_
                        width as integer)
one as integer
a as integer

   if str""
      for one=1 to len(str)
         a=asc(mid$(str,one))
         select a
            case  32       :  rem A Space
                              endcase
            case default   :  if image exist(a)
                                 paste image a,x+((one-1)*width),y,1
                              endif
                              endcase
         endselect
      next one
   endif
endfunction

function createFont(width as integer,_
                   height as integer,_
                   charXWidth as integer,_
                   charYWidth as integer,_
                   charXOffset as integer,_
                   charYOffset as integer,_
                   charXStep as integer,_
                   charYStep as integer,_
                   filename as string,_
                   chars as string)
xLoop as integer
yLoop as integer
pos as integer

   load bitmap filename,1
   set current bitmap 1
   pos=1
   for y=0 to height-1
      for x=0 to width-1
         if pos>len(chars) then exitfunction
         get image asc(mid$(chars,pos)),_
                        (x*charXStep)+charXOffset,_
                        (y*charYStep)+charYOffset,_
                        (x*charXStep)+charXOffset+charXWidth,_
                        (y*charYStep)+charYOffset+charYWidth,_
                        1
         inc pos
      next x
   next y
   set current bitmap 0
   delete bitmap 1
endfunction


Here is a small test program

+ Code Snippet
set display mode 800,600,32
createFont(9,5,_
            32,32,_
            1,1,_
            34,34,_
            "E:\Users\Nicholas\Bitmap fonts\32_32V3.BMP",_
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789,.-'():!")
writeFontChars("HELLO",32,32,32)
wait key


Any other versions will be on my web site.
Posted: 5th Nov 2002 3:38
THX YOU SAVED ME THE TROUBLE OF MAKING A POINTER.DLL AND NOW A FONT FUNCTION... i think im in love
Posted: 5th Nov 2002 4:30
your function doesnt work... something with the _ things... i dunno ive never used those before... what do they do
Posted: 5th Nov 2002 12:09
Ah - thats the concatenation symbol - I use _ - you might need to change either yours to _ or change mine to ...

Thats if you've updated the editor...
If you haven't then now would be a good time!
Posted: 5th Nov 2002 20:41
By the way, I think you've spelt your e-mail address incorrectly.
Posted: 6th Nov 2002 5:00
EEEEEEEK your right.... =\ damn typo... ok i fixed that error... (first thing i tried...) but whats bothering me is that it says it cannot load the image... i used the same image as you =\...
Posted: 6th Nov 2002 10:24
Change the "e:\users.." to point to your bitmaped fonts. I'll also describe the parameters later.
Posted: 6th Nov 2002 11:17
Right, the parameters that need to be passed to createFont are :

width - Width in characters
height - Height in characters
charXWidth - Width of each character
charYWidth - Height of each character
charXOffset - Offset within each step value to start grabbing the characer
charYOffset - Offset within each step value to start grabbing the character
charXStep - Horizontal step value charYStep - Vertical step value
filename - Filename of bitmap to load
chars - Characters contained within the bitmap from left to right and top to bottom.
Posted: 7th Nov 2002 3:34
-_- i mean i used your same bmp i changed the path to where it was... BUT... it says it cannot load at line 41 with your text... k =)... oh and your str"" and string$"" need = on my comp... do they on yours?
Posted: 7th Nov 2002 10:33
Ah - Its gone an mucked it up...

I'll send you the correct ones again via e-mail