File: otfcmap.hh

package info (click to toggle)
lcdf-typetools 2.92%2Bdfsg1-0.1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,884 kB
  • sloc: cpp: 34,407; ansic: 2,106; sh: 1,032; makefile: 306
file content (54 lines) | stat: -rw-r--r-- 1,544 bytes parent folder | download | duplicates (6)
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
// -*- 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;
    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 };

    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 Glyph Cmap::map_uni(uint32_t c) const
{
    return map_table(first_unicode_table(), c, ErrorHandler::default_handler());
}

inline void Cmap::unmap_all(Vector<uint32_t> &g2c) const
{
    dump_table(first_unicode_table(), g2c, ErrorHandler::default_handler());
}

}}
#endif