Marcus von Appen avatar Marcus von Appen committed b7cbf89

- add some documentation for the sdl2.ext.FontManager class
- minor documentation fixes

Comments (0)

Files changed (4)

doc/modules/sdl2ext_common.rst

 
 .. function:: quit() -> None
 
-   Quits the underlying SDL2 video subysystem. If no other SDL2 subsystems are
-   active, this will also call :func:`quit()`.
+   Quits the underlying SDL2 video subysystem. If no other SDL2
+   subsystems are active, this will also call :func:`quit()`,
+   :func:`sdl2.sdlttf.TTF_Quit()` and :func:`sdl2.sdlimage.IMG_Quit()`.
 
 .. function:: get_events() -> [SDL_Event, SDL_Event, ...]
 

doc/modules/sdl2ext_font.rst

    .. method:: can_render(text : string) -> bool
 
       Checks, whether all characters in the passed *text* can be rendered.
+
+.. class:: FontManager(font_path : str[, alias=None[, color=Color(255, 255, 255)[, bg_color=Color(0, 0, 0)]]])
+
+   Manage font and rendering of text.
+
+   One font path must be given to initialize the FontManager.
+   :attr:`default_font` will be set to this font. *color* and *bg_color*
+   will give the FontManager a default color.
+
+   .. attribute:: bg_color
+
+      The :class:`sdl2.ext.Color` to be used as background color.
+
+   .. attribute:: color
+
+      The :class:`sdl2.ext.Color` to be used for rendering text.
+
+   .. attribute:: default_font
+
+      Returns the name and size of the current default font being used
+      by the :class:`FontManager`. On assigning :attr:`default_font`,
+      the value must be a tuple with a font alias and a size: ``(alias,
+      size)``.
+
+   .. method:: add(font_path : str[, alias=None[, size=16]]) -> sdl2.sdlttf.TTF_Font
+
+      Add a font to the :class:`FontManager`. *alias* is by default the
+      font name, any other name can be passed, *size* is the font size
+      in pixels. though. Returns the font pointer stored in :attr:`fonts`.
+
+   .. method:: close()
+
+      Closes all fonts used by the :class:`FontManager`.
+
+   .. method:: render(text : str[, alias=None[, size=16[, width=None[, color=None[, bg_color=None[, **kwargs]]]]]]) -> sdl2.SDL_Surface
+
+      Renders text to a surface. This method uses the font designated by
+      the passed *alias* or, if *alias* is omitted, by the set
+      :attr:`default_font`.  A *size* can be passed even if the font was
+      not loaded with this size.  A *width* can be given for automatic line
+      wrapping.  If no *bg_color* or *color* are given, it will default to
+      the FontManager's :attr:`bg_color` and :attr:`color`.
+

doc/modules/sdl2ext_sprite.rst

       :class:`sdl2.SDL_Surface`. If *free* is set to
       ``True``, the passed *surface* will be freed automatically.
 
+   .. method:: from_text(text : str[, **kwargs]) -> Sprite
+
+      Creates a :class:`Sprite` from a string of text. This method
+      requires a :class:`sdl2.ext.FontManager` to be in *kwargs* or
+      :attr:`default_args`.
+
 .. class:: RenderContext(target : obj[, index=-1[, flags=sdl2.SDL_RENDERER_ACCELERATED]])
 
    A rendering context for windows and sprites that can use hardware or
                  color=Color(255, 255, 255), bg_color=Color(0, 0, 0)):
         """Initialize the FontManager
 
-        One font path must be given to initialize the FontManager.
-        A list or tuple of font paths can also be given. In this
-        case, the alias is applied to the first entry. The other
-        fonts will have a default alias. The size is given to all
-        fonts.  The default_font will be set to this font.
-        text_color and bg_color will give the FontManager a default
-        color.
+        One font path must be given to initialize the FontManager. The
+        default_font will be set to this font. color and bg_color
+        will give the FontManager a default color.
         """
         if not _HASSDLTTF:
             raise UnsupportedError("FontManager requires sdlttf support")
 
     @default_font.setter
     def default_font(self, value):
-        """default must be a tuple with a font alias and a size: (alias, size)
+        """value must be a tuple with a font alias and a size: (alias, size)
 
         Set the default_font to the given font name alias and size,
         provided it's loaded in the font manager.
 
     def render(self, text, alias=None, size=16, width=None, color=None,
                bg_color=None, **kwargs):
-        """Renders the text to a surface.
+        """Renders text to a surface.
 
         This method uses the font designated by the alias or the
         default_font.  A size can be passed even if the font was not
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.