Debian Codegraph @

texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.hh

raw
1 #ifndef OTFTOTFM_DVIPSENCODING_HH
2 #define OTFTOTFM_DVIPSENCODING_HH
3 #include <efont/otfcmap.hh>
4 #include <efont/cff.hh>
5 #include <lcdf/hashmap.hh>
6 class Metrics;
7 class Secondary;
8 struct FontInfo;
9
10 class DvipsEncoding { public:
11
12 DvipsEncoding();
13
14 static void add_glyphlist(String);
15
16 operator bool() const { return _e.size() > 0; }
17 const String &name() const { return _name; }
18 const String &filename() const { return _filename; }
19 int boundary_char() const { return _boundary_char; }
20 const String &coding_scheme() const { return _coding_scheme; }
21 void set_coding_scheme(const String &s) { _coding_scheme = s; }
22 void set_warn_missing(bool wm) { _warn_missing = wm; }
23
24 void encode(int, PermString);
25 inline int encoding_of(PermString) const;
26 int encoding_of(PermString, bool encode);
27 inline bool encoded(int e) const;
28 inline PermString encoding(int e) const;
29 int encoding_size() const { return _e.size(); }
30
31 int parse(String filename, bool ignore_ligkern, bool ignore_other, ErrorHandler *);
32 int parse_ligkern(const String &ligkern_text, int override, ErrorHandler *);
33 int parse_position(const String &ligkern_text, int override, ErrorHandler *);
34 int parse_unicoding(const String &unicoding_text, int override, ErrorHandler *);
35
36 bool file_had_ligkern() const { return _file_had_ligkern; }
37
38 // also modifies 'this':
39 void make_metrics(Metrics &, const FontInfo &, Secondary *, bool literal, ErrorHandler *);
40 void make_base_mappings(Vector<int> &mappings, const FontInfo &);
41
42 void apply_ligkern_lig(Metrics &, ErrorHandler *) const;
43 void apply_ligkern_kern(Metrics &, ErrorHandler *) const;
44 void apply_position(Metrics &, ErrorHandler *) const;
45
46 enum { JT_KERN = 32, JT_LIG = 64, JT_ADDLIG = 128, JT_LIGALL = 199,
47 JL_LIG = JT_LIG | JT_ADDLIG, JL_CLIG = JL_LIG | 1,
48 JL_CLIG_S = JL_LIG | 2, JL_LIGC = JL_LIG | 3,
49 JL_LIGC_S = JL_LIG | 4, JL_CLIGC = JL_LIG | 5,
50 JL_CLIGC_S = JL_LIG | 6, JL_CLIGC_SS = JL_LIG | 7,
51 JT_NOLIGKERN = JT_KERN | JT_LIG,
52 J_ALL = 0x7FFFFFFF }; // also see nokern_names in dvipsencoding.cc
53
54 private:
55
56 struct Ligature {
57 int c1, c2, join, k, d;
58 };
59
60 Vector<PermString> _e;
61 Vector<bool> _encoding_required;
62 int _boundary_char;
63 int _altselector_char;
64
65 Vector<Ligature> _lig;
66 Vector<Ligature> _pos;
67 HashMap<PermString, int> _unicoding_map;
68 Vector<uint32_t> _unicoding;
69
70 mutable Vector<uint32_t> _unicodes;
71
72 String _name;
73 String _filename;
74 String _printable_filename;
75 String _coding_scheme;
76 String _initial_comment;
77 String _final_text;
78 bool _file_had_ligkern;
79 bool _warn_missing;
80
81 struct WordType {
82 const char *name;
83 int (DvipsEncoding::*parsefunc)(Vector<String>&, int, ErrorHandler*);
84 };
85 static const WordType word_types[];
86 enum { WT_LIGKERN = 0, WT_POSITION, WT_UNICODING };
87
88 void add_ligkern(const Ligature &, int override);
89 enum { EPARSE = 90000 };
90 int parse_ligkern_words(Vector<String> &, int override, ErrorHandler *);
91 int parse_position_words(Vector<String> &, int override, ErrorHandler *);
92 int parse_unicoding_words(Vector<String> &, int override, ErrorHandler *);
93 void parse_word_group(Vector<String> &, int override, int wt, ErrorHandler *);
94 int parse_words(const String &, int override, int wt, ErrorHandler *);
95 void bad_codepoint(int, Metrics &, HashMap<PermString, int> &bad_unicodes);
96 bool x_unicodes(PermString chname, Vector<uint32_t> &unicodes) const;
97 String landmark(int line) const;
98
99 static PermString dot_notdef;
100
101 static bool glyphname_unicode(String, Vector<uint32_t> &);
102
103 friend inline bool operator==(const Ligature&, const Ligature&);
104
105 };
106
107 inline bool
108 DvipsEncoding::encoded(int e) const
109 {
110 return e >= 0 && e < _e.size() && _e[e] != dot_notdef;
111 }
112
113 inline PermString
114 DvipsEncoding::encoding(int e) const
115 {
116 if (encoded(e))
117 return _e[e];
118 else
119 return PermString();
120 }
121
122 inline int
123 DvipsEncoding::encoding_of(PermString what) const
124 {
125 return const_cast<DvipsEncoding *>(this)->encoding_of(what, false);
126 }
127
128 #endif