class
AbstractFontInterface for font plugins
Similarly to C++, font plugins are loaded through FontManager:
>>> manager = text.FontManager() >>> font = manager.load_and_instantiate('StbTrueTypeFont')
Unlike C++, errors in both API usage and file parsing are reported by raising an exception. See particular function documentation for detailed behavior.
Methods
- def close(self, /) -> None
- Close currently opened file
- def fill_glyph_cache(self, cache: AbstractGlyphCache, characters: str) -> bool
- Fill glyph cache with given character set
- def glyph_advance(self, glyph: int) -> Vector2
- Glyph advance in pixels
- def glyph_id(self, character: str) -> int
- Glyph ID for given character
- def glyph_size(self, glyph: int) -> Vector2
- Glyph size in pixels
- def open_data(self, data: corrade.containers.ArrayView, size: float) -> None
- Open raw data
- def open_file(self, filename: str, size: float) -> None
- Open a file
Properties
- ascent: float get
- Font ascent
- configuration: corrade.utility.ConfigurationGroup get
- Plugin-specific configuration
- descent: float get
- Font descent
- glyph_count: int get
- Total count of glyphs in the font
- is_opened: bool get
- Whether any file is opened
- line_height: float get
- Line height
- manager: object get
- Manager owning this plugin instance
- metadata: corrade.pluginmanager.PluginMetadata get
- Plugin metadata
- plugin: str get
- Plugin identifier string
- size: float get
- Font size
Data
- plugin_interface: str
- Plugin interface string
- plugin_metadata_suffix: str
- Plugin metadata suffix
- plugin_search_paths: typing.List[str]
- Plugin search paths
- plugin_suffix: str
- Plugin suffix
Method documentation
def magnum. text. AbstractFont. fill_glyph_cache(self,
cache: AbstractGlyphCache,
characters: str) -> bool
Fill glyph cache with given character set
Exceptions | |
---|---|
AssertionError | If no file is opened |
def magnum. text. AbstractFont. glyph_advance(self,
glyph: int) -> Vector2
Glyph advance in pixels
Exceptions | |
---|---|
AssertionError | If no file is opened |
IndexError | If glyph is negative or not less than
glyph_count |
def magnum. text. AbstractFont. glyph_id(self,
character: str) -> int
Glyph ID for given character
Exceptions | |
---|---|
AssertionError | If no file is opened |
def magnum. text. AbstractFont. glyph_size(self,
glyph: int) -> Vector2
Glyph size in pixels
Exceptions | |
---|---|
AssertionError | If no file is opened |
IndexError | If glyph is negative or not less than
glyph_count |
def magnum. text. AbstractFont. open_data(self,
data: corrade.containers.ArrayView,
size: float) -> None
Open raw data
Exceptions | |
---|---|
RuntimeError | If file opening fails |
def magnum. text. AbstractFont. open_file(self,
filename: str,
size: float) -> None
Open a file
Exceptions | |
---|---|
RuntimeError | If file opening fails |
For compatibility with os.path, on Windows this function converts
all backslashes in filename
to forward slashes before passing it to
Text::AbstractFont::openFile(), which expects forward slashes as
directory separators on all platforms.
Property documentation
magnum. text. AbstractFont. ascent: float get
Font ascent
Exceptions | |
---|---|
AssertionError | If no file is opened |
magnum. text. AbstractFont. descent: float get
Font descent
Exceptions | |
---|---|
AssertionError | If no file is opened |
magnum. text. AbstractFont. glyph_count: int get
Total count of glyphs in the font
Exceptions | |
---|---|
AssertionError | If no file is opened |
magnum. text. AbstractFont. line_height: float get
Line height
Exceptions | |
---|---|
AssertionError | If no file is opened |