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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
// -*- related-file-name: "../../libefont/amfm.cc" -*-
#ifndef EFONT_AMFM_HH
#define EFONT_AMFM_HH
#include <efont/metrics.hh>
#include <efont/t1mm.hh>
#include <lcdf/hashmap.hh>
class Slurper;
class Filename;
class ErrorHandler;
namespace Efont {
class AfmParser;
class MetricsFinder;
class Type1Charstring;
struct AmfmMaster {
PermString font_name;
PermString family;
PermString full_name;
PermString version;
Vector<double> weight_vector;
bool loaded;
Metrics *afm;
AmfmMaster() : loaded(0), afm(0) { }
};
struct AmfmPrimaryFont {
Vector<int> design_vector;
Vector<PermString> labels;
PermString name;
AmfmPrimaryFont *next;
};
class AmfmMetrics { public:
AmfmMetrics(MetricsFinder *);
~AmfmMetrics();
void use() { _uses++; }
void unuse() { if (--_uses == 0) delete this; }
bool sanity(ErrorHandler *) const;
double fd(int i) const { return _fdv[i]; }
double &fd(int i) { return _fdv[i]; }
PermString font_name() const { return _font_name; }
PermString directory() const { return _directory; }
int naxes() const { return _naxes; }
int nmasters() const { return _nmasters; }
MultipleMasterSpace *mmspace() const { return _mmspace; }
int primary_label_value(int, PermString) const;
Metrics *interpolate(const Vector<double> &design,
const Vector<double> &weight, ErrorHandler *);
private:
MetricsFinder *_finder;
PermString _directory;
Vector<double> _fdv;
PermString _font_name;
PermString _family;
PermString _full_name;
PermString _weight;
PermString _version;
PermString _notice;
Vector<PermString> _opening_comments;
PermString _encoding_scheme;
Vector<double> _weight_vector;
int _nmasters;
int _naxes;
AmfmMaster *_masters;
MultipleMasterSpace *_mmspace;
AmfmPrimaryFont *_primary_fonts;
Metrics *_sanity_afm;
unsigned _uses;
friend class AmfmReader;
AmfmMetrics(const AmfmMetrics &) { assert(0); }
AmfmMetrics &operator=(const AmfmMetrics &) { assert(0); return *this; }
AmfmPrimaryFont *find_primary_font(const Vector<double> &design) const;
Metrics *master(int, ErrorHandler *);
};
class AmfmReader { public:
static AmfmMetrics *read(const Filename &, MetricsFinder *, ErrorHandler*);
static AmfmMetrics *read(Slurper &, MetricsFinder *, ErrorHandler *);
static void add_amcp_file(Slurper &, AmfmMetrics *, ErrorHandler *);
private:
typedef Vector<double> NumVector;
AmfmMetrics *_amfm;
MetricsFinder *_finder;
AfmParser &_l;
MultipleMasterSpace *_mmspace;
ErrorHandler *_errh;
double &fd(int i) const { return _amfm->fd(i); }
int naxes() const { return _amfm->_naxes; }
int nmasters() const { return _amfm->_nmasters; }
void check_mmspace();
void lwarning(const char *, ...) const;
void lerror(const char *, ...) const;
void no_match_warning(const char *context = 0) const;
bool read_simple_array(Vector<double> &) const;
void read_positions() const;
void read_normalize() const;
void read_axis_types() const;
void read_axis(int axis) const;
void read_master(int master) const;
void read_primary_fonts() const;
void read_one_primary_font() const;
void read_conversion_programs() const;
bool read();
void read_amcp_file();
AmfmReader(AfmParser &, AmfmMetrics *, ErrorHandler *);
};
}
#endif
|