w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Font.hpp
Go to the documentation of this file.
1 /*************************************************************************
2 ** Font.hpp **
3 ** **
4 ** This file is part of dvisvgm -- a fast DVI to SVG converter **
5 ** Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de> **
6 ** **
7 ** This program is free software; you can redistribute it and/or **
8 ** modify it under the terms of the GNU General Public License as **
9 ** published by the Free Software Foundation; either version 3 of **
10 ** the License, or (at your option) any later version. **
11 ** **
12 ** This program is distributed in the hope that it will be useful, but **
13 ** WITHOUT ANY WARRANTY; without even the implied warranty of **
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
15 ** GNU General Public License for more details. **
16 ** **
17 ** You should have received a copy of the GNU General Public License **
18 ** along with this program; if not, see <http://www.gnu.org/licenses/>. **
19 *************************************************************************/
20 
21 #ifndef FONT_HPP
22 #define FONT_HPP
23 
24 #include <memory>
25 #include <string>
26 #include <unordered_map>
27 #include <vector>
28 #include "Character.hpp"
29 #include "CharMapID.hpp"
30 #include "Color.hpp"
31 #include "FontCache.hpp"
32 #include "FontEncoding.hpp"
33 #include "FontMap.hpp"
34 #include "FontMetrics.hpp"
35 #include "GFGlyphTracer.hpp"
36 #include "Glyph.hpp"
37 #include "GraphicsPath.hpp"
38 #include "MessageException.hpp"
39 #include "RangeMap.hpp"
40 #include "ToUnicodeMap.hpp"
41 #include "VFActions.hpp"
42 #include "VFReader.hpp"
43 #include "utility.hpp"
44 
45 struct FontStyle;
46 
47 struct GlyphMetrics {
48  GlyphMetrics () : wl(0), wr(0), h(0), d(0) {}
49  GlyphMetrics (double wwl, double wwr, double hh, double dd) : wl(wwl), wr(wwr), h(hh), d(dd) {}
50  double wl, wr, h, d;
51 };
52 
53 
54 /** Abstract base for all font classes. */
55 class Font {
56  public:
57  virtual ~Font () =default;
58  virtual std::unique_ptr<Font> clone (double ds, double sc) const =0;
59  virtual const Font* uniqueFont () const =0;
60  virtual std::string name () const =0;
61  virtual double designSize () const =0;
62  virtual double scaledSize () const =0;
63  virtual double scaleFactor () const {return scaledSize()/designSize();}
64  virtual double charWidth (int c) const =0;
65  virtual double charDepth (int c) const =0;
66  virtual double charHeight (int c) const =0;
67  virtual double italicCorr (int c) const =0;
68  virtual const FontMetrics* getMetrics () const =0;
69  virtual const char* path () const =0;
70  virtual const char* filename () const;
71  virtual const FontEncoding* encoding () const;
72  virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *callback=nullptr) const =0;
73  virtual void getGlyphMetrics (int c, bool vertical, GlyphMetrics &metrics) const;
74  virtual uint32_t unicode (uint32_t c) const;
75  virtual void tidy () const {}
76  virtual bool findAndAssignBaseFontMap () {return true;}
77  virtual bool verticalLayout () const {return getMetrics() ? getMetrics()->verticalLayout() : false;}
78  virtual bool verifyChecksums () const {return true;}
79  virtual int fontIndex () const {return 0;}
80  virtual const FontStyle* style () const {return nullptr;}
81  virtual Color color () const {return Color::BLACK;}
82  virtual const FontMap::Entry* fontMapEntry () const;
83 };
84 
85 
86 /** Empty font without any glyphs. Instances of this class are used
87  * if no physical or virtual font file can be found.
88  * The metric values returned by the member functions are based on cmr10. */
89 class EmptyFont : public Font {
90  public:
92  std::unique_ptr<Font> clone (double ds, double sc) const override {return util::make_unique<EmptyFont>(*this);}
93  const Font* uniqueFont () const override {return this;}
94  std::string name () const override {return _fontname;}
95  double designSize () const override {return 10;} // cmr10 design size in pt
96  double scaledSize () const override {return 10;} // cmr10 scaled size in pt
97  double charWidth (int c) const override {return 9.164;} // width of cmr10's 'M' in pt
98  double charHeight (int c) const override {return 6.833;} // height of cmr10's 'M' in pt
99  double charDepth (int c) const override {return 0;}
100  double italicCorr (int c) const override {return 0;}
101  const FontMetrics* getMetrics () const override {return nullptr;}
102  const char* path () const override {return nullptr;}
103  bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override {return false;}
104 
105  private:
107 };
108 
109 
110 /** Interface for all physical fonts. */
111 class PhysicalFont : public virtual Font {
112  public:
113  enum class Type {MF, OTF, PFB, TTC, TTF, UNKNOWN};
114 
115  static std::unique_ptr<Font> create (const std::string &name, uint32_t checksum, double dsize, double ssize, PhysicalFont::Type type);
116  static std::unique_ptr<Font> create (const std::string &name, int fontindex, uint32_t checksum, double dsize, double ssize);
117  virtual Type type () const =0;
118  bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override;
119  virtual bool getExactGlyphBox (int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb=nullptr) const;
120  virtual bool getExactGlyphBox (int c, GlyphMetrics &metrics, bool vertical, GFGlyphTracer::Callback *cb=nullptr) const;
121  virtual bool isCIDFont () const;
122  virtual int hAdvance () const;
123  virtual std::string familyName () const;
124  virtual std::string styleName () const;
125  virtual double hAdvance (int c) const;
126  virtual double vAdvance (int c) const;
127  std::string glyphName (int c) const;
128  virtual int unitsPerEm () const;
129  virtual double scaledAscent () const;
130  virtual int ascent () const;
131  virtual int descent () const;
132  virtual int traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb=nullptr) const;
133  virtual int collectCharMapIDs (std::vector<CharMapID> &charmapIDs) const;
134  virtual CharMapID getCharMapID () const =0;
135  virtual void setCharMapID (const CharMapID &id) {}
136  virtual Character decodeChar (uint32_t c) const;
137  const char* path () const override;
138 
139  protected:
140  bool createGF (std::string &gfname) const;
141 
142  public:
143  static bool EXACT_BBOX;
144  static bool KEEP_TEMP_FILES;
145  static std::string CACHE_PATH; ///< path to cache directory ("" if caching is disabled)
146  static double METAFONT_MAG; ///< magnification factor for Metafont calls
147 
148  protected:
150 };
151 
152 
153 /** Interface for all virtual fonts. */
154 class VirtualFont : public virtual Font {
155  friend class FontManager;
156  public:
157  using DVIVector = std::vector<uint8_t>;
158 
159  public:
160  static std::unique_ptr<Font> create (const std::string &name, uint32_t checksum, double dsize, double ssize);
161  virtual const DVIVector* getDVI (int c) const =0;
162  bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override {return false;}
163 
164  protected:
165  virtual void assignChar (uint32_t c, DVIVector &&dvi) =0;
166 };
167 
168 
169 class TFMFont : public virtual Font {
170  public:
171  TFMFont (std::string name, uint32_t cs, double ds, double ss);
172  const FontMetrics* getMetrics () const override;
173  std::string name () const override {return _fontname;}
174  double designSize () const override {return _dsize;}
175  double scaledSize () const override {return _ssize;}
176  double charWidth (int c) const override;
177  double charDepth (int c) const override;
178  double charHeight (int c) const override;
179  double italicCorr (int c) const override;
180  bool verifyChecksums () const override;
181 
182  private:
183  mutable std::unique_ptr<FontMetrics> _metrics;
185  uint32_t _checksum; ///< cheksum to be compared with TFM checksum
186  double _dsize; ///< design size in PS point units
187  double _ssize; ///< scaled size in PS point units
188 };
189 
190 
192  friend class PhysicalFontImpl;
193  public:
194  std::unique_ptr<Font> clone (double ds, double sc) const override {
195  return std::unique_ptr<PhysicalFontProxy>(new PhysicalFontProxy(*this, ds, sc));
196  }
197 
198  const Font* uniqueFont () const override {return _pf;}
199  std::string name () const override {return _pf->name();}
200  double designSize () const override {return _dsize;}
201  double scaledSize () const override {return _ssize;}
202  double charWidth (int c) const override {return _pf->charWidth(c);}
203  double charDepth (int c) const override {return _pf->charDepth(c);}
204  double charHeight (int c) const override {return _pf->charHeight(c);}
205  double italicCorr (int c) const override {return _pf->italicCorr(c);}
206  const FontMetrics* getMetrics () const override {return _pf->getMetrics();}
207  Type type () const override {return _pf->type();}
208  uint32_t unicode (uint32_t c) const override {return _pf->unicode(c);}
209  int fontIndex () const override {return _pf->fontIndex();}
210  const FontStyle* style () const override {return _pf->style();}
211  const FontMap::Entry* fontMapEntry () const override {return _pf->fontMapEntry();}
212  const FontEncoding* encoding () const override {return _pf->encoding();}
213  CharMapID getCharMapID () const override {return _pf->getCharMapID();}
214  int collectCharMapIDs (std::vector<CharMapID> &charmapIDs) const override {return _pf->collectCharMapIDs(charmapIDs);}
215 
216  protected:
217  PhysicalFontProxy (const PhysicalFont *font, double ds, double ss) : _pf(font), _dsize(ds), _ssize(ss) {}
218  PhysicalFontProxy (const PhysicalFontProxy &proxy, double ds, double ss) : _pf(proxy._pf), _dsize(ds), _ssize(ss) {}
219 
220  private:
222  double _dsize; ///< design size in PS point units
223  double _ssize; ///< scaled size in PS point units
224 };
225 
226 
227 class PhysicalFontImpl : public PhysicalFont, public TFMFont {
228  friend class PhysicalFont;
229  public:
230  ~PhysicalFontImpl () override;
231 
232  std::unique_ptr<Font> clone (double ds, double ss) const override {
233  return std::unique_ptr<PhysicalFontProxy>(new PhysicalFontProxy(this, ds, ss));
234  }
235 
236  const Font* uniqueFont () const override {return this;}
237  Type type () const override {return _filetype;}
238  int fontIndex() const override {return _fontIndex;}
239  const FontStyle* style () const override;
240  const FontEncoding* encoding () const override;
241  uint32_t unicode (uint32_t c) const override;
242  bool findAndAssignBaseFontMap () override;
243  void tidy () const override;
244  CharMapID getCharMapID () const override {return _charmapID;}
245 
246  protected:
247  PhysicalFontImpl (const std::string &name, int fontindex, uint32_t checksum, double dsize, double ssize, PhysicalFont::Type type);
248 
249  private:
253  CharMapID _charmapID; ///< ID of the font's charmap to use
254  std::unique_ptr<const RangeMap> _localCharMap;
255 };
256 
257 
258 class NativeFont : public PhysicalFont {
259  public:
260  virtual std::unique_ptr<NativeFont> clone (double ptsize, const FontStyle &style, Color color) const =0;
261  std::unique_ptr<Font> clone (double ds, double sc) const override =0;
262  std::string name () const override;
263  Type type () const override;
264  double designSize () const override {return _ptsize;}
265  double scaledSize () const override {return _ptsize;}
266  double charWidth (int c) const override;
267  double charDepth (int c) const override;
268  double charHeight (int c) const override;
269  double italicCorr (int c) const override;
270  const FontMetrics* getMetrics () const override {return nullptr;}
271  const FontStyle* style () const override {return &_style;}
272  Color color () const override {return _color;}
273  const FontMap::Entry* fontMapEntry () const override {return nullptr;}
274  static std::string uniqueName (const std::string &path, const FontStyle &style);
275 
276  protected:
278 
279  private:
280  double _ptsize; ///< font size in PS point units
283 };
284 
285 
286 class NativeFontProxy : public NativeFont {
287  friend class NativeFontImpl;
288  public:
289  std::unique_ptr<NativeFont> clone (double ptsize, const FontStyle &style, Color color) const override {
290  return std::unique_ptr<NativeFontProxy>(new NativeFontProxy(this, ptsize, style, color));
291  }
292 
293  std::unique_ptr<Font> clone (double ds, double sc) const override {
294  return std::unique_ptr<NativeFontProxy>(new NativeFontProxy(this , sc, *style(), color()));
295  }
296 
297  const Font* uniqueFont () const override {return _nfont;}
298  const char* path () const override {return _nfont->path();}
299  int fontIndex () const override {return _nfont->fontIndex();}
300  Character decodeChar (uint32_t c) const override {return _nfont->decodeChar(c);}
301  uint32_t unicode (uint32_t c) const override {return _nfont->unicode(c);}
302  CharMapID getCharMapID () const override {return _nfont->getCharMapID();}
303 
304  protected:
305  NativeFontProxy (const NativeFont *nfont, double ptsize, const FontStyle &style, Color color)
306  : NativeFont(ptsize, style, color), _nfont(nfont) {}
307 
308  private:
310 };
311 
312 
313 class NativeFontImpl : public NativeFont {
314  public:
317 
318  std::unique_ptr<NativeFont> clone (double ptsize, const FontStyle &style, Color color) const override {
319  return std::unique_ptr<NativeFontProxy>(new NativeFontProxy(this, ptsize, style, color));
320  }
321 
322  std::unique_ptr<Font> clone (double ds, double sc) const override {
323  return std::unique_ptr<NativeFontProxy>(new NativeFontProxy(this , sc, *style(), color()));
324  }
325 
326  const Font* uniqueFont () const override {return this;}
327  const char* path () const override {return _path.c_str();}
328  int fontIndex() const override {return _fontIndex;}
330  bool findAndAssignBaseFontMap () override;
331  CharMapID getCharMapID () const override {return CharMapID::NONE;}
332  Character decodeChar (uint32_t c) const override;
333  uint32_t unicode (uint32_t c) const override;
334 
335  private:
338  ToUnicodeMap _toUnicodeMap; ///< maps from char indexes to unicode points
339 };
340 
341 
343  friend class VirtualFontImpl;
344  public:
345  std::unique_ptr<Font> clone (double ds, double ss) const override {
346  return std::unique_ptr<VirtualFontProxy>(new VirtualFontProxy(*this, ds, ss));
347  }
348 
349  const Font* uniqueFont () const override {return _vf;}
350  std::string name () const override {return _vf->name();}
351  const DVIVector* getDVI (int c) const override {return _vf->getDVI(c);}
352  double designSize () const override {return _dsize;}
353  double scaledSize () const override {return _ssize;}
354  double charWidth (int c) const override {return _vf->charWidth(c);}
355  double charDepth (int c) const override {return _vf->charDepth(c);}
356  double charHeight (int c) const override {return _vf->charHeight(c);}
357  double italicCorr (int c) const override {return _vf->italicCorr(c);}
358  const FontMetrics* getMetrics () const override {return _vf->getMetrics();}
359  const char* path () const override {return _vf->path();}
360 
361  protected:
362  VirtualFontProxy (const VirtualFont *font, double ds, double ss) : _vf(font), _dsize(ds), _ssize(ss) {}
363  VirtualFontProxy (const VirtualFontProxy &proxy, double ds, double ss) : _vf(proxy._vf), _dsize(ds), _ssize(ss) {}
364  void assignChar (uint32_t c, DVIVector &&dvi) override {}
365 
366  private:
367  const VirtualFont *_vf;
368  double _dsize; ///< design size in PS point units
369  double _ssize; ///< scaled size in PS point units
370 };
371 
372 
373 class VirtualFontImpl : public VirtualFont, public TFMFont {
374  friend class VirtualFont;
375  public:
376  std::unique_ptr<Font> clone (double ds, double ss) const override {
377  return std::unique_ptr<VirtualFontProxy>(new VirtualFontProxy(this, ds, ss));
378  }
379 
380  const Font* uniqueFont () const override {return this;}
381  const DVIVector* getDVI (int c) const override;
382  const char* path () const override;
383 
384  protected:
385  VirtualFontImpl (const std::string &name, uint32_t checksum, double dsize, double ssize);
386  void assignChar (uint32_t c, DVIVector &&dvi) override;
387 
388  private:
389  std::unordered_map<uint32_t, DVIVector> _charDefs; ///< dvi subroutines defining the characters
390 };
391 
392 
395 };
396 
397 #endif
#define sc
Definition: aptex-macros.h:57
unsigned long Glyph
EmptyFont(std::string name)
Definition: Font.hpp:91
double charWidth(int c) const override
Definition: Font.hpp:97
double charHeight(int c) const override
Definition: Font.hpp:98
std::unique_ptr< Font > clone(double ds, double sc) const override
Definition: Font.hpp:92
double italicCorr(int c) const override
Definition: Font.hpp:100
std::string name() const override
Definition: Font.hpp:94
const FontMetrics * getMetrics() const override
Definition: Font.hpp:101
const char * path() const override
Definition: Font.hpp:102
double charDepth(int c) const override
Definition: Font.hpp:99
bool getGlyph(int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override
Definition: Font.hpp:103
std::string _fontname
Definition: Font.hpp:106
double designSize() const override
Definition: Font.hpp:95
double scaledSize() const override
Definition: Font.hpp:96
const Font * uniqueFont() const override
Definition: Font.hpp:93
Definition: Font.hpp:55
virtual double charWidth(int c) const =0
virtual double charDepth(int c) const =0
virtual const char * path() const =0
virtual const Font * uniqueFont() const =0
virtual double scaledSize() const =0
virtual const char * filename() const
Definition: Font.cpp:93
virtual const FontMetrics * getMetrics() const =0
virtual double designSize() const =0
virtual std::string name() const =0
virtual int fontIndex() const
Definition: Font.hpp:79
virtual bool findAndAssignBaseFontMap()
Definition: Font.hpp:76
virtual double italicCorr(int c) const =0
virtual double scaleFactor() const
Definition: Font.hpp:63
virtual bool verifyChecksums() const
Definition: Font.hpp:78
virtual std::unique_ptr< Font > clone(double ds, double sc) const =0
virtual ~Font()=default
virtual void getGlyphMetrics(int c, bool vertical, GlyphMetrics &metrics) const
Definition: Font.cpp:68
virtual const FontStyle * style() const
Definition: Font.hpp:80
virtual const FontMap::Entry * fontMapEntry() const
Definition: Font.cpp:55
virtual void tidy() const
Definition: Font.hpp:75
virtual Color color() const
Definition: Font.hpp:81
virtual bool verticalLayout() const
Definition: Font.hpp:77
virtual double charHeight(int c) const =0
virtual uint32_t unicode(uint32_t c) const
Definition: Font.cpp:41
virtual const FontEncoding * encoding() const
Definition: Font.cpp:48
virtual bool getGlyph(int c, Glyph &glyph, GFGlyphTracer::Callback *callback=nullptr) const =0
CharMapID getCharMapID() const override
Definition: Font.hpp:331
int _fontIndex
Definition: Font.hpp:337
int fontIndex() const override
Definition: Font.hpp:328
const Font * uniqueFont() const override
Definition: Font.hpp:326
const char * path() const override
Definition: Font.hpp:327
bool findAndAssignBaseFontMap() override
Definition: Font.cpp:635
std::unique_ptr< NativeFont > clone(double ptsize, const FontStyle &style, Color color) const override
Definition: Font.hpp:318
ToUnicodeMap _toUnicodeMap
maps from char indexes to unicode points
Definition: Font.hpp:338
std::string fontFamily() const
Character decodeChar(uint32_t c) const override
Definition: Font.cpp:646
std::unique_ptr< Font > clone(double ds, double sc) const override
Definition: Font.hpp:322
std::string _path
Definition: Font.hpp:336
NativeFontImpl(std::string fname, int fontIndex, double ptsize, const FontStyle &style, Color color)
Definition: Font.hpp:315
uint32_t unicode(uint32_t c) const override
Definition: Font.cpp:651
std::unique_ptr< NativeFont > clone(double ptsize, const FontStyle &style, Color color) const override
Definition: Font.hpp:289
int fontIndex() const override
Definition: Font.hpp:299
std::unique_ptr< Font > clone(double ds, double sc) const override
Definition: Font.hpp:293
Character decodeChar(uint32_t c) const override
Definition: Font.hpp:300
NativeFontProxy(const NativeFont *nfont, double ptsize, const FontStyle &style, Color color)
Definition: Font.hpp:305
const NativeFont * _nfont
Definition: Font.hpp:309
const Font * uniqueFont() const override
Definition: Font.hpp:297
CharMapID getCharMapID() const override
Definition: Font.hpp:302
uint32_t unicode(uint32_t c) const override
Definition: Font.hpp:301
const char * path() const override
Definition: Font.hpp:298
static std::string uniqueName(const std::string &path, const FontStyle &style)
Definition: Font.cpp:570
double charWidth(int c) const override
Definition: Font.cpp:607
std::unique_ptr< Font > clone(double ds, double sc) const override=0
double scaledSize() const override
Definition: Font.hpp:265
const FontStyle * style() const override
Definition: Font.hpp:271
const FontMap::Entry * fontMapEntry() const override
Definition: Font.hpp:273
const FontMetrics * getMetrics() const override
Definition: Font.hpp:270
double _ptsize
font size in PS point units
Definition: Font.hpp:280
double italicCorr(int c) const override
Definition: Font.cpp:614
double designSize() const override
Definition: Font.hpp:264
std::string name() const override
Definition: Font.cpp:586
Type type() const override
Definition: Font.cpp:591
double charHeight(int c) const override
Definition: Font.cpp:621
FontStyle _style
Definition: Font.hpp:281
NativeFont(double ptsize, const FontStyle &style, Color color)
Definition: Font.hpp:277
double charDepth(int c) const override
Definition: Font.cpp:628
virtual std::unique_ptr< NativeFont > clone(double ptsize, const FontStyle &style, Color color) const =0
Color color() const override
Definition: Font.hpp:272
Color _color
Definition: Font.hpp:282
const Font * uniqueFont() const override
Definition: Font.hpp:236
void tidy() const override
Definition: Font.cpp:558
FontEncodingPair _encodingPair
Definition: Font.hpp:252
std::unique_ptr< const RangeMap > _localCharMap
Definition: Font.hpp:254
const FontEncoding * encoding() const override
Definition: Font.cpp:489
Type _filetype
Definition: Font.hpp:250
int fontIndex() const override
Definition: Font.hpp:238
CharMapID getCharMapID() const override
Definition: Font.hpp:244
Type type() const override
Definition: Font.hpp:237
std::unique_ptr< Font > clone(double ds, double ss) const override
Definition: Font.hpp:232
CharMapID _charmapID
ID of the font's charmap to use.
Definition: Font.hpp:253
const FontStyle * style() const override
Definition: Font.cpp:550
~PhysicalFontImpl() override
Definition: Font.cpp:481
uint32_t unicode(uint32_t c) const override
Definition: Font.cpp:519
PhysicalFontImpl(const std::string &name, int fontindex, uint32_t checksum, double dsize, double ssize, PhysicalFont::Type type)
Definition: Font.cpp:474
bool findAndAssignBaseFontMap() override
Definition: Font.cpp:496
PhysicalFontProxy(const PhysicalFont *font, double ds, double ss)
Definition: Font.hpp:217
double _dsize
design size in PS point units
Definition: Font.hpp:222
double charDepth(int c) const override
Definition: Font.hpp:203
double charWidth(int c) const override
Definition: Font.hpp:202
double charHeight(int c) const override
Definition: Font.hpp:204
const FontMap::Entry * fontMapEntry() const override
Definition: Font.hpp:211
double scaledSize() const override
Definition: Font.hpp:201
double _ssize
scaled size in PS point units
Definition: Font.hpp:223
int fontIndex() const override
Definition: Font.hpp:209
const Font * uniqueFont() const override
Definition: Font.hpp:198
std::string name() const override
Definition: Font.hpp:199
Type type() const override
Definition: Font.hpp:207
double italicCorr(int c) const override
Definition: Font.hpp:205
double designSize() const override
Definition: Font.hpp:200
CharMapID getCharMapID() const override
Definition: Font.hpp:213
uint32_t unicode(uint32_t c) const override
Definition: Font.hpp:208
std::unique_ptr< Font > clone(double ds, double sc) const override
Definition: Font.hpp:194
int collectCharMapIDs(std::vector< CharMapID > &charmapIDs) const override
Definition: Font.hpp:214
const FontEncoding * encoding() const override
Definition: Font.hpp:212
const FontStyle * style() const override
Definition: Font.hpp:210
PhysicalFontProxy(const PhysicalFontProxy &proxy, double ds, double ss)
Definition: Font.hpp:218
const PhysicalFont * _pf
Definition: Font.hpp:221
const FontMetrics * getMetrics() const override
Definition: Font.hpp:206
virtual int collectCharMapIDs(std::vector< CharMapID > &charmapIDs) const
Definition: Font.cpp:205
virtual Type type() const =0
virtual CharMapID getCharMapID() const =0
std::string glyphName(int c) const
Definition: Font.cpp:266
static FontCache _cache
Definition: Font.hpp:149
static std::string CACHE_PATH
path to cache directory ("" if caching is disabled)
Definition: Font.hpp:145
virtual Character decodeChar(uint32_t c) const
Definition: Font.cpp:217
bool getGlyph(int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override
Definition: Font.cpp:324
static double METAFONT_MAG
magnification factor for Metafont calls
Definition: Font.hpp:146
virtual int ascent() const
Definition: Font.cpp:283
const char * path() const override
Definition: Font.cpp:177
static bool EXACT_BBOX
Definition: Font.hpp:143
virtual int descent() const
Definition: Font.cpp:292
static bool KEEP_TEMP_FILES
Definition: Font.hpp:144
virtual std::string styleName() const
Definition: Font.cpp:309
virtual double scaledAscent() const
Definition: Font.cpp:277
virtual int unitsPerEm() const
Definition: Font.cpp:228
virtual int traceAllGlyphs(bool includeCached, GFGlyphTracer::Callback *cb=nullptr) const
Definition: Font.cpp:393
virtual bool isCIDFont() const
Definition: Font.cpp:194
virtual bool getExactGlyphBox(int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb=nullptr) const
Definition: Font.cpp:428
virtual double vAdvance(int c) const
Definition: Font.cpp:255
virtual int hAdvance() const
Definition: Font.cpp:236
virtual std::string familyName() const
Definition: Font.cpp:300
bool createGF(std::string &gfname) const
Definition: Font.cpp:372
static std::unique_ptr< Font > create(const std::string &name, uint32_t checksum, double dsize, double ssize, PhysicalFont::Type type)
Definition: Font.cpp:167
virtual void setCharMapID(const CharMapID &id)
Definition: Font.hpp:135
std::string name() const override
Definition: Font.hpp:173
double charHeight(int c) const override
Definition: Font.cpp:147
const FontMetrics * getMetrics() const override
Definition: Font.cpp:110
std::string _fontname
Definition: Font.hpp:184
std::unique_ptr< FontMetrics > _metrics
Definition: Font.hpp:183
double _ssize
scaled size in PS point units
Definition: Font.hpp:187
bool verifyChecksums() const override
Definition: Font.cpp:151
TFMFont(std::string name, uint32_t cs, double ds, double ss)
Definition: Font.cpp:102
uint32_t _checksum
cheksum to be compared with TFM checksum
Definition: Font.hpp:185
double italicCorr(int c) const override
Definition: Font.cpp:136
double scaledSize() const override
Definition: Font.hpp:175
double charWidth(int c) const override
Definition: Font.cpp:128
double _dsize
design size in PS point units
Definition: Font.hpp:186
double charDepth(int c) const override
Definition: Font.cpp:146
double designSize() const override
Definition: Font.hpp:174
const char * path() const override
Definition: Font.cpp:664
const Font * uniqueFont() const override
Definition: Font.hpp:380
void assignChar(uint32_t c, DVIVector &&dvi) override
Definition: Font.cpp:669
VirtualFontImpl(const std::string &name, uint32_t checksum, double dsize, double ssize)
Definition: Font.cpp:658
std::unique_ptr< Font > clone(double ds, double ss) const override
Definition: Font.hpp:376
const DVIVector * getDVI(int c) const override
Definition: Font.cpp:677
std::unordered_map< uint32_t, DVIVector > _charDefs
dvi subroutines defining the characters
Definition: Font.hpp:389
double designSize() const override
Definition: Font.hpp:352
double charDepth(int c) const override
Definition: Font.hpp:355
double charHeight(int c) const override
Definition: Font.hpp:356
double charWidth(int c) const override
Definition: Font.hpp:354
double italicCorr(int c) const override
Definition: Font.hpp:357
const Font * uniqueFont() const override
Definition: Font.hpp:349
const FontMetrics * getMetrics() const override
Definition: Font.hpp:358
std::string name() const override
Definition: Font.hpp:350
double _ssize
scaled size in PS point units
Definition: Font.hpp:369
const char * path() const override
Definition: Font.hpp:359
VirtualFontProxy(const VirtualFontProxy &proxy, double ds, double ss)
Definition: Font.hpp:363
VirtualFontProxy(const VirtualFont *font, double ds, double ss)
Definition: Font.hpp:362
void assignChar(uint32_t c, DVIVector &&dvi) override
Definition: Font.hpp:364
double _dsize
design size in PS point units
Definition: Font.hpp:368
const DVIVector * getDVI(int c) const override
Definition: Font.hpp:351
std::unique_ptr< Font > clone(double ds, double ss) const override
Definition: Font.hpp:345
const VirtualFont * _vf
Definition: Font.hpp:367
double scaledSize() const override
Definition: Font.hpp:353
virtual const DVIVector * getDVI(int c) const =0
virtual void assignChar(uint32_t c, DVIVector &&dvi)=0
std::vector< uint8_t > DVIVector
Definition: Font.hpp:157
static std::unique_ptr< Font > create(const std::string &name, uint32_t checksum, double dsize, double ssize)
Definition: Font.cpp:466
bool getGlyph(int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override
Definition: Font.hpp:162
long hh
Definition: dvi2xx.h:579
struct dvi_data * dvi
int ptsize
Definition: ftlib.c:46
#define c(n)
Definition: gpos-common.c:150
unsigned int uint32_t
Definition: stdint.h:80
#define string
Definition: ctangleboot.c:111
STL namespace.
integer checksum
Definition: pbmtopk.c:63
char * fname
Definition: plain2.c:121
#define cb(n)
static const CharMapID NONE
Definition: CharMapID.hpp:41
Definition: xim.h:41
static const Color BLACK
Definition: Color.hpp:36
FontException(const std::string &msg)
Definition: Font.hpp:394
virtual bool verticalLayout() const =0
double d
Definition: Font.hpp:50
double wl
Definition: Font.hpp:50
GlyphMetrics(double wwl, double wwr, double hh, double dd)
Definition: Font.hpp:49
GlyphMetrics()
Definition: Font.hpp:48
double h
Definition: Font.hpp:50
double wr
Definition: Font.hpp:50
Definition: nsfix.c:44
Definition: pdfdev.c:706
Definition: pst1form.c:310
Definition: pbmfont.h:11
Definition: pbmfont.h:4
Definition: texview.c:48
Definition: tpic.c:45