pub(crate) struct CharacterSet {
    characters: HashMap<char, Character>,
    font_type: String,
    font_size: u32,
    is_italic: bool,
    is_bold: bool,
    encoding: String,
    line_height: u32,
    character_number: usize,
    texture_file: String,
    texture_size: (u32, u32),
    pub(crate) binder: Binder,
    image_as_vec: Vec<u8>,
}
Expand description

General Information

A list of characters with a series of important options that make it into a font.

Fields

  • characters - Every character literal (char) with it’s corresponding character struct.
  • font_type - Name of the font.
  • font_size - Size of the font (pt).
  • is_italic - Self-explanatory.
  • is_bool - Self-explanatory.
  • encoding - Type of encoding (unicode, normally)
  • line_height - Where characters should start to be drawn vertically.
  • character_number - Number of characters in font.
  • texture_file - Where texture file is located.
  • texture_size - Dimension of the texture file.
  • binder - Binder associated to font.
  • image_as_vec - Image as a vector.

Fields§

§characters: HashMap<char, Character>§font_type: String§font_size: u32§is_italic: bool§is_bold: bool§encoding: String§line_height: u32§character_number: usize§texture_file: String§texture_size: (u32, u32)§binder: Binder§image_as_vec: Vec<u8>

Implementations§

General Information

Creates new character set given a character file (fnt). It reads every line, substracting information neccesary to create every struct and later create every character struct associating them to their char version. It also loads the image and generates a vector with it inside.

Parameters
  • character_file - fnt file. It is important that the file is correctly created since metadata is important to struct instance.
General Information

Struct has it’s own method to send to gpu since texture has to be considered. This means send_to_gpu method inside bindable trait does not work with this struct. Text are sent by letter. Performance is not affected much since the amount of letters is small. Image vector is sent in it’s entirety.

Parameters
  • &self - Only a couple properties within self are enough to configure: vector from image, size of image.
General Information

Obtains every letter given an entry of text, generating everything necessary to send each one to the gpu: indices, coordinates and texture coordinates.

Parameters
  • &self - Obtain character struct for a given character to access it’s properties.
  • text - A text string to parse and display on screen. Every character has to be in the original font (CharacterSet).
General Information

Draw a given text string. It can even be dynamic and, as long as the text is not too big, there will be no framerate drop.

Parameters
  • &self - Obtain vertices from text function
  • text - A given text input to draw into screen
General Information

Obtain a matrix to make text appear on screen in a certain position with a certain size. There’s still a problem of scale happening: should be chosen dynamically.

Parameters
  • viewport_x - Place where text will be rendered in viewport
  • viewport_y - Place where text will be rendered in viewport
  • projection_matrix - Matrix to inverse and obtain view coordinates
  • camera - A reference to a camera to obtain a projection matrix (should change)
  • window_height - Size of viewport to normalize coordinates
  • window_width - Size of viewport to normalize coordinates
  • text_scale - Scale of text to display

Trait Implementations§

Obtains binder associated to object. Getter.
Obtain binder mutable reference.
Shortcut to binder setup function.
Shortcut to setup texture function.
Shortcut to bind all without texture function.
Shortcut to bind all function.
Shortcut to bind vao function
Shortcut to bind texture
Shortcut to unbind texture
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.