Index: xc/lib/font/bitmap/pcfread.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/bitmap/pcfread.c,v retrieving revision 1.1.4.2.6.1 diff -u -1 -0 -0 -r1.1.4.2.6.1 pcfread.c --- a/xc/lib/font/bitmap/pcfread.c 4 Mar 2004 17:47:10 -0000 1.1.4.2.6.1 +++ b/xc/lib/font/bitmap/pcfread.c 14 Apr 2004 23:50:33 -0000 @@ -799,190 +799,190 @@ 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; 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++; } #ifdef FONTMODULE sizebitmaps = 1024; /* Default - we xalloc the size anyway */ #else sizebitmaps = BUFSIZ; #endif /* 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), + encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding)+512, 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; encoding[i] = 0; } 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; iinfo.props); pFont->info.nprops = 0; pFont->info.props = 0; xfree (pFont->info.isStringProp); xfree(bitmapFont); xfree(tables); return AllocError; }