1 /* $XConsortium: bitmapfunc.c /main/10 1996/11/03 19:31:55 kaleb $ */
2 /* $XFree86: xc/lib/font/bitmap/bitmapfunc.c,v 3.4 1996/12/23 06:01:49 dawes Exp $ */
6 Copyright (c) 1991 X Consortium
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of the X Consortium shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings
27 in this Software without prior written authorization from the X Consortium.
32 * Author: Keith Packard, MIT X Consortium
38 typedef struct _BitmapFileFunctions {
39 int (*ReadFont) ( /* pFont, file, bit, byte, glyph, scan */ );
40 int (*ReadInfo) ( /* pFontInfo, file */ );
41 } BitmapFileFunctionsRec, *BitmapFileFunctionsPtr;
43 extern int pcfReadFont(), pcfReadFontInfo();
44 extern int snfReadFont(), snfReadFontInfo();
45 extern int bdfReadFont(), bdfReadFontInfo();
46 extern int pmfReadFont();
47 int BitmapOpenBitmap ();
48 extern int BitmapOpenScalable ();
49 int BitmapGetInfoBitmap ();
50 extern int BitmapGetInfoScalable ();
51 int BitmapGetRenderIndex ();
54 * these two arrays must be in the same order
56 static BitmapFileFunctionsRec readers[] = {
57 pcfReadFont, pcfReadFontInfo,
58 pcfReadFont, pcfReadFontInfo,
59 #ifdef X_GZIP_FONT_COMPRESSION
60 pcfReadFont, pcfReadFontInfo,
63 pcfReadFont, pcfReadFontInfo,
65 snfReadFont, snfReadFontInfo,
66 snfReadFont, snfReadFontInfo,
67 #ifdef X_GZIP_FONT_COMPRESSION
68 snfReadFont, snfReadFontInfo,
70 bdfReadFont, bdfReadFontInfo,
71 bdfReadFont, bdfReadFontInfo,
72 #ifdef X_GZIP_FONT_COMPRESSION
73 bdfReadFont, bdfReadFontInfo,
75 pmfReadFont, pcfReadFontInfo,
79 #define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
81 static FontRendererRec renderers[] = {
83 BitmapOpenBitmap, BitmapOpenScalable,
84 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
87 BitmapOpenBitmap, BitmapOpenScalable,
88 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
90 #ifdef X_GZIP_FONT_COMPRESSION
92 BitmapOpenBitmap, BitmapOpenScalable,
93 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
98 BitmapOpenBitmap, BitmapOpenScalable,
99 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
103 BitmapOpenBitmap, BitmapOpenScalable,
104 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
107 BitmapOpenBitmap, BitmapOpenScalable,
108 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
110 #ifdef X_GZIP_FONT_COMPRESSION
112 BitmapOpenBitmap, BitmapOpenScalable,
113 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
117 BitmapOpenBitmap, BitmapOpenScalable,
118 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
121 BitmapOpenBitmap, BitmapOpenScalable,
122 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
124 #ifdef X_GZIP_FONT_COMPRESSION
126 BitmapOpenBitmap, BitmapOpenScalable,
127 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
131 BitmapOpenBitmap, BitmapOpenScalable,
132 BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
136 BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
138 FontPathElementPtr fpe;
143 fsBitmapFormat format;
144 fsBitmapFormatMask fmask;
145 FontPtr non_cachable_font; /* We don't do licensing */
157 i = BitmapGetRenderIndex(entry->u.bitmap.renderer);
158 file = FontFileOpen (fileName);
161 pFont = (FontPtr) xalloc(sizeof(FontRec));
163 FontFileClose (file);
166 /* set up default values */
167 FontDefaultFormat(&bit, &byte, &glyph, &scan);
168 /* get any changes made from above */
169 ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
171 /* Fill in font record. Data format filled in by reader. */
173 pFont->maxPrivate = -1;
174 pFont->devPrivates = (pointer *) 0;
176 ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan);
178 FontFileClose (file);
179 if (ret != Successful)
186 BitmapGetInfoBitmap (fpe, pFontInfo, entry, fileName)
187 FontPathElementPtr fpe;
188 FontInfoPtr pFontInfo;
195 FontRendererPtr renderer;
197 renderer = FontFileMatchRenderer (fileName);
200 i = BitmapGetRenderIndex(renderer);
201 file = FontFileOpen (fileName);
204 ret = (*readers[i].ReadInfo) (pFontInfo, file);
205 FontFileClose (file);
209 #define numRenderers (sizeof renderers / sizeof renderers[0])
211 BitmapRegisterFontFileFunctions ()
215 for (i = 0; i < numRenderers; i++)
216 FontFileRegisterRenderer (&renderers[i]);
220 * compute offset into renderers array - used to find the font reader,
221 * the font info reader, and the bitmap scaling routine. All users
222 * of this routine must be kept in step with the renderer array.
224 BitmapGetRenderIndex(renderer)
225 FontRendererPtr renderer;
227 return renderer - renderers;