I've added my fixed font, also known as simple font code to the lispbuilder-sdl-examples package. It includes a demo program which sets up a font

         (sdl-simple-font:initialise-font (namestring *font-path*) 4 5
                                                "abcdefghijklmnopqrstuvwxyz:'!?_-,.()#~0123456789" 99 0 0))

which loads a simple bmp file which has all the characters you want in your font in a single row. You then specify the height and width, the order that the characters appear in the bmp (as a string) and finally a background mask color (r g b).

When you are done with the font call

 (sdl-simple-font:close-font small-font))))))

to get rid of the surface created to hold the font graphics.

You can draw text in two ways. You can draw to an sdl surface (which is created automatically for the string size you need and then made to be screen format) and then blit that as needed

(text-image (sdl-simple-font:make-text-image small-font "draw text image")))

...

(sdl-simple-font:draw-text-image display text-image 10 10 )

...

(sdl-simple-font:free-text-image text-image)

Or you can draw text dynamically to screen (or any other surface) as needed using various functions as below

            (sdl-simple-font:draw-string-right-justify display small-font
                                             (1- *WINDOW-WIDTH*) (screen-center-y)
                                             "draw string right justified")

             (sdl-simple-font:draw-string display small-font
                                             (+ (- (screen-center-x) 100) (random 200))
                                             (+ (- (screen-center-y) 100) (random 200))
                                             "draw string")

             (sdl-simple-font:draw-string-centered display small-font
                                                   (screen-center-x) (screen-center-y)
                                             "draw string centered")

Hope somebody finds this useful.

Justin





<<attachment: simplefont.jpg>>

_______________________________________________
application-builder mailing list
[EMAIL PROTECTED]
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to