class font_renderer

Declaration

class font_renderer { /* full declaration omitted */ };

Declared at: include/ekg/draw/font_renderer.hpp:35

Member Variables

public ekg::draw::font_face_t font_face_text = {}
public ekg::draw::font_face_t font_face_emoji = {}
public FT_Bool ft_bool_kerning = {}
public FT_UInt ft_uint_previous = {}
public std::string_view font_path = {}
public uint32_t font_size = {18}
public ekg::gpu::sampler_t sampler_texture = {}
public int32_t full_width = {}
public int32_t full_height = {}
public float offset_text_height = {}
public float text_height = {}
public float non_swizzlable_range = {}
public bool flag_unloaded = {}
public bool flag_first_time = {true}
public bool font_face_changed = {}
public bool font_size_changed = {}
public ekg::gpu::allocator* p_allocator = {}
public std::unordered_map<char32_t, ekg::draw::glyph_char_t> mapped_glyph_char_data = {}
public std::vector<char32_t> loaded_sampler_generate_list = {}
public uint64_t last_sampler_generate_list_size = {}
public static FT_Library ft_library

Method Overview

Methods

void bind_allocator(
    ekg::gpu::allocator* p_allocator_bind)

Description

Bind an external GPU allocator, but is not recommend pass a nullptr value.

Declared at: include/ekg/draw/font_renderer.hpp:111

Parameters

ekg::gpu::allocator* p_allocator_bind

void blit(std::string_view text,
          float x,
          float y,
          const ekg::vec4& color)

Description

Generate GPU data to render text on screen. Note: The positions `x` and `y` are unuscaled by DPI, there is no solution still to this issue, perhaps a pow2-based pixel position should be the way.

Declared at: include/ekg/draw/font_renderer.hpp:121

Parameters

std::string_view text
float x
float y
const ekg::vec4& color

void flush()

Description

flush new glyph(s) to re-generate texture atlas and map for the GPU-side.

Declared at: include/ekg/draw/font_renderer.hpp:136

ekg::gpu::sampler_t* get_sampler_texture()

Description

Return the sampler atlas font.

Declared at: include/ekg/draw/font_renderer.hpp:69

float get_text_height()

Description

Return the font face height.

Declared at: include/ekg/draw/font_renderer.hpp:86

float get_text_width(std::string_view text)

Description

Return the text width. Note: font-rendering is UTF-8-based.

Declared at: include/ekg/draw/font_renderer.hpp:75

Parameters

std::string_view text

float get_text_width(std::string_view text,
                     int32_t& lines)

Description

Return the text width and the lines `\n`. Note: font-rendering is UTF-8-based.

Declared at: include/ekg/draw/font_renderer.hpp:81

Parameters

std::string_view text
int32_t& lines

void init()

Description

Init the internal-system of font-rendering.

Declared at: include/ekg/draw/font_renderer.hpp:126

void quit()

Description

Quit the internal-system and free FreeType features from memory.

Declared at: include/ekg/draw/font_renderer.hpp:131

void reload()

Description

Reload the font face with the new metrics and file path.

Declared at: include/ekg/draw/font_renderer.hpp:106

void set_font(std::string_view font_face_path)

Description

Set a new font face, check FreeType docs.

Declared at: include/ekg/draw/font_renderer.hpp:96

Parameters

std::string_view font_face_path

void set_font_emoji(
    std::string_view font_face_emoji_path)

Description

Set a new font face for emoji, check FreeType docs.

Declared at: include/ekg/draw/font_renderer.hpp:91

Parameters

std::string_view font_face_emoji_path

void set_size(uint32_t font_face_size)

Description

Set the font face height.

Declared at: include/ekg/draw/font_renderer.hpp:101

Parameters

uint32_t font_face_size