diff options
author | Adam Jackson <ajax@redhat.com> | 2008-09-27 01:30:13 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2009-01-20 23:00:05 -0500 |
commit | 632a2e90a4b209facc84d7a18873f19a720ea7df (patch) | |
tree | ce0021d080c121d5ae11fc403999fc555d010222 /src/bitmap/pcfread.c | |
parent | e1927f80deabe0268dc18b4a9f3ceda1325171f5 (diff) |
Remove PMF support.
.pmf files are printer font metrics; they have no glyphs, just boxes for
layout. They can't possibly be useful in a post-Xprint world.
Diffstat (limited to 'src/bitmap/pcfread.c')
-rw-r--r-- | src/bitmap/pcfread.c | 238 |
1 files changed, 0 insertions, 238 deletions
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; -} |