summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfpost.hh
blob: 57564efc6a39f3bf618073d1ef61d512f16f4f2a (plain)
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
// -*- related-file-name: "../../libefont/otfpost.cc" -*-
#ifndef EFONT_OTFPOST_HH
#define EFONT_OTFPOST_HH
#include <efont/otfdata.hh>
#include <lcdf/error.hh>
namespace Efont { namespace OpenType {

class Post { public:

    Post(const String &, ErrorHandler * = 0);
    // default destructor

    bool ok() const                     { return _error >= 0; }
    int error() const                   { return _error; }

    double italic_angle() const;
    bool is_fixed_pitch() const;
    inline int underline_position() const;
    inline int underline_thickness() const;
    inline uint32_t mem_type42(bool ismax) const;
    int nglyphs() const                 { return _nglyphs; }
    bool glyph_names(Vector<PermString> &gnames) const;

  private:

    Data _str;
    int _error;
    uint32_t _version;
    int _nglyphs;
    Vector<int> _extend_glyph_names;

    enum { HEADER_SIZE = 32, N_MAC_GLYPHS = 258 };
    int parse_header(ErrorHandler *);

};

inline int
Post::underline_position() const
{
    // NB: "This is the suggested distance of the top of the underline from
    // the baseline (negative values indicate below baseline).  The PostScript
    // definition of this FontInfo dictionary key (the y coordinate of the
    // center of the stroke) is not used for historical reasons. The value of
    // the PostScript key may be calculated by subtracting half the
    // underlineThickness from the value of this field." -- OpenType spec
    return ok() ? _str.s16(8) : 0;
}

inline int
Post::underline_thickness() const
{
    return ok() ? _str.s16(10) : 0;
}

inline uint32_t
Post::mem_type42(bool ismax) const
{
    return ok() ? _str.u32(ismax ? 20 : 16) : 0;
}

}}
#endif