smk::Font Class Reference

Description

Examples
sound.cpp, text.cpp, and vibrate.cpp.

Definition at line 18 of file Font.hpp.

Classes

struct  Glyph
 

Public Member Functions

 Font (std::string filename, float line_height)
 
float line_height () const
 
float baseline_position () const
 
GlyphFetchGlyph (wchar_t in)
 
 Font (Font &&)=default
 
 Font (const Font &)=delete
 
Fontoperator= (Font &&) noexcept
 
Fontoperator= (const Font &)=delete
 

Class Documentation

◆ smk::Font::Glyph

struct smk::Font::Glyph

Definition at line 26 of file Font.hpp.

Class Members
float advance
ivec2 bearing
Texture texture

Constructor & Destructor Documentation

◆ Font()

smk::Font::Font ( std::string  filename,
float  line_height 
)

Definition at line 43 of file Font.cpp.

44 : filename_(std::move(filename)), line_height_(line_height) {
45 std::vector<wchar_t> preloaded_characters;
46 const int character_to_preload = 256;
47 for (wchar_t c = 0; c < character_to_preload; ++c) {
48 preloaded_characters.push_back(c);
49 }
50 LoadGlyphs(preloaded_characters);
51}

Member Function Documentation

◆ baseline_position()

float smk::Font::baseline_position ( ) const
inline

Definition at line 24 of file Font.hpp.

24{ return baseline_position_; }

◆ FetchGlyph()

Font::Glyph * smk::Font::FetchGlyph ( wchar_t  in)

Definition at line 14 of file Font.cpp.

14 {
15 // Load from cache.
16 auto character = glyphs_.find(in);
17 if (character != glyphs_.end()) {
18 return character->second.get();
19 }
20
21 // Load from file.
22 if (line_height_ == 0.F) {
23 LoadGlyphs({in});
24 auto character = glyphs_.find(in);
25 if (character != glyphs_.end()) {
26 return character->second.get();
27 }
28 }
29
30 // Fallback.
31 return nullptr;
32}

◆ line_height()

float smk::Font::line_height ( ) const
inline

Definition at line 23 of file Font.hpp.

23{ return line_height_; }

◆ operator=()

Font & smk::Font::operator= ( Font &&  other)
noexcept

Definition at line 34 of file Font.cpp.

34 {
35 glyphs_.insert(std::make_move_iterator(begin(other.glyphs_)),
36 std::make_move_iterator(end(other.glyphs_)));
37 filename_ = other.filename_;
38 line_height_ = other.line_height_;
39 baseline_position_ = other.baseline_position_;
40 return *this;
41}

The documentation for this class was generated from the following files: