Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/graphite/src/inc/Face.h
9906 views
1
// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later
2
// Copyright 2010, SIL International, All rights reserved.
3
4
#pragma once
5
6
#include <cstdio>
7
8
#include "graphite2/Font.h"
9
10
#include "inc/Main.h"
11
#include "inc/FeatureMap.h"
12
#include "inc/TtfUtil.h"
13
#include "inc/Silf.h"
14
#include "inc/Error.h"
15
16
namespace graphite2 {
17
18
class Cmap;
19
class FileFace;
20
class GlyphCache;
21
class NameTable;
22
class json;
23
class Font;
24
25
26
using TtfUtil::Tag;
27
28
// These are the actual tags, as distinct from the consecutive IDs in TtfUtil.h
29
30
class Face
31
{
32
// Prevent any kind of copying
33
Face(const Face&);
34
Face& operator=(const Face&);
35
36
public:
37
class Table;
38
static float default_glyph_advance(const void* face_ptr, gr_uint16 glyphid);
39
40
Face(const void* appFaceHandle/*non-NULL*/, const gr_face_ops & ops);
41
virtual ~Face();
42
43
virtual bool runGraphite(Segment *seg, const Silf *silf) const;
44
45
public:
46
bool readGlyphs(uint32 faceOptions);
47
bool readGraphite(const Table & silf);
48
bool readFeatures();
49
void takeFileFace(FileFace* pFileFace/*takes ownership*/);
50
51
const SillMap & theSill() const;
52
const GlyphCache & glyphs() const;
53
Cmap & cmap() const;
54
NameTable * nameTable() const;
55
void setLogger(FILE *log_file);
56
json * logger() const throw();
57
58
const Silf * chooseSilf(uint32 script) const;
59
uint16 languageForLocale(const char * locale) const;
60
61
// Features
62
uint16 numFeatures() const;
63
const FeatureRef * featureById(uint32 id) const;
64
const FeatureRef * feature(uint16 index) const;
65
66
// Glyph related
67
int32 getGlyphMetric(uint16 gid, uint8 metric) const;
68
uint16 findPseudo(uint32 uid) const;
69
70
// Errors
71
unsigned int error() const { return m_error; }
72
bool error(Error e) { m_error = e.error(); return false; }
73
unsigned int error_context() const { return m_error; }
74
void error_context(unsigned int errcntxt) { m_errcntxt = errcntxt; }
75
76
CLASS_NEW_DELETE;
77
private:
78
SillMap m_Sill;
79
gr_face_ops m_ops;
80
const void * m_appFaceHandle; // non-NULL
81
FileFace * m_pFileFace; //owned
82
mutable GlyphCache * m_pGlyphFaceCache; // owned - never NULL
83
mutable Cmap * m_cmap; // cmap cache if available
84
mutable NameTable * m_pNames;
85
mutable json * m_logger;
86
unsigned int m_error;
87
unsigned int m_errcntxt;
88
protected:
89
Silf * m_silfs; // silf subtables.
90
uint16 m_numSilf; // num silf subtables in the silf table
91
private:
92
uint16 m_ascent,
93
m_descent;
94
#ifdef GRAPHITE2_TELEMETRY
95
public:
96
mutable telemetry tele;
97
#endif
98
};
99
100
101
102
inline
103
const SillMap & Face::theSill() const
104
{
105
return m_Sill;
106
}
107
108
inline
109
uint16 Face::numFeatures() const
110
{
111
return m_Sill.theFeatureMap().numFeats();
112
}
113
114
inline
115
const FeatureRef * Face::featureById(uint32 id) const
116
{
117
return m_Sill.theFeatureMap().findFeatureRef(id);
118
}
119
120
inline
121
const FeatureRef *Face::feature(uint16 index) const
122
{
123
return m_Sill.theFeatureMap().feature(index);
124
}
125
126
inline
127
const GlyphCache & Face::glyphs() const
128
{
129
return *m_pGlyphFaceCache;
130
}
131
132
inline
133
Cmap & Face::cmap() const
134
{
135
return *m_cmap;
136
};
137
138
inline
139
json * Face::logger() const throw()
140
{
141
return m_logger;
142
}
143
144
145
146
class Face::Table
147
{
148
const Face * _f;
149
mutable const byte * _p;
150
size_t _sz;
151
bool _compressed;
152
153
Error decompress();
154
155
void release();
156
157
public:
158
Table() throw();
159
Table(const Face & face, const Tag n, uint32 version=0xffffffff) throw();
160
~Table() throw();
161
Table(const Table && rhs) throw();
162
163
operator const byte * () const throw();
164
165
size_t size() const throw();
166
Table & operator = (const Table && rhs) throw();
167
};
168
169
inline
170
Face::Table::Table() throw()
171
: _f(0), _p(0), _sz(0), _compressed(false)
172
{
173
}
174
175
inline
176
Face::Table::Table(const Table && rhs) throw()
177
: _f(rhs._f), _p(rhs._p), _sz(rhs._sz), _compressed(rhs._compressed)
178
{
179
rhs._p = 0;
180
}
181
182
inline
183
Face::Table::~Table() throw()
184
{
185
release();
186
}
187
188
inline
189
Face::Table::operator const byte * () const throw()
190
{
191
return _p;
192
}
193
194
inline
195
size_t Face::Table::size() const throw()
196
{
197
return _sz;
198
}
199
200
} // namespace graphite2
201
202
struct gr_face : public graphite2::Face {};
203
204