2005-12-15 21:34:10 +00:00
|
|
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
|
2003-06-17 06:42:22 +00:00
|
|
|
// fontEncoding.h
|
|
|
|
//
|
2005-10-19 22:43:24 +00:00
|
|
|
// Part of KDVI - A DVI previewer for the KDE desktop environment
|
2003-06-17 06:42:22 +00:00
|
|
|
//
|
|
|
|
// (C) 2003 Stefan Kebekus
|
|
|
|
// Distributed under the GPL
|
|
|
|
|
|
|
|
#ifndef _FONTENCODING_H
|
|
|
|
#define _FONTENCODING_H
|
|
|
|
|
2005-09-21 18:10:56 +00:00
|
|
|
#include <QString>
|
2003-06-17 06:42:22 +00:00
|
|
|
|
|
|
|
|
2003-06-20 08:13:42 +00:00
|
|
|
/**
|
|
|
|
* 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>
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2003-06-17 06:42:22 +00:00
|
|
|
class fontEncoding {
|
|
|
|
public:
|
2003-06-20 08:13:42 +00:00
|
|
|
// 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
|
2014-09-11 00:03:46 +00:00
|
|
|
// located, opened or parsed, errors are printed using the kError()
|
2003-06-20 08:13:42 +00:00
|
|
|
// channel, and the array glyphNameVector will contain empty
|
|
|
|
// strings.
|
2003-06-17 06:42:22 +00:00
|
|
|
fontEncoding(const QString &encName);
|
|
|
|
|
2003-06-20 08:13:42 +00:00
|
|
|
// Full name of the encoding, as read from the encoding file
|
2003-06-17 06:42:22 +00:00
|
|
|
QString encodingFullName;
|
2003-06-20 08:13:42 +00:00
|
|
|
|
|
|
|
// 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
|
2003-06-17 06:42:22 +00:00
|
|
|
QString glyphNameVector[256];
|
2004-12-21 06:06:43 +00:00
|
|
|
|
|
|
|
// 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;
|
2003-06-17 06:42:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|