Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Test for PySDL2's BitmapFont.
# To use this script, save the image from the page below as '7sled.png'.
# http://imgur.com/C2OLhYj
# The script should create a file 'test_bmp_font.bmp' that looks like this:
# http://imgur.com/WFJNRTT
import atexit
import sdl2
import sdl2.ext
sdl2.ext.init()
atexit.register(sdl2.ext.quit)
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.