1 / 15

Fonts

Fonts. Andrew Williams A.Williams@bolton.ac.uk http://www.bolton.ac.uk/staff/adw1. AWFont Class. Very simple Very restrictive Can print strings… print_string(..) .. Or integers print_integer(..). Supplied Font. Bitstream Vera Sans, 10.5pt Nothing special about this It just looks nice

claude
Download Presentation

Fonts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fonts Andrew Williams A.Williams@bolton.ac.uk http://www.bolton.ac.uk/staff/adw1

  2. AWFont Class • Very simple • Very restrictive • Can print strings… • print_string(..) • .. Or integers • print_integer(..)

  3. Supplied Font • Bitstream Vera Sans, 10.5pt • Nothing special about this • It just looks nice • You can create your own font files • But there are rules that you MUST follow • There can be no exceptions to these rules

  4. Bitmapped Font File • Created with a program called Bitmap Font Builder, by Thom Wetzel • See the link on my webpage • There is also a data file which gives character widths

  5. Font Files • There are two in the example project • vera.bmp • vera.dat • These contain the bitmap and the character width data, respectively

  6. Bitmap Font Builder Must be 256x256

  7. Bitmap Font Builder Background must be black

  8. Bitmap Font Builder Grid must be OFF

  9. Bitmap Font Builder Must be only one font

  10. Bitmap Font Builder You should accept the default size

  11. Bitmap Font Builder You should left-justify your font

  12. Saving Your Font Save as .BMP, eg arial.bmp

  13. Saving Your Font Save font widths (Byte Format) eg arial.dat

  14. Using AWFont • You can use as many as you like • You load each one like this (do this at the top of the program, but after SDL_SetVideoMode): font1 = new AWFont(“arial.bmp”, “arial.dat”); • Of course, the files must be in the project directory

  15. Using AWFont • Printing something out: int endX = font->print_string(“SCORE: ", 10, 10); font->print_integer(score, endX, 10); • Parameters (for both) are: • What you want to print • X coordinate (screen, not world) • Y coordinate (screen, not world) • Do this in the game loop, sometime after drawing the background

More Related