summaryrefslogtreecommitdiff
path: root/Build/source/utils/lcdf-typetools/otftotfm/secondary.hh
blob: a4abd36f35299b416a115a5d44d971dcd6b3482b (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef OTFTOTFM_SECONDARY_HH
#define OTFTOTFM_SECONDARY_HH
#include <efont/otfcmap.hh>
#include <efont/cff.hh>
class Metrics;
class Transform;
struct Setting;
namespace Efont { class TrueTypeBoundsCharstringProgram; }

struct FontInfo {
    
    const Efont::OpenType::Font *otf;
    const Efont::OpenType::Cmap *cmap;
    
    Efont::Cff *cff_file;
    const Efont::Cff::Font *cff;
    
    const Efont::OpenType::Post *post;
    const Efont::OpenType::Name *name;
    
    FontInfo(const Efont::OpenType::Font *otf, ErrorHandler *);
    ~FontInfo();

    bool ok() const;
    
    int nglyphs() const			{ return _nglyphs; }
    bool glyph_names(Vector<PermString> &) const;
    int glyphid(PermString) const;
    const Efont::CharstringProgram *program() const;
    
    bool is_fixed_pitch() const;
    double italic_angle() const;
    
    String family_name() const;
    String postscript_name() const;

  private:

    int _nglyphs;
    mutable Vector<PermString> _glyph_names;
    mutable bool _got_glyph_names;
    mutable Vector<uint32_t> _unicodes;
    mutable Efont::TrueTypeBoundsCharstringProgram *_ttb_program;

};

class Secondary { public:
    Secondary()				: _next(0) { }
    virtual ~Secondary();
    void set_next(Secondary *s)		{ _next = s; }
    typedef Efont::OpenType::Glyph Glyph;
    virtual bool encode_uni(int code, PermString name, uint32_t uni, Metrics &, ErrorHandler *);
    virtual bool setting(uint32_t uni, Vector<Setting> &, Metrics &, ErrorHandler *);
  private:
    Secondary *_next;
};

class T1Secondary : public Secondary { public:
    T1Secondary(const FontInfo &, const String &font_name, const String &otf_file_name);
    bool encode_uni(int code, PermString name, uint32_t uni, Metrics &, ErrorHandler *);
    bool setting(uint32_t uni, Vector<Setting> &, Metrics &, ErrorHandler *);
  private:
    const FontInfo &_finfo;
    String _font_name;
    String _otf_file_name;
    int _xheight;
    int _spacewidth;
    bool char_setting(Vector<Setting> &, Metrics &, int uni, ...);
    enum { J_NODOT = -1031892 /* unlikely value */ };
    int dotlessj_font(Metrics &, ErrorHandler *, Glyph &dj_glyph);
};

bool char_bounds(int bounds[4], int &width, const FontInfo &,
		 const Transform &, uint32_t uni);

int char_one_bound(const FontInfo &, const Transform &,
		   int dimen, bool max, int best, uint32_t uni, ...);

#endif