NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Auxiliary

Classes

struct  nnl::text::BitmapFont
 Represents a bitmap font consisting of glyph atlases and advance widths. More...
struct  nnl::text::BitmapFontParams
 Parameters for generating a bitmap font. More...

Functions

BitmapFont nnl::text::GenerateBitmapFont (Text &text, const std::filesystem::path &ttf_font_path, const BitmapFontParams &params={})
 Generates a bitmap font from a TrueType font file.
std::string nnl::text::GenerateFNT (const Text &text, const std::vector< u8 > &advance_width, const std::vector< STexture > &bitmaps, int columns=-1)
 Generates a BMFont .fnt file.

Detailed Description


Class Documentation

◆ nnl::text::BitmapFont

struct nnl::text::BitmapFont

Represents a bitmap font consisting of glyph atlases and advance widths.

Note
This struct is auxiliary and should be used to create other parts of a complete text archive.
See also
nnl::text::GenerateBitmapFont
nnl::text::Text
nnl::asset::BitmapText

Public Attributes

std::vector< STexturebitmaps
 Glyph atlases.
std::vector< u8advance_width

Member Data Documentation

◆ advance_width

std::vector<u8> nnl::text::BitmapFont::advance_width

Advance width for every character glyph. Each entry corresponds to a character defined in the Text struct.

◆ bitmaps

std::vector<STexture> nnl::text::BitmapFont::bitmaps

Glyph atlases.

See also
nnl::texture::TextureContainer

◆ nnl::text::BitmapFontParams

struct nnl::text::BitmapFontParams

Parameters for generating a bitmap font.

See also
nnl::text::GenerateBitmapFont

Public Attributes

unsigned int size = 128
unsigned int columns = 8
 Number of glyphs in a row of the bitmap.
float opacity_factor = 1.5f
 A multiplier that makes glyphs brighter or dimmer.
float scale_factor = 1.0f
 A multiplier that forcibly scales glyphs.
int spacing_offset = 0
 An additional offset for character spacing.
bool simulate_kerning = false
bool filter_nearest = false
 Flag to use the nearest/linear neighbor filtering.
unsigned int alpha_levels = 256
 Number of shades to use.

Member Data Documentation

◆ alpha_levels

unsigned int nnl::text::BitmapFontParams::alpha_levels = 256

Number of shades to use.

◆ columns

unsigned int nnl::text::BitmapFontParams::columns = 8

Number of glyphs in a row of the bitmap.

◆ filter_nearest

bool nnl::text::BitmapFontParams::filter_nearest = false

Flag to use the nearest/linear neighbor filtering.

◆ opacity_factor

float nnl::text::BitmapFontParams::opacity_factor = 1.5f

A multiplier that makes glyphs brighter or dimmer.

◆ scale_factor

float nnl::text::BitmapFontParams::scale_factor = 1.0f

A multiplier that forcibly scales glyphs.

◆ simulate_kerning

bool nnl::text::BitmapFontParams::simulate_kerning = false

Simulates kerning between characters (by using more characters)

◆ size

unsigned int nnl::text::BitmapFontParams::size = 128

The width and height of the bitmap.

Note
The games may need to be patched to use bigger values.

◆ spacing_offset

int nnl::text::BitmapFontParams::spacing_offset = 0

An additional offset for character spacing.

Function Documentation

◆ GenerateBitmapFont()

BitmapFont nnl::text::GenerateBitmapFont ( Text & text,
const std::filesystem::path & ttf_font_path,
const BitmapFontParams & params = {} )

Generates a bitmap font from a TrueType font file.

This function creates a BitmapFont object based on the provided text and TrueType font, using the specified parameters for customization.

Parameters
textThe Text object containing the character data for the font (The object may be changed if simulate_kerning is true)
ttf_font_pathThe path to the TrueType font file.
paramsAn object containing customization options.
Returns
A BitmapFont object representing the generated bitmap font.
See also
nnl::text::BitmapFont

◆ GenerateFNT()

std::string nnl::text::GenerateFNT ( const Text & text,
const std::vector< u8 > & advance_width,
const std::vector< STexture > & bitmaps,
int columns = -1 )

Generates a BMFont .fnt file.

This function creates a BMFont .fnt file using the provided data. The generated .fnt file can be utilized in Godot.

Parameters
textThe Text object containing the character data to be included in the .fnt file.
advance_widthAdvance width for each character.
bitmapsCharacter glyph bitmaps.
columnsAn optional parameter specifying the number of columns in the bitmap. If not provided, it's calculated automatically.
Returns
A string containing the contents of the generated .fnt file.
See also
https://docs.godotengine.org/en/stable/tutorials/ui/gui_using_fonts.html#bitmap-fonts