|
1 | | -Basic Bitmap Font Rendering |
2 | | -=========================== |
| 1 | +`sdl2.ext.bitmapfont` - Basic Bitmap Font Rendering |
| 2 | +=================================================== |
3 | 3 |
|
4 | 4 | This module provides the :class:`~sdl2.ext.BitmapFont` class, which allows for |
5 | 5 | basic font rendering in PySDL2 without depending on the SDL_ttf library. |
6 | 6 |
|
7 | | - |
8 | | -.. class:: BitmapFont(surface : Sprite, size : iterable[, mapping=None) |
9 | | - |
10 | | - A bitmap graphics to character mapping. The :class:`BitmapFont` class |
11 | | - uses an image *surface* to find and render font character glyphs for |
12 | | - text. It requires a mapping table, which denotes the characters |
13 | | - available on the image. |
14 | | - |
15 | | - The mapping table is a list of strings, where each string reflects a |
16 | | - *line* of characters on the image. Each character within each line |
17 | | - has the same size as specified by the size argument. |
18 | | - |
19 | | - A typical mapping table might look like :: |
20 | | - |
21 | | - [ '0123456789', |
22 | | - 'ABCDEFGHIJ', |
23 | | - 'KLMNOPQRST', |
24 | | - 'UVWXYZ ', |
25 | | - 'abcdefghij', |
26 | | - 'klmnopqrst', |
27 | | - 'uvwxyz ', |
28 | | - ',;.:!?+-()' ] |
29 | | - |
30 | | - .. attribute:: surface |
31 | | - |
32 | | - The :class:`sdl2.SDL_Surface` containing the character bitmaps. |
33 | | - |
34 | | - .. attribute:: offsets |
35 | | - |
36 | | - A dict containing the character offsets on the :attr:`surface`. |
37 | | - |
38 | | - .. attribute:: mapping |
39 | | - |
40 | | - The character mapping table, a list of strings. |
41 | | - |
42 | | - .. attribute:: size |
43 | | - |
44 | | - The size of an individual glyph bitmap on the font. |
45 | | - |
46 | | - .. method:: render(text : string[, bpp=None]) -> Sprite |
47 | | - |
48 | | - Renders the passed text on a new :class:`Sprite` and returns it. |
49 | | - If no explicit *bpp* are provided, the bpp settings of the |
50 | | - :attr:`.surface` are used. |
51 | | - |
52 | | - .. method:: render_on(surface : Sprite, text : string[, \ |
53 | | - offset=(0, 0)]) -> (int, int, int, int) |
54 | | - |
55 | | - Renders a text on the passed sprite, starting at a specific |
56 | | - offset. The top-left start position of the text will be the |
57 | | - passed *offset* and a 4-value tuple with the changed area will be |
58 | | - returned. |
59 | | - |
60 | | - .. method:: contains(c : string) -> bool |
61 | | - |
62 | | - Checks, whether a certain character exists in the font. |
63 | | - |
64 | | - .. method:: can_render(text : string) -> bool |
65 | | - |
66 | | - Checks, whether all characters in the passed *text* can be rendered. |
| 7 | +.. automodule:: sdl2.ext.bitmapfont |
| 8 | + :members: |
0 commit comments