summaryrefslogtreecommitdiffstats log msg author committer range
path: root/kdvi/fontMap.h
blob: 4e02f742fdf147091ae54c40a550e8731c2e8d87 (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 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 ``` ``````// -*- 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 #include /** * 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 **/ 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' TQString fontFileName; // This string contains the full name of the font, // e.g. 'URWBookmanL-DemiBold' TQString 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. TQString fontEncoding; // Some fonts need to be slanted, and the font map file defines by // how much. This field is set to 0.0 if no slanting is specified in // the map file. double slant; }; /** * 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 * **/ class fontMap { public: /** The default constructor will try to locate the file 'ps2pk.map', and read its contents. If the file 'ps2pk.map' cannot be found using the kpsewhich command, or if it cannot be read, or is (partially) in an improper format, an error message is printed to stderr using the kdDebug() stream. */ fontMap( void ); /** find the name of a font file (e.g. 'ubkd8a.pfb') from a TeX font name (e.g. 'rpbkd'). This method return a reference to TQString() if the font could not be found. */ const TQString &findFileName(const TQString &TeXName); /** find the name of a font (e.g. 'URWBookmanL-DemiBold') from a TeX font name (e.g. 'rpbkd'). This method return a reference to TQString() if the font could not be found. */ const TQString &findFontName(const TQString &TeXName); /** find the name of an encoding file for a font (e.g. '8r') from a TeX font name (e.g. 'rpbkd'). This method return a reference to TQString() if the font could not be found. */ const TQString &findEncoding(const TQString &TeXName); /** This method finds the slant of a font. Returns 0.0 if no slant was defined. */ double findSlant(const TQString &TeXName); private: /** This member maps TeX font names mapEntry classes that contain the font's filenames, full font names and encodings. */ TQMap fontMapEntries; }; #endif // ifndef _FONTMAP_H ``````