forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglyph_cache.hpp
90 lines (73 loc) · 1.83 KB
/
glyph_cache.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#include "drape/drape_global.hpp"
#include "base/string_utils.hpp"
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace software_renderer
{
/// metrics of the single glyph
struct GlyphMetrics
{
int m_xAdvance;
int m_yAdvance;
int m_xOffset;
int m_yOffset;
int m_width;
int m_height;
};
struct GlyphBitmap
{
unsigned m_width;
unsigned m_height;
unsigned m_pitch;
std::vector<unsigned char> m_data;
};
struct GlyphKey
{
strings::UniChar m_symbolCode;
int m_fontSize;
bool m_isMask;
dp::Color m_color;
GlyphKey(strings::UniChar symbolCode,
int fontSize,
bool isMask,
dp::Color const & color);
GlyphKey();
};
struct Font;
bool operator<(GlyphKey const & l, GlyphKey const & r);
bool operator!=(GlyphKey const & l, GlyphKey const & r);
struct GlyphCacheImpl;
class GlyphCache
{
private:
std::shared_ptr<GlyphCacheImpl> m_impl;
public:
struct Params
{
std::string m_blocksFile;
std::string m_whiteListFile;
std::string m_blackListFile;
size_t m_maxSize;
double m_visualScale;
bool m_isDebugging;
Params(std::string const & blocksFile,
std::string const & whiteListFile,
std::string const & blackListFile,
size_t maxSize,
double visualScale,
bool isDebugging);
};
GlyphCache();
GlyphCache(Params const & params);
void reset();
void addFonts(std::vector<std::string> const & fontNames);
std::pair<Font*, int> getCharIDX(GlyphKey const & key);
std::shared_ptr<GlyphBitmap> const getGlyphBitmap(GlyphKey const & key);
/// return control box(could be slightly larger than the precise bound box).
GlyphMetrics const getGlyphMetrics(GlyphKey const & key);
double getTextLength(double fontSize, std::string const & text);
};
} // namespace software_renderer