Debian Codegraph @

texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfcmap.hh

raw
1 // -*- related-file-name: "../../libefont/otfcmap.cc" -*-
2 #ifndef EFONT_OTFCMAP_HH
3 #define EFONT_OTFCMAP_HH
4 #include <efont/otf.hh>
5 #include <lcdf/error.hh>
6 #include <utility>
7 namespace Efont { namespace OpenType {
8
9 class Cmap { public:
10
11 Cmap(const String &, ErrorHandler * = 0);
12 // default destructor
13
14 bool ok() const { return _error >= 0; }
15 int error() const { return _error; }
16
17 inline Glyph map_uni(uint32_t c) const;
18 int map_uni(const Vector<uint32_t> &in, Vector<Glyph> &out) const;
19 inline void unmap_all(Vector<std::pair<uint32_t, Glyph> > &ugp) const;
20
21 private:
22
23 String _str;
24 int _error;
25 int _ntables;
26 mutable int _best_unicode_table;
27 mutable Vector<int> _table_error;
28
29 enum { HEADER_SIZE = 4, ENCODING_SIZE = 8,
30 HIBYTE_SUBHEADERS = 524 };
31 enum Format { F_BYTE = 0, F_HIBYTE = 2, F_SEGMENTED = 4, F_TRIMMED = 6,
32 F_HIBYTE32 = 8, F_TRIMMED32 = 10, F_SEGMENTED32 = 12,
33 F_MANYTOONE = 13 };
34 enum { USE_BEST_UNICODE_TABLE = -2 };
35
36 int parse_header(ErrorHandler *);
37 int best_unicode_table() const { return _best_unicode_table; }
38 int first_table(int platform, int encoding) const;
39 int check_table(int t, ErrorHandler * = 0) const;
40 Glyph map_table(int t, uint32_t, ErrorHandler * = 0) const;
41 void dump_table(int t, Vector<std::pair<uint32_t, Glyph> > &ugp, ErrorHandler * = 0) const;
42 inline const uint8_t* table_data(int t) const;
43
44 };
45
46
47 inline Glyph Cmap::map_uni(uint32_t c) const {
48 return map_table(USE_BEST_UNICODE_TABLE, c, ErrorHandler::default_handler());
49 }
50
51 inline void Cmap::unmap_all(Vector<std::pair<uint32_t, Glyph> > &ugp) const {
52 dump_table(USE_BEST_UNICODE_TABLE, ugp, ErrorHandler::default_handler());
53 }
54
55 inline const uint8_t* Cmap::table_data(int t) const {
56 const uint8_t* data = _str.udata();
57 return data + Data::u32_aligned(data + HEADER_SIZE + t * ENCODING_SIZE + 4);
58 }
59
60 }}
61 #endif