]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/FontFile.h
Merge changes from 1.1 tree.
[thirdparty/cups.git] / pdftops / FontFile.h
1 //========================================================================
2 //
3 // FontFile.h
4 //
5 // Copyright 1999 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifndef FONTFILE_H
10 #define FONTFILE_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include <stdio.h>
17 #include "gtypes.h"
18 #include "GString.h"
19 #include "FontEncoding.h"
20
21 //------------------------------------------------------------------------
22 // FontFile
23 //------------------------------------------------------------------------
24
25 class FontFile {
26 public:
27
28 FontFile();
29 virtual ~FontFile();
30
31 // Returns the font name, as specified internally by the font file.
32 // Returns NULL if no name is available.
33 virtual const char *getName() = 0;
34
35 // Returns the custom font encoding, or NULL if the encoding is
36 // not available. If <taken> is set, the caller of this function
37 // will be responsible for freeing the encoding object.
38 virtual FontEncoding *getEncoding(GBool taken) = 0;
39 };
40
41 //------------------------------------------------------------------------
42 // Type1FontFile
43 //------------------------------------------------------------------------
44
45 class Type1FontFile: public FontFile {
46 public:
47
48 Type1FontFile(const char *file, int len);
49 virtual ~Type1FontFile();
50 virtual const char *getName() { return name; }
51 virtual FontEncoding *getEncoding(GBool taken);
52
53 private:
54
55 const char *name;
56 FontEncoding *encoding;
57 GBool freeEnc;
58 };
59
60 //------------------------------------------------------------------------
61 // Type1CFontFile
62 //------------------------------------------------------------------------
63
64 class Type1CFontFile: public FontFile {
65 public:
66
67 Type1CFontFile(const char *file, int len);
68 virtual ~Type1CFontFile();
69 virtual const char *getName() { return name; }
70 virtual FontEncoding *getEncoding(GBool taken);
71
72 private:
73
74 const char *name;
75 FontEncoding *encoding;
76 GBool freeEnc;
77 };
78
79 //------------------------------------------------------------------------
80 // Type1CFontConverter
81 //------------------------------------------------------------------------
82
83 class Type1CFontConverter {
84 public:
85
86 Type1CFontConverter(const char *file, int len, FILE *out);
87 ~Type1CFontConverter();
88 void convert();
89
90 private:
91
92 void eexecWrite(const char *s);
93 void cvtGlyph(const char *name, Guchar *s, int n);
94 void cvtGlyphWidth(GBool useOp);
95 void eexecDumpNum(double x, GBool fp);
96 void eexecDumpOp1(int op);
97 void eexecDumpOp2(int op);
98 void eexecWriteCharstring(Guchar *s, int n);
99 void getDeltaInt(char *buf, const char *name, double *op, int n);
100 void getDeltaReal(char *buf, const char *name, double *op, int n);
101
102 const char *file;
103 int len;
104 FILE *out;
105 double op[48]; // operands
106 GBool fp[48]; // true if operand is fixed point
107 int nOps; // number of operands
108 double defaultWidthX; // default glyph width
109 double nominalWidthX; // nominal glyph width
110 GBool defaultWidthXFP; // true if defaultWidthX is fixed point
111 GBool nominalWidthXFP; // true if nominalWidthX is fixed point
112 Gushort r1; // eexec encryption key
113 GString *charBuf; // charstring output buffer
114 int line; // number of eexec chars on current line
115 };
116
117 #endif