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