summaryrefslogtreecommitdiff
path: root/src/bitmap/bitmapfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bitmap/bitmapfunc.c')
-rw-r--r--src/bitmap/bitmapfunc.c93
1 files changed, 52 insertions, 41 deletions
diff --git a/src/bitmap/bitmapfunc.c b/src/bitmap/bitmapfunc.c
index c52c7e8..da06e7d 100644
--- a/src/bitmap/bitmapfunc.c
+++ b/src/bitmap/bitmapfunc.c
@@ -26,54 +26,65 @@ in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bitmapfunc.c,v 3.18 2002/09/24 20:48:52 tsi Exp $ */
+
/*
* Author: Keith Packard, MIT X Consortium
*/
#include "fntfilst.h"
#include "bitmap.h"
+#include "fontutil.h"
+#include "bdfint.h"
+#include "pcf.h"
+#include "snfstr.h"
typedef struct _BitmapFileFunctions {
- int (*ReadFont) ( /* pFont, file, bit, byte, glyph, scan */ );
- int (*ReadInfo) ( /* pFontInfo, file */ );
+ int (*ReadFont) (FontPtr /* pFont */, FontFilePtr /* file */,
+ int /* bit */, int /* byte */,
+ int /* glyph */, int /* scan */);
+ int (*ReadInfo) ( FontInfoPtr /* pFontInfo */,
+ FontFilePtr /* file */ );
} BitmapFileFunctionsRec, *BitmapFileFunctionsPtr;
-extern int pcfReadFont(), pcfReadFontInfo();
-extern int snfReadFont(), snfReadFontInfo();
-extern int bdfReadFont(), bdfReadFontInfo();
-extern int pmfReadFont();
-int BitmapOpenBitmap ();
-extern int BitmapOpenScalable ();
-int BitmapGetInfoBitmap ();
-extern int BitmapGetInfoScalable ();
-int BitmapGetRenderIndex ();
/*
- * these two arrays must be in the same order
+ * the readers[] and renderers[] arrays must be in the same order,
+ * and also in the same order as scale[] and find_scale[] in bitscale.c
+ *
*/
static BitmapFileFunctionsRec readers[] = {
+#ifdef PCFFORMAT
{ pcfReadFont, pcfReadFontInfo} ,
{ pcfReadFont, pcfReadFontInfo} ,
#ifdef X_GZIP_FONT_COMPRESSION
{ pcfReadFont, pcfReadFontInfo} ,
#endif
- { snfReadFont, snfReadFontInfo} ,
- { snfReadFont, snfReadFontInfo} ,
+#endif
+#ifdef SNFFORMAT
+ { snfReadFont, snfReadFontInfo},
+ { snfReadFont, snfReadFontInfo},
#ifdef X_GZIP_FONT_COMPRESSION
{ snfReadFont, snfReadFontInfo} ,
#endif
+#endif
+#ifdef BDFFORMAT
{ bdfReadFont, bdfReadFontInfo} ,
{ bdfReadFont, bdfReadFontInfo} ,
#ifdef X_GZIP_FONT_COMPRESSION
{ bdfReadFont, bdfReadFontInfo} ,
#endif
+#endif
+#ifdef PCFFORMAT
{ pmfReadFont, pcfReadFontInfo} ,
+#endif
};
#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
static FontRendererRec renderers[] = {
+#ifdef PCFFORMAT
{ ".pcf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -81,10 +92,13 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#ifdef X_GZIP_FONT_COMPRESSION
- { ".pcf.gz", 7, BitmapOpenBitmap, BitmapOpenScalable,
+ { ".pcf.gz", 7,
+ BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef SNFFORMAT
{ ".snf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -96,6 +110,8 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef BDFFORMAT
{ ".bdf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -107,21 +123,19 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef PCFFORMAT
{ ".pmf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES }
+#endif
};
-int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
- non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *ppFont;
- int flags;
- FontEntryPtr entry;
- char *fileName;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+int
+BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags,
+ FontEntryPtr entry, char *fileName,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
FontFilePtr file;
FontPtr pFont;
@@ -137,13 +151,12 @@ int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
file = FontFileOpen (fileName);
if (!file)
return BadFontName;
- pFont = (FontPtr) xalloc(sizeof(FontRec));
- if (!pFont) {
- fprintf(stderr, "Error: Couldn't allocate pFont (%d)\n", sizeof(FontRec));
+ if (!(pFont = CreateFontRec())) {
+ fprintf(stderr, "Error: Couldn't allocate pFont (%ld)\n",
+ (unsigned long)sizeof(FontRec));
FontFileClose (file);
return AllocError;
}
- bzero((char *)pFont, sizeof(FontRec));
/* set up default values */
FontDefaultFormat(&bit, &byte, &glyph, &scan);
/* get any changes made from above */
@@ -151,24 +164,21 @@ int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
/* Fill in font record. Data format filled in by reader. */
pFont->refcnt = 0;
- pFont->maxPrivate = -1;
- pFont->devPrivates = (pointer *) 0;
ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan);
FontFileClose (file);
- if (ret != Successful)
+ if (ret != Successful) {
xfree(pFont);
- else
+ } else {
*ppFont = pFont;
+ }
return ret;
}
-int BitmapGetInfoBitmap (fpe, pFontInfo, entry, fileName)
- FontPathElementPtr fpe;
- FontInfoPtr pFontInfo;
- FontEntryPtr entry;
- char *fileName;
+int
+BitmapGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry, char *fileName)
{
FontFilePtr file;
int i;
@@ -189,7 +199,8 @@ int BitmapGetInfoBitmap (fpe, pFontInfo, entry, fileName)
#define numRenderers (sizeof renderers / sizeof renderers[0])
-void BitmapRegisterFontFileFunctions ()
+void
+BitmapRegisterFontFileFunctions (void)
{
int i;
@@ -202,8 +213,8 @@ void BitmapRegisterFontFileFunctions ()
* the font info reader, and the bitmap scaling routine. All users
* of this routine must be kept in step with the renderer array.
*/
-int BitmapGetRenderIndex(renderer)
- FontRendererPtr renderer;
+int
+BitmapGetRenderIndex(FontRendererPtr renderer)
{
return renderer - renderers;
}