1 //========================================================================
5 // Base class for font rasterizers.
7 // Copyright 2001-2002 Glyph & Cog, LLC
9 //========================================================================
16 #ifdef USE_GCC_PRAGMAS
21 #include <X11/Xutil.h>
23 #include "CharTypes.h"
27 //------------------------------------------------------------------------
32 SFontEngine(Display *displayA, Visual *visualA, int depthA,
34 virtual ~SFontEngine();
36 // Use a TrueColor visual. Pixel values are computed as:
38 // (r << rShift) + (g << gShift) + (b << bShift)
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);
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:
49 // |--- colors[i] ---|
51 // - ----- ----- -----
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);
67 // Find the closest match to (<r>,<g>,<b>).
68 Gulong findColor(int r, int g, int b);
76 GBool trueColor; // true for TrueColor, false for RGB cube
78 //----- TrueColor parameters
80 int rShift, gShift, bShift;
82 //----- RGB color cube parameters
87 //------------------------------------------------------------------------
92 // A typical subclass will provide a constructor along the lines of:
94 // SomeFontFile(SomeFontEngine *engine, char *fontFileName);
102 //------------------------------------------------------------------------
107 // A typical subclass will provide a constructor along the lines of:
109 // SomeFont(SomeFontFile *fontFile, double *m);
111 // where <m> is a transform matrix consisting of four elements,
112 // using the PostScript ordering conventions (without any
115 // [x' y'] = [x y] * [m0 m1]
118 // This is the level at which fonts are cached, and so the font
119 // cannot be transformed after it is created.
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;
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
137 virtual GBool getCharPath(CharCode c, Unicode u, GfxState *state);