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