ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
Font+Bitmap.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for SDL3 and C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 * 1. The origin of this software must not be misrepresented; you must not
11 * claim that you wrote the original software. If you use this software
12 * in a product, an acknowledgment in the product documentation would be
13 * appreciated but is not required.
14 * 2. Altered source versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software.
16 */
17
18#pragma once
19
22
31#define FONT_BITMAP_FIRST ' '
32
40#define FONT_BITMAP_COUNT 1024
41
45#define FONT_BITMAP_LAST (FONT_BITMAP_FIRST + FONT_BITMAP_COUNT)
50#define FONT_BITMAP_COLUMNS 32
51
55#define FONT_BITMAP_REPLACEMENT '?'
56
57typedef struct Font Font;
58typedef struct ImageAtlas ImageAtlas;
59
82typedef struct {
87
93
97 SDL_Size cellSize;
98
103 SDL_Surface *surface;
104
109 Texture *texture;
110} FontBitmap;
111
122
128
133
137OBJECTIVELYMVC_EXPORT void renderCharactersBitmap(Font *self, const Renderer *renderer, const char *chars, SDL_Color color, int wrapWidth, const SDL_Point *origin, const ImageAtlas *icons);
138
142OBJECTIVELYMVC_EXPORT void sizeCharactersBitmap(const Font *self, const char *chars, int wrapWidth, const ImageAtlas *icons, int *w, int *h);
OBJECTIVELYMVC_EXPORT 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.
OBJECTIVELYMVC_EXPORT void deallocBitmap(FontBitmap *bitmap)
Releases the resources held by bitmap. Safe to call on a zeroed FontBitmap.
OBJECTIVELYMVC_EXPORT void renderDeviceWillResetBitmap(Font *self)
Implements Font::renderDeviceWillReset.
OBJECTIVELYMVC_EXPORT bool initBitmap(FontBitmap *bitmap, Font *font)
Bakes FONT_BITMAP_COUNT codepoints of font, from FONT_BITMAP_FIRST, into a glyph sheet,...
OBJECTIVELYMVC_EXPORT void sizeCharactersBitmap(const Font *self, const char *chars, int wrapWidth, const ImageAtlas *icons, int *w, int *h)
Implements Font::sizeBitmapCharacters.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
static ImageAtlas * icons(Theme *self)
Definition Theme.c:144
static Font * font(Theme *self, const FontAttributes *attributes, float pixelDensity)
Definition Theme.c:108
ObjectivelyMVC base types.
#define OBJECTIVELYMVC_EXPORT
Definition Types.h:40
A fixed-width Font's glyphs, baked into one sheet, drawn as one quad per glyph.
Definition Font+Bitmap.h:82
int bearing
The horizontal offset from the pen to a cell's left edge, in texels.
Definition Font+Bitmap.h:92
SDL_Size cellSize
The size of one cell, in texels.
Definition Font+Bitmap.h:97
int advance
The pen advance per glyph, in texels.
Definition Font+Bitmap.h:86
SDL_Surface * surface
The glyph sheet: a grid of FONT_BITMAP_COLUMNS by FONT_BITMAP_COLUMNS cells of cellSize,...
TrueType fonts.
Definition Font.h:88
Packs many Images into one sheet, backed by one Texture.
Definition ImageAtlas.h:49
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
Definition Renderer.h:75