Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
BitmapFont.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
3#pragma once
4
5#include "../core/Types.hpp"
7
8#include <string>
9#include <unordered_map>
10
11namespace esengine {
12namespace resource { class ResourceManager; }
13}
14
15namespace esengine::text {
16
24
26public:
27 bool loadFromFntText(const std::string& content,
28 const std::string& basePath,
30
31 bool loadFromFntText(const std::string& content,
33 u32 texWidth, u32 texHeight);
34
36 u32 texWidth, u32 texHeight,
37 const std::string& chars,
38 u32 charWidth, u32 charHeight);
39
44
45 TextMetrics measureText(const std::string& text, f32 fontSize, f32 spacing) const;
46
47 const Glyph* getGlyph(u32 charCode) const;
48 f32 getKerning(u32 first, u32 second) const;
49 resource::TextureHandle getTexture() const { return texture_; }
50 f32 getLineHeight() const { return line_height_; }
51 f32 getBase() const { return base_; }
52 u32 getTexWidth() const { return tex_width_; }
53 u32 getTexHeight() const { return tex_height_; }
54
55private:
56 bool parseFntContent(const std::string& content);
57
59 u32 tex_width_ = 0;
60 u32 tex_height_ = 0;
61 f32 line_height_ = 0;
62 f32 base_ = 0;
63 std::unordered_map<u32, Glyph> glyphs_;
64 std::unordered_map<u64, f32> kerning_;
65 std::string page_file_;
66};
67
68} // namespace esengine::text
Type-safe resource handle system.
Core type definitions and utilities for ESEngine.
Central manager for GPU resources.
void createLabelAtlas(resource::TextureHandle texture, u32 texWidth, u32 texHeight, const std::string &chars, u32 charWidth, u32 charHeight)
bool loadFromFntText(const std::string &content, const std::string &basePath, resource::ResourceManager &rm)
f32 getKerning(u32 first, u32 second) const
const Glyph * getGlyph(u32 charCode) const
resource::TextureHandle getTexture() const
TextMetrics measureText(const std::string &text, f32 fontSize, f32 spacing) const
Handle< esengine::Texture > TextureHandle
Handle to a texture resource.
Definition Handle.hpp:217
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
float f32
32-bit floating point
Definition Types.hpp:59