Partial fix for 687029, Different results on Alpha, 2nd installment
Alex Cherepanov <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Organization | Coscript Software |
| Message-ID | <[email protected]> |
Fix non-portable types in the Apple TTF header and related places. _______________________________________________ gs-code-review mailing list [email protected] http://www.ghostscript.com/mailman/listinfo/gs-code-review
types.diff
(text/plain, 13.3 KB)
Index: gs/src/ttfmain.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/ttfmain.c,v
retrieving revision 1.18
diff -b -u -r1.18 ttfmain.c
--- gs/src/ttfmain.c 14 Oct 2003 12:53:51 -0000 1.18
+++ gs/src/ttfmain.c 15 Nov 2003 12:42:10 -0000
@@ -48,8 +48,8 @@
typedef struct {
bool bCompound;
- int32 contourCount;
- uint32 pointCount;
+ int32_t contourCount;
+ uint32_t pointCount;
F26Dot6Point advance;
F26Dot6 sideBearing;
F26Dot6 xMinB, yMinB, xMaxB, yMaxB;
@@ -724,7 +724,7 @@
Clear_CodeRange(exec, TT_CodeRange_Glyph);
}
} else if (gOutline->contourCount > 0) {
- uint16 i;
+ uint16_t i;
int nPoints;
bool bInsOK;
byte *onCurve, *stop, flag;
Index: gs/src/ttfinp.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/ttfinp.c,v
retrieving revision 1.1
diff -b -u -r1.1 ttfinp.c
--- gs/src/ttfinp.c 1 Oct 2003 13:44:56 -0000 1.1
+++ gs/src/ttfinp.c 15 Nov 2003 12:42:10 -0000
@@ -42,22 +42,22 @@
{ unsigned char buf[2];
r->Read(r, buf, 2);
- return ((int16)buf[0] << 8) | (int16)buf[1];
+ return ((int16_t)buf[0] << 8) | (int16_t)buf[1];
}
unsigned short ttfReader__UShort(ttfReader *r)
{ unsigned char buf[2];
r->Read(r, buf, 2);
- return ((uint16)buf[0] << 8) | (uint16)buf[1];
+ return ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];
}
unsigned int ttfReader__UInt(ttfReader *r)
{ unsigned char buf[4];
r->Read(r, buf, 4);
- return ((int32)buf[0] << 24) | ((int32)buf[1] << 16) |
- ((int32)buf[2] << 8) | (int32)buf[3];
+ return ((int32_t)buf[0] << 24) | ((int32_t)buf[1] << 16) |
+ ((int32_t)buf[2] << 8) | (int32_t)buf[3];
}
signed int ttfReader__Int(ttfReader *r)
Index: gs/src/ttfsfnt.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/ttfsfnt.h,v
retrieving revision 1.1
diff -b -u -r1.1 ttfsfnt.h
--- gs/src/ttfsfnt.h 1 Oct 2003 13:44:56 -0000 1.1
+++ gs/src/ttfsfnt.h 15 Nov 2003 12:42:10 -0000
@@ -6,37 +6,30 @@
Copyright 1991 Apple Computer, Inc.
*/
+/* $Id: ttfmain.c,v 1.18 2003/10/14 12:53:51 igor Exp $ */
#ifndef sfntIncludes
#define sfntIncludes
-typedef unsigned char uint8; /* 8-bit unsigned integer */
-typedef signed char int8; /* 8-bit signed integer */
-typedef unsigned short int uint16; /* 16-bit unsigned integer */
-typedef signed short int int16; /* 16-bit signed integer */
-typedef unsigned long int uint32; /* 32-bit unsigned integer */
-typedef signed long int int32; /* 32-bit signed integer */
+typedef int32_t Fixed32; /* 16.16 32-bit signed fixed-point number */
+typedef int16_t FUnit; /* Smallest measurable distance in em space (16-bit signed integer) */
+typedef int16_t FWord; /* 16-bit signed integer that describes a quantity in FUnits */
+typedef uint16_t uFWord; /* 16-bit unsigned integer that describes a quantity in FUnits */
+typedef int16_t F2Dot14; /* 2.14 16-bit signed fixed-point number */
#if 0
-typedef signed long int Fixed; /* 16.16 32-bit signed fixed-point number */
-#endif
-typedef signed short int FUnit; /* Smallest measurable distance in em space (16-bit signed integer) */
-typedef signed short int FWord; /* 16-bit signed integer that describes a quantity in FUnits */
-typedef unsigned short int uFWord; /* 16-bit unsigned integer that describes a quantity in FUnits */
-typedef signed short int F2Dot14; /* 2.14 16-bit signed fixed-point number */
-#if 0
-typedef signed long int F26Dot6; /* 26.6 32-bit signed fixed-point number */
+typedef int32_t F26Dot6; /* 26.6 32-bit signed fixed-point number */
#endif
typedef struct {
- unsigned long bc;
- unsigned long ad;
+ uint32_t bc;
+ uint32_t ad;
} BigDate;
typedef struct {
- uint32 tag;
- uint32 checkSum;
- uint32 offset;
- uint32 length;
+ uint32_t tag;
+ uint32_t checkSum;
+ uint32_t offset;
+ uint32_t length;
} sfnt_DirectoryEntry;
#define SFNT_VERSION 0x10000
@@ -45,11 +38,11 @@
* The search fields limits numOffsets to 4096.
*/
typedef struct {
- Fixed version; /* 1.0 */
- uint16 numOffsets; /* number of tables */
- uint16 searchRange; /* (max2 <= numOffsets)*16 */
- uint16 entrySelector; /* log2(max2 <= numOffsets) */
- uint16 rangeShift; /* numOffsets*16-searchRange*/
+ Fixed32 version; /* 1.0 */
+ uint16_t numOffsets; /* number of tables */
+ uint16_t searchRange; /* (max2 <= numOffsets)*16 */
+ uint16_t entrySelector; /* log2(max2 <= numOffsets) */
+ uint16_t rangeShift; /* numOffsets*16-searchRange*/
sfnt_DirectoryEntry table[1]; /* table[numOffsets] */
} sfnt_OffsetTable;
@@ -72,54 +65,54 @@
#define FONT_HEADER_VERSION 0x10000
typedef struct {
- Fixed version; /* for this table, set to 1.0 */
- Fixed fontRevision; /* For Font Manufacturer */
- unsigned long checkSumAdjustment;
- unsigned long magicNumber; /* signature, should always be 0x5F0F3CF5 == MAGIC */
- unsigned short flags;
- unsigned short unitsPerEm; /* Specifies how many in Font Units we have per EM */
+ Fixed32 version; /* for this table, set to 1.0 */
+ Fixed32 fontRevision; /* For Font Manufacturer */
+ uint32_t checkSumAdjustment;
+ uint32_t magicNumber; /* signature, should always be 0x5F0F3CF5 == MAGIC */
+ uint16_t flags;
+ uint16_t unitsPerEm; /* Specifies how many in Font Units we have per EM */
BigDate created;
BigDate modified;
/** This is the font wide bounding box in ideal space
(baselines and metrics are NOT worked into these numbers) **/
- short xMin;
- short yMin;
- short xMax;
- short yMax;
+ int16_t xMin;
+ int16_t yMin;
+ int16_t xMax;
+ int16_t yMax;
- unsigned short macStyle; /* macintosh style word */
- unsigned short lowestRecPPEM; /* lowest recommended pixels per Em */
+ uint16_t macStyle; /* macintosh style word */
+ uint16_t lowestRecPPEM; /* lowest recommended pixels per Em */
/* 0: fully mixed directional glyphs, 1: only strongly L->R or T->B glyphs,
-1: only strongly R->L or B->T glyphs, 2: like 1 but also contains neutrals,
-2: like -1 but also contains neutrals */
- short fontDirectionHint;
+ int16_t fontDirectionHint;
- short indexToLocFormat;
- short glyphDataFormat;
+ int16_t indexToLocFormat;
+ int16_t glyphDataFormat;
} sfnt_FontHeader;
#define METRIC_HEADER_FORMAT 0x10000
typedef struct {
- Fixed version; /* for this table, set to 1.0 */
- short ascender;
- short descender;
- short lineGap; /* linespacing = ascender - descender + linegap */
- unsigned short advanceMax;
- short sideBearingMin; /* left or top */
- short otherSideBearingMin; /* right or bottom */
- short extentMax; /* Max of ( SB[i] + bounds[i] ), i loops through all glyphs */
- short caretSlopeNumerator;
- short caretSlopeDenominator;
- short caretOffset;
+ Fixed32 version; /* for this table, set to 1.0 */
+ int16_t ascender;
+ int16_t descender;
+ int16_t lineGap; /* linespacing = ascender - descender + linegap */
+ uint16_t advanceMax;
+ int16_t sideBearingMin; /* left or top */
+ int16_t otherSideBearingMin; /* right or bottom */
+ int16_t extentMax; /* Max of ( SB[i] + bounds[i] ), i loops through all glyphs */
+ int16_t caretSlopeNumerator;
+ int16_t caretSlopeDenominator;
+ int16_t caretOffset;
- unsigned long reserved1, reserved2; /* set to 0 */
+ uint32_t reserved1, reserved2; /* set to 0 */
- short metricDataFormat; /* set to 0 for current format */
- unsigned short numberLongMetrics; /* if format == 0 */
+ int16_t metricDataFormat; /* set to 0 for current format */
+ uint16_t numberLongMetrics; /* if format == 0 */
} sfnt_MetricsHeader;
typedef sfnt_MetricsHeader sfnt_HorizontalHeader;
@@ -128,69 +121,69 @@
#define MAX_PROFILE_VERSION 0x10000
typedef struct {
- Fixed version; /* for this table, set to 1.0 */
- unsigned short numGlyphs;
- unsigned short maxPoints; /* in an individual glyph */
- unsigned short maxContours; /* in an individual glyph */
- unsigned short maxCompositePoints; /* in an composite glyph */
- unsigned short maxCompositeContours; /* in an composite glyph */
- unsigned short maxElements; /* set to 2, or 1 if no twilightzone points */
- unsigned short maxTwilightPoints; /* max points in element zero */
- unsigned short maxStorage; /* max number of storage locations */
- unsigned short maxFunctionDefs; /* max number of FDEFs in any preprogram */
- unsigned short maxInstructionDefs; /* max number of IDEFs in any preprogram */
- unsigned short maxStackElements; /* max number of stack elements for any individual glyph */
- unsigned short maxSizeOfInstructions; /* max size in bytes for any individual glyph */
- unsigned short maxComponentElements; /* number of glyphs referenced at top level */
- unsigned short maxComponentDepth; /* levels of recursion, 1 for simple components */
+ Fixed32 version; /* for this table, set to 1.0 */
+ uint16_t numGlyphs;
+ uint16_t maxPoints; /* in an individual glyph */
+ uint16_t maxContours; /* in an individual glyph */
+ uint16_t maxCompositePoints; /* in an composite glyph */
+ uint16_t maxCompositeContours; /* in an composite glyph */
+ uint16_t maxElements; /* set to 2, or 1 if no twilightzone points */
+ uint16_t maxTwilightPoints; /* max points in element zero */
+ uint16_t maxStorage; /* max number of storage locations */
+ uint16_t maxFunctionDefs; /* max number of FDEFs in any preprogram */
+ uint16_t maxInstructionDefs; /* max number of IDEFs in any preprogram */
+ uint16_t maxStackElements; /* max number of stack elements for any individual glyph */
+ uint16_t maxSizeOfInstructions; /* max size in bytes for any individual glyph */
+ uint16_t maxComponentElements; /* number of glyphs referenced at top level */
+ uint16_t maxComponentDepth; /* levels of recursion, 1 for simple components */
} sfnt_maxProfileTable;
typedef struct {
- unsigned short advance;
- short sideBearing;
+ uint16_t advance;
+ int16_t sideBearing;
} sfnt_GlyphMetrics;
typedef sfnt_GlyphMetrics sfnt_HorizontalMetrics;
typedef sfnt_GlyphMetrics sfnt_VerticalMetrics;
-typedef short sfnt_ControlValue;
+typedef int16_t sfnt_ControlValue;
/*
* Char2Index structures, including platform IDs
*/
typedef struct {
- unsigned short format;
- unsigned short length;
- unsigned short version;
+ uint16_t format;
+ uint16_t length;
+ uint16_t version;
} sfnt_mappingTable;
typedef struct {
- unsigned short platformID;
- unsigned short specificID;
- unsigned long offset;
+ uint16_t platformID;
+ uint16_t specificID;
+ uint32_t offset;
} sfnt_platformEntry;
typedef struct {
- unsigned short version;
- unsigned short numTables;
+ uint16_t version;
+ uint16_t numTables;
sfnt_platformEntry platform[1]; /* platform[numTables] */
} sfnt_char2IndexDirectory;
#define SIZEOFCHAR2INDEXDIR 4
typedef struct {
- unsigned short platformID;
- unsigned short specificID;
- unsigned short languageID;
- unsigned short nameID;
- unsigned short length;
- unsigned short offset;
+ uint16_t platformID;
+ uint16_t specificID;
+ uint16_t languageID;
+ uint16_t nameID;
+ uint16_t length;
+ uint16_t offset;
} sfnt_NameRecord;
typedef struct {
- unsigned short format;
- unsigned short count;
- unsigned short stringOffset;
+ uint16_t format;
+ uint16_t count;
+ uint16_t stringOffset;
/* sfnt_NameRecord[count] */
} sfnt_NamingTable;
@@ -200,9 +193,9 @@
* First byte is ppem, second is maxWidth, rest are widths for each glyph
*/
typedef struct {
- short version;
- short numRecords;
- long recordSize;
+ int16_t version;
+ int16_t numRecords;
+ int32_t recordSize;
/* Byte widths[numGlyphs+DEVWIDTHEXTRA] * numRecords */
} sfnt_DeviceMetrics;
@@ -212,16 +205,16 @@
#define richardsPostTableFormat 0x30000
typedef struct {
- Fixed version;
- Fixed italicAngle;
- short underlinePosition;
- short underlineThickness;
- short isFixedPitch;
- short pad;
- unsigned long minMemType42;
- unsigned long maxMemType42;
- unsigned long minMemType1;
- unsigned long maxMemType1;
+ Fixed32 version;
+ Fixed32 italicAngle;
+ int16_t underlinePosition;
+ int16_t underlineThickness;
+ int16_t isFixedPitch;
+ int16_t pad;
+ uint32_t minMemType42;
+ uint32_t maxMemType42;
+ uint32_t minMemType1;
+ uint32_t maxMemType1;
/* if version == 2.0
{
numberGlyphs;
@@ -268,17 +261,17 @@
} componentPacking;
typedef struct {
- unsigned short firstCode;
- unsigned short entryCount;
- short idDelta;
- unsigned short idRangeOffset;
+ uint16_t firstCode;
+ uint16_t entryCount;
+ int16_t idDelta;
+ uint16_t idRangeOffset;
} sfnt_subheader;
typedef struct {
- unsigned short segCountX2;
- unsigned short searchRange;
- unsigned short entrySelector;
- unsigned short rangeShift;
+ uint16_t segCountX2;
+ uint16_t searchRange;
+ uint16_t entrySelector;
+ uint16_t rangeShift;
} sfnt_4_subheader;
/* sfnt_enum.h */
@@ -318,13 +311,13 @@
#define fCMapNotFound -5
#define fGlyphNotFound -6
-typedef long FontError;
+typedef int32_t FontError;
#endif
typedef struct FontTableInfo {
- long offset; /* from beginning of sfnt to beginning of the table */
- long length; /* length of the table */
- long checkSum; /* checkSum of the table */
+ int32_t offset; /* from beginning of sfnt to beginning of the table */
+ int32_t length; /* length of the table */
+ int32_t checkSum; /* checkSum of the table */
} FontTableInfo;
#define RAW_TRUE_TYPE_SIZE 512