23#ifndef CORSIX_TH_TH_GFX_FONT_H_
24#define CORSIX_TH_TH_GFX_FONT_H_
27#include <SDL_render.h>
179 int letter_spacing{};
241 int* width,
int* height);
278 size_t message_length;
281 size_t message_buffer_length;
290 int widest_line_width;
314 static int freetype_init_count;
315 static constexpr int cache_size_log2{7};
319 bool is_done_freetype_init{
false};
320 mutable cached_text cache[1 << cache_size_log2]{};
330 bool is_monochrome()
const;
346 std::vector<argb_colour>::iterator
outIter);
Definition th_gfx_font.h:139
void draw_text(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY) const override
Draw a single line of text.
Definition th_gfx_font.cpp:82
text_layout draw_text_wrapped(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY, int iWidth, int iMaxRows=INT_MAX, int iSkipRows=0, text_alignment eAlign=text_alignment::left) const override
Draw a single line of text, splitting it at word boundaries.
Definition th_gfx_font.cpp:111
sprite_sheet * get_sprite_sheet()
Definition th_gfx_font.h:157
text_layout get_text_dimensions(const char *sMessage, size_t iMessageLength, int iMaxWidth=INT_MAX) const override
Get the size of drawn text.
Definition th_gfx_font.cpp:75
void set_scale_factor(int factor)
Definition th_gfx_font.cpp:73
void set_sprite_sheet(sprite_sheet *pSpriteSheet, bitmap_font_character_set character_set)
Set the character glyph sprite sheet.
Definition th_gfx_font.cpp:62
void set_separation(int iCharSep, int iLineSep)
Set the separation between characters and between lines.
Definition th_gfx_font.cpp:68
Definition th_gfx_font.h:81
virtual text_layout draw_text_wrapped(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY, int iWidth, int iMaxRows=INT_MAX, int iSkipRows=0, text_alignment eAlign=text_alignment::left) const =0
Draw a single line of text, splitting it at word boundaries.
virtual text_layout get_text_dimensions(const char *sMessage, size_t iMessageLength, int iMaxWidth=INT_MAX) const =0
Get the size of drawn text.
virtual void draw_text(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY) const =0
Draw a single line of text.
Adaptor around the FreeType2 library to a THFont.
Definition th_gfx_font.h:198
void draw_text(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY) const override
Draw a single line of text.
Definition th_gfx_font.cpp:377
void set_shadow_options(const font_shadow_options &options)
Definition th_gfx_font.cpp:366
FT_Error set_ideal_character_size(int iWidth, int iHeight)
Set the ideal character size using pixel values.
Definition th_gfx_font.cpp:327
freetype_font()
Definition th_gfx_font.cpp:216
text_layout draw_text_wrapped(render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY, int iWidth, int iMaxRows=INT_MAX, int iSkipRows=0, text_alignment eAlign=text_alignment::left) const override
Draw a single line of text, splitting it at word boundaries.
Definition th_gfx_font.cpp:416
~freetype_font() override
Definition th_gfx_font.cpp:233
void clear_cache()
Remove all cached strings, as our graphics context has changed.
Definition th_gfx_font.cpp:265
void set_font_color(argb_colour color)
Definition th_gfx_font.cpp:364
FT_Error match_bitmap_font(sprite_sheet *font_spritesheet, argb_colour *color, int *width, int *height)
Find colour and size to best match a bitmap font.
Definition th_gfx_font.cpp:289
static const char * get_copyright_notice()
Get the copyright notice which should be displayed for FreeType2.
Definition th_gfx_font.cpp:249
FT_Error initialise()
Initialise the FreeType2 library.
Definition th_gfx_font.cpp:254
text_layout get_text_dimensions(const char *sMessage, size_t iMessageLength, int iMaxWidth=INT_MAX) const override
Get the size of drawn text.
Definition th_gfx_font.cpp:370
FT_Error set_face(const uint8_t *pData, size_t iLength)
Set the font face to be used.
Definition th_gfx_font.cpp:273
Definition th_gfx_sdl.h:247
Sheet of sprites.
Definition th_gfx_sdl.h:504
Definition th_gfx_font.h:67
int offset_y
Vertical offset of the shadow, in pixels.
Definition th_gfx_font.h:75
int offset_x
Horizontal offset of the shadow, in pixels.
Definition th_gfx_font.h:72
argb_colour color
Colour of the shadow.
Definition th_gfx_font.h:78
bool enabled
Whether to draw a shadow.
Definition th_gfx_font.h:69
Definition th_gfx_font.h:47
int start_y
Top Y-coordinate for the start of the text.
Definition th_gfx_font.h:58
int width
Width of the widest line in the text.
Definition th_gfx_font.h:64
int end_x
Right X-coordinate for the right part of the last letter rendered.
Definition th_gfx_font.h:55
int start_x
Left X-coordinate for the start of the text.
Definition th_gfx_font.h:52
int end_y
Bottom Y-coordinate for the end of the text.
Definition th_gfx_font.h:61
int row_count
Number of rows the rendered text spans.
Definition th_gfx_font.h:49
text_alignment
Definition th_gfx_font.h:38
bitmap_font_character_set
Definition th_gfx_font.h:44
uint32_t argb_colour
32bpp ARGB colour. See palette::pack_argb
Definition th_gfx_sdl.h:65