summaryrefslogtreecommitdiff
path: root/src/bitmap/pcfwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bitmap/pcfwrite.c')
-rw-r--r--src/bitmap/pcfwrite.c79
1 files changed, 28 insertions, 51 deletions
diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c
index 39f79bc..74b099e 100644
--- a/src/bitmap/pcfwrite.c
+++ b/src/bitmap/pcfwrite.c
@@ -1,5 +1,4 @@
/* $Xorg: pcfwrite.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
-
/*
Copyright 1990, 1994, 1998 The Open Group
@@ -27,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/pcfwrite.c,v 1.10 2003/01/12 03:55:46 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -39,27 +39,23 @@ from The Open Group.
extern void pcfError(
#if NeedVarargsPrototypes
- char* message, ...
+ char* message, ...
#endif
-);
+ );
/* Write PCF font files */
-static int current_position;
+static CARD32 current_position;
static int
-pcfWrite(file, b, c)
- FontFilePtr file;
- char *b;
- int c;
+pcfWrite(FontFilePtr file, char *b, int c)
{
current_position += c;
return FontFileWrite(file, b, c);
}
static int
-pcfPutLSB32(file, c)
- FontFilePtr file;
+pcfPutLSB32(FontFilePtr file, int c)
{
current_position += 4;
(void) FontFilePutc(c, file);
@@ -69,9 +65,7 @@ pcfPutLSB32(file, c)
}
static int
-pcfPutINT32(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT32(FontFilePtr file, CARD32 format, int c)
{
current_position += 4;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
@@ -88,9 +82,7 @@ pcfPutINT32(file, format, c)
}
static int
-pcfPutINT16(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT16(FontFilePtr file, CARD32 format, int c)
{
current_position += 2;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
@@ -104,19 +96,14 @@ pcfPutINT16(file, format, c)
/*ARGSUSED*/
static int
-pcfPutINT8(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT8(FontFilePtr file, CARD32 format, int c)
{
current_position += 1;
return FontFilePutc(c, file);
}
static void
-pcfWriteTOC(file, table, count)
- FontFilePtr file;
- PCFTablePtr table;
- int count;
+pcfWriteTOC(FontFilePtr file, PCFTablePtr table, int count)
{
CARD32 version;
int i;
@@ -134,10 +121,7 @@ pcfWriteTOC(file, table, count)
}
static void
-pcfPutCompressedMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+pcfPutCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT8(file, format, metric->leftSideBearing + 0x80);
pcfPutINT8(file, format, metric->rightSideBearing + 0x80);
@@ -147,10 +131,7 @@ pcfPutCompressedMetric(file, format, metric)
}
static void
-pcfPutMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+pcfPutMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT16(file, format, metric->leftSideBearing);
pcfPutINT16(file, format, metric->rightSideBearing);
@@ -161,10 +142,7 @@ pcfPutMetric(file, format, metric)
}
static void
-pcfPutBitmap(file, format, pCI)
- FontFilePtr file;
- CARD32 format;
- CharInfoPtr pCI;
+pcfPutBitmap(FontFilePtr file, CARD32 format, CharInfoPtr pCI)
{
int count;
unsigned char *bits;
@@ -177,10 +155,7 @@ pcfPutBitmap(file, format, pCI)
}
static void
-pcfPutAccel(file, format, pFontInfo)
- FontFilePtr file;
- CARD32 format;
- FontInfoPtr pFontInfo;
+pcfPutAccel(FontFilePtr file, CARD32 format, FontInfoPtr pFontInfo)
{
pcfPutINT8(file, format, pFontInfo->noOverlap);
pcfPutINT8(file, format, pFontInfo->constantMetrics);
@@ -220,16 +195,13 @@ pcfPutAccel(file, format, pFontInfo)
#define CanCompressMetrics(min,max) (CanCompressMetric(min) && CanCompressMetric(max))
static char *
-pcfNameForAtom(a)
- Atom a;
+pcfNameForAtom(Atom a)
{
return NameForAtom(a);
}
int
-pcfWriteFont(pFont, file)
- FontPtr pFont;
- FontFilePtr file;
+pcfWriteFont(FontPtr pFont, FontFilePtr file)
{
PCFTableRec tables[32],
*table;
@@ -247,13 +219,13 @@ pcfWriteFont(pFont, file)
xCharInfo *ink_minbounds,
*ink_maxbounds;
BitmapFontPtr bitmapFont;
- int nencodings;
+ int nencodings = 0;
int header_size;
FontPropPtr offsetProps;
- int prop_pad;
+ int prop_pad = 0;
char *atom_name;
int glyph;
- int offset;
+ CARD32 offset;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
if (bitmapFont->bitmapExtra) {
@@ -269,7 +241,7 @@ pcfWriteFont(pFont, file)
}
offsetProps = (FontPropPtr) xalloc(pFont->info.nprops * sizeof(FontPropRec));
if (!offsetProps) {
- pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, sizeof(FontPropRec));
+ pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, sizeof(FontPropRec));
return AllocError;
}
prop_string_size = 0;
@@ -388,7 +360,8 @@ pcfWriteFont(pFont, file)
cur_table++, table++) {
if (current_position > table->offset) {
printf("can't go backwards... %d > %d\n",
- current_position, table->offset);
+ (int)current_position, (int)table->offset);
+ xfree(offsetProps);
return BadFontName;
}
while (current_position < table->offset)
@@ -461,8 +434,10 @@ pcfWriteFont(pFont, file)
pcfPutINT16(file, format, pFont->info.lastRow);
pcfPutINT16(file, format, pFont->info.defaultCh);
for (i = 0; i < nencodings; i++) {
- if (bitmapFont->encoding[i])
- pcfPutINT16(file, format, bitmapFont->encoding[i] - bitmapFont->metrics);
+ if (ACCESSENCODING(bitmapFont->encoding,i))
+ pcfPutINT16(file, format,
+ ACCESSENCODING(bitmapFont->encoding, i) -
+ bitmapFont->metrics);
else
pcfPutINT16(file, format, 0xFFFF);
}
@@ -490,5 +465,7 @@ pcfWriteFont(pFont, file)
break;
}
}
+
+ xfree(offsetProps);
return Successful;
}