载入中...
搜索中...
未找到
Font.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cstdint>
6#include <string>
7#include <unordered_map>
8
9namespace eve::font {
10class FontData;
11}
12
13namespace eve::graphics {
14
15class Graphics;
16class Texture;
17
23uint32_t nextCodepointUtf8(const std::string &text, size_t &i);
24
36public:
38 static std::string defaultCharset();
39
41 Font(Graphics *gfx, font::FontData *data, std::string charset = defaultCharset());
44
45 Font(const Font &) = delete;
46 Font &operator=(const Font &) = delete;
47
49 font::FontData *getData() const { return data; }
51 Texture *getTexture() const { return atlas; }
52
54 float getHeight() const;
56 float getAscent() const;
58 float getBaseline() const;
59
61 float getWidth(const std::string &text) const;
62
64 bool hasGlyph(int codepoint) const;
65
67 struct Glyph {
68 float u0 = 0.f, v0 = 0.f, u1 = 0.f, v1 = 0.f; // atlas UV rect (empty if width/height == 0)
69 int width = 0, height = 0; // glyph bitmap size, px
70 int bearingX = 0, bearingY = 0;
71 int advance = 0;
72 };
73
75 const Glyph *findGlyph(int codepoint) const;
76
77private:
78 void buildAtlas(const std::string &charset);
79
80 font::FontData *data = nullptr;
81 Texture *atlas = nullptr;
82 std::unordered_map<int, Glyph> glyphs;
83};
84
85} // namespace eve::graphics
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::uint32_t height
std::uint32_t width
std::string text
CPU-side decoded font face (FreeType FT_Face + owned font bytes). Does not upload to GPU — rasterize ...
Definition FontData.h:25
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:35
font::FontData * getData() const
Returns the data.
Definition Font.h:49
Texture * getTexture() const
Returns the texture.
Definition Font.h:51
Font(const Font &)=delete
Font & operator=(const Font &)=delete
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
uint32_t nextCodepointUtf8(const std::string &text, size_t &i)
Decodes one UTF-8 codepoint from text starting at byte offset i, advancing i past it....
Definition Font.cpp:17
Glyph public API.
Definition Font.h:67