bn::sprite_font class

Contains the required information to generate text sprites.

Currently, it supports 4 bits per pixel (16 colors) fixed width AND variable width characters.

Also, UTF-8 characters are supported.

UTF-8 characters map and character widths are not copied but referenced, so they should outlive the sprite_font to avoid dangling references.

Public static variables

static int minimum_graphics constexpr
Minimum number of sprite tile sets that must contain the sprite_tiles_item of a sprite_font.

Constructors, destructors, conversion operators

sprite_font(const sprite_item& item) explicit constexpr
Constructor.
sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref) constexpr
Constructor.
sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref, const span<const int8_t>& character_widths_ref) constexpr
Constructor.
sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref, const span<const int8_t>& character_widths_ref, int space_between_characters) constexpr
Constructor.

Public functions

auto item() const -> const sprite_item& constexpr
Returns the sprite_item used to generate text sprites.
auto utf8_characters_ref() const -> const utf8_characters_map_ref& constexpr
Returns the reference to the map of the supported UTF-8 characters and their position in the tile sets.
auto character_widths_ref() const -> const span<const int8_t>& constexpr
Returns the reference to the width in pixels of each supported character.
auto space_between_characters() const -> int
Returns the space between two consecutive characters in pixels (it can be negative).

Function documentation

bn::sprite_font::sprite_font(const sprite_item& item) explicit constexpr

Constructor.

Parameters
item sprite_item used to generate text sprites.

bn::sprite_font::sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref) constexpr

Constructor.

Parameters
item sprite_item used to generate text sprites.
utf8_characters_ref Reference to the map of the supported UTF-8 characters and their position in the tile sets.

UTF-8 characters should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters map is not copied but referenced, so it should outlive the sprite_font to avoid dangling references.

bn::sprite_font::sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref, const span<const int8_t>& character_widths_ref) constexpr

Constructor.

Parameters
item sprite_item used to generate text sprites.
utf8_characters_ref Reference to the map of the supported UTF-8 characters and their position in the tile sets.
character_widths_ref Reference to the width in pixels of each supported character.

UTF-8 characters should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters map is not copied but referenced, so it should outlive the sprite_font to avoid dangling references.

Character widths are not copied but referenced, so they should outlive the sprite_font to avoid dangling references.

bn::sprite_font::sprite_font(const sprite_item& item, const utf8_characters_map_ref& utf8_characters_ref, const span<const int8_t>& character_widths_ref, int space_between_characters) constexpr

Constructor.

Parameters
item sprite_item used to generate text sprites.
utf8_characters_ref Reference to the map of the supported UTF-8 characters and their position in the tile sets.
character_widths_ref Reference to the width in pixels of each supported character.
space_between_characters Space between two consecutive characters in pixels (it can be negative).

UTF-8 characters should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters map is not copied but referenced, so it should outlive the sprite_font to avoid dangling references.

Character widths are not copied but referenced, so they should outlive the sprite_font to avoid dangling references.

const utf8_characters_map_ref& bn::sprite_font::utf8_characters_ref() const constexpr

Returns the reference to the map of the supported UTF-8 characters and their position in the tile sets.

UTF-8 characters should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters map is not copied but referenced, so it should outlive the sprite_font to avoid dangling references.

const span<const int8_t>& bn::sprite_font::character_widths_ref() const constexpr

Returns the reference to the width in pixels of each supported character.

Character widths are not copied but referenced, so they should outlive the sprite_font to avoid dangling references.