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