okular/fontMap.h
Stefan Kebekus 384bd2934f added proper support for font encodings
svn path=/trunk/kdegraphics/kdvi/; revision=231906
2003-06-17 06:42:22 +00:00

101 lines
3.3 KiB
C++

// fontMap.h
//
// Part of KDVI - A DVI previewer for the KDE desktop environemt
//
// (C) 2003 Stefan Kebekus
// Distributed under the GPL
#ifndef _FONTMAP_H
#define _FONTMAP_H
#include <../config.h>
#ifdef HAVE_FREETYPE
#include <qmap.h>
#include <qstring.h>
/**
* This class represents one line of a font map file, and contains
* three pieces of information about a font: its file name, the full
* name of the font, and the encoding.
*
* @author Stefan Kebekus <kebekus@kde.org>
**/
class fontMapEntry {
public:
// File name of the font WITHOUT the path. The full path name must
// be looked by using the kpathsea library, e.g. by means of the
// kpsewhich command. A valid entry would be 'ubkd8a.pfb'
QString fontFileName;
// This string contains the full name of the font,
// e.g. 'URWBookmanL-DemiBold'
QString fullFontName;
// If the font requires an encoding (see fontEncoding.h for an
// explanation), this string is not empty and contains the name of
// the encoding, e.g. '8r'. The path of the associated encoding file
// (on the author's machine: /usr/share/texmf/dvips/psnfss/8r.enc)
// must be looked up using the kpsewhich comman.
QString fontEncoding;
};
/**
* This class represents the contents of the font map file "ps2pk.map"
*
* A font map file is part of the machinery that make it possible to
* access PostScript (and possibly also TrueType and OpenType) fonts
* from a DVI file.
*
* Long time ago, when TeX was only used with MetaFont fonts, the DVI
* file would specify a font by giving an 8-character name, such as
* 'cmr10'. The DVI previewer would then locate the associated PK font
* file, load it, and retrieve the character shaped. Happy times, they
* were.
*
* Today TeX is also used to access Type1 and TrueType fonts, which do
* not fit well into the TeX naming scheme. Like in earlier times, the
* DVI file specifies the name of a font, e.g. 'rpbkd', but nowadays
* the DVI previewer cannot just go and find a file 'rpbkd.pk'. No,
* no. Instead, the DVI previewr needs to look up the meaning of
* 'rpbkd' in a map-file. There it finds that 'rpbkd' refers to a font
* called 'URWBookmanL-DemiBold', to be found under the file name
* 'ubkd8a.pfb' whose glyphs are to be encoded using the '8a' encoding
* file (see the header file 'fontEncoding.h' for more information
* about encodings)
*
* Such map files exists for all dvi output drivers that are part of
* the TeX distribution that is installed on your
* computer. Unfortunately, KDVI is not part of a TeX distribution,
* and therefore does not have its own map file. As a workaround, KDVI
* uses the map file of the program ps2pk which is similar to KDVI in
* that the ps2pk driver does not have built-in fonts, unlike the
* PostScript printers for which dvips is used.
*
* @author Stefan Kebekus <kebekus@kde.org>
*
**/
class fontMap {
public:
/** The default constructor will try to locate the file 'ps2pk.map',
and read its contents. */
fontMap( void );
/** */
const QString &findFileName(const QString &TeXName);
const QString &findEncoding(const QString &TeXName);
/** This member maps TeX font names mapEntry classes that contain
the font's filenames, full font names and encodings. */
QMap<QString, fontMapEntry> fontMapEntries;
};
#endif // ifdef HAVE_FREETYPE
#endif // ifndef _FONTMAP_H