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
|
// -*- related-file-name: "../../libefont/otfcmap.cc" -*-
#ifndef EFONT_OTFCMAP_HH
#define EFONT_OTFCMAP_HH
#include <efont/otf.hh>
#include <lcdf/error.hh>
namespace Efont { namespace OpenType {
class Cmap { public:
Cmap(const String &, ErrorHandler * = 0);
// default destructor
bool ok() const { return _error >= 0; }
int error() const { return _error; }
inline Glyph map_uni(uint32_t c) const;
int map_uni(const Vector<uint32_t> &in, Vector<Glyph> &out) const;
inline void unmap_all(Vector<uint32_t> &g2c) const;
private:
String _str;
int _error;
int _ntables;
mutable int _first_unicode_table;
mutable Vector<int> _table_error;
enum { HEADER_SIZE = 4, ENCODING_SIZE = 8,
HIBYTE_SUBHEADERS = 524 };
enum Format { F_BYTE = 0, F_HIBYTE = 2, F_SEGMENTED = 4, F_TRIMMED = 6,
F_HIBYTE32 = 8, F_TRIMMED32 = 10, F_SEGMENTED32 = 12 };
enum { USE_FIRST_UNICODE_TABLE = -2 };
int parse_header(ErrorHandler *);
int first_unicode_table() const { return _first_unicode_table; }
int first_table(int platform, int encoding) const;
int check_table(int t, ErrorHandler * = 0) const;
Glyph map_table(int t, uint32_t, ErrorHandler * = 0) const;
void dump_table(int t, Vector<uint32_t> &g2c, ErrorHandler * = 0) const;
inline const uint8_t* table_data(int t) const;
};
inline Glyph Cmap::map_uni(uint32_t c) const
{
return map_table(USE_FIRST_UNICODE_TABLE, c, ErrorHandler::default_handler());
}
inline void Cmap::unmap_all(Vector<uint32_t> &g2c) const
{
dump_table(USE_FIRST_UNICODE_TABLE, g2c, ErrorHandler::default_handler());
}
inline const uint8_t* Cmap::table_data(int t) const {
const uint8_t* data = _str.udata();
return data + Data::u32_aligned(data + HEADER_SIZE + t * ENCODING_SIZE + 4);
}
}}
#endif
|