summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bitmap/bitmapfunc.c11
-rw-r--r--src/bitmap/bitscale.c269
-rw-r--r--src/bitmap/pcfread.c238
3 files changed, 6 insertions, 512 deletions
diff --git a/src/bitmap/bitmapfunc.c b/src/bitmap/bitmapfunc.c
index e980dfb..27f0cd1 100644
--- a/src/bitmap/bitmapfunc.c
+++ b/src/bitmap/bitmapfunc.c
@@ -67,6 +67,7 @@ typedef struct _BitmapFileFunctions {
FontFilePtr /* file */ );
} BitmapFileFunctionsRec, *BitmapFileFunctionsPtr;
+static int BitmapGetRenderIndex(FontRendererPtr renderer);
/*
* the readers[] and renderers[] arrays must be in the same order,
@@ -104,9 +105,6 @@ static BitmapFileFunctionsRec readers[] = {
{ bdfReadFont, bdfReadFontInfo} ,
# endif
#endif
-#if XFONT_PCFFORMAT
- { pmfReadFont, pcfReadFontInfo} ,
-#endif
};
@@ -235,11 +233,6 @@ static FontRendererRec renderers[] = {
CAPABILITIES },
# endif
#endif
-#if XFONT_PCFFORMAT
- { ".pmf", 4, BitmapOpenBitmap, BitmapOpenScalable,
- BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
- CAPABILITIES }
-#endif
};
#define numRenderers (sizeof renderers / sizeof renderers[0])
@@ -258,7 +251,7 @@ BitmapRegisterFontFileFunctions (void)
* the font info reader, and the bitmap scaling routine. All users
* of this routine must be kept in step with the renderer array.
*/
-int
+static int
BitmapGetRenderIndex(FontRendererPtr renderer)
{
return renderer - renderers;
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index 91c0451..4b90f5d 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -1,4 +1,3 @@
-/* $Xorg: bitscale.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
/*
Copyright 1991, 1994, 1998 The Open Group
@@ -71,9 +70,6 @@ static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
static FontPtr BitmapScaleBitmaps(FontPtr pf, FontPtr opf,
double widthMult, double heightMult,
FontScalablePtr vals);
-static FontPtr PrinterScaleBitmaps(FontPtr pf, FontPtr opf,
- double widthMult, double heightMult,
- FontScalablePtr vals);
enum scaleType {
atom, truncate_atom, pixel_size, point_size, resolution_x,
@@ -88,50 +84,6 @@ typedef struct _fontProp {
enum scaleType type;
} fontProp;
-typedef FontPtr (*ScaleFunc) ( FontPtr /* pf */,
- FontPtr /* opf */,
- double /* widthMult */,
- double /* heightMult */,
- FontScalablePtr /* vals */);
-
-/* These next two arrays must be kept in step with the renderer array */
-static const ScaleFunc scale[] =
-{
-#if XFONT_PCFFORMAT
- BitmapScaleBitmaps,
- BitmapScaleBitmaps,
-# ifdef X_GZIP_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-# ifdef X_BZIP2_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-#endif
-#if XFONT_SNFFORMAT
- BitmapScaleBitmaps,
- BitmapScaleBitmaps,
-# ifdef X_GZIP_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-# ifdef X_BZIP2_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-#endif
-#if XFONT_BDFFORMAT
- BitmapScaleBitmaps,
- BitmapScaleBitmaps,
-# ifdef X_GZIP_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-# ifdef X_BZIP2_FONT_COMPRESSION
- BitmapScaleBitmaps,
-# endif
-#endif
-#if XFONT_PCFFORMAT
- PrinterScaleBitmaps,
-#endif
-};
-
static FontEntryPtr FindBestToScale ( FontPathElementPtr fpe,
FontEntryPtr entry,
FontScalablePtr vals,
@@ -139,48 +91,6 @@ static FontEntryPtr FindBestToScale ( FontPathElementPtr fpe,
double *dxp, double *dyp,
double *sdxp, double *sdyp,
FontPathElementPtr *fpep );
-static FontEntryPtr FindPmfToScale ( FontPathElementPtr fpe,
- FontEntryPtr entry,
- FontScalablePtr vals,
- FontScalablePtr best,
- double *dxp, double *dyp,
- double *sdxp, double *sdyp,
- FontPathElementPtr *fpep );
-
-typedef FontEntryPtr (*FindToScale) (FontPathElementPtr fpe,
- FontEntryPtr entry,
- FontScalablePtr vals,
- FontScalablePtr best,
- double *dxp, double *dyp,
- double *sdxp, double *sdyp,
- FontPathElementPtr *fpep);
-static const FindToScale find_scale[] =
-{
-#if XFONT_PCFFORMAT
- FindBestToScale,
- FindBestToScale,
-#ifdef X_GZIP_FONT_COMPRESSION
- FindBestToScale,
-#endif
-#endif
-#if XFONT_SNFFORMAT
- FindBestToScale,
- FindBestToScale,
-#ifdef X_GZIP_FONT_COMPRESSION
- FindBestToScale,
-#endif
-#endif
-#if XFONT_BDFFORMAT
- FindBestToScale,
- FindBestToScale,
-#ifdef X_GZIP_FONT_COMPRESSION
- FindBestToScale,
-#endif
-#endif
-#if XFONT_PCFFORMAT
- FindPmfToScale,
-#endif
-};
static unsigned long bitscaleGeneration = 0; /* initialization flag */
@@ -619,58 +529,6 @@ FindBestToScale(FontPathElementPtr fpe, FontEntryPtr entry,
return result;
}
-static FontEntryPtr
-FindPmfToScale(FontPathElementPtr fpe, FontEntryPtr entry,
- FontScalablePtr vals, FontScalablePtr best,
- double *dxp, double *dyp,
- double *sdxp, double *sdyp,
- FontPathElementPtr *fpep)
-{
- FontEntryPtr result = NULL;
- FontScaledPtr scaled;
- FontScalableExtraPtr extra;
- int i;
-
- extra = entry->u.scalable.extra;
- for (i = 0; i < extra->numScaled; i++)
- {
- double rescale_x;
-
- scaled = &extra->scaled[i];
- if (!scaled->bitmap)
- continue;
- if (!ComputeScaleFactors(&scaled->vals, vals, dxp, dyp, sdxp, sdyp,
- &rescale_x))
- continue;
- *best = scaled->vals;
- *fpep = fpe;
- result = scaled->bitmap;
- if (rescale_x != 1.0)
- {
- /* We have rescaled horizontally due to an XLFD width field. Change
- the matrix appropriately */
- vals->pixel_matrix[0] *= rescale_x;
- vals->pixel_matrix[1] *= rescale_x;
-#ifdef NOTDEF
- /* This would force the pointsize and pixelsize fields in the
- FONT property to display as matrices to more accurately
- report the font being supplied. It might also break existing
- applications that expect a single number in that field. */
- vals->values_supplied =
- vals->values_supplied & ~(PIXELSIZE_MASK | POINTSIZE_MASK) |
- PIXELSIZE_ARRAY;
-#else /* NOTDEF */
- vals->values_supplied = vals->values_supplied & ~POINTSIZE_MASK;
-#endif /* NOTDEF */
- /* Recompute and reround the FontScalablePtr values after
- rescaling for the new width. */
- FontFileCompleteXLFD(vals, vals);
- }
- break;
- }
- return result;
-}
-
static long
doround(double x)
{
@@ -1702,124 +1560,6 @@ bail:
return NULL;
}
-static FontPtr
-PrinterScaleBitmaps(FontPtr pf, /* scaled font */
- FontPtr opf, /* originating font */
- double widthMult, /* glyphs width scale factor */
- double heightMult, /* glyphs height scale factor */
- FontScalablePtr vals)
-{
- register int i;
- int nchars = 0;
- char *glyphBytes;
- BitmapFontPtr bitmapFont,
- obitmapFont;
- CharInfoPtr pci;
- FontInfoPtr pfi;
- int glyph;
- unsigned bytestoalloc = 0;
- int firstCol, lastCol, firstRow, lastRow;
-
- double xform[4], inv_xform[4];
- double xmult, ymult;
-
- bitmapFont = (BitmapFontPtr) pf->fontPrivate;
- obitmapFont = (BitmapFontPtr) opf->fontPrivate;
-
- if (!compute_xform_matrix(vals, widthMult, heightMult, xform,
- inv_xform, &xmult, &ymult))
- goto bail;
-
- pfi = &pf->info;
- firstCol = pfi->firstCol;
- lastCol = pfi->lastCol;
- firstRow = pfi->firstRow;
- lastRow = pfi->lastRow;
-
- nchars = (lastRow - firstRow + 1) * (lastCol - firstCol + 1);
- glyph = pf->glyph;
- for (i = 0; i < nchars; i++)
- {
- if ((pci = ACCESSENCODING(bitmapFont->encoding, i)))
- bytestoalloc = MAX(bytestoalloc,BYTES_FOR_GLYPH(pci, glyph));
- }
-
- /* Do we add the font malloc stuff for VALUE ADDED ? */
- /* Will need to remember to free in the Unload routine */
-
-
- bitmapFont->bitmaps = (char *) xalloc(bytestoalloc);
- if (!bitmapFont->bitmaps) {
- fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
- goto bail;
- }
- bzero(bitmapFont->bitmaps, bytestoalloc);
-
- glyphBytes = bitmapFont->bitmaps;
- for (i = 0; i < nchars; i++)
- {
- if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
- (ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
- {
- pci->bits = glyphBytes;
- }
- }
- return pf;
-
-bail:
- if (pf)
- xfree(pf);
- if (bitmapFont) {
- xfree(bitmapFont->metrics);
- xfree(bitmapFont->ink_metrics);
- xfree(bitmapFont->bitmaps);
- if(bitmapFont->encoding)
- for(i=0; i<NUM_SEGMENTS(nchars); i++)
- xfree(bitmapFont->encoding[i]);
- xfree(bitmapFont->encoding);
- }
- return NULL;
-}
-
-#ifdef NOTDEF
-/*
- * exported interfaces
- */
-
-FontFileLoadName(FontFileDirPtr *dirs, int ndirs, char *name, FontPtr *pfont,
- fsBitmapFormat format, fsBitmapFormatMask fmask)
-{
- FontFileNamePtr fname;
- char full_name[1024];
- int ret = BadFontName;
- int i;
-
- i = 0;
- while (i < ndirs) {
- if (fname = FontFileFindNameInDir(dirs[i], name)) {
- if (!fname->alias) {
- if (!fname->font) {
- strcpy(full_name, dirs[i]->dir);
- strcat(full_name, fname->file);
- ret = FontFileLoad(pfont, full_name, format, fmask);
- if (ret == Successful) {
- fname->font = *pfont;
- (*pfont)->fpePrivate = (pointer) fname;
- }
- return ret;
- }
- *pfont = fname->font;
- return Successful;
- }
- name = fname->file;
- i = 0;
- } else
- i++;
- }
- return BadFontName;
-}
-#endif
-
/* ARGSUSED */
int
BitmapOpenScalable (FontPathElementPtr fpe,
@@ -1844,7 +1584,7 @@ BitmapOpenScalable (FontPathElementPtr fpe,
long sWidth;
FontEntryPtr scaleFrom;
- FontPathElementPtr scaleFPE;
+ FontPathElementPtr scaleFPE = NULL;
FontPtr sourceFont;
char fontName[MAXFONTNAMELEN];
@@ -1862,8 +1602,8 @@ BitmapOpenScalable (FontPathElementPtr fpe,
get_matrix_horizontal_component(vals->pixel_matrix) < 1.0)
return BadFontName;
- scaleFrom = (*find_scale[BitmapGetRenderIndex(entry->u.bitmap.renderer)])
- (fpe, entry, vals, &best, &dx, &dy, &sdx, &sdy, &scaleFPE);
+ scaleFrom = FindBestToScale(fpe, entry, vals, &best, &dx, &dy, &sdx, &sdy,
+ &scaleFPE);
if (!scaleFrom)
return BadFontName;
@@ -1883,8 +1623,7 @@ BitmapOpenScalable (FontPathElementPtr fpe,
savedY = dy;
font = ScaleFont(sourceFont, dx, dy, sdx, sdy, vals, &dx, &dy, &sWidth);
if (font)
- font = (*scale[ BitmapGetRenderIndex(entry->u.bitmap.renderer) ])
- (font, sourceFont, savedX, savedY, vals);
+ font = BitmapScaleBitmaps(font, sourceFont, savedX, savedY, vals);
if (!font)
{
diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c
index 3a0eeeb..2d4d19e 100644
--- a/src/bitmap/pcfread.c
+++ b/src/bitmap/pcfread.c
@@ -1,4 +1,3 @@
-/* $Xorg: pcfread.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
/*
Copyright 1990, 1998 The Open Group
@@ -782,240 +781,3 @@ pcfUnloadFont(FontPtr pFont)
xfree(bitmapFont);
DestroyFontRec(pFont);
}
-
-int
-pmfReadFont(FontPtr pFont, FontFilePtr file,
- int bit, int byte, int glyph, int scan)
-{
- CARD32 format;
- CARD32 size;
- BitmapFontPtr bitmapFont = 0;
- int i;
- PCFTablePtr tables = 0;
- int ntables;
- int nmetrics;
- int sizebitmaps;
- int nink_metrics;
- CharInfoPtr metrics = 0;
- xCharInfo *ink_metrics = 0;
- char *bitmaps = 0;
- CharInfoPtr **encoding = 0;
- int nencoding = 0;
- int encodingOffset;
- Bool hasBDFAccelerators;
- CharInfoPtr pci;
-
- pFont->info.nprops = 0;
- pFont->info.props = 0;
-
- if (!(tables = pcfReadTOC(file, &ntables)))
- goto Bail;
-
- /* properties */
-
- if (!pcfGetProperties(&pFont->info, file, tables, ntables))
- goto Bail;
-
- /* Use the old accelerators if no BDF accelerators are in the file */
-
- hasBDFAccelerators = pcfHasType (tables, ntables, PCF_BDF_ACCELERATORS);
- if (!hasBDFAccelerators)
- if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_ACCELERATORS))
- goto Bail;
-
- /* metrics */
-
- if (!pcfSeekToType(file, tables, ntables, PCF_METRICS, &format, &size)) {
- goto Bail;
- }
- format = pcfGetLSB32(file);
- if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
- !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
- goto Bail;
- }
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- nmetrics = pcfGetINT32(file, format);
- else
- nmetrics = pcfGetINT16(file, format);
- if (IS_EOF(file)) goto Bail;
- if (nmetrics < 0 || nmetrics > INT32_MAX / sizeof(CharInfoRec)) {
- pcfError("pmfReadFont(): invalid file format\n");
- goto Bail;
- }
- metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
- if (!metrics) {
- pcfError("pmfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
- goto Bail;
- }
- for (i = 0; i < nmetrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
- if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
- goto Bail;
- } else {
- if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
- goto Bail;
- }
-
- /* Set the bitmaps to all point to the same zero filled array
- * that is the size of the largest bitmap.
- */
-
- pci = metrics;
- sizebitmaps = 0;
- for (i = 0; i < nmetrics; i++)
- {
- sizebitmaps = MAX(sizebitmaps,BYTES_FOR_GLYPH(pci, glyph));
- pci++;
- }
-
- sizebitmaps = BUFSIZ;
-
- /* guard against completely empty font */
- bitmaps = (char *) xalloc(sizebitmaps);
- if (!bitmaps) {
- pcfError("pmfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps);
- goto Bail;
- }
-
- memset(bitmaps,0,sizebitmaps);
- for (i = 0; i < nmetrics; i++)
- metrics[i].bits = bitmaps;
-
- /* ink metrics ? */
-
- ink_metrics = NULL;
- if (pcfSeekToType(file, tables, ntables, PCF_INK_METRICS, &format, &size)) {
- format = pcfGetLSB32(file);
- if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
- !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
- goto Bail;
- }
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- nink_metrics = pcfGetINT32(file, format);
- else
- nink_metrics = pcfGetINT16(file, format);
- if (nink_metrics != nmetrics)
- goto Bail;
- if (IS_EOF(file)) goto Bail;
- ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
- if (!ink_metrics) {
- pcfError("pmfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
- goto Bail;
- }
- for (i = 0; i < nink_metrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
- if (!pcfGetMetric(file, format, ink_metrics + i))
- goto Bail;
- } else {
- if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
- goto Bail;
- }
- }
-
- /* encoding */
-
- if (!pcfSeekToType(file, tables, ntables, PCF_BDF_ENCODINGS, &format, &size))
- goto Bail;
- format = pcfGetLSB32(file);
- if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- goto Bail;
-
- pFont->info.firstCol = pcfGetINT16(file, format);
- pFont->info.lastCol = pcfGetINT16(file, format);
- pFont->info.firstRow = pcfGetINT16(file, format);
- pFont->info.lastRow = pcfGetINT16(file, format);
- pFont->info.defaultCh = pcfGetINT16(file, format);
- if (IS_EOF(file)) goto Bail;
-
- nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
- (pFont->info.lastRow - pFont->info.firstRow + 1);
-
- encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
- sizeof(CharInfoPtr*));
- if (!encoding) {
- pcfError("pmfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
- goto Bail;
- }
- pFont->info.allExist = TRUE;
- for (i = 0; i < nencoding; i++) {
- encodingOffset = pcfGetINT16(file, format);
- if (IS_EOF(file)) goto Bail;
- if (encodingOffset == 0xFFFF) {
- pFont->info.allExist = FALSE;
- } else {
- if(!encoding[SEGMENT_MAJOR(i)]) {
- encoding[SEGMENT_MAJOR(i)]=
- (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
- sizeof(CharInfoPtr));
- if(!encoding[SEGMENT_MAJOR(i)])
- goto Bail;
- }
- ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
- }
- }
- if (IS_EOF(file)) goto Bail;
-
- /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
-
- if (hasBDFAccelerators)
- if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_BDF_ACCELERATORS))
- goto Bail;
-
- bitmapFont = (BitmapFontPtr) xalloc(sizeof *bitmapFont);
- if (!bitmapFont) {
- pcfError("pmfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
- goto Bail;
- }
-
- bitmapFont->version_num = PCF_FILE_VERSION;
- bitmapFont->num_chars = nmetrics;
- bitmapFont->num_tables = ntables;
- bitmapFont->metrics = metrics;
- bitmapFont->ink_metrics = ink_metrics;
- bitmapFont->bitmaps = bitmaps;
- bitmapFont->encoding = encoding;
- bitmapFont->pDefault = (CharInfoPtr) 0;
- if (pFont->info.defaultCh != (unsigned short) NO_SUCH_CHAR) {
- unsigned int r,
- c,
- cols;
-
- r = pFont->info.defaultCh >> 8;
- c = pFont->info.defaultCh & 0xFF;
- if (pFont->info.firstRow <= r && r <= pFont->info.lastRow &&
- pFont->info.firstCol <= c && c <= pFont->info.lastCol) {
- cols = pFont->info.lastCol - pFont->info.firstCol + 1;
- r = r - pFont->info.firstRow;
- c = c - pFont->info.firstCol;
- bitmapFont->pDefault = ACCESSENCODING(encoding, r * cols + c);
- }
- }
- bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
- pFont->fontPrivate = (pointer) bitmapFont;
- pFont->get_glyphs = bitmapGetGlyphs;
- pFont->get_metrics = bitmapGetMetrics;
- pFont->unload_font = pcfUnloadFont;
- pFont->unload_glyphs = NULL;
- pFont->bit = bit;
- pFont->byte = byte;
- pFont->glyph = glyph;
- pFont->scan = scan;
- xfree(tables);
- return Successful;
-Bail:
- xfree(ink_metrics);
- if(encoding) {
- for(i=0; i<NUM_SEGMENTS(nencoding); i++)
- xfree(encoding[i]);
- }
- xfree(encoding);
- xfree(bitmaps);
- xfree(metrics);
- xfree(pFont->info.props);
- pFont->info.nprops = 0;
- pFont->info.props = 0;
- xfree (pFont->info.isStringProp);
- xfree(bitmapFont);
- xfree(tables);
- return AllocError;
-}