Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Font.h
1// Copyright 2022 ShenMian
2// License(Apache-2.0)
3
4#pragma once
5
6#include "Core/Image.h"
7#include <filesystem>
8#include <unordered_map>
9
10struct FT_FaceRec_;
11typedef struct FT_FaceRec_* FT_Face;
12
13class Font
14{
15public:
16 struct Glyph
17 {
18 Image image;
19 Vector2i advance;
20 };
21
22 Font(const std::filesystem::path& path);
23 virtual ~Font();
24
28 void load(const std::filesystem::path& path);
29
33 Glyph get_glyph(unsigned long code, uint16_t size);
34
35 static void init();
36 static void deinit();
37
38private:
39 void set_pixel_size(uint16_t size);
40 uint16_t get_pixel_size() const;
41
42 std::unordered_map<uint64_t, Glyph> glyph_cache_;
43
44 FT_Face handle_;
45};
Definition: Font.h:14
Glyph get_glyph(unsigned long code, uint16_t size)
获取字形.
Definition: Font.cpp:44
void load(const std::filesystem::path &path)
从字体文件加载.
Definition: Font.cpp:35
图像.
Definition: Image.h:19
Definition: Font.h:17