le2d v0.4.3
2D game engine framework
 
Loading...
Searching...
No Matches
font.hpp
Go to the documentation of this file.
1#pragma once
2#include <kvf/ttf.hpp>
5
6namespace le {
8class IFontAtlas : public IResource {
9 public:
10 using Glyph = kvf::ttf::Glyph;
11 using GlyphLayout = kvf::ttf::GlyphLayout;
12
13 virtual auto build(gsl::not_null<kvf::ttf::Typeface*> face, TextHeight height) -> bool = 0;
14
15 [[nodiscard]] virtual auto get_glyphs() const -> std::span<Glyph const> = 0;
16 [[nodiscard]] virtual auto get_texture() const -> ITexture const& = 0;
17 [[nodiscard]] virtual auto get_height() const -> TextHeight = 0;
18
19 virtual auto push_layouts(std::vector<GlyphLayout>& out, std::string_view text, float n_line_height = 1.5f, bool use_tofu = true) const -> glm::vec2 = 0;
20};
21
23class IFont : public IResource {
24 public:
25 virtual auto load_face(std::vector<std::byte> font_bytes) -> bool = 0;
26
27 [[nodiscard]] virtual auto get_name() const -> klib::CString = 0;
28
29 [[nodiscard]] virtual auto get_atlas(TextHeight height) -> IFontAtlas& = 0;
30};
31} // namespace le
Opaque interface for a Font Atlas.
Definition font.hpp:8
virtual auto get_texture() const -> ITexture const &=0
kvf::ttf::Glyph Glyph
Definition font.hpp:10
virtual auto get_glyphs() const -> std::span< Glyph const >=0
virtual auto build(gsl::not_null< kvf::ttf::Typeface * > face, TextHeight height) -> bool=0
virtual auto push_layouts(std::vector< GlyphLayout > &out, std::string_view text, float n_line_height=1.5f, bool use_tofu=true) const -> glm::vec2=0
virtual auto get_height() const -> TextHeight=0
kvf::ttf::GlyphLayout GlyphLayout
Definition font.hpp:11
Opaque interface for a Font.
Definition font.hpp:23
virtual auto get_name() const -> klib::CString=0
virtual auto load_face(std::vector< std::byte > font_bytes) -> bool=0
Interface for all shared resources in the engine.
Definition resource.hpp:6
Concrete drawable Texture.
Definition texture.hpp:31
Definition animation.hpp:8
TextHeight
Strongly typed integer for text height.
Definition text_height.hpp:6