Untitled
Loading...
Searching...
No Matches
fonts.h File Reference

Functions that modify TextBoxes and load Fonts. More...

#include "utilities/types.h"
#include "ui/ui.h"

Go to the source code of this file.

Functions

void FONTS_INIT ()
 Simply clears the FONTS buffer and re-initializes the Vector.
int find_empty_text_box_slot (UIMenu *m)
 Finds an empty slot for a TextBox that is marked as free.
Font * read_json_msdf (const char *json_path, const char *png_path)
 Reads the JSON for an MSDF Font, and creates a Font from it.
void determine_text_box_dimensions (TextBox *tb, float *width, float *height)
 Determines TextBox dimensions by iterating through its text as if it was rendering the Font.
void move_text_box_to_origin (TextBox *box)
 Moves a TextBox to \((0, 0)\), while accounting for Justify.
int create_text_box (int menu_id)
 Creates a DEFAULT_TEXT_BOX.
void delete_text_box (int menu, int id)
 Deletes a TextBox and its text and frees it from the UIMenu.

Variables

Vector FONTS
 All loaded Fonts.

Detailed Description

Functions that modify TextBoxes and load Fonts.

Definition in file fonts.h.

Function Documentation

◆ FONTS_INIT()

void FONTS_INIT ( )
inline

Simply clears the FONTS buffer and re-initializes the Vector.

Definition at line 21 of file fonts.h.

References Vector::buffer, FONTS, FONTS_INIT(), and init_vector().

Referenced by FONTS_INIT(), and init().

◆ find_empty_text_box_slot()

int find_empty_text_box_slot ( UIMenu * m)

Finds an empty slot for a TextBox that is marked as free.

Parameters
mThe UIMenu to search.

Definition at line 21 of file fonts.c.

References find_empty_text_box_slot(), TextBox::free, MAX_TEXT_BOXES, and UIMenu::text_boxes.

Referenced by create_text_box(), find_empty_text_box_slot(), and move_text_box_to_menu().

◆ read_json_msdf()

Font * read_json_msdf ( const char * json_path,
const char * png_path )

Reads the JSON for an MSDF Font, and creates a Font from it.

Parameters
json_pathThe path to the json.
png_pathThe path to the png.
Returns
The pointer to the resulting Font.

Definition at line 33 of file fonts.c.

References Vector::count, FONTS, Font::glyph_count, Font::glyphs, Glyph::height, Font::highest_dist, Font::highest_y, Font::id, Glyph::id, Font::name, read_json_msdf(), Font::tex_h, Font::tex_w, Glyph::u0, Glyph::u1, Glyph::v0, Glyph::v1, vector_expand(), Glyph::width, Glyph::xadvance, Glyph::xoffset, and Glyph::yoffset.

Referenced by init_globals(), and read_json_msdf().

◆ determine_text_box_dimensions()

void determine_text_box_dimensions ( TextBox * tb,
float * width,
float * height )

Determines TextBox dimensions by iterating through its text as if it was rendering the Font.

Parameters
tbThe TextBox.
widthPointer to out width.
heightPointer to out height.

Definition at line 97 of file fonts.c.

References CAST_VEC, determine_text_box_dimensions(), TextBox::font_id, FONTS, Font::glyph_count, Font::glyphs, Glyph::height, Font::highest_dist, TextBox::start, Font::tex_h, Font::tex_w, TextBox::text, TextBox::text_size, Glyph::u0, Glyph::u1, Glyph::v0, Glyph::v1, TextBox::w, Glyph::width, vec2::x, Glyph::xadvance, Glyph::xoffset, vec2::y, and Glyph::yoffset.

Referenced by determine_text_box_dimensions(), and move_text_box_to_origin().

◆ move_text_box_to_origin()

void move_text_box_to_origin ( TextBox * box)

◆ create_text_box()

int create_text_box ( int menu_id)

◆ delete_text_box()

void delete_text_box ( int menu,
int id )

Variable Documentation

◆ FONTS

Vector FONTS
extern