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 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 a 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 span<const string_view>& utf8_characters_ref) constexpr
Constructor.
sprite_font(const sprite_item& item, const span<const string_view>& utf8_characters_ref, const span<const int8_t>& character_widths_ref) constexpr
Constructor.
sprite_font(const sprite_item& item, const span<const string_view>& 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 span<const string_view>& constexpr
Returns the reference to the list of supported UTF-8 characters.
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 span<const string_view>& utf8_characters_ref) constexpr

Constructor.

Parameters
item sprite_item used to generate text sprites.
utf8_characters_ref Reference to a list of supported UTF-8 characters.

They should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters 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 span<const string_view>& 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 a list of supported UTF-8 characters.
character_widths_ref Reference to the width in pixels of each supported character.

They should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters are not copied but referenced, so they 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 span<const string_view>& 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 a list of supported UTF-8 characters.
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).

They should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters are not copied but referenced, so they 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 span<const string_view>& bn::sprite_font::utf8_characters_ref() const constexpr

Returns the reference to the list of supported UTF-8 characters.

They should appear in the tile sets referenced by item just after ASCII characters.

UTF-8 characters are not copied but referenced, so they 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.