summaryrefslogtreecommitdiffstats
path: root/kdvi/fontEncoding.h
blob: b5ca1344c4f3ff338458b33aa5e45b031e1e0c7c (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
80
81
82
83
84
85
86
// -*- C++ -*-
// fontEncoding.h
//
// Part of KDVI - A DVI previewer for the KDE desktop environemt 
//
// (C) 2003 Stefan Kebekus
// Distributed under the GPL

#ifndef _FONTENCODING_H
#define _FONTENCODING_H

#include <qstring.h>


/**
 * This class represents the contents of a font encoding file,
 * e.g. "8r.enc"
 *
 * Explanation of font encodings: TeX was designed to only use
 * MetaFont fonts. A DVI file referres to a MetaFont font by giving an
 * at-most-8-character name, such as 'cmr10'. The DVI previewer would
 * then locate the associated PK font file (e.g. cmr10.600pk), load
 * it, and retrieve the character shaped.
 *
 * Today TeX is also used to access Type1 and TrueType fonts, which it
 * was never designed to do. As in the case of MetaFont font, the DVI
 * file specifies the name of a font, e.g. 'rpbkd', and the DVI
 * previewer finds the associated font file 'ubkd8a.pfb' by means of a
 * map file (see fontMap.h). The font map file also specifies an
 * encoding (e.g. '8r', to be found in a file '8r.enc'). Font
 * encodings are necessary because TeX can only use the first 256
 * characters of a font, while modern PostScript fonts often contain
 * more.
 *
 * In a PostScript font, glyphs can often be accessed in two ways:
 *
 * (a) by an integer, the 'glyph index', which need not be
 * positive. Glyph indices can be found in every font.
 *
 * (b) by the name of the glyph, such as 'A', 'plusminus' or
 * 'ogonek'. Note: Not all fonts contain glyph names, and if a font
 * contains glyph names, they are not always reliable.
 *
 * An encoding file is essentially a list of 256 names of glyphs that
 * TeX wishes to use from a certain font. If the font contains more
 * than 256 glyphs, TeX is still limited to use at most 256 glyphs. If
 * more glyphs are required, TeX can probably use the same font under
 * a different name and with a different encoding ---the map file
 * (fontMap.h) can probably see to that.
 *
 * Summing up: this class contains 256 glyph names read from an
 * encoding file during the construction of this class.
 *
 * @author Stefan Kebekus   <kebekus@kde.org>
 *
 **/

class fontEncoding {
 public:
  // The constructor takes the name of an encoding file, such as
  // '8r.enc', locate the file on the hard disk using the 'kpsewhich'
  // command, reads it in and parses it. If the file cannot be
  // located, opened or parsed, errors are printed using the kdError()
  // channel, and the array glyphNameVector will contain empty
  // strings.
  fontEncoding(const QString &encName);

  // Full name of the encoding, as read from the encoding file
  QString encodingFullName;

  // List of 256 glyph names. The name can be '.notdef' to indicate
  // that a certain position is left open, or empty, if the encoding
  // file did not contain 256 characters or could not be properly read
  QString glyphNameVector[256];

  // Returns 'true' if the encoding file was found and could
  // successfully be loaded.
  bool isValid() {return _isValid;}

 private:
  // Set by the constructor to 'true', if the encoding file was found
  // and could be loaded successfully.
  bool _isValid;
};

#endif