]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/SFont.h
Synched with Xpdf 0.92
[evince.git] / pdf / xpdf / SFont.h
1 //========================================================================
2 //
3 // SFont.h
4 //
5 // Base class for font rasterizers.
6 //
7 //========================================================================
8
9 #ifndef SFONT_H
10 #define SFONT_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include <X11/Xlib.h>
17 #include <X11/Xutil.h>
18 #include "gtypes.h"
19
20 //------------------------------------------------------------------------
21
22 class SFontEngine {
23 public:
24
25   SFontEngine(Display *display, Visual *visual, int depth,
26               Colormap colormap);
27   virtual ~SFontEngine();
28
29   // Use a TrueColor visual.  Pixel values are computed as:
30   //
31   //     (r << rShift) + (g << gShift) + (b << bShift)
32   //
33   // where r, g, and b are scaled to the ranges [0,rMax], [0,gMax],
34   // and [0,bMax], respectively.
35   virtual void useTrueColor(int rMax, int rShift, int gMax, int gShift,
36                             int bMax, int bShift);
37
38   // Use an RGB color cube.  <colors> is an array containing
39   // <nRGB>*<nRGB>*<nRGB> pixel values in red,green,blue order, e.g.,
40   // for <nRGB>=2, there will be 8 entries:
41   //
42   //        |--- colors[i] ---|
43   //     i  red    green  blue
44   //     -  -----  -----  -----
45   //     0  0000   0000   0000
46   //     1  0000   0000   ffff
47   //     2  0000   ffff   0000
48   //     3  0000   ffff   ffff
49   //     4  ffff   0000   0000
50   //     5  ffff   0000   ffff
51   //     6  ffff   ffff   0000
52   //     7  ffff   ffff   ffff
53   //
54   // The <colors> array is not copied and must remain valid for the
55   // lifetime of this SFont object.
56   virtual void useColorCube(Gulong *colors, int nRGB);
57
58 protected:
59
60   // Find the closest match to (<r>,<g>,<b>).
61   Gulong findColor(int r, int g, int b);
62
63   //----- X parameters
64   Display *display;
65   Visual *visual;
66   int depth;
67   Colormap colormap;
68
69   GBool trueColor;              // true for TrueColor, false for RGB cube
70
71   //----- TrueColor parameters
72   int rMax, gMax, bMax;
73   int rShift, gShift, bShift;
74
75   //----- RGB color cube parameters
76   Gulong *colors;
77   int nRGB;
78 };
79
80 //------------------------------------------------------------------------
81
82 class SFontFile {
83 public:
84
85   // A typical subclass will provide a constructor along the lines of:
86   //
87   //     SomeFontFile(SomeFontEngine *engine, char *fontFileName);
88   SFontFile();
89
90   virtual ~SFontFile();
91
92 private:
93 };
94
95 //------------------------------------------------------------------------
96
97 class SFont {
98 public:
99
100   // A typical subclass will provide a constructor along the lines of:
101   //
102   //     SomeFont(SomeFontFile *fontFile, double *m);
103   //
104   // where <m> is a transform matrix consisting of four elements,
105   // using the PostScript ordering conventions (without any
106   // translation):
107   //
108   //   [x' y'] = [x y] * [m0 m1]
109   //                     [m2 m3]
110   //
111   // This is the level at which fonts are cached, and so the font
112   // cannot be transformed after it is created.
113   SFont();
114
115   virtual ~SFont();
116
117   // Draw a character <c> at <x>,<y> in color (<r>,<g>,<b>).  The RGB
118   // values should each be in the range [0,65535].  Draws into <d>,
119   // clipped to the rectangle (0,0)-(<w>-1,<h>-1).  Returns true if
120   // the character was drawn successfully.
121   virtual GBool drawChar(Drawable d, int w, int h, GC gc,
122                          int x, int y, int r, int g, int b, Gushort c) = 0;
123
124 protected:
125 };
126
127 #endif