Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Test for PySDL2's BitmapFont.
# To use this script, save the image from the page below as '7sled.png'.
# The script should create a file 'test_bmp_font.bmp' that looks like this:
import atexit
import sdl2
import sdl2.ext
ffile = b"7sled.png"
fwidth = 70
fheight = 100
surf = sdl2.sdlimage.IMG_Load(ffile).contents
bmpfont = sdl2.ext.BitmapFont(surf, (fwidth, fheight), ["01234-", "56789:"])
s = "01 23 45\n --::-- "
assert bmpfont.can_render(s)
surf = bmpfont.render(s).surface
s = ": :"
assert bmpfont.can_render(s)
bmpfont.render_on(surf, s, (fwidth * 2, 0))
sdl2.SDL_SaveBMP(surf, b"test_bmp_font.bmp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.