载入中...
搜索中...
未找到
FontData.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Resource.h"
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
11struct FT_FaceRec_;
12typedef struct FT_FaceRec_ *FT_Face;
13
14namespace eve {
15namespace image {
16class ImageData;
17}
18
19namespace font {
20
26public:
28 FontData(std::vector<uint8_t> bytes, int pixelSize, std::string uri = "");
30 ~FontData() override;
31
33 int getSize() const;
35 float getAscent() const;
37 float getDescent() const;
39 float getLineHeight() const;
41 float getBaseline() const;
42
44 std::string getFamilyName() const;
46 std::string getStyleName() const;
48 int getGlyphCount() const;
49
51 bool hasGlyph(int codepoint) const;
53 bool hasGlyphs(std::string text) const;
55 float getWidth(std::string text) const;
57 float getKerning(int leftCodepoint, int rightCodepoint) const;
58
60 void adopt(eve::Resource &replacement) override;
61
63 int getGlyphWidth(int codepoint) const;
65 int getGlyphHeight(int codepoint) const;
67 int getGlyphBearingX(int codepoint) const;
69 int getGlyphBearingY(int codepoint) const;
71 int getGlyphAdvance(int codepoint) const;
72
77 image::ImageData *newGlyphImageData(int codepoint);
78
79private:
80 struct GlyphCache {
81 int width = 0;
82 int height = 0;
83 int bearingX = 0;
84 int bearingY = 0;
85 int advance = 0;
86 bool loaded = false;
87 bool empty = true;
88 };
89
90 const GlyphCache &ensureGlyph(int codepoint) const;
91 unsigned int glyphIndex(int codepoint) const;
92
93 std::vector<uint8_t> bytes;
94 FT_Face face = nullptr;
95 int pixelSize = 16;
96 mutable std::vector<GlyphCache> glyphCache; // indexed by glyph index
97};
98
99} // namespace font
100} // namespace eve
#define EVENGINE_API_BACKENDS
Definition Export.h:108
int pixelSize
struct FT_FaceRec_ * FT_Face
Definition FontData.h:12
vk::UniqueImage image
std::uint32_t height
std::uint32_t width
std::string text
std::uint64_t bytes
std::string uri
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or gen...
Definition Resource.h:51
CPU-side decoded font face (FreeType FT_Face + owned font bytes). Does not upload to GPU — rasterize ...
Definition FontData.h:25
Represents raw pixel data.
Definition ImageData.h:38
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16