38 for (char32_t code: charset)
67 bool dyslexia_font_loaded =
false;
70 const auto dyslexia_font_path =
get_string(ctx,
"font_dyslexia");
72 dyslexia_font_loaded =
true;
76 if (dyslexia_font_loaded)
86 const auto serif_font_path =
get_string(ctx,
"font_serif");
87 const auto sans_serif_font_path =
get_string(ctx,
"font_sans_serif");
88 const auto monospace_font_path =
get_string(ctx,
"font_monospace");
122 const float pt_to_px = (dpi / 72.0f) * ctx.
font_scale;
std::unique_ptr< app::window_manager > window_manager
type::bitmap_font menu_font
std::unique_ptr< resource_manager > resource_manager
type::bitmap_font title_font
std::shared_ptr< render::material > debug_font_material
type::bitmap_font debug_font
std::shared_ptr< render::material > menu_font_material
std::unordered_map< hash::fnv1a32_t, std::shared_ptr< type::typeface > > typefaces
std::shared_ptr< render::material > title_font_material
Template used to for generating one or more shader variants from a single source.
A material is associated with exactly one shader program and contains a set of material properties wh...
void set_variable(hash::fnv1a32_t key, std::shared_ptr< material_variable_base > value)
Sets the value of a material variable with the given name.
void set_blend_mode(material_blend_mode mode) noexcept
Sets the material blend mode.
void set_shader_template(std::shared_ptr< gl::shader_template > shader_template)
Sets the material's shader template.
Raster font in which glyphs are stored as arrays of pixels.
bool pack(bool resize=true)
Packs all glyph bitmaps into the font bitmap.
const std::shared_ptr< gl::texture_2d > & get_texture() const noexcept
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr if no such glyph ...
bitmap_glyph & insert(char32_t code)
Inserts a glyph into the font.
void set_font_metrics(const font_metrics &metrics)
Sets the font metrics.
Abstract base class for a typeface, which corresponds to a single digital font file.
virtual bool get_metrics(float height, font_metrics &metrics) const =0
Gets metrics for a font of the specified size.
virtual bool get_bitmap(float height, char32_t code, std::vector< std::byte > &bitmap, std::uint32_t &bitmap_width, std::uint32_t &bitmap_height) const =0
Gets a bitmap of a glyph in a font of the specified size.
const std::unordered_set< char32_t > & get_charset() const noexcept
Returns the set of characters supported by the typeface.
void load_fonts(::game &ctx)
@ translucent
Material is translucent.
std::string get_string(const ::game &ctx, hash::fnv1a32_t key)
Returns a localized string.
Single glyph in a bitmap font.
glyph_metrics metrics
Metrics describing the glyph.
std::uint32_t bitmap_height
Height of the glyph bitmap, in pixels.
std::vector< std::byte > bitmap
Bitmap representing the glyph.
std::uint32_t bitmap_width
Width of the glyph bitmap, in pixels.
Metrics describing properties of a font.