|
ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
|
#include <assert.h>#include <limits.h>#include <math.h>#include <string.h>#include <Objectively/String.h>#include "Colors.h"#include "Font.h"#include "ImageAtlas.h"#include "Log.h"#include "Text.h"Go to the source code of this file.
Data Structures | |
| struct | RenderContext |
| struct | Token |
Macros | |
| #define | _Class _Font |
Typedefs | |
| typedef void(* | TokenVisitor) (const FontBitmap *bitmap, const Token *token, int x, int y, ident data) |
| Receives each drawable token with the pen position of its cell, in texels. | |
Enumerations | |
| enum | TokenType { TokenEnd , TokenNewline , TokenColor , TokenGlyph , TokenImage } |
Functions | |
| static void | blit (SDL_Surface *src, SDL_Surface *dest, const SDL_Rect *rect) |
Copies src into dest at rect, scaling if necessary, without alpha blending, so that glyph coverage lands in the sheet exactly as rasterized. | |
| static Uint32 | cellForCodepoint (Uint32 codepoint) |
Resolves codepoint to a cell: FONT_BITMAP_REPLACEMENT's for one outside the baked range. | |
| static SDL_Point | cellOrigin (const FontBitmap *bitmap, Uint32 cell) |
| The top-left texel of the given cell within the grid surface. | |
| void | deallocBitmap (FontBitmap *bitmap) |
Releases the resources held by bitmap. Safe to call on a zeroed FontBitmap. | |
| bool | initBitmap (FontBitmap *bitmap, Font *font) |
Bakes FONT_BITMAP_COUNT codepoints of font, from FONT_BITMAP_FIRST, into a glyph sheet, initializing bitmap. | |
| static void | initGlyph (const FontBitmap *bitmap, TTF_Font *font, Uint32 codepoint, Uint32 cell) |
Rasterizes codepoint into the given cell, with its bearing baked in. | |
| static void | nextToken (const char **chars, const ImageAtlas *icons, Token *token) |
Advances *chars past the next token, describing it in token. | |
| void | renderCharactersBitmap (Font *self, const Renderer *renderer, const char *chars, SDL_Color color, int wrapWidth, const SDL_Point *origin, const ImageAtlas *icons) |
| Implements Font::renderBitmapCharacters. | |
| void | renderDeviceWillResetBitmap (Font *self) |
| Implements Font::renderDeviceWillReset. | |
| static void | renderToken (const FontBitmap *bitmap, const Token *token, int x, int y, ident data) |
| TokenVisitor for Font::renderBitmapCharacters. | |
| void | sizeCharactersBitmap (const Font *self, const char *chars, int wrapWidth, const ImageAtlas *icons, int *w, int *h) |
| Implements Font::sizeBitmapCharacters. | |
| static int | tokenAdvance (const FontBitmap *bitmap, const Token *token) |
| The pen advance of the given token, in texels. | |
| static void | walk (const FontBitmap *bitmap, const char *chars, int wrapWidth, SDL_Color color, const ImageAtlas *icons, TokenVisitor visitor, ident data, int *w, int *h) |
Walks chars, wrapping at word boundaries when wrapWidth (in texels) is non-zero, and reports the extent of the text in texels. | |
| static int | wordAdvance (const FontBitmap *bitmap, const char *chars, const ImageAtlas *icons) |
The advance of the word starting at chars, up to the next space, newline or end. | |
| #define _Class _Font |
Definition at line 31 of file Font+Bitmap.c.
| typedef void(* TokenVisitor) (const FontBitmap *bitmap, const Token *token, int x, int y, ident data) |
Receives each drawable token with the pen position of its cell, in texels.
Definition at line 240 of file Font+Bitmap.c.
| enum TokenType |
| Enumerator | |
|---|---|
| TokenEnd | |
| TokenNewline | |
| TokenColor | |
| TokenGlyph | |
| TokenImage | |
Definition at line 106 of file Font+Bitmap.c.
|
static |
Copies src into dest at rect, scaling if necessary, without alpha blending, so that glyph coverage lands in the sheet exactly as rasterized.
Definition at line 46 of file Font+Bitmap.c.
|
static |
Resolves codepoint to a cell: FONT_BITMAP_REPLACEMENT's for one outside the baked range.
Definition at line 125 of file Font+Bitmap.c.
|
static |
The top-left texel of the given cell within the grid surface.
Definition at line 38 of file Font+Bitmap.c.
| void deallocBitmap | ( | FontBitmap * | bitmap | ) |
Releases the resources held by bitmap. Safe to call on a zeroed FontBitmap.
| bitmap | The FontBitmap. |
Definition at line 375 of file Font+Bitmap.c.
| bool initBitmap | ( | FontBitmap * | bitmap, |
| Font * | font | ||
| ) |
Bakes FONT_BITMAP_COUNT codepoints of font, from FONT_BITMAP_FIRST, into a glyph sheet, initializing bitmap.
A codepoint outside the range draws FONT_BITMAP_REPLACEMENT instead.
| bitmap | The FontBitmap, zero-initialized. |
| font | The Font, which MUST be fixed-width. |
font is not fixed-width or has no glyphs in the range, in which case bitmap is left zeroed. Definition at line 322 of file Font+Bitmap.c.
|
static |
Rasterizes codepoint into the given cell, with its bearing baked in.
Definition at line 64 of file Font+Bitmap.c.
|
static |
Advances *chars past the next token, describing it in token.
Definition at line 137 of file Font+Bitmap.c.
| void renderCharactersBitmap | ( | Font * | self, |
| const Renderer * | renderer, | ||
| const char * | chars, | ||
| SDL_Color | color, | ||
| int | wrapWidth, | ||
| const SDL_Point * | origin, | ||
| const ImageAtlas * | icons | ||
| ) |
Implements Font::renderBitmapCharacters.
Definition at line 452 of file Font+Bitmap.c.
| void renderDeviceWillResetBitmap | ( | Font * | self | ) |
Implements Font::renderDeviceWillReset.
Definition at line 390 of file Font+Bitmap.c.
|
static |
TokenVisitor for Font::renderBitmapCharacters.
Definition at line 408 of file Font+Bitmap.c.
| void sizeCharactersBitmap | ( | const Font * | self, |
| const char * | chars, | ||
| int | wrapWidth, | ||
| const ImageAtlas * | icons, | ||
| int * | w, | ||
| int * | h | ||
| ) |
Implements Font::sizeBitmapCharacters.
Definition at line 485 of file Font+Bitmap.c.
|
static |
The pen advance of the given token, in texels.
Definition at line 196 of file Font+Bitmap.c.
|
static |
Walks chars, wrapping at word boundaries when wrapWidth (in texels) is non-zero, and reports the extent of the text in texels.
Definition at line 246 of file Font+Bitmap.c.
|
static |
The advance of the word starting at chars, up to the next space, newline or end.
Definition at line 212 of file Font+Bitmap.c.