diff options
Diffstat (limited to 'Build/source/texk/ttfdump/libttf')
32 files changed, 345 insertions, 920 deletions
diff --git a/Build/source/texk/ttfdump/libttf/cmap.c b/Build/source/texk/ttfdump/libttf/cmap.c index 0fa44d50369..d876cfb8a96 100644 --- a/Build/source/texk/ttfdump/libttf/cmap.c +++ b/Build/source/texk/ttfdump/libttf/cmap.c @@ -12,7 +12,7 @@ * true data to map character code to glyph index * USHORT PlatformID shows which platform the subtable is to be used * (e.g. Mac, PC) - * USHORT Platfrom specofic EncodingID shows what kind of encoding scheme + * USHORT Platfrom specific EncodingID shows what kind of encoding scheme * this table uses (e.g. Big5, iso8859, Unicode etc.) * ULONG offset is the offset from the beginning of the whole cmap table * to the beginning of the corresponding subtable @@ -47,26 +47,20 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ +typedef union _TwoBytes { + USHORT u; + unsigned char c[2]; +} TwoBytes; -static CMAPPtr ttfAllocCMAP(TTFontPtr font); static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset); static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset); -static SubTablePtr ttfAllocSubTable(CMAPPtr cmap); static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG offset); static void ttfPrintSubTable(FILE* fp,SubTablePtr ptable); static void ttfFreeSubTable(SubTablePtr ptable); -static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable); static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset); static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable); static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc); @@ -89,37 +83,27 @@ static void ttfFreeCMAP6(SubTablePtr subTable); void ttfInitCMAP(TTFontPtr font) { - ULONG tag = 'c' | 'm' << 8 | 'a' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('c', 'm', 'a', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->cmap = ttfAllocCMAP(font); + font->cmap = XCALLOC1 (CMAP); ttfLoadCMAP(font->fp,font->cmap,ptd->offset); } } -static CMAPPtr ttfAllocCMAP(TTFontPtr font) -{ - CMAPPtr cmap; - if ((cmap = (CMAPPtr) calloc(1,sizeof(CMAP))) == NULL) - { - ttfError("Out Of Memory in __FILE_ : __LINE__ \n"); - return NULL; - } - return cmap; -} + static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset) { USHORT i,n; ULONG posEnc; /* beginning of the Encoding Table */ ULONG baseSub = offset; /* base of SubTable offset */ - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP"); cmap->version = ttfGetUSHORT(fp); cmap->numberOfEncodings = n = ttfGetUSHORT(fp); - cmap->subTables = ttfAllocSubTable(cmap); + cmap->subTables = XCALLOC (cmap->numberOfEncodings, SubTable); posEnc = baseSub + sizeof(USHORT)*2; /* step over the beginning of encoding * table */ @@ -198,24 +182,13 @@ void ttfFreeCMAP(CMAPPtr cmap) /* actually, EncodingTable is a part of SubTable */ static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadEncodingTable \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadEncodingTable"); subTable->PlatformID = ttfGetUSHORT(fp); subTable->EncodingID = ttfGetUSHORT(fp); subTable->offset = ttfGetULONG(fp); } -static SubTablePtr ttfAllocSubTable(CMAPPtr cmap) -{ - SubTablePtr subTable; - - if ((subTable = (SubTablePtr) calloc(cmap->numberOfEncodings,sizeof(SubTable))) == NULL) - { - ttfError("Out Of Memory in __FILE__ : __LINE__ \n"); - return NULL; - } - return subTable; -} + /* should this one be static ? */ static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG base) { @@ -226,8 +199,7 @@ static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG base) * base: beginning of cmap * offset: offset field of each encoding table */ pos = base + subTable->offset; - if (fseek(fp,pos,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadSubTable\n"); + xfseek(fp, pos, SEEK_SET, "ttfLoadSubTable"); subTable->format = format = ttfGetUSHORT(fp); subTable->length = ttfGetUSHORT(fp); @@ -309,32 +281,20 @@ static void ttfFreeSubTable(SubTablePtr ptable) } } -static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable) -{ - CMAP0 * cmap0; - - if ((cmap0 = (CMAP0 *) calloc(1,sizeof(CMAP0))) == NULL) - { - ttfError("Out Of Memory in __FILE__ : __LINE__ \n"); - return NULL; - } - return cmap0; -} static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset) { BYTE * array; - subTable->map.cmap0 = ttfAllocCMAP0(subTable); + subTable->map.cmap0 = XCALLOC1 (CMAP0); array = subTable->map.cmap0->glyphIndexArray; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCMAP0 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP0"); /* Attention: we get lots of bytes at once as a work around of the * usual ttfGet*, this cause byte sex trouble as will be seen * in the fellowing procedures */ if (fread(array,sizeof(BYTE),256,fp) != 256) - ttfError("Error when getting glyphIndexArray \n"); + ttfError("Error when getting glyphIndexArray\n"); } static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable) { @@ -344,7 +304,7 @@ static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable) for (i=0;i<256;i++) { index = ttfLookUpCMAP(subTable,i); - fprintf(fp,"\t\t Char %3d -> Index %4d \n",i,index); + fprintf(fp,"\t\t Char %3d -> Index %4d\n",i,index); } } static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc) @@ -362,17 +322,12 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) USHORT numGlyphId; SubHeaderPtr header; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCMAP2 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP2"); - subTable->map.cmap2 = (CMAP2 *) calloc(1,sizeof(CMAP2)); + subTable->map.cmap2 = XCALLOC1 (CMAP2); array = subTable->map.cmap2->subHeaderKeys; - if (fread(array,sizeof(USHORT),256,fp) != 256) - ttfError("Error when getting subHeaderKeys \n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,256*sizeof(USHORT)); -#endif + ttfReadUSHORT (array, 256, fp); for (i=0;i<256;i++) { @@ -382,8 +337,7 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) } n += 1; /* the number of subHeaders is one plus the max of subHeaderKeys */ - subTable->map.cmap2->subHeaders = header = - (SubHeaderPtr) calloc(n,sizeof(SubHeader)); + subTable->map.cmap2->subHeaders = header = XCALLOC (n, SubHeader); for (i=0;i<n;i++) { (header+i)->firstCode = ttfGetUSHORT(fp); @@ -403,8 +357,7 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) numGlyphId = subTable->length - (256 + 3) * sizeof(USHORT) - n * sizeof(SubHeader); numGlyphId /= sizeof(USHORT); - subTable->map.cmap2->glyphIndexArray = - (USHORT *) calloc(numGlyphId,sizeof(USHORT)); + subTable->map.cmap2->glyphIndexArray = XCALLOC (numGlyphId, USHORT); for (i=0;i<numGlyphId;i++) { subTable->map.cmap2->glyphIndexArray[i] = ttfGetUSHORT(fp); @@ -415,7 +368,7 @@ static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable) USHORT i,j,numGlyphId; USHORT *array,n=0,index; SubHeaderPtr header; - unsigned short cc; + TwoBytes tb; array = subTable->map.cmap2->subHeaderKeys; header = subTable->map.cmap2->subHeaders; @@ -454,27 +407,21 @@ static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable) i = 0; fprintf(fp,"\t\t First Byte:\t %2x\n",i); + tb.c[1] = i; for(j=0;j<=255;j++) { -#ifndef WORDS_BIGENDIAN - cc = i + (j << 8); -#else - cc = j + (i << 8); -#endif - index = ttfLookUpCMAP2(subTable,cc); + tb.c[0] = j; + index = ttfLookUpCMAP2(subTable,tb.u); fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index); } for (i=128;i<=255;i++) { fprintf(fp,"\t\t First Byte:\t %2x\n",i); + tb.c[1] = i; for(j=0;j<=255;j++) { -#ifndef WORDS_BIGENDIAN - cc = i + (j << 8); -#else - cc = j + (i << 8); -#endif - index = ttfLookUpCMAP2(subTable,cc); + tb.c[0] = j; + index = ttfLookUpCMAP2(subTable,tb.u); fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index); } } @@ -486,25 +433,22 @@ static USHORT ttfLookUpCMAP2(SubTablePtr subTable,USHORT cc) SubHeaderPtr headers = subTable->map.cmap2->subHeaders; SHORT idDelta; USHORT firstCode, entryCount, idRangeOffset; + TwoBytes tb; unsigned char first,second; /* On little endian platforms "low byte" is the "first byte". - * It determines that if it is necessary to use the second byte to - * fully interprete the character code, for expamle, if the first byte - * is obivously an ASCII character then it is not necessary to + * It determines if it is necessary to use the second byte to + * fully interprete the character code; for example, if the first byte + * is obviously an ASCII character then it is not necessary to * interpret the second byte, on the other hand, if the first byte is * zero then the second byte is a ASCII char, when the first byte * is not an ASCII char nor zero, those two bytes together determine * the meanning of the character code */ -#ifndef WORDS_BIGENDIAN - first = cc & 0x00ff; - second = cc >> 8; -#else - first = cc >> 8; - second = cc & 0x00ff; -#endif + tb.u = cc; + first = tb.c[1]; + second = tb.c[0]; /* select which subHeader to use */ idx = array[first]; @@ -542,12 +486,11 @@ static void ttfFreeCMAP2(SubTablePtr subTable) static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset) { USHORT segCount; - USHORT * array,len; + USHORT len; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCMAP4 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP4"); - subTable->map.cmap4 = (CMAP4 *) calloc(1,sizeof(CMAP4)); + subTable->map.cmap4 = XCALLOC1 (CMAP4); subTable->map.cmap4->segCountX2 = segCount = ttfGetUSHORT(fp); subTable->map.cmap4->searchRange = ttfGetUSHORT(fp); @@ -555,51 +498,21 @@ static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset) subTable->map.cmap4->rangeShift = ttfGetUSHORT(fp); segCount /= 2; - subTable->map.cmap4->endCount = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting endCount\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif + subTable->map.cmap4->endCount = ttfMakeUSHORT (segCount, fp); subTable->map.cmap4->reservedPad = ttfGetUSHORT(fp); - subTable->map.cmap4->startCount = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting startCount\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif - - subTable->map.cmap4->idDelta = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting idDelta\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif - - subTable->map.cmap4->idRangeOffset = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif + subTable->map.cmap4->startCount = ttfMakeUSHORT (segCount, fp); + + subTable->map.cmap4->idDelta = ttfMakeUSHORT (segCount, fp); + + subTable->map.cmap4->idRangeOffset = ttfMakeUSHORT (segCount, fp); /* caculate the length of glyphIndexArray, this is ugly, there should be * a better way to get this information. */ len = subTable->length - 8*sizeof(USHORT) - 4*segCount*sizeof(USHORT); len /= sizeof(USHORT); - subTable->map.cmap4->glyphIndexArray = array = - (USHORT *) calloc(len,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),len,fp) != len) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,len*sizeof(USHORT)); -#endif + subTable->map.cmap4->glyphIndexArray = ttfMakeUSHORT (len, fp); } static void ttfPrintCMAP4(FILE *fp,SubTablePtr subTable) { @@ -700,22 +613,14 @@ static void ttfFreeCMAP4(SubTablePtr subTable) static void ttfLoadCMAP6(FILE *fp,SubTablePtr subTable,ULONG offset) { - USHORT * array,len; + USHORT len; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCMAP6 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP6"); - subTable->map.cmap6 = (CMAP6 *) calloc(1,sizeof(CMAP6)); + subTable->map.cmap6 = XCALLOC1 (CMAP6); subTable->map.cmap6->firstCode = ttfGetUSHORT(fp); subTable->map.cmap6->entryCount = len = ttfGetUSHORT(fp); - subTable->map.cmap6->glyphIndexArray = array = - (USHORT *) calloc(subTable->map.cmap6->entryCount,sizeof(USHORT)); - - if (fread(array,sizeof(USHORT),len,fp) != len) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,len*sizeof(USHORT)); -#endif + subTable->map.cmap6->glyphIndexArray = ttfMakeUSHORT (len, fp); } static void ttfPrintCMAP6(FILE *fp, SubTablePtr subTable) { diff --git a/Build/source/texk/ttfdump/libttf/cvt.c b/Build/source/texk/ttfdump/libttf/cvt.c index 0e9c2f14782..2621a938e62 100644 --- a/Build/source/texk/ttfdump/libttf/cvt.c +++ b/Build/source/texk/ttfdump/libttf/cvt.c @@ -7,42 +7,28 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT lenght,ULONG offset); void ttfInitCVT(TTFontPtr font) { - ULONG tag = 'c' | 'v' << 8 | 't' << 16 | ' ' << 24; + ULONG tag = FT_MAKE_TAG ('c', 'v', 't', ' '); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->cvtLength = ptd->length / sizeof(FWord); - font->cvt = (FWord *) calloc(font->cvtLength, sizeof(FWord)); - if (font->cvt != NULL) - ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset); + font->cvt = XCALLOC (font->cvtLength, FWord); + ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset); } } static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCVT \n"); - - if (fread(cvt, sizeof(FWord), length, fp) != length) - ttfError("Error when getting CVT\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCVT"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) cvt,length*sizeof(FWord)); -#endif + ttfReadFWord (cvt, length, fp); } void ttfPrintCVT(FILE *fp, FWord *cvt, USHORT cvtLength) diff --git a/Build/source/texk/ttfdump/libttf/disasm.c b/Build/source/texk/ttfdump/libttf/disasm.c index fc263ddcda9..e716ea72a04 100644 --- a/Build/source/texk/ttfdump/libttf/disasm.c +++ b/Build/source/texk/ttfdump/libttf/disasm.c @@ -4,16 +4,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - void ttfPrintInstructions(FILE *fp, BYTE * ins) { /* not implemented yet */ diff --git a/Build/source/texk/ttfdump/libttf/fixed.c b/Build/source/texk/ttfdump/libttf/fixed.c index 3b5276ff209..3ff834b300a 100644 --- a/Build/source/texk/ttfdump/libttf/fixed.c +++ b/Build/source/texk/ttfdump/libttf/fixed.c @@ -5,12 +5,4 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ - -#ifndef lint -static char vcid[] = "$Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ diff --git a/Build/source/texk/ttfdump/libttf/font.c b/Build/source/texk/ttfdump/libttf/font.c index c8b3784a6eb..0ee6c25ec02 100644 --- a/Build/source/texk/ttfdump/libttf/font.c +++ b/Build/source/texk/ttfdump/libttf/font.c @@ -9,23 +9,15 @@ #include "ttfutil.h" #include "protos.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static void ttfInitInterpreter(TTFontPtr font); TTFontPtr ttfInitFont(char *filename) { TTFontPtr font; - font = (TTFontPtr) calloc(1,sizeof(TTFont)); + font = XCALLOC1 (TTFont); font->ttfname = filename; if ((font->fp = fopen (filename,"r")) == NULL) @@ -40,8 +32,7 @@ TTFontPtr ttfInitFont(char *filename) } void ttfLoadFont(TTFontPtr font, ULONG offset) { - if (fseek(font->fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed\n"); + xfseek(font->fp, offset, SEEK_SET, "ttfLoadFont"); /* offset table */ font->version = ttfGetFixed(font->fp); @@ -55,7 +46,7 @@ void ttfLoadFont(TTFontPtr font, ULONG offset) ttfInitInterpreter(font); /* initialize the reference count to 1 */ - font->refcount = (int *) calloc(1, sizeof(int)); + font->refcount = XCALLOC1 (int); *(font->refcount) = 1; } void ttfFreeFont(TTFontPtr font) @@ -147,7 +138,7 @@ TTFontPtr ttfCloneFont(TTFontPtr font) { TTFontPtr newfont; - newfont = (TTFontPtr) calloc(1,sizeof(TTFont)); + newfont = XTALLOC1 (TTFont); memcpy(newfont, font, sizeof(TTFont)); newfont->refcount += 1; diff --git a/Build/source/texk/ttfdump/libttf/fpgm.c b/Build/source/texk/ttfdump/libttf/fpgm.c index ad6ed3ee68d..0eb35ea1c8f 100644 --- a/Build/source/texk/ttfdump/libttf/fpgm.c +++ b/Build/source/texk/ttfdump/libttf/fpgm.c @@ -7,35 +7,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT lenght,ULONG offset); void ttfInitFPGM(TTFontPtr font) { - ULONG tag = 'f' | 'p' << 8 | 'g' << 16 | 'm' << 24; + ULONG tag = FT_MAKE_TAG ('f', 'p', 'g', 'm'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->fpgmLength = ptd->length; - font->fpgm = (BYTE *) calloc(font->fpgmLength, sizeof(BYTE)); - if (font->fpgm != NULL) - ttfLoadFPGM(font->fp,font->fpgm,font->fpgmLength,ptd->offset); + font->fpgm = XCALLOC (font->fpgmLength, BYTE); + ttfLoadFPGM(font->fp,font->fpgm,font->fpgmLength,ptd->offset); } } static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCVT \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadFPGM"); if (fread(fpgm, sizeof(BYTE), length, fp) != length) ttfError("Error when getting CVT\n"); diff --git a/Build/source/texk/ttfdump/libttf/gasp.c b/Build/source/texk/ttfdump/libttf/gasp.c index 4ab1aaaf11e..34bf5111237 100644 --- a/Build/source/texk/ttfdump/libttf/gasp.c +++ b/Build/source/texk/ttfdump/libttf/gasp.c @@ -7,61 +7,38 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static GASPPtr ttfAllocGASP(TTFontPtr font); static void ttfLoadGASP(FILE *fp,GASPPtr gasp,ULONG offset); void ttfInitGASP(TTFontPtr font) { - ULONG tag = 'g' | 'a' << 8 | 's' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('g', 'a', 's', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->gasp = ttfAllocGASP(font); + font->gasp = XCALLOC1 (GASP); ttfLoadGASP(font->fp,font->gasp,ptd->offset); } } -static GASPPtr ttfAllocGASP(TTFontPtr font) -{ - GASPPtr gasp; - - if ((gasp = (GASPPtr) calloc(1,sizeof(GASP))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return gasp; -} + static void ttfLoadGASP (FILE *fp,GASPPtr gasp,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadGASP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadGASP"); gasp->version = ttfGetUSHORT(fp); gasp->numRanges = ttfGetUSHORT(fp); - gasp->gaspRange = (GASPRANGE *) calloc(gasp->numRanges, sizeof(GASPRANGE)); + gasp->gaspRange = XCALLOC (gasp->numRanges, GASPRANGE); - if (gasp->gaspRange == NULL) - ttfError("Out of Memory in __FILE__:__LINE__\n"); - else - for (i=0;i<gasp->numRanges;i++) - { - gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp); - gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp); - } + for (i=0;i<gasp->numRanges;i++) + { + gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp); + gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp); + } } void ttfPrintGASP(FILE *fp,GASPPtr gasp) diff --git a/Build/source/texk/ttfdump/libttf/gcache.c b/Build/source/texk/ttfdump/libttf/gcache.c index 7ecdb0a8ed7..5666d040a42 100644 --- a/Build/source/texk/ttfdump/libttf/gcache.c +++ b/Build/source/texk/ttfdump/libttf/gcache.c @@ -7,7 +7,7 @@ * Basically the cache can be divided onto two parts, the first one is a * linear part which is a least recently utilitied list (LRU), * the second part is the nonlinear one which is a binary serach tree. - * Normally each cache element is one the LRU as well as on the BST. + * Normally each cache element is on the LRU as well as on the BST. * Those glyph elements are allocated at once as an array of glyph cache * elements at the init phase of glyph cache. * @@ -83,17 +83,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static GlyphCachePtr ttfAllocCache(TTFontPtr font); static void ttfInitCache(TTFontPtr font); static void ttfFreeCache(TTFontPtr font); static void ttfRotateCache(TTFontPtr font); @@ -116,12 +107,13 @@ void ttfInitGlyphCache(TTFontPtr font) else font->numCacheElements = 64; - font->gcache = ttfAllocCache(font); + font->gcache = XCALLOC (font->numCacheElements+1, GlyphCache); ttfInitCache(font); ttfAllocCacheData(font); ttfInitCacheData(font); } + void ttfCleanUpGlyphCache(TTFontPtr font) { ttfFreeCacheData(font); @@ -157,19 +149,6 @@ GLYFPtr ttfLoadGlyphCached(TTFontPtr font,ULONG offset) #endif } -/* alloc GlyphCache headers */ -static GlyphCachePtr ttfAllocCache(TTFontPtr font) -{ - USHORT numCache = font->numCacheElements+1; - GlyphCachePtr gcache; - - if ((gcache = (GlyphCachePtr) calloc(numCache,sizeof(GlyphCache))) == NULL) - { - ttfError("Out of Memory"); - return NULL; - } - return gcache; -} /* threading glyph cache headers */ static void ttfInitCache(TTFontPtr font) { @@ -222,16 +201,11 @@ static void ttfAllocCacheData(TTFontPtr font) USHORT maxContours = font->maxp->maxContours; USHORT insLength = font->maxp->maxSizeOfInstructions; - font->gcache->glyf.endPtsOfContours = (USHORT *) calloc(numCache*maxContours, - sizeof(USHORT)); - font->gcache->glyf.instructions = (BYTE *) calloc(numCache*insLength, - sizeof(BYTE)); - font->gcache->glyf.flags = (BYTE *) calloc(numCache*maxPoints, - sizeof(BYTE)); - font->gcache->glyf.xCoordinates = (SHORT *) calloc(numCache*maxPoints, - sizeof(SHORT)); - font->gcache->glyf.yCoordinates = (SHORT *) calloc(numCache*maxPoints, - sizeof(SHORT)); + font->gcache->glyf.endPtsOfContours = XCALLOC (numCache*maxContours, USHORT); + font->gcache->glyf.instructions = XCALLOC (numCache*insLength, BYTE); + font->gcache->glyf.flags = XCALLOC (numCache*maxPoints, BYTE); + font->gcache->glyf.xCoordinates = XCALLOC (numCache*maxPoints, SHORT); + font->gcache->glyf.yCoordinates = XCALLOC (numCache*maxPoints, SHORT); font->gcache->glyf.comp = NULL; } static void ttfInitCacheData(TTFontPtr font) diff --git a/Build/source/texk/ttfdump/libttf/glyf.c b/Build/source/texk/ttfdump/libttf/glyf.c index e19eb7fb170..9804d1bb126 100644 --- a/Build/source/texk/ttfdump/libttf/glyf.c +++ b/Build/source/texk/ttfdump/libttf/glyf.c @@ -8,16 +8,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static void ttfLoadSimpleGlyph(FILE *fp,GLYFPtr glyf,ULONG offset); static void ttfPrintSimpleGlyph(FILE *fp,GLYFPtr glyf); static void ttfLoadCompositeGlyph(FILE *fp,GLYFPtr glyf,ULONG offset); @@ -33,7 +25,7 @@ double fix2dbl(F2Dot14 fixed); */ void ttfInitGLYF(TTFontPtr font) { - ULONG tag = 'g' | 'l' << 8 | 'y' << 16 | 'f' << 24; + ULONG tag = FT_MAKE_TAG ('g', 'l', 'y', 'f'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) @@ -45,8 +37,7 @@ void ttfInitGLYF(TTFontPtr font) * callers should compute this themself form the loca tables */ void ttfLoadGLYF(FILE *fp, GLYFPtr glyf, ULONG offset) { - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadGLYF\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadGLYF"); glyf->numberOfContours = ttfGetSHORT(fp); glyf->xMin = ttfGetFWord(fp); @@ -85,18 +76,13 @@ static void ttfLoadSimpleGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) SHORT nCnts = glyf->numberOfContours; USHORT i,nIns,nPts; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadSimpleGlyph\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadSimpleGlyph"); - if (fread(glyf->endPtsOfContours, sizeof(USHORT), nCnts, fp) != nCnts) - ttfError("Error when getting endPtsOfContours\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) glyf->endPtsOfContours, - nCnts*sizeof(USHORT)); -#endif - if (nCnts != 0) - nPts = (glyf->endPtsOfContours)[nCnts-1]+1; + { + ttfReadUSHORT (glyf->endPtsOfContours, nCnts, fp); + nPts = (glyf->endPtsOfContours)[nCnts-1]+1; + } else /* there seems to be something wrong with my interpretation of * NOGLYPH chars, doing this way in case there is a char that has @@ -214,7 +200,7 @@ static void ttfPrintSimpleGlyph(FILE *fp, GLYFPtr glyf) else strcat(buf," "); if (flag & FLAGS_ON_CURVE) - strcat(buf,"On \n"); + strcat(buf,"On\n"); else strcat(buf,"Off\n"); @@ -238,11 +224,9 @@ static void ttfLoadCompositeGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) USHORT nIns,flags; Component *cur; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCompositeGlyph\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCompositeGlyph"); - if((glyf->comp = cur = (Component *) calloc(1, sizeof(Component))) == NULL) - ttfError("Out Of Memory\n"); + glyf->comp = cur = XCALLOC1 (Component); cur->previous = NULL; /* beginning of a linked list */ do { @@ -273,9 +257,7 @@ static void ttfLoadCompositeGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) (cur->data).transform.tensor.yscale = ttfGetF2Dot14(fp); } /* allocate next component */ - if ((cur->next = (Component *) calloc(1, sizeof(Component))) == NULL) - ttfError("Out Of Memory\n"); - + cur->next = XCALLOC1 (Component); cur->next->previous = cur; cur = cur->next; /* move to next component */ } while (flags & MORE_COMPONENT); diff --git a/Build/source/texk/ttfdump/libttf/gstate.c b/Build/source/texk/ttfdump/libttf/gstate.c index ba94ca69c79..d436bae3569 100644 --- a/Build/source/texk/ttfdump/libttf/gstate.c +++ b/Build/source/texk/ttfdump/libttf/gstate.c @@ -6,38 +6,30 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - GraphicsState gsdefault; void ttfInitGraphicsState(TTFontPtr font) { - /*font->gstate = GS_DEFAULT; - font->gstate_init = GS_DEFAULT;*/ +#if 0 + font->gstate = GS_DEFAULT; + font->gstate_init = GS_DEFAULT; +#endif - /*ttfExecuteInstruction(font, font->fpgm); - ttfExecuteInstruction(font, font->prep);*/ +#if 0 + ttfExecuteInstruction(font, font->fpgm); + ttfExecuteInstruction(font, font->prep); +#endif } void ttfInitStack(TTFontPtr font) { font->vm.sp = 0; - font->vm.Stack = (LONG *) calloc (font->maxp->maxStackElements, sizeof(LONG)); - if (font->vm.Stack == NULL) - ttfError("Out of memory\n"); + font->vm.Stack = XCALLOC (font->maxp->maxStackElements, LONG); } void ttfInitStorageArea(TTFontPtr font) { - font->vm.StorageArea = (LONG *) calloc (font->maxp->maxStorage, sizeof(LONG)); - if (font->vm.StorageArea == NULL) - ttfError("Out of memory\n"); + font->vm.StorageArea = XCALLOC (font->maxp->maxStorage, LONG); } diff --git a/Build/source/texk/ttfdump/libttf/hdmx.c b/Build/source/texk/ttfdump/libttf/hdmx.c index a1bd36d6ae7..f4d7b0ef3a2 100644 --- a/Build/source/texk/ttfdump/libttf/hdmx.c +++ b/Build/source/texk/ttfdump/libttf/hdmx.c @@ -7,68 +7,42 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HDMXPtr ttfAllocHDMX(TTFontPtr font); static void ttfLoadHDMX(FILE *fp,HDMXPtr hdmx,ULONG offset); void ttfInitHDMX(TTFontPtr font) { - ULONG tag = 'h' | 'd' << 8 | 'm' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'd', 'm', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hdmx = ttfAllocHDMX(font); + font->hdmx = XCALLOC1 (HDMX); font->hdmx->numGlyphs = font->maxp->numGlyphs; ttfLoadHDMX(font->fp,font->hdmx,ptd->offset); } } -static HDMXPtr ttfAllocHDMX(TTFontPtr font) -{ - HDMXPtr hdmx; - - if ((hdmx = (HDMXPtr) calloc(1,sizeof(HDMX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hdmx; -} + static void ttfLoadHDMX (FILE *fp,HDMXPtr hdmx,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadHDMX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHDMX"); hdmx->version = ttfGetUSHORT(fp); hdmx->numDevices = ttfGetUSHORT(fp); hdmx->size = ttfGetLONG(fp); - hdmx->Records = (DeviceRecord *) calloc(hdmx->numDevices, - sizeof(DeviceRecord)); + hdmx->Records = XCALLOC (hdmx->numDevices, DeviceRecord); - if (hdmx->Records == NULL) - ttfError("Out of Memory in __FILE__:__LINE__\n"); - else - for (i=0;i<hdmx->numDevices;i++) - { - hdmx->Records[i].PixelSize = ttfGetBYTE(fp); - hdmx->Records[i].MaxWidth = ttfGetBYTE(fp); - hdmx->Records[i].Width = (BYTE *) calloc(hdmx->size, - sizeof(BYTE)); - fread ((hdmx->Records+i)->Width, sizeof(BYTE), - hdmx->numGlyphs+1,fp); - } + for (i=0;i<hdmx->numDevices;i++) + { + hdmx->Records[i].PixelSize = ttfGetBYTE(fp); + hdmx->Records[i].MaxWidth = ttfGetBYTE(fp); + hdmx->Records[i].Width = XCALLOC (hdmx->size, BYTE); + fread ((hdmx->Records+i)->Width, sizeof(BYTE), hdmx->numGlyphs+1,fp); + } } void ttfPrintHDMX(FILE *fp,HDMXPtr hdmx) diff --git a/Build/source/texk/ttfdump/libttf/head.c b/Build/source/texk/ttfdump/libttf/head.c index 93365d8f485..ec4b33bcbaa 100644 --- a/Build/source/texk/ttfdump/libttf/head.c +++ b/Build/source/texk/ttfdump/libttf/head.c @@ -7,45 +7,25 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HEADPtr ttfAllocHEAD(TTFontPtr font); static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset); void ttfInitHEAD(TTFontPtr font) { - ULONG tag = 'h' | 'e' << 8 | 'a' << 16 | 'd' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'e', 'a', 'd'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->head = ttfAllocHEAD(font); + font->head = XCALLOC1 (HEAD); ttfLoadHEAD(font->fp,font->head,ptd->offset); } } -static HEADPtr ttfAllocHEAD(TTFontPtr font) -{ - HEADPtr head; - if ((head = (HEADPtr) calloc(1,sizeof(HEAD))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return head; -} static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadHEAD \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHEAD"); head->version = ttfGetFixed(fp); head->fontRevision = ttfGetFixed(fp); @@ -54,8 +34,10 @@ static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset) head->flags = ttfGetUSHORT(fp); head->unitsPerEm = ttfGetUSHORT(fp); - fread(head->created,sizeof(char),8,fp); - fread(head->modified,sizeof(char),8,fp); + if (fread(head->created,sizeof(char),8,fp) != 8) + ttfError("Error when getting HEAD created\n"); + if (fread(head->modified,sizeof(char),8,fp) != 8) + ttfError("Error when getting HEAD modified\n"); head->xMin = ttfGetFWord(fp); head->yMin = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/hhea.c b/Build/source/texk/ttfdump/libttf/hhea.c index 086f3b7c300..9b056dde6ab 100644 --- a/Build/source/texk/ttfdump/libttf/hhea.c +++ b/Build/source/texk/ttfdump/libttf/hhea.c @@ -7,47 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HHEAPtr ttfAllocHHEA(TTFontPtr font); static void ttfLoadHHEA(FILE *fp,HHEAPtr hhea,ULONG offset); void ttfInitHHEA(TTFontPtr font) { - ULONG tag = 'h' | 'h' << 8 | 'e' << 16 | 'a' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'h', 'e', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hhea = ttfAllocHHEA(font); + font->hhea = XCALLOC1 (HHEA); ttfLoadHHEA(font->fp,font->hhea,ptd->offset); } } -static HHEAPtr ttfAllocHHEA(TTFontPtr font) -{ - HHEAPtr hhea; - - if ((hhea = (HHEAPtr) calloc(1,sizeof(HHEA))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hhea; -} + static void ttfLoadHHEA (FILE *fp,HHEAPtr hhea,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHHEA"); hhea->version = ttfGetFixed(fp); hhea->Ascender = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/hmtx.c b/Build/source/texk/ttfdump/libttf/hmtx.c index 4d71edfe956..1dc40d06d8d 100644 --- a/Build/source/texk/ttfdump/libttf/hmtx.c +++ b/Build/source/texk/ttfdump/libttf/hmtx.c @@ -7,17 +7,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HMTXPtr ttfAllocHMTX(TTFontPtr font); static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset); /* Caution: Because of interdependency between tables, @@ -26,52 +17,36 @@ static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset); */ void ttfInitHMTX(TTFontPtr font) { - ULONG tag = 'h' | 'm' << 8 | 't' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'm', 't', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hmtx = ttfAllocHMTX(font); + font->hmtx = XCALLOC1 (HMTX); font->hmtx->numberOfHMetrics = font->hhea->numberOfHMetrics; font->hmtx->numberOfLSB = font->maxp->numGlyphs - font->hhea->numberOfHMetrics; ttfLoadHMTX(font->fp,font->hmtx,ptd->offset); } } -static HMTXPtr ttfAllocHMTX(TTFontPtr font) -{ - HMTXPtr hmtx; - if ((hmtx = (HMTXPtr) calloc(1,sizeof(HMTX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hmtx; -} static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset) { USHORT i,n = hmtx->numberOfHMetrics,m=hmtx->numberOfLSB; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADHMTX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHMTX"); - if ((hmtx->hMetrics = (longHorMetric *) calloc(n,sizeof(longHorMetric))) != NULL) - { - for (i=0;i<n;i++) - { - (hmtx->hMetrics+i)->advanceWidth = ttfGetuFWord(fp); - (hmtx->hMetrics+i)->lsb = ttfGetFWord(fp); - } - } - else + hmtx->hMetrics = XCALLOC (n, longHorMetric); + for (i=0;i<n;i++) { - ttfError("Out Of Memory in __FILE__ : __LINE__\n"); + (hmtx->hMetrics+i)->advanceWidth = ttfGetuFWord(fp); + (hmtx->hMetrics+i)->lsb = ttfGetFWord(fp); } /* codes dealing with leftSideBearing entry */ - if (m && ((hmtx->leftSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL)) + if (m) { + hmtx->leftSideBearing = XCALLOC (m, FWord); for (i=0;i<m;i++) { (hmtx->leftSideBearing)[i] = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/interp.c b/Build/source/texk/ttfdump/libttf/interp.c index 6adfbee38bc..030c4bbadde 100644 --- a/Build/source/texk/ttfdump/libttf/interp.c +++ b/Build/source/texk/ttfdump/libttf/interp.c @@ -5,19 +5,11 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - /* A bit about error checking: The execution of a TrueType instruction is - * "atomic" which mean that we don't process the error until a single - * instruction is fully decoded and exectued */ + * "atomic" which means that we don't process the error until a single + * instruction is fully decoded and executed */ /* Pushing data onto the interpreter stack */ diff --git a/Build/source/texk/ttfdump/libttf/kern.c b/Build/source/texk/ttfdump/libttf/kern.c index 79e8cb6ebd3..54104a0aba4 100644 --- a/Build/source/texk/ttfdump/libttf/kern.c +++ b/Build/source/texk/ttfdump/libttf/kern.c @@ -7,53 +7,32 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static KERNPtr ttfAllocKERN(TTFontPtr font); static void ttfLoadKERN(FILE *fp,KERNPtr kern,ULONG offset); void ttfInitKERN(TTFontPtr font) { - ULONG tag = 'k' | 'e' << 8 | 'r' << 16 | 'n' << 24; + ULONG tag = FT_MAKE_TAG ('k', 'e', 'r', 'n'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->kern = ttfAllocKERN(font); + font->kern = XCALLOC1 (KERN); ttfLoadKERN(font->fp,font->kern,ptd->offset); } } -static KERNPtr ttfAllocKERN(TTFontPtr font) -{ - KERNPtr kern; - - if ((kern = (KERNPtr) calloc(1,sizeof(KERN))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return kern; -} + static void ttfLoadKERN (FILE *fp,KERNPtr kern,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadKERN \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadKERN"); kern->version = ttfGetUSHORT(fp); kern->nTables = ttfGetUSHORT(fp); - kern->subtable = (KernSubtable *) calloc(kern->nTables, - sizeof(KernSubtable)); + kern->subtable = XCALLOC (kern->nTables, KernSubtable); for (i=0;i<kern->nTables;i++) { @@ -75,7 +54,7 @@ static void ttfLoadKERN (FILE *fp,KERNPtr kern,ULONG offset) (kern->subtable+i)->kern.kern0.rangeShift = ttfGetUSHORT(fp); (kern->subtable+i)->kern.kern0.pairs = pairs = - (struct kernpair *) calloc(n,sizeof (struct kernpair)); + XCALLOC (n, struct kernpair); for (j=0;j<n;j++) { @@ -114,7 +93,7 @@ void ttfPrintKERN(FILE *fp,KERNPtr kern) (kern->subtable+i)->version); fprintf(fp,"\t Bytes in subtable \t %d\n", (kern->subtable+i)->length); - fprintf(fp,"\t Coverage bits \t 0x%x \n", + fprintf(fp,"\t Coverage bits \t 0x%x\n", (kern->subtable+i)->coverage); switch ((kern->subtable+i)->coverage >> 8) { diff --git a/Build/source/texk/ttfdump/libttf/loca.c b/Build/source/texk/ttfdump/libttf/loca.c index 3d09b8959a8..44ec5e05fcc 100644 --- a/Build/source/texk/ttfdump/libttf/loca.c +++ b/Build/source/texk/ttfdump/libttf/loca.c @@ -4,22 +4,14 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static LOCAPtr ttfAllocLOCA(TTFontPtr font); static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset); void ttfInitLOCA(TTFontPtr font) { - ULONG tag = 'l' | 'o' << 8 | 'c' << 16 | 'a' <<24; + ULONG tag = FT_MAKE_TAG ('l', 'o', 'c', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) @@ -33,33 +25,21 @@ static LOCAPtr ttfAllocLOCA(TTFontPtr font) USHORT n=0; LOCAPtr loca; - if ((loca = (LOCAPtr) calloc(1,sizeof(LOCA))) == NULL) - { - ttfError("Out of Memory\n"); - } - else - { - loca->indexToLocFormat = font->head->indexToLocFormat; - loca->numGlyphs = n = font->maxp->numGlyphs; - } + loca = XCALLOC1 (LOCA); + loca->indexToLocFormat = font->head->indexToLocFormat; + loca->numGlyphs = n = font->maxp->numGlyphs; n += 1;/* the number of loca entry is numberOfGlyph+1 */ - if ((loca->offset = (ULONG *) calloc(n,sizeof(ULONG))) == NULL) - { - ttfError("Out Of Memory\n"); - free (loca); - return NULL; - } + loca->offset = XCALLOC (n, ULONG); return loca; } static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset) { - /* warrning: the number of loca entry is numberOfGlyph+1 !! */ + /* warning: the number of loca entry is numberOfGlyph+1 !! */ USHORT i,n = loca->numGlyphs+1; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADLOCA \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadLOCA"); switch (loca->indexToLocFormat) { @@ -70,11 +50,7 @@ static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset) } break; case LOCA_OFFSET_LONG: - if (fread(loca->offset,sizeof(ULONG),n,fp) != n) - ttfError("Error reading loca data\n"); -#ifndef WORDS_BIGENDIAN - FourByteSwap((unsigned char *) loca->offset,n*sizeof(ULONG)); -#endif + ttfReadULONG (loca->offset, n, fp); break; } } diff --git a/Build/source/texk/ttfdump/libttf/ltsh.c b/Build/source/texk/ttfdump/libttf/ltsh.c index 7f50b22f73b..a433c32a06a 100644 --- a/Build/source/texk/ttfdump/libttf/ltsh.c +++ b/Build/source/texk/ttfdump/libttf/ltsh.c @@ -7,53 +7,30 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static LTSHPtr ttfAllocLTSH(TTFontPtr font); static void ttfLoadLTSH(FILE *fp,LTSHPtr ltsh,ULONG offset); void ttfInitLTSH(TTFontPtr font) { - ULONG tag = 'L' | 'T' << 8 | 'S' << 16 | 'H' << 24; + ULONG tag = FT_MAKE_TAG ('L', 'T', 'S', 'H'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->ltsh = ttfAllocLTSH(font); + font->ltsh = XCALLOC1 (LTSH); ttfLoadLTSH(font->fp,font->ltsh,ptd->offset); } } -static LTSHPtr ttfAllocLTSH(TTFontPtr font) -{ - LTSHPtr ltsh; - - if ((ltsh = (LTSHPtr) calloc(1,sizeof(LTSH))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return ltsh; -} + static void ttfLoadLTSH (FILE *fp,LTSHPtr ltsh,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadLTSH \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadLTSH"); ltsh->version = ttfGetUSHORT(fp); ltsh->numGlyphs = ttfGetUSHORT(fp); - ltsh->yPels = (BYTE *) calloc(ltsh->numGlyphs, sizeof(BYTE)); - - if(fread(ltsh->yPels, sizeof(BYTE), ltsh->numGlyphs, fp) != ltsh->numGlyphs) - ttfError("Error when getting yPels\n"); + ltsh->yPels = ttfMakeBYTE (ltsh->numGlyphs, fp); } void ttfPrintLTSH(FILE *fp,LTSHPtr ltsh) diff --git a/Build/source/texk/ttfdump/libttf/maxp.c b/Build/source/texk/ttfdump/libttf/maxp.c index 8a8a81eb74a..cefa38a4c0d 100644 --- a/Build/source/texk/ttfdump/libttf/maxp.c +++ b/Build/source/texk/ttfdump/libttf/maxp.c @@ -4,45 +4,25 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static MAXPPtr ttfAllocMAXP(TTFontPtr font); static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset); void ttfInitMAXP(TTFontPtr font) { - ULONG tag = 'm' | 'a' << 8 | 'x' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('m', 'a', 'x', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->maxp = ttfAllocMAXP(font); + font->maxp = XCALLOC1 (MAXP); ttfLoadMAXP(font->fp,font->maxp,ptd->offset); } } -static MAXPPtr ttfAllocMAXP(TTFontPtr font) -{ - MAXPPtr maxp; - if ((maxp = (MAXPPtr) calloc(1,sizeof(MAXP))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return maxp; -} static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadMAXP"); maxp->version = ttfGetFixed(fp); maxp->numGlyphs = ttfGetUSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/name.c b/Build/source/texk/ttfdump/libttf/name.c index 968af094c7e..2ccc971c688 100644 --- a/Build/source/texk/ttfdump/libttf/name.c +++ b/Build/source/texk/ttfdump/libttf/name.c @@ -6,17 +6,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static NAMEPtr ttfAllocNAME(TTFontPtr font); static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset); static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset); static void ttfPrintNameRecord(FILE *fp,NameRecordPtr rec); @@ -27,40 +18,28 @@ static void HexDump(char *p,char *hex,char *asc,int len); void ttfInitNAME(TTFontPtr font) { - ULONG tag = 'n' | 'a' << 8 | 'm' << 16 | 'e' <<24; + ULONG tag = FT_MAKE_TAG ('n', 'a', 'm', 'e'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->name = ttfAllocNAME(font); + font->name = XCALLOC1 (NAME); ttfLoadNAME(font->fp,font->name,ptd->offset); } } -static NAMEPtr ttfAllocNAME(TTFontPtr font) -{ - NAMEPtr name; - if((name = (NAMEPtr) calloc(1,sizeof(NAME))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return name; -} static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset) { USHORT i,n; ULONG pos; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADNAME \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadNAME"); name->format = ttfGetUSHORT(fp); name->numberOfRecords = n = ttfGetUSHORT(fp); name->offset = ttfGetUSHORT(fp); - if ((name->NameRecords = (NameRecordPtr) calloc(n,sizeof(NameRecord))) == NULL) - ttfError("Out Of Memory\n"); + name->NameRecords = XCALLOC (n, NameRecord); pos = offset + sizeof(USHORT)*3; @@ -98,8 +77,7 @@ void ttfFreeNAME(NAMEPtr name) /* offset: address of the beginning of the name record */ static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadNameRecord \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadNameRecord"); rec->PlatformID = ttfGetUSHORT(fp); rec->EncodingID = ttfGetUSHORT(fp); @@ -126,11 +104,9 @@ static void ttfLoadNameRecordData(FILE *fp,NameRecordPtr rec,ULONG offset) ULONG pos; pos = offset + rec->offset; - if (fseek(fp,pos,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadSubTable\n"); + xfseek(fp, pos, SEEK_SET, "ttfLoadNameRecordData"); - if ((rec->data = (char *) calloc(rec->length,sizeof(char))) == NULL) - ttfError("Out Of Memory\n"); + rec->data = XTALLOC (rec->length, char); if (fread(rec->data,sizeof(char),rec->length,fp) != rec->length) ttfError("Error when getting Name Record Data\n"); } diff --git a/Build/source/texk/ttfdump/libttf/os2.c b/Build/source/texk/ttfdump/libttf/os2.c index b6d21072e5f..b140c356d6b 100644 --- a/Build/source/texk/ttfdump/libttf/os2.c +++ b/Build/source/texk/ttfdump/libttf/os2.c @@ -8,47 +8,25 @@ #define __TTF_OS2 #include "os2_P.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $"; -#endif /* lint */ - -static OS_2Ptr ttfAllocOS2(TTFontPtr font); static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset); void ttfInitOS2(TTFontPtr font) { - ULONG tag = 'O' | 'S' << 8 | '/' << 16 | '2' << 24; + ULONG tag = FT_MAKE_TAG ('O', 'S', '/', '2'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) { - font->os2 = ttfAllocOS2(font); + font->os2 = XCALLOC1 (OS_2); ttfLoadOS2(font->fp, font->os2, ptd->offset); } } -static OS_2Ptr ttfAllocOS2(TTFontPtr font) -{ - OS_2Ptr os2; - - if ((os2 = (OS_2Ptr) calloc(1, sizeof(OS_2))) == NULL) - { - ttfError("Out of Memofy in __FILE__:__LINE__\n"); - return NULL; - } - return os2; -} - static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset) { - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadGLYF\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadOS2"); os2->version = ttfGetUSHORT(fp); os2->xAvgCharWidth = ttfGetSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/pclt.c b/Build/source/texk/ttfdump/libttf/pclt.c index e62574a7f04..b2108d43a45 100644 --- a/Build/source/texk/ttfdump/libttf/pclt.c +++ b/Build/source/texk/ttfdump/libttf/pclt.c @@ -7,47 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static PCLTPtr ttfAllocPCLT(TTFontPtr font); static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset); void ttfInitPCLT(TTFontPtr font) { - ULONG tag = 'P' | 'C' << 8 | 'L' << 16 | 'T' << 24; + ULONG tag = FT_MAKE_TAG ('P', 'C', 'L', 'T'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->pclt = ttfAllocPCLT(font); + font->pclt = XCALLOC1 (PCLT); ttfLoadPCLT(font->fp,font->pclt,ptd->offset); } } -static PCLTPtr ttfAllocPCLT(TTFontPtr font) -{ - PCLTPtr pclt; - if ((pclt = (PCLTPtr) calloc(1,sizeof(PCLT))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return pclt; -} static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPCLT"); pclt->version = ttfGetFixed(fp); pclt->FontNumber = ttfGetULONG(fp); @@ -78,7 +58,7 @@ void ttfPrintPCLT(FILE *fp,PCLTPtr pclt) fprintf(fp,"`PCLT' Table - Printer Command Language Table\n"); fprintf(fp,"---------------------------------------------\n"); fprintf(fp,"\t version \t %d.%d\n",b[1],b[0]); - fprintf(fp,"\t fontNumber \t %d (0x%x) \n",pclt->FontNumber, + fprintf(fp,"\t fontNumber \t %d (0x%x)\n",pclt->FontNumber, pclt->FontNumber ); fprintf(fp,"\t pitch \t %d\n",pclt->Pitch); fprintf(fp,"\t xHeight \t %d\n",pclt->xHeight); diff --git a/Build/source/texk/ttfdump/libttf/post.c b/Build/source/texk/ttfdump/libttf/post.c index 6757ddd5979..e1a54f5ed31 100644 --- a/Build/source/texk/ttfdump/libttf/post.c +++ b/Build/source/texk/ttfdump/libttf/post.c @@ -4,46 +4,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $"; -#endif /* lint */ - -static POSTPtr ttfAllocPOST(TTFontPtr font); static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset); void ttfInitPOST(TTFontPtr font) { - ULONG tag = 'p' | 'o' << 8 | 's' << 16 | 't' << 24; + ULONG tag = FT_MAKE_TAG ('p', 'o', 's', 't'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) { - font->post = ttfAllocPOST(font); + font->post = XCALLOC1 (POST); ttfLoadPOST(font->fp, font->post, ptd->offset); } } -static POSTPtr ttfAllocPOST(TTFontPtr font) -{ - POSTPtr post; - if ((post = (POSTPtr) calloc(1, sizeof(POST))) == NULL) - { - ttfError("Out of Memofy in __FILE__:__LINE__\n"); - return NULL; - } - return post; -} static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) { USHORT i,numGlyphs; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadPOST\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPOST"); post->format = ttfGetFixed(fp); post->italicAngle = ttfGetFixed(fp); @@ -58,19 +38,11 @@ static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) switch (post->format) { case 0x00020000: - post->name.format20 = (Format20 *) calloc(1, sizeof(Format20)); + post->name.format20 = XCALLOC1 (Format20); post->name.format20->numGlyphs = numGlyphs = ttfGetUSHORT(fp); - post->name.format20->glyphNameIndex = - (USHORT *) calloc(numGlyphs, sizeof(USHORT)); - post->name.format20->GlyphName = - (CHAR **) calloc(numGlyphs, sizeof(CHAR *)); - fread(post->name.format20->glyphNameIndex, sizeof(USHORT), - numGlyphs, fp); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) post->name.format20->glyphNameIndex, - numGlyphs*sizeof(USHORT)); -#endif + post->name.format20->glyphNameIndex = ttfMakeUSHORT (numGlyphs, fp); + post->name.format20->GlyphName = XCALLOC (numGlyphs, CHAR *); for (i=0;i<numGlyphs;i++) { unsigned char len; @@ -86,8 +58,7 @@ static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) * but the string is not ended with a null * character */ len = (unsigned char) ttfGetCHAR(fp); - post->name.format20->GlyphName[i] = - (CHAR *) calloc(len+1, sizeof(CHAR)); + post->name.format20->GlyphName[i] = XTALLOC (len+1, CHAR); if (len) fread(post->name.format20->GlyphName[i], sizeof(CHAR), len, fp); diff --git a/Build/source/texk/ttfdump/libttf/prep.c b/Build/source/texk/ttfdump/libttf/prep.c index 55d674b7521..03a123ea044 100644 --- a/Build/source/texk/ttfdump/libttf/prep.c +++ b/Build/source/texk/ttfdump/libttf/prep.c @@ -7,35 +7,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT lenght,ULONG offset); void ttfInitPREP(TTFontPtr font) { - ULONG tag = 'p' | 'r' << 8 | 'e' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('p', 'r', 'e', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->prepLength = ptd->length; - font->prep = (BYTE *) calloc(font->prepLength, sizeof(BYTE)); - if (font->prep != NULL) - ttfLoadPREP(font->fp,font->prep,font->prepLength,ptd->offset); + font->prep = XCALLOC (font->prepLength, BYTE); + ttfLoadPREP(font->fp,font->prep,font->prepLength,ptd->offset); } } static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadPREP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPREP"); if (fread(prep, sizeof(BYTE), length, fp) != length) ttfError("Error when getting PREP\n"); diff --git a/Build/source/texk/ttfdump/libttf/stack.c b/Build/source/texk/ttfdump/libttf/stack.c index 5ca56deb90a..e560fc854e7 100644 --- a/Build/source/texk/ttfdump/libttf/stack.c +++ b/Build/source/texk/ttfdump/libttf/stack.c @@ -5,16 +5,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - #define stack (vm->Stack) #define sp (vm->sp) #define limit (vm->stklimit) diff --git a/Build/source/texk/ttfdump/libttf/tabledir.c b/Build/source/texk/ttfdump/libttf/tabledir.c index e950a8a7aab..390d43aa414 100644 --- a/Build/source/texk/ttfdump/libttf/tabledir.c +++ b/Build/source/texk/ttfdump/libttf/tabledir.c @@ -9,17 +9,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $"; -#endif /* lint */ - -static TableDirPtr ttfAllocTableDir(TTFontPtr font); static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset); #define Offset 12 /* start point of table dir */ @@ -28,7 +19,7 @@ void ttfInitTableDir(TTFontPtr font, ULONG offset) { int i,pos; /* table directory starts form position 12 */ - font->dir = ttfAllocTableDir(font); + font->dir = XCALLOC (font->numTables, TableDir); pos = Offset + offset; for (i=0;i<font->numTables;i++) { @@ -37,24 +28,11 @@ void ttfInitTableDir(TTFontPtr font, ULONG offset) } } -static TableDirPtr ttfAllocTableDir(TTFontPtr font) -{ - TableDirPtr ptable; - - if ((ptable = (TableDirPtr) calloc(font->numTables,sizeof(TableDir))) == NULL) - { - ttfError("Out Of memory\n in __FILE__:__LINE__"); - return NULL; - } - return ptable; -} - static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadTableDir"); - p -> tag = (ULONG) ttfGetLSB32(fp); + p -> tag = ttfGetULONG(fp); p -> checksum = ttfGetULONG(fp); p -> offset = ttfGetULONG(fp); p -> length = ttfGetULONG(fp); @@ -62,17 +40,8 @@ static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset) void ttfPrintTableDir(FILE *fp,TableDirPtr p) { - char tagname[5]; - - /* make ULONG tag names more like a string */ - memcpy(tagname,&(p->tag),4); - tagname[4] = '\0'; -#ifdef WORDS_BIGENDIAN - FourByteSwap((unsigned char *)tagname,4); -#endif - - fprintf(fp,"'%s' - checksum = 0x%08x, offset = 0x%08x, len = %9u \n", - tagname,p->checksum,p->offset,p->length); + fprintf(fp,"'%s' - checksum = 0x%08x, offset = 0x%08x, len = %9u\n", + TagToStr(p->tag),p->checksum,p->offset,p->length); } void ttfFreeTableDir(TableDirPtr p) @@ -112,7 +81,7 @@ ULONG ttfCalcTableCheckSum(ULONG tagname,TTFontPtr font) Length = ((ptable->length+3) & ~3) / sizeof(ULONG); ptable = ttfLookUpTableDir(tagname, font); - fseek(font->fp,ptable->offset,SEEK_SET); + xfseek(font->fp, ptable->offset, SEEK_SET, "ttfCalcTableCheckSum"); while (Length--) { diff --git a/Build/source/texk/ttfdump/libttf/ttc.c b/Build/source/texk/ttfdump/libttf/ttc.c index 853fcc103b5..72741083869 100644 --- a/Build/source/texk/ttfdump/libttf/ttc.c +++ b/Build/source/texk/ttfdump/libttf/ttc.c @@ -10,19 +10,11 @@ #include "ttfutil.h" #include "ttc.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - TTCHeaderPtr ttfLoadTTCHeader(char * filename) { - ULONG tag = 't' | 't' << 8 | 'c' << 16 | 'f' << 24; + ULONG tag = FT_MAKE_TAG ('t', 't', 'c', 'f'); TTCHeaderPtr ttc; FILE *fp; @@ -31,24 +23,14 @@ TTCHeaderPtr ttfLoadTTCHeader(char * filename) fprintf(stderr,"Can't open ttc file %s\n",filename); return NULL; } - ttc = (TTCHeaderPtr) calloc(1, sizeof(TTCHeader)); + ttc = XCALLOC1 (TTCHeader); /* True Type Collection's TTCHeader */ - if ((ttc->TTCTag = (ULONG) ttfGetLSB32(fp)) == tag) + if ((ttc->TTCTag = ttfGetULONG(fp)) == tag) { ttc->version = ttfGetFixed(fp); ttc->DirCount = (USHORT) ttfGetULONG(fp); - ttc->offset = (ULONG *) calloc(ttc->DirCount, - sizeof(ULONG)); - if (fread(ttc->offset, sizeof(ULONG), - ttc->DirCount,fp) != ttc->DirCount) - { - ttfError("Error when reading Table Direcotry Offset/n"); - } -#ifndef WORDS_BIGENDIAN - FourByteSwap((unsigned char *) ttc->offset, - ttc->DirCount*sizeof(ULONG)); -#endif + ttc->offset = ttfMakeULONG (ttc->DirCount, fp); ttfLoadTTCFont(ttc,fp); return ttc; } @@ -61,13 +43,8 @@ void ttfLoadTTCFont(TTCHeaderPtr ttc,FILE *fp) { int i; - ttc->font = (TTFontPtr) calloc(ttc->DirCount, sizeof(TTFont)); + ttc->font = XCALLOC (ttc->DirCount, TTFont); - if (ttc->font == NULL) - { - ttfError("Out of Memory"); - return; - } /* currently, we are loading all fonts in a TTC file. * I still can't find a good way to share the data. */ for (i=0;i<ttc->DirCount;i++) diff --git a/Build/source/texk/ttfdump/libttf/ttfread.c b/Build/source/texk/ttfdump/libttf/ttfread.c index aabad984041..a707113fffc 100644 --- a/Build/source/texk/ttfdump/libttf/ttfread.c +++ b/Build/source/texk/ttfdump/libttf/ttfread.c @@ -15,39 +15,18 @@ typedef long blkcnt_t; /* number of blocks in the file */ /* $Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $"; -#endif /* lint */ - BYTE ttfGetBYTE(FILE *fp) { int cc; if ((cc = fgetc(fp)) == EOF) { - /*if (feof(fp) != 0) - ttfError("Unexpected EOF \n"); + if (feof(fp) != 0) + ttfError("Unexpected EOF\n"); else - ttfError("Error Getting BYTE\n");*/ + ttfError("Error Getting BYTE\n"); } return (BYTE) cc; } -short ttfGetLSB16(FILE *fp) -{ - int cc; - cc = ttfGetBYTE(fp); - cc |= ttfGetBYTE(fp) <<8; - return cc; -} - -int ttfGetLSB32(FILE *fp) -{ - int cc; - cc = ttfGetBYTE(fp); - cc |= ttfGetBYTE(fp) << 8; - cc |= ttfGetBYTE(fp) << 16; - cc |= ttfGetBYTE(fp) << 24; - return cc; -} CHAR ttfGetCHAR(FILE *fp) { @@ -55,7 +34,7 @@ CHAR ttfGetCHAR(FILE *fp) if ((cc = fgetc(fp)) == EOF) { if (feof(fp) != 0) - ttfError("Unexpected EOF \n"); + ttfError("Unexpected EOF\n"); else ttfError("Error Getting CHAR\n"); } @@ -71,7 +50,7 @@ USHORT ttfGetUSHORT(FILE *fp) return (USHORT) cc; } -USHORT ttfGetSHORT(FILE *fp) +SHORT ttfGetSHORT(FILE *fp) { int cc; cc = ttfGetBYTE(fp) << 8; @@ -127,3 +106,71 @@ F2Dot14 ttfGetF2Dot14(FILE *fp) return (F2Dot14) ttfGetUSHORT(fp); } +/* Read arrays. */ +void ttfReadUSHORT(USHORT *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetUSHORT (fp); +} + +void ttfReadULONG(ULONG *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetULONG (fp); +} + +void ttfReadFWord(FWord *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetFWord (fp); +} + +/* Allocate and read arrays. */ +BYTE *ttfMakeBYTE(size_t nelem, FILE *fp) +{ + int i; + BYTE *array = XTALLOC (nelem, BYTE); + for (i = 0; i < nelem; i++) + array[i] = ttfGetBYTE (fp); + return array; +} + +USHORT *ttfMakeUSHORT(size_t nelem, FILE *fp) +{ + int i; + USHORT *array = XTALLOC (nelem, USHORT); + for (i = 0; i < nelem; i++) + array[i] = ttfGetUSHORT (fp); + return array; +} + +SHORT *ttfMakeSHORT(size_t nelem, FILE *fp) +{ + int i; + SHORT *array = XTALLOC (nelem, SHORT); + for (i = 0; i < nelem; i++) + array[i] = ttfGetSHORT (fp); + return array; +} + +ULONG *ttfMakeULONG(size_t nelem, FILE *fp) +{ + int i; + ULONG *array = XTALLOC (nelem, ULONG); + for (i = 0; i < nelem; i++) + array[i] = ttfGetULONG (fp); + return array; +} + +LONG *ttfMakeLONG(size_t nelem, FILE *fp) +{ + int i; + LONG *array = XTALLOC (nelem, LONG); + for (i = 0; i < nelem; i++) + array[i] = ttfGetLONG (fp); + return array; +} + diff --git a/Build/source/texk/ttfdump/libttf/ttfutil.c b/Build/source/texk/ttfdump/libttf/ttfutil.c index 1c3402b5521..96a1bd3eb53 100644 --- a/Build/source/texk/ttfdump/libttf/ttfutil.c +++ b/Build/source/texk/ttfdump/libttf/ttfutil.c @@ -1,13 +1,11 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include "ttf.h" #include "ttfutil.h" /* $Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - /* FixedSplit: split Fixed in to two interger (16.16) */ void FixedSplit(Fixed f,int b[]) { @@ -15,43 +13,65 @@ void FixedSplit(Fixed f,int b[]) b[1] = f >> 16; } -/* - * Invert byte order within each 16-bits of an array. - */ -void -TwoByteSwap(unsigned char *buf, int nbytes) +char * +TagToStr(ULONG tag) { - register unsigned char c; - - for (; nbytes > 0; nbytes -= 2, buf += 2) - { - c = buf[0]; - buf[0] = buf[1]; - buf[1] = c; - } + static char str[5] = "XXXX"; + + str[0] = (tag >> 24) & 0xff; + str[1] = (tag >> 16) & 0xff; + str[2] = (tag >> 8) & 0xff; + str[3] = tag & 0xff; + return str; } -/* - * Invert byte order within each 32-bits of an array. - */ +void ttfError(const char * msg) +{ + fprintf(stderr,"%s",msg); + exit(EXIT_FAILURE); +} +/* Functions copied or adapted from kpathsea. */ void -FourByteSwap(unsigned char *buf, int nbytes) +xfseek (FILE *f, long offset, int wherefrom, const char *funcname) { - register unsigned char c; - - for (; nbytes > 0; nbytes -= 4, buf += 4) - { - c = buf[0]; - buf[0] = buf[3]; - buf[3] = c; - c = buf[1]; - buf[1] = buf[2]; - buf[2] = c; - } + if (fseek (f, offset, wherefrom) < 0) { + FATAL_PERROR(funcname); + } } -void ttfError(const char * msg) +void * +xmalloc (size_t size) { - fprintf(stderr,"%s",msg); + void *new_mem = (void *)malloc(size ? size : 1); + + if (new_mem == NULL) { + fprintf(stderr, "fatal: memory exhausted (xmalloc of %lu bytes).\n", + (unsigned long)size); + exit(EXIT_FAILURE); + } + + return new_mem; +} + +void * +xcalloc (size_t nelem, size_t elsize) +{ + void *new_mem = (void*)calloc(nelem ? nelem : 1, elsize ? elsize : 1); + + if (new_mem == NULL) { + fprintf(stderr, + "xcalloc: request for %lu elements of size %lu failed.\n", + (unsigned long)nelem, (unsigned long)elsize); + exit(EXIT_FAILURE); + } + + return new_mem; +} + +char * +xstrdup (const char *s) +{ + char *new_string = xmalloc(strlen (s) + 1); + return strcpy(new_string, s); } diff --git a/Build/source/texk/ttfdump/libttf/vdmx.c b/Build/source/texk/ttfdump/libttf/vdmx.c index ad5629acfe7..2cfc0ef34e7 100644 --- a/Build/source/texk/ttfdump/libttf/vdmx.c +++ b/Build/source/texk/ttfdump/libttf/vdmx.c @@ -7,55 +7,33 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static VDMXPtr ttfAllocVDMX(TTFontPtr font); static void ttfLoadVDMX(FILE *fp,VDMXPtr vdmx,ULONG offset); void ttfInitVDMX(TTFontPtr font) { - ULONG tag = 'V' | 'D' << 8 | 'M' << 16 | 'X' << 24; + ULONG tag = FT_MAKE_TAG ('V', 'D', 'M', 'X'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vdmx = ttfAllocVDMX(font); + font->vdmx = XCALLOC1 (VDMX); ttfLoadVDMX(font->fp,font->vdmx,ptd->offset); } } -static VDMXPtr ttfAllocVDMX(TTFontPtr font) -{ - VDMXPtr vdmx; - - if ((vdmx = (VDMXPtr) calloc(1,sizeof(VDMX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vdmx; -} + static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadVDMX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVDMX"); vdmx->version = ttfGetUSHORT(fp); vdmx->numRecs = ttfGetUSHORT(fp); vdmx->numRatios = ttfGetUSHORT(fp); - vdmx->ratRange = (Ratios *) calloc(vdmx->numRatios, sizeof(Ratios)); - vdmx->offset = (USHORT *) calloc(vdmx->numRatios, sizeof(USHORT)); - vdmx->groups = (Vdmx *) calloc(vdmx->numRecs, sizeof(Vdmx)); + vdmx->ratRange = XCALLOC (vdmx->numRatios, Ratios); for (i=0;i<vdmx->numRatios;i++) { (vdmx->ratRange+i)->CharSet = ttfGetBYTE(fp); @@ -64,14 +42,10 @@ static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) (vdmx->ratRange+i)->yEndRatio = ttfGetBYTE(fp); } - if (fread(vdmx->offset, sizeof(USHORT), vdmx->numRatios,fp) != - vdmx->numRatios) - ttfError("Error when getting Offset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) vdmx->offset, - vdmx->numRatios*sizeof(USHORT)); -#endif + vdmx->offset = ttfMakeUSHORT (vdmx->numRatios, fp); + + vdmx->groups = XCALLOC (vdmx->numRecs, Vdmx); for (i=0;i<vdmx->numRecs;i++) { int j; @@ -79,8 +53,7 @@ static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) (vdmx->groups+i)->startsz = ttfGetBYTE(fp); (vdmx->groups+i)->endsz = ttfGetBYTE(fp); - (vdmx->groups+i)->entry = - (vTable *) calloc((vdmx->groups+i)->recs, sizeof(vTable)); + (vdmx->groups+i)->entry = XCALLOC ((vdmx->groups+i)->recs, vTable); for (j=0;j<(vdmx->groups+i)->recs;j++) { diff --git a/Build/source/texk/ttfdump/libttf/vhea.c b/Build/source/texk/ttfdump/libttf/vhea.c index e00c4f2268f..374c2c1bef7 100644 --- a/Build/source/texk/ttfdump/libttf/vhea.c +++ b/Build/source/texk/ttfdump/libttf/vhea.c @@ -7,48 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - - -static VHEAPtr ttfAllocVHEA(TTFontPtr font); static void ttfLoadVHEA(FILE *fp,VHEAPtr vhea,ULONG offset); void ttfInitVHEA(TTFontPtr font) { - ULONG tag = 'v' | 'h' << 8 | 'e' << 16 | 'a' << 24; + ULONG tag = FT_MAKE_TAG ('v', 'h', 'e', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vhea = ttfAllocVHEA(font); + font->vhea = XCALLOC1 (VHEA); ttfLoadVHEA(font->fp,font->vhea,ptd->offset); } } -static VHEAPtr ttfAllocVHEA(TTFontPtr font) -{ - VHEAPtr vhea; - - if ((vhea = (VHEAPtr) calloc(1,sizeof(VHEA))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vhea; -} + static void ttfLoadVHEA (FILE *fp,VHEAPtr vhea,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadVHEA \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVHEA"); vhea->version = ttfGetFixed(fp); vhea->ascent = ttfGetSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/vmtx.c b/Build/source/texk/ttfdump/libttf/vmtx.c index 990f824a66a..d1dae4082a5 100644 --- a/Build/source/texk/ttfdump/libttf/vmtx.c +++ b/Build/source/texk/ttfdump/libttf/vmtx.c @@ -7,17 +7,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static VMTXPtr ttfAllocVMTX(TTFontPtr font); static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset); /* Caution: Because of interdependency between tables, @@ -26,12 +17,12 @@ static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset); */ void ttfInitVMTX(TTFontPtr font) { - ULONG tag = 'v' | 'm' << 8 | 't' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('v', 'm', 't', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vmtx = ttfAllocVMTX(font); + font->vmtx = XCALLOC1 (VMTX); font->vmtx->numOfLongVerMetrics = font->vhea->numOfLongVerMetrics; font->vmtx->numOfTSB = font->maxp->numGlyphs - @@ -39,40 +30,24 @@ void ttfInitVMTX(TTFontPtr font) ttfLoadVMTX(font->fp,font->vmtx,ptd->offset); } } -static VMTXPtr ttfAllocVMTX(TTFontPtr font) -{ - VMTXPtr vmtx; - if ((vmtx = (VMTXPtr) calloc(1,sizeof(VMTX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vmtx; -} static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset) { USHORT i,n = vmtx->numOfLongVerMetrics,m=vmtx->numOfTSB; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADVMTX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVMTX"); - if ((vmtx->vMetrics = (longVerMetric *) calloc(n,sizeof(longVerMetric))) != NULL) - { - for (i=0;i<n;i++) - { - (vmtx->vMetrics+i)->advanceHeight = ttfGetuFWord(fp); - (vmtx->vMetrics+i)->topSideBearing = ttfGetFWord(fp); - } - } - else + vmtx->vMetrics = XCALLOC (n, longVerMetric); + for (i=0;i<n;i++) { - ttfError("Out Of Memory in __FILE__ : __LINE__\n"); + (vmtx->vMetrics+i)->advanceHeight = ttfGetuFWord(fp); + (vmtx->vMetrics+i)->topSideBearing = ttfGetFWord(fp); } - /* codes dealing with leftSideBearing entry */ - if (m && ((vmtx->topSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL)) + /* codes dealing with topSideBearing entry */ + if (m) { + vmtx->topSideBearing = XCALLOC (m, FWord); for (i=0;i<m;i++) { (vmtx->topSideBearing)[i] = ttfGetFWord(fp); |