Initial revision
[swftools.git] / pdf2swf / xpdf / FontEncoding.h
1 //========================================================================
2 //
3 // FontEncoding.h
4 //
5 // Copyright 1999 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifndef FONTENCODING_H
10 #define FONTENCODING_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include "gtypes.h"
17
18 //------------------------------------------------------------------------
19 // FontEncoding
20 //------------------------------------------------------------------------
21
22 #define fontEncHashSize 419
23
24 class FontEncoding {
25 public:
26
27   // Construct an empty encoding.
28   FontEncoding();
29
30   // Construct an encoding from an array of char names.
31   FontEncoding(char **encoding, int size);
32
33   // Destructor.
34   ~FontEncoding();
35
36   // Create a copy of the encoding.
37   FontEncoding *copy() { return new FontEncoding(this); }
38
39   // Return number of codes in encoding, i.e., max code + 1.
40   int getSize() { return size; }
41
42   // Add a char to the encoding.
43   void addChar(int code, char *name);
44
45   // Return the character name associated with <code>.
46   char *getCharName(int code) { return encoding[code]; }
47
48   // Return the code associated with <name>.
49   int getCharCode(char *name);
50
51 private:
52
53   FontEncoding(FontEncoding *fontEnc);
54   int hash(char *name);
55   void addChar1(int code, char *name);
56
57   char **encoding;              // code --> name mapping
58   int size;                     // number of codes
59   GBool freeEnc;                // should we free the encoding array?
60   short                         // name --> code hash table
61     hashTab[fontEncHashSize];
62 };
63
64 #endif