Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Test for PySDL2's BitmapFont.

View test_bmp_font.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# 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.