|
ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
|
TrueType fonts. More...
#include <Font.h>
Public Member Functions | |
| Class * | _Font (void) |
| The Font archetype. | |
| void | cacheFont (Data *data, const char *family) |
| void | clearCache (void) |
| Clears the Font cache. | |
| Font * | defaultFont (void) |
| Font * | defaultMonospaceFont (void) |
| Font * | fontWithAttributes (const FontAttributes *attributes, float pixelDensity) |
| Resolves a new Font with the given attributes from the cached font Data. | |
| Font * | fontWithName (const char *name, float pixelDensity) |
| Resolves a Font from a name in the format produced by Font::name. | |
| Font * | initWithData (Font *self, Data *data, const FontAttributes *attributes, float pixelDensity) |
| Initializes this Font with the given TTF Data and attributes. | |
| String * | name (const Font *self) |
| String * | nameWithAttributes (const FontAttributes *attributes) |
| void | renderBitmapCharacters (Font *self, const Renderer *renderer, const char *chars, SDL_Color color, int wrapWidth, const SDL_Point *origin, const ImageAtlas *icons) |
| Records one quad per glyph of the given characters from this Font's bitmap. | |
| void | renderCharacters (const Font *self, const char *chars, SDL_Color color, int wrapWidth) |
| Renders the given characters in this Font. | |
| void | renderDeviceWillReset (Font *self) |
| Releases this Font's bitmap Texture, if any, ahead of a render device reset. It is recreated on the next draw. | |
| void | sizeBitmapCharacters (const Font *self, const char *chars, int wrapWidth, const ImageAtlas *icons, int *w, int *h) |
| Measures the given characters against this Font's bitmap. | |
| void | sizeCharacters (const Font *self, const char *chars, int *w, int *h) |
| Measures the given characters in this Font. | |
Data Fields | |
| FontBitmap | bitmap |
The glyphs of a fixed-width Font, baked into one sheet; bitmap.surface is NULL for a proportional Font. | |
| Data * | data |
| The raw font data. | |
| char * | family |
| The family name. | |
| TTF_Font * | font |
| The backing font. | |
| Object | object |
| The superclass. | |
| float | pixelDensity |
| The display pixel density scale, greater than 1.0 on high-density displays. | |
| int | renderSize |
| The render size, adjusted for pixel density. | |
| int | size |
| The point size. | |
| int | style |
| The style. | |
Static Public Attributes | |
| void(* | cacheFont )(Data *data, const char *family) |
| Caches the specified font Data. | |
Protected Attributes | |
| FontInterface * | interface [0] |
| The interface type. | |
| Class * _Font | ( | void | ) |
The Font archetype.
Definition at line 464 of file Font.c.
| void cacheFont | ( | Data * | data, |
| const char * | family | ||
| ) |
| void clearCache | ( | void | ) |
| Font * defaultFont | ( | void | ) |
1.0. Definition at line 159 of file Font.c.
| Font * defaultMonospaceFont | ( | void | ) |
1.0. Definition at line 180 of file Font.c.
| Font * fontWithAttributes | ( | const FontAttributes * | attributes, |
| float | pixelDensity | ||
| ) |
Resolves a new Font with the given attributes from the cached font Data.
"Cached" refers to the font Data registered via Font::cacheFont; the returned instance itself is newly created. Instance caching is provided by Theme::font, which callers with a Theme SHOULD prefer, since it supplies the pixel density implicitly and avoids re-opening the same Font repeatedly. Attributes are normalized to their defaults exactly as Font::nameWithAttributes normalizes them.
| attributes | The FontAttributes. |
| pixelDensity | The pixel density. |
attributes->family is not registered. The caller owns the returned Font, and MUST release it. Definition at line 199 of file Font.c.
| Font * fontWithName | ( | const char * | name, |
| float | pixelDensity | ||
| ) |
Resolves a Font from a name in the format produced by Font::name.
The name is parsed from the right, so families MAY contain -: the final token is the style, the preceding token the point size, and the remainder the family.
| name | The name, e.g. "Coda-16-regular". |
| pixelDensity | The pixel density. |
name is not parseable or not registered. The caller owns the returned Font, and MUST release it. Definition at line 224 of file Font.c.
| Font * initWithData | ( | Font * | self, |
| Data * | data, | ||
| const FontAttributes * | attributes, | ||
| float | pixelDensity | ||
| ) |
Initializes this Font with the given TTF Data and attributes.
Fonts are immutable: the backing TTF_Font is opened here at size * pixelDensity and never re-opened. A pixel density change MUST be handled by resolving a new instance (see Theme::font).
| self | The Font. |
| data | The Data. |
| attributes | The FontAttributes. |
| pixelDensity | The pixel density. |
NULL on error. Definition at line 263 of file Font.c.
| String * name | ( | const Font * | self | ) |
family-size-style, e.g. "Coda-16-regular". | String * nameWithAttributes | ( | const FontAttributes * | attributes | ) |
Definition at line 312 of file Font.c.
| void renderBitmapCharacters | ( | Font * | self, |
| const Renderer * | renderer, | ||
| const char * | chars, | ||
| SDL_Color | color, | ||
| int | wrapWidth, | ||
| const SDL_Point * | origin, | ||
| const ImageAtlas * | icons | ||
| ) |
Records one quad per glyph of the given characters from this Font's bitmap.
| self | The Font, which MUST have a bitmap. |
| renderer | The Renderer. |
| chars | The null-terminated UTF-8 encoded C string to render. |
| color | The color; ^0 through ^9 in chars select from TextEscapeColors, and ^^ is a literal ^. |
| wrapWidth | The maximum line width, in logical pixels, or 0 for no wrapping. |
| origin | The top-left corner of the first line, in logical pixels. |
| icons | The ImageAtlas resolving :icon: escapes, or NULL for none. |
| SDL_Surface * renderCharacters | ( | const Font * | self, |
| const char * | chars, | ||
| SDL_Color | color, | ||
| int | wrapWidth | ||
| ) |
Renders the given characters in this Font.
| self | The Font. |
| chars | The null-terminated UTF-8 encoded C string to render. |
| color | The color. |
| wrapWidth | The maximum line width, in logical pixels, where wrapping should occur. |
NULL on error. Definition at line 330 of file Font.c.
| void renderDeviceWillReset | ( | Font * | self | ) |
| void sizeBitmapCharacters | ( | const Font * | self, |
| const char * | chars, | ||
| int | wrapWidth, | ||
| const ImageAtlas * | icons, | ||
| int * | w, | ||
| int * | h | ||
| ) |
Measures the given characters against this Font's bitmap.
| self | The Font, which MUST have a bitmap. |
| chars | The null-terminated UTF-8 encoded C string to size. |
| wrapWidth | The maximum line width, in logical pixels, or 0 for no wrapping. |
| icons | The ImageAtlas resolving :icon: escapes, or NULL for none. |
| w | The width to return, in logical pixels. |
| h | The height to return, in logical pixels. |
| void sizeCharacters | ( | const Font * | self, |
| const char * | chars, | ||
| int * | w, | ||
| int * | h | ||
| ) |
Measures the given characters in this Font.
| self | The Font. |
| chars | The null-terminated UTF-8 encoded C string to size. |
| w | The width to return. |
| h | The height to return. |
Definition at line 352 of file Font.c.
| FontBitmap Font::bitmap |
|
protected |
| float Font::pixelDensity |
| int Font::renderSize |