diff options
author | Philipp Lohmann <pl@openoffice.org> | 2002-08-02 11:11:34 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2002-08-02 11:11:34 +0000 |
commit | df7db7b89be747977fb36938f53deff44a7893dd (patch) | |
tree | 6f8569ebdc6c4fc647e8b786b3641b8804ee9ecb /psprint/source/fontsubset | |
parent | cb387b1d0b4395a065a51d9eac10df983106bd38 (diff) |
#100608# fontsubsetting on windows
Diffstat (limited to 'psprint/source/fontsubset')
-rw-r--r-- | psprint/source/fontsubset/crc32.h | 10 | ||||
-rw-r--r-- | psprint/source/fontsubset/gsub.cxx | 18 | ||||
-rw-r--r-- | psprint/source/fontsubset/makefile.mk | 5 | ||||
-rw-r--r-- | psprint/source/fontsubset/sft.c | 538 | ||||
-rw-r--r-- | psprint/source/fontsubset/sft.h | 217 | ||||
-rw-r--r-- | psprint/source/fontsubset/ttcr.c | 388 | ||||
-rw-r--r-- | psprint/source/fontsubset/ttcr.h | 74 | ||||
-rw-r--r-- | psprint/source/fontsubset/u2big5.inc | 6 | ||||
-rw-r--r-- | psprint/source/fontsubset/u2johab.inc | 6 | ||||
-rw-r--r-- | psprint/source/fontsubset/u2prc.inc | 6 | ||||
-rw-r--r-- | psprint/source/fontsubset/u2shiftjis.inc | 6 | ||||
-rw-r--r-- | psprint/source/fontsubset/u2wansung.inc | 6 | ||||
-rw-r--r-- | psprint/source/fontsubset/xlat.c | 50 | ||||
-rw-r--r-- | psprint/source/fontsubset/xlat.h | 26 |
14 files changed, 666 insertions, 690 deletions
diff --git a/psprint/source/fontsubset/crc32.h b/psprint/source/fontsubset/crc32.h index 8fe50e1076dd..28637aeb13b1 100644 --- a/psprint/source/fontsubset/crc32.h +++ b/psprint/source/fontsubset/crc32.h @@ -2,9 +2,9 @@ * * $RCSfile: crc32.h,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:36 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: crc32.h,v 1.1.1.1 2001-05-08 11:45:36 pl Exp $ */ +/* $Id: crc32.h,v 1.2 2002-08-02 12:11:20 pl Exp $ */ /** * @@ -68,12 +68,10 @@ * @author Alexander Gelfenbain */ -#include <sys/types.h> - #ifdef __cplusplus extern "C"{ #endif - uint32 crc32(const void *ptr, size_t len); + sal_Int32 crc32(const void *ptr, sal_Int32 len); #ifdef __cplusplus } #endif diff --git a/psprint/source/fontsubset/gsub.cxx b/psprint/source/fontsubset/gsub.cxx index cb5ff86dc7e0..0ba6cd817e98 100644 --- a/psprint/source/fontsubset/gsub.cxx +++ b/psprint/source/fontsubset/gsub.cxx @@ -2,9 +2,9 @@ * * $RCSfile: gsub.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: pl $ $Date: 2002-05-29 08:49:19 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,9 +72,9 @@ extern "C" #include <map> #include <algorithm> -typedef uint32 ULONG; -typedef uint16 USHORT; -typedef uint8 FT_Byte; +typedef sal_uInt32 ULONG; +typedef sal_uInt16 USHORT; +typedef sal_uInt8 FT_Byte; typedef std::map<USHORT,USHORT> GlyphSubstitution; @@ -86,9 +86,9 @@ inline long NEXT_Long( const unsigned char* &p ) return nVal; } -inline long NEXT_UShort( const unsigned char* &p ) +inline USHORT NEXT_UShort( const unsigned char* &p ) { - long nVal = (p[0]<<8) + p[1]; + USHORT nVal = (p[0]<<8) + p[1]; p += 2; return nVal; } @@ -128,7 +128,7 @@ int ReadGSUB( struct _TrueTypeFont* pTTFile, unsigned char* pGsubBase, { const ULONG nTag = NEXT_Long( pScriptHeader ); // e.g. hani/arab/kana/hang const USHORT nOfsScriptTable= NEXT_UShort( pScriptHeader ); - if( (nTag != nRequestedScript) && (nRequestedScript != 0) ) + if( (nTag != (USHORT)nRequestedScript) && (nRequestedScript != 0) ) continue; const FT_Byte* pScriptTable = pGsubBase + nOfsScriptList + nOfsScriptTable; @@ -139,7 +139,7 @@ int ReadGSUB( struct _TrueTypeFont* pTTFile, unsigned char* pGsubBase, { const ULONG nTag = NEXT_Long( pScriptTable ); // e.g. KOR/ZHS/ZHT/JAN const USHORT nOffset= NEXT_UShort( pScriptTable ); - if( (nTag != nRequestedLangsys) && (nRequestedLangsys != 0) ) + if( (nTag != (USHORT)nRequestedLangsys) && (nRequestedLangsys != 0) ) continue; nLangsysOffset = nOffset; break; diff --git a/psprint/source/fontsubset/makefile.mk b/psprint/source/fontsubset/makefile.mk index 15e389009286..9c597f0ba759 100644 --- a/psprint/source/fontsubset/makefile.mk +++ b/psprint/source/fontsubset/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: pl $ $Date: 2001-05-08 11:45:36 $ +# last change: $Author: pl $ $Date: 2002-08-02 12:11:21 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -82,7 +82,6 @@ SLOFILES=\ $(SLO)$/list.obj \ $(SLO)$/sft.obj \ $(SLO)$/xlat.obj \ - $(SLO)$/crc32.obj \ $(SLO)$/ttcr.obj \ $(SLO)$/gsub.obj diff --git a/psprint/source/fontsubset/sft.c b/psprint/source/fontsubset/sft.c index dab1569f2044..bfb3e6dab767 100644 --- a/psprint/source/fontsubset/sft.c +++ b/psprint/source/fontsubset/sft.c @@ -2,9 +2,9 @@ * * $RCSfile: sft.c,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: pl $ $Date: 2002-04-17 08:35:04 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: sft.c,v 1.11 2002-04-17 08:35:04 pl Exp $ +/* $Id: sft.c,v 1.12 2002-08-02 12:11:22 pl Exp $ * Sun Font Tools * * Author: Alexander Gelfenbain @@ -70,8 +70,10 @@ #include <stdlib.h> #include <string.h> #include <fcntl.h> +#ifdef UNX #include <sys/mman.h> #include <sys/stat.h> +#endif #include "sft.h" #include "gsub.h" #if ! (defined(NO_TTCR) && defined(NO_TYPE42)) @@ -84,9 +86,11 @@ #include "xlat.h" #endif #ifndef NO_TYPE3 /* include CreateT3FromTTGlyphs() */ -#include "crc32.h" +#include <rtl/crc.h> #endif +#include <osl/endian.h> + #ifdef TEST7 #include <ctype.h> #endif @@ -117,14 +121,14 @@ typedef struct { /*- In horisontal writing mode right sidebearing is calculated using this formula *- rsb = aw - (lsb + xMax - xMin) -*/ typedef struct { - int16 xMin; - int16 yMin; - int16 xMax; - int16 yMax; - uint16 aw; /*- Advance Width (horisontal writing mode) */ - int16 lsb; /*- Left sidebearing (horisontal writing mode) */ - uint16 ah; /*- advance height (vertical writing mode) */ - int16 tsb; /*- top sidebearing (vertical writing mode) */ + sal_Int16 xMin; + sal_Int16 yMin; + sal_Int16 xMax; + sal_Int16 yMax; + sal_uInt16 aw; /*- Advance Width (horisontal writing mode) */ + sal_Int16 lsb; /*- Left sidebearing (horisontal writing mode) */ + sal_uInt16 ah; /*- advance height (vertical writing mode) */ + sal_Int16 tsb; /*- top sidebearing (vertical writing mode) */ } TTGlyphMetrics; #define HFORMAT_LINELEN 64 @@ -137,34 +141,34 @@ typedef struct { } HexFmt; typedef struct { - uint32 nGlyphs; /* number of glyphs in the font + 1 */ - uint32 *offs; /* array of nGlyphs offsets */ + sal_uInt32 nGlyphs; /* number of glyphs in the font + 1 */ + sal_uInt32 *offs; /* array of nGlyphs offsets */ } GlyphOffsets; /* private tags */ -static const uint32 TTFontClassTag = 0x74746663; /* 'ttfc' */ +static const sal_uInt32 TTFontClassTag = 0x74746663; /* 'ttfc' */ -static const uint32 T_true = 0x74727565; /* 'true' */ -static const uint32 T_ttcf = 0x74746366; /* 'ttcf' */ +static const sal_uInt32 T_true = 0x74727565; /* 'true' */ +static const sal_uInt32 T_ttcf = 0x74746366; /* 'ttcf' */ /* standard TrueType table tags and their ordinal numbers */ -static const uint32 T_maxp = 0x6D617870; static const uint32 O_maxp = 0; /* 'maxp' */ -static const uint32 T_glyf = 0x676C7966; static const uint32 O_glyf = 1; /* 'glyf' */ -static const uint32 T_head = 0x68656164; static const uint32 O_head = 2; /* 'head' */ -static const uint32 T_loca = 0x6C6F6361; static const uint32 O_loca = 3; /* 'loca' */ -static const uint32 T_name = 0x6E616D65; static const uint32 O_name = 4; /* 'name' */ -static const uint32 T_hhea = 0x68686561; static const uint32 O_hhea = 5; /* 'hhea' */ -static const uint32 T_hmtx = 0x686D7478; static const uint32 O_hmtx = 6; /* 'hmtx' */ -static const uint32 T_cmap = 0x636D6170; static const uint32 O_cmap = 7; /* 'cmap' */ -static const uint32 T_vhea = 0x76686561; static const uint32 O_vhea = 8; /* 'vhea' */ -static const uint32 T_vmtx = 0x766D7478; static const uint32 O_vmtx = 9; /* 'vmtx' */ -static const uint32 T_OS2 = 0x4F532F32; static const uint32 O_OS2 = 10; /* 'OS/2' */ -static const uint32 T_post = 0x706F7374; static const uint32 O_post = 11; /* 'post' */ -static const uint32 T_kern = 0x6B65726E; static const uint32 O_kern = 12; /* 'kern' */ -static const uint32 T_cvt = 0x63767420; static const uint32 O_cvt = 13; /* 'cvt_' - only used in TT->TT generation */ -static const uint32 T_prep = 0x70726570; static const uint32 O_prep = 14; /* 'prep' - only used in TT->TT generation */ -static const uint32 T_fpgm = 0x6670676D; static const uint32 O_fpgm = 15; /* 'fpgm' - only used in TT->TT generation */ -static const uint32 T_gsub = 0x47535542; static const uint32 O_gsub = 16; /* 'GSUB' */ +static const sal_uInt32 T_maxp = 0x6D617870; static const sal_uInt32 O_maxp = 0; /* 'maxp' */ +static const sal_uInt32 T_glyf = 0x676C7966; static const sal_uInt32 O_glyf = 1; /* 'glyf' */ +static const sal_uInt32 T_head = 0x68656164; static const sal_uInt32 O_head = 2; /* 'head' */ +static const sal_uInt32 T_loca = 0x6C6F6361; static const sal_uInt32 O_loca = 3; /* 'loca' */ +static const sal_uInt32 T_name = 0x6E616D65; static const sal_uInt32 O_name = 4; /* 'name' */ +static const sal_uInt32 T_hhea = 0x68686561; static const sal_uInt32 O_hhea = 5; /* 'hhea' */ +static const sal_uInt32 T_hmtx = 0x686D7478; static const sal_uInt32 O_hmtx = 6; /* 'hmtx' */ +static const sal_uInt32 T_cmap = 0x636D6170; static const sal_uInt32 O_cmap = 7; /* 'cmap' */ +static const sal_uInt32 T_vhea = 0x76686561; static const sal_uInt32 O_vhea = 8; /* 'vhea' */ +static const sal_uInt32 T_vmtx = 0x766D7478; static const sal_uInt32 O_vmtx = 9; /* 'vmtx' */ +static const sal_uInt32 T_OS2 = 0x4F532F32; static const sal_uInt32 O_OS2 = 10; /* 'OS/2' */ +static const sal_uInt32 T_post = 0x706F7374; static const sal_uInt32 O_post = 11; /* 'post' */ +static const sal_uInt32 T_kern = 0x6B65726E; static const sal_uInt32 O_kern = 12; /* 'kern' */ +static const sal_uInt32 T_cvt = 0x63767420; static const sal_uInt32 O_cvt = 13; /* 'cvt_' - only used in TT->TT generation */ +static const sal_uInt32 T_prep = 0x70726570; static const sal_uInt32 O_prep = 14; /* 'prep' - only used in TT->TT generation */ +static const sal_uInt32 T_fpgm = 0x6670676D; static const sal_uInt32 O_fpgm = 15; /* 'fpgm' - only used in TT->TT generation */ +static const sal_uInt32 T_gsub = 0x47535542; static const sal_uInt32 O_gsub = 16; /* 'GSUB' */ #define NUM_TAGS 17 #define LAST_URANGE_BIT 69 @@ -265,14 +269,14 @@ _inline void *scalloc(size_t n, size_t size) return res; } -_inline uint32 mkTag(byte a, byte b, byte c, byte d) { +_inline sal_uInt32 mkTag(sal_uInt8 a, sal_uInt8 b, sal_uInt8 c, sal_uInt8 d) { return (a << 24) | (b << 16) | (c << 8) | d; } /*- Data access macros for data stored in big-endian or little-endian format */ -_inline int16 GetInt16(const byte *ptr, size_t offset, int bigendian) +_inline sal_Int16 GetInt16(const sal_uInt8 *ptr, size_t offset, int bigendian) { - int16 t; + sal_Int16 t; assert(ptr != 0); if (bigendian) { @@ -284,9 +288,9 @@ _inline int16 GetInt16(const byte *ptr, size_t offset, int bigendian) return t; } -_inline uint16 GetUInt16(const byte *ptr, size_t offset, int bigendian) +_inline sal_uInt16 GetUInt16(const sal_uInt8 *ptr, size_t offset, int bigendian) { - uint16 t; + sal_uInt16 t; assert(ptr != 0); if (bigendian) { @@ -298,9 +302,9 @@ _inline uint16 GetUInt16(const byte *ptr, size_t offset, int bigendian) return t; } -_inline int32 GetInt32(const byte *ptr, size_t offset, int bigendian) +_inline sal_Int32 GetInt32(const sal_uInt8 *ptr, size_t offset, int bigendian) { - int32 t; + sal_Int32 t; assert(ptr != 0); if (bigendian) { @@ -314,9 +318,9 @@ _inline int32 GetInt32(const byte *ptr, size_t offset, int bigendian) return t; } -_inline uint32 GetUInt32(const byte *ptr, size_t offset, int bigendian) +_inline sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t offset, int bigendian) { - uint32 t; + sal_uInt32 t; assert(ptr != 0); @@ -331,7 +335,7 @@ _inline uint32 GetUInt32(const byte *ptr, size_t offset, int bigendian) return t; } -_inline void PutInt16(int16 val, byte *ptr, size_t offset, int bigendian) +_inline void PutInt16(sal_Int16 val, sal_uInt8 *ptr, size_t offset, int bigendian) { assert(ptr != 0); @@ -345,11 +349,11 @@ _inline void PutInt16(int16 val, byte *ptr, size_t offset, int bigendian) } -#if defined(G_BIG_ENDIAN) +#if defined(_BIG_ENDIAN) #define Int16FromMOTA(a) (a) #else -static uint16 Int16FromMOTA(uint16 a) { - return (uint16) (((byte)((a) >> 8)) | ((byte)(a) << 8)); +static sal_uInt16 Int16FromMOTA(sal_uInt16 a) { + return (sal_uInt16) (((sal_uInt8)((a) >> 8)) | ((sal_uInt8)(a) << 8)); } #endif @@ -421,7 +425,7 @@ _inline int XUnits(int unitsPerEm, int n) return (n * 1000) / unitsPerEm; } -_inline const char *UnicodeRangeName(uint16 bit) +_inline const char *UnicodeRangeName(sal_uInt16 bit) { if (bit > LAST_URANGE_BIT) bit = LAST_URANGE_BIT+1; @@ -435,10 +439,10 @@ _inline const char *UnicodeRangeName(uint16 bit) * stuff. */ -static byte *getTDEntry(TrueTypeFont *ttf, uint32 tag) /*FOLD01*/ +static sal_uInt8 *getTDEntry(TrueTypeFont *ttf, sal_uInt32 tag) /*FOLD01*/ { int l = 0, r = ttf->ntables-1, i; - uint32 t; + sal_uInt32 t; do { i = (l + r) >> 1; @@ -453,17 +457,17 @@ static byte *getTDEntry(TrueTypeFont *ttf, uint32 tag) /*FOLD01*/ return 0; } -static byte *getTable(TrueTypeFont *ttf, uint32 tag) /*FOLD01*/ +static sal_uInt8 *getTable(TrueTypeFont *ttf, sal_uInt32 tag) /*FOLD01*/ { - byte *ptr = getTDEntry(ttf, tag); + sal_uInt8 *ptr = getTDEntry(ttf, tag); if (!ptr) return 0; return ttf->ptr + GetUInt32(ptr, 8, 1); } -static uint32 getTableSize(TrueTypeFont *ttf, uint32 tag) /*FOLD01*/ +static sal_uInt32 getTableSize(TrueTypeFont *ttf, sal_uInt32 tag) /*FOLD01*/ { - byte *ptr = getTDEntry(ttf, tag); + sal_uInt8 *ptr = getTDEntry(ttf, tag); if (!ptr) return 0; return GetUInt32(ptr, 12, 1); @@ -471,12 +475,12 @@ static uint32 getTableSize(TrueTypeFont *ttf, uint32 tag) /*FOLD01*/ #endif -_inline byte *getTable(TrueTypeFont *ttf, uint32 ord) +_inline sal_uInt8 *getTable(TrueTypeFont *ttf, sal_uInt32 ord) { return ttf->tables[ord]; } -_inline uint32 getTableSize(TrueTypeFont *ttf, uint32 ord) +_inline sal_uInt32 getTableSize(TrueTypeFont *ttf, sal_uInt32 ord) { return ttf->tlens[ord]; } @@ -519,10 +523,10 @@ _inline void HexFmtDispose(HexFmt *_this) free(_this); } -static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, off_t size) +static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, sal_uInt32 size) { - byte Ch; - off_t i; + sal_uInt8 Ch; + sal_uInt32 i; if (_this->total + size > 65534) { HexFmtFlush(_this); @@ -531,7 +535,7 @@ static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, off_t size) HexFmtOpenString(_this); } for (i=0; i<size; i++) { - Ch = ((byte *) ptr)[i]; + Ch = ((sal_uInt8 *) ptr)[i]; _this->buffer[_this->bufpos++] = HexChars[Ch >> 4]; _this->buffer[_this->bufpos++] = HexChars[Ch & 0xF]; if (_this->bufpos == HFORMAT_LINELEN) { @@ -549,9 +553,9 @@ static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, off_t size) /* Outline Extraction functions */ /*FOLD01*/ /* fills the aw and lsb entries of the TTGlyphMetrics structure from hmtx table -*/ -static void GetMetrics(TrueTypeFont *ttf, uint32 glyphID, TTGlyphMetrics *metrics) +static void GetMetrics(TrueTypeFont *ttf, sal_uInt32 glyphID, TTGlyphMetrics *metrics) { - byte *table = getTable(ttf, O_hmtx); + sal_uInt8 *table = getTable(ttf, O_hmtx); metrics->aw = metrics->lsb = metrics->ah = metrics->tsb = 0; if (!table || !ttf->numberOfHMetrics) return; @@ -576,15 +580,15 @@ static void GetMetrics(TrueTypeFont *ttf, uint32 glyphID, TTGlyphMetrics *metric } } -static int GetTTGlyphOutline(TrueTypeFont *, uint32 , ControlPoint **, TTGlyphMetrics *, list ); +static int GetTTGlyphOutline(TrueTypeFont *, sal_uInt32 , ControlPoint **, TTGlyphMetrics *, list ); /* returns the number of control points, allocates the pointArray */ -static int GetSimpleTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics) /*FOLD02*/ +static int GetSimpleTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics) /*FOLD02*/ { - byte *table = getTable(ttf, O_glyf); - byte *ptr, *p, flag, n; - int16 numberOfContours; - uint16 t, instLen, lastPoint=0; + sal_uInt8 *table = getTable(ttf, O_glyf); + sal_uInt8 *ptr, *p, flag, n; + sal_Int16 numberOfContours; + sal_uInt16 t, instLen, lastPoint=0; int i, j, z; ControlPoint* pa; @@ -616,7 +620,7 @@ static int GetSimpleTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint ** i = 0; while (i <= lastPoint) { - pa[i++].flags = flag = (uint32) *p++; + pa[i++].flags = (sal_uInt32) (flag = *p++); if (flag & 8) { /*- repeat flag */ n = *p++; for (j=0; j<n; j++) { @@ -669,12 +673,12 @@ static int GetSimpleTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint ** return lastPoint + 1; } -static int GetCompoundTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, list glyphlist) /*FOLD02*/ +static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, list glyphlist) /*FOLD02*/ { - uint16 flags, index; - int16 e, f, numberOfContours; - byte *table = getTable(ttf, O_glyf); - byte *ptr; + sal_uInt16 flags, index; + sal_Int16 e, f, numberOfContours; + sal_uInt8 *table = getTable(ttf, O_glyf); + sal_uInt8 *ptr; list myPoints; ControlPoint *nextComponent, *pa; int i, np; @@ -764,8 +768,8 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint ptr += 4; } else { if (flags & ARGS_ARE_XY_VALUES) { /* args are signed */ - e = (int8) *ptr++; - f = (int8) *ptr++; + e = (sal_Int8) *ptr++; + f = (sal_Int8) *ptr++; /* printf("ARGS_ARE_XY_VALUES: %d %d\n", e & 0xFF, f & 0xFF); */ } else { /* args are unsigned */ /* printf("!ARGS_ARE_XY_VALUES\n"); */ @@ -838,9 +842,9 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint ControlPoint *cp = malloc(sizeof(ControlPoint)); cp->flags = nextComponent[i].flags; t = fixedMulDiv(a, nextComponent[i].x << 16, m) + fixedMulDiv(c, nextComponent[i].y << 16, m) + (e << 16); - cp->x = fixedMul(t, m) >> 16; + cp->x = (sal_Int16)(fixedMul(t, m) >> 16); t = fixedMulDiv(b, nextComponent[i].x << 16, n) + fixedMulDiv(d, nextComponent[i].y << 16, n) + (f << 16); - cp->y = fixedMul(t, n) >> 16; + cp->y = (sal_Int16)(fixedMul(t, n) >> 16); #ifdef DEBUG2 fprintf(stderr, "( %d %d ) -> ( %d %d )\n", nextComponent[i].x, nextComponent[i].y, cp->x, cp->y); @@ -877,10 +881,10 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint * a composite glyph. This is a safequard against endless recursion * in corrupted fonts. */ -static int GetTTGlyphOutline(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, list glyphlist) +static int GetTTGlyphOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, list glyphlist) { - byte *ptr, *table = getTable(ttf, O_glyf); - int16 numberOfContours; + sal_uInt8 *ptr, *table = getTable(ttf, O_glyf); + sal_Int16 numberOfContours; int length; int res; *pointArray = 0; @@ -1080,11 +1084,11 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat /*- Extracts a string from the name table and allocates memory for it -*/ -static char *nameExtract(byte *name, int n, int dbFlag, uint16** ucs2result ) +static char *nameExtract(sal_uInt8 *name, int n, int dbFlag, sal_uInt16** ucs2result ) { int i; char *res; - byte *ptr = name + GetUInt16(name, 4, 1) + GetUInt16(name + 6, 12 * n + 10, 1); + sal_uInt8 *ptr = name + GetUInt16(name, 4, 1) + GetUInt16(name + 6, 12 * n + 10, 1); int len = GetUInt16(name+6, 12 * n + 8, 1); if( ucs2result ) @@ -1110,11 +1114,11 @@ static char *nameExtract(byte *name, int n, int dbFlag, uint16** ucs2result ) return res; } -static int findname(byte *name, uint16 n, uint16 platformID, uint16 encodingID, uint16 languageID, uint16 nameID) +static int findname(sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID, sal_uInt16 encodingID, sal_uInt16 languageID, sal_uInt16 nameID) { int l = 0, r = n-1, i; - uint32 t1, t2; - uint32 m1, m2; + sal_uInt32 t1, t2; + sal_uInt32 m1, m2; if (n == 0) return -1; @@ -1152,8 +1156,8 @@ static int findname(byte *name, uint16 n, uint16 platformID, uint16 encodingID, static void GetNames(TrueTypeFont *t) { - byte *table = getTable(t, O_name); - uint16 n = GetUInt16(table, 2, 1); + sal_uInt8 *table = getTable(t, O_name); + sal_uInt16 n = GetUInt16(table, 2, 1); int i, r; /* PostScript name: preferred Microsoft */ @@ -1218,7 +1222,7 @@ enum cmapType { * All getGlyph?() functions and freinds are implemented by: * @author Manpreet Singh */ -static uint16 getGlyph0(const byte* cmap, uint16 c) { +static sal_uInt16 getGlyph0(const sal_uInt8* cmap, sal_uInt16 c) { if (c <= 255) { return *(cmap + 6 + c); } else { @@ -1227,25 +1231,25 @@ static uint16 getGlyph0(const byte* cmap, uint16 c) { } typedef struct _subHeader2 { - uint16 firstCode; - uint16 entryCount; - uint16 idDelta; - uint16 idRangeOffset; + sal_uInt16 firstCode; + sal_uInt16 entryCount; + sal_uInt16 idDelta; + sal_uInt16 idRangeOffset; } subHeader2; -static uint16 getGlyph2(const byte *cmap, uint16 c) { - uint16 *CMAP2 = (uint16 *) cmap; - byte theHighByte; +static sal_uInt16 getGlyph2(const sal_uInt8 *cmap, sal_uInt16 c) { + sal_uInt16 *CMAP2 = (sal_uInt16 *) cmap; + sal_uInt8 theHighByte; - byte theLowByte; + sal_uInt8 theLowByte; subHeader2* subHeader2s; - uint16* subHeader2Keys; - uint16 firstCode; + sal_uInt16* subHeader2Keys; + sal_uInt16 firstCode; int k; int ToReturn; - theHighByte = (byte)((c >> 8) & 0x00ff); - theLowByte = (byte)(c & 0x00ff); + theHighByte = (sal_uInt8)((c >> 8) & 0x00ff); + theLowByte = (sal_uInt8)(c & 0x00ff); subHeader2Keys = CMAP2 + 3; subHeader2s = (subHeader2 *)(subHeader2Keys + 256); k = Int16FromMOTA(subHeader2Keys[theHighByte]) / 8; @@ -1270,7 +1274,7 @@ static uint16 getGlyph2(const byte *cmap, uint16 c) { if(ToReturn == 0) { return MISSING_GLYPH_INDEX; } else { - return (uint16)((ToReturn + Int16FromMOTA(subHeader2s[k].idDelta)) % 0xFFFF); + return (sal_uInt16)((ToReturn + Int16FromMOTA(subHeader2s[k].idDelta)) % 0xFFFF); } } else { return MISSING_GLYPH_INDEX; @@ -1280,9 +1284,9 @@ static uint16 getGlyph2(const byte *cmap, uint16 c) { } } -static uint16 getGlyph6(const byte *cmap, uint16 c) { - uint16 firstCode; - uint16 *CMAP6 = (uint16 *) cmap; +static sal_uInt16 getGlyph6(const sal_uInt8 *cmap, sal_uInt16 c) { + sal_uInt16 firstCode; + sal_uInt16 *CMAP6 = (sal_uInt16 *) cmap; firstCode = *(CMAP6 + 3); if (c < firstCode || c > (firstCode + (*(CMAP6 + 4))/*entryCount*/ - 1)) { @@ -1292,11 +1296,11 @@ static uint16 getGlyph6(const byte *cmap, uint16 c) { } } -static uint16 GEbinsearch(uint16 *ar, uint16 length, uint16 toSearch) { +static sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSearch) { signed int low, mid, high, lastfound = 0xffff; - uint16 res; - if(length == (uint16)0 || length == (uint16)0xFFFF) { - return (uint16)0xFFFF; + sal_uInt16 res; + if(length == (sal_uInt16)0 || length == (sal_uInt16)0xFFFF) { + return (sal_uInt16)0xFFFF; } low = 0; high = length - 1; @@ -1314,24 +1318,24 @@ static uint16 GEbinsearch(uint16 *ar, uint16 length, uint16 toSearch) { } -static uint16 getGlyph4(const byte *cmap, uint16 c) { - uint16 i; +static sal_uInt16 getGlyph4(const sal_uInt8 *cmap, sal_uInt16 c) { + sal_uInt16 i; int ToReturn; - uint16 segCount; - uint16 * startCode; - uint16 * endCode; - uint16 * idDelta; - /* uint16 * glyphIdArray; */ - uint16 * idRangeOffset; - uint16 * glyphIndexArray; - uint16 *CMAP4 = (uint16 *) cmap; - /* uint16 GEbinsearch(uint16 *ar, uint16 length, uint16 toSearch); */ + sal_uInt16 segCount; + sal_uInt16 * startCode; + sal_uInt16 * endCode; + sal_uInt16 * idDelta; + /* sal_uInt16 * glyphIdArray; */ + sal_uInt16 * idRangeOffset; + sal_uInt16 * glyphIndexArray; + sal_uInt16 *CMAP4 = (sal_uInt16 *) cmap; + /* sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSearch); */ segCount = Int16FromMOTA(*(CMAP4 + 3))/2; endCode = CMAP4 + 7; i = GEbinsearch(endCode, segCount, c); - if (i == (uint16) 0xFFFF) { + if (i == (sal_uInt16) 0xFFFF) { return MISSING_GLYPH_INDEX; } startCode = endCode + segCount + 1; @@ -1353,20 +1357,20 @@ static uint16 getGlyph4(const byte *cmap, uint16 c) { static void FindCmap(TrueTypeFont *ttf) { - byte *table = getTable(ttf, O_cmap); - uint16 ncmaps = GetUInt16(table, 2, 1); + sal_uInt8 *table = getTable(ttf, O_cmap); + sal_uInt16 ncmaps = GetUInt16(table, 2, 1); int i; - uint32 ThreeZero = 0; /* MS Symbol */ - uint32 ThreeOne = 0; /* MS Unicode */ - uint32 ThreeTwo = 0; /* MS ShiftJIS */ - uint32 ThreeThree = 0; /* MS Big5 */ - uint32 ThreeFour = 0; /* MS PRC */ - uint32 ThreeFive = 0; /* MS Wansung */ - uint32 ThreeSix = 0; /* MS Johab */ + sal_uInt32 ThreeZero = 0; /* MS Symbol */ + sal_uInt32 ThreeOne = 0; /* MS Unicode */ + sal_uInt32 ThreeTwo = 0; /* MS ShiftJIS */ + sal_uInt32 ThreeThree = 0; /* MS Big5 */ + sal_uInt32 ThreeFour = 0; /* MS PRC */ + sal_uInt32 ThreeFive = 0; /* MS Wansung */ + sal_uInt32 ThreeSix = 0; /* MS Johab */ for (i = 0; i < ncmaps; i++) { - uint32 offset; - uint16 pID, eID; + sal_uInt32 offset; + sal_uInt16 pID, eID; pID = GetUInt16(table, 4 + i * 8, 1); eID = GetUInt16(table, 6 + i * 8, 1); @@ -1431,21 +1435,21 @@ static void FindCmap(TrueTypeFont *ttf) static void GetKern(TrueTypeFont *ttf) { - byte *table = getTable(ttf, O_kern); - byte *ptr; - int i; + sal_uInt8 *table = getTable(ttf, O_kern); + sal_uInt8 *ptr; + sal_uInt32 i; /* - uint16 v1; - uint32 v2; + sal_uInt16 v1; + sal_uInt32 v2; */ if (!table) goto badtable; if (GetUInt16(table, 0, 1) == 0) { /* Traditional Microsoft style table with USHORT version and nTables fields */ ttf->nkern = GetUInt16(table, 2, 1); - ttf->kerntables = calloc(ttf->nkern, sizeof(byte *)); + ttf->kerntables = calloc(ttf->nkern, sizeof(sal_uInt8 *)); assert(ttf->kerntables != 0); - memset(ttf->kerntables, 0, ttf->nkern * sizeof(byte *)); + memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *)); ttf->kerntype = KT_MICROSOFT; ptr = table + 4; for (i=0; i < ttf->nkern; i++) { @@ -1461,11 +1465,11 @@ static void GetKern(TrueTypeFont *ttf) return; } - if (GetUInt32(table, 0, 1) == 0x00010000) { /* MacOS style kern tables: fixed32 version and uint32 nTables fields */ + if (GetUInt32(table, 0, 1) == 0x00010000) { /* MacOS style kern tables: fixed32 version and sal_uInt32 nTables fields */ ttf->nkern = GetUInt32(table, 4, 1); - ttf->kerntables = calloc(ttf->nkern, sizeof(byte *)); + ttf->kerntables = calloc(ttf->nkern, sizeof(sal_uInt8 *)); assert(ttf->kerntables != 0); - memset(ttf->kerntables, 0, ttf->nkern * sizeof(byte *)); + memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *)); ttf->kerntype = KT_APPLE_NEW; ptr = table + 8; for (i = 0; i < ttf->nkern; i++) { @@ -1491,17 +1495,20 @@ static void GetKern(TrueTypeFont *ttf) /* KernGlyphsPrim?() functions expect the caller to ensure the validity of their arguments and * that x and y elements of the kern array are initialized to zeroes */ -static void KernGlyphsPrim1(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int wmode, KernData *kern) +static void KernGlyphsPrim1(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern) { fprintf(stderr, "MacOS kerning tables have not been implemented yet!\n"); } -static void KernGlyphsPrim2(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int wmode, KernData *kern) +static void KernGlyphsPrim2(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern) { - int i, j; - uint32 gpair; + sal_uInt32 i, j; + sal_uInt32 gpair; + + if( ! nglyphs ) + return; - for (i = 0; i < nglyphs - 1; i++) { + for (i = 0; i < (sal_uInt32)nglyphs - 1; i++) { gpair = (glyphs[i] << 16) | glyphs[i+1]; #ifdef DEBUG2 /* All fonts with MS kern table that I've seen so far contain just one kern subtable. @@ -1514,10 +1521,10 @@ static void KernGlyphsPrim2(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int } #endif for (j = 0; j < ttf->nkern; j++) { - uint16 coverage = GetUInt16(ttf->kerntables[j], 4, 1); - byte *ptr; + sal_uInt16 coverage = GetUInt16(ttf->kerntables[j], 4, 1); + sal_uInt8 *ptr; int npairs; - uint32 t; + sal_uInt32 t; int l, r, k; if (! ((coverage & 1) ^ wmode)) continue; @@ -1555,34 +1562,41 @@ static void KernGlyphsPrim2(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int int CountTTCFonts(const char* fname) { int nFonts = 0; - byte buffer[12]; - int fd = open(fname, O_RDONLY); - if( fd != -1 ) { - if (read(fd, buffer, 12) == 12) { + sal_uInt8 buffer[12]; + FILE* fd = fopen(fname, "rb"); + if( fd ) { + if (fread(buffer, 1, 12, fd) == 12) { if(GetUInt32(buffer, 0, 1) == T_ttcf ) nFonts = GetUInt32(buffer, 8, 1); } - close(fd); + fclose(fd); } return nFonts; } - -int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ +#if defined WIN32 +int OpenTTFont(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf) /*FOLD01*/ +#else +int OpenTTFont(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf) /*FOLD01*/ +#endif { TrueTypeFont *t; int ret, i, fd = -1; + sal_uInt32 version; + sal_uInt8 *table, *offset; + sal_uInt32 length, tag; + sal_uInt32 tdoffset = 0; /* offset to TableDirectory in a TTC file. For TTF files is 0 */ +#ifndef WIN32 struct stat st; - uint32 version; - byte *table, *offset; - uint32 length, tag; - uint32 tdoffset = 0; /* offset to TableDirectory in a TTC file. For TTF files is 0 */ +#endif int indexfmt, k; *ttf = 0; +#ifndef WIN32 if (!fname || !*fname) return SF_BADFILE; +#endif t = calloc(1,sizeof(TrueTypeFont)); assert(t != 0); @@ -1593,6 +1607,7 @@ int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ t->nglyphs = 0xFFFFFFFF; t->pGSubstitution = 0; +#ifndef WIN32 t->fname = strdup(fname); assert(t->fname != 0); @@ -1610,11 +1625,16 @@ int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ t->fsize = st.st_size; - if ((t->ptr = (byte *) mmap(0, t->fsize, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { + if ((t->ptr = (sal_uInt8 *) mmap(0, t->fsize, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { ret = SF_MEMORY; goto cleanup; } close(fd); +#else + t->fname = NULL; + t->fsize = nLen; + t->ptr = pBuffer; +#endif version = GetInt32(t->ptr, 0, 1); @@ -1646,15 +1666,15 @@ int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ t->tables = calloc(NUM_TAGS, sizeof(void *)); assert(t->tables != 0); - t->tlens = calloc(NUM_TAGS, sizeof(uint32)); + t->tlens = calloc(NUM_TAGS, sizeof(sal_uInt32)); assert(t->tlens != 0); memset(t->tables, 0, NUM_TAGS * sizeof(void *)); - memset(t->tlens, 0, NUM_TAGS * sizeof(uint32)); + memset(t->tlens, 0, NUM_TAGS * sizeof(sal_uInt32)); /* parse the tables */ - for (i=0; i<t->ntables; i++) { + for (i=0; i<(int)t->ntables; i++) { tag = GetUInt32(t->ptr + tdoffset + 12, 16 * i, 1); offset = t->ptr + GetUInt32(t->ptr + tdoffset + 12, 16 * i + 8, 1); length = GetUInt32(t->ptr + tdoffset + 12, 16 * i + 12, 1); @@ -1704,14 +1724,14 @@ int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ } k = (getTableSize(t, O_loca) / (indexfmt ? 4 : 2)) - 1; - if (k < t->nglyphs) t->nglyphs = k; /* Hack for broken Chinese fonts */ + if (k < (int)t->nglyphs) t->nglyphs = k; /* Hack for broken Chinese fonts */ table = getTable(t, O_loca); - t->goffsets = (uint32 *) calloc(1+t->nglyphs, sizeof(uint32)); + t->goffsets = (sal_uInt32 *) calloc(1+t->nglyphs, sizeof(sal_uInt32)); assert(t->goffsets != 0); - for (i = 0; i <= t->nglyphs; i++) { + for (i = 0; i <= (int)t->nglyphs; i++) { t->goffsets[i] = indexfmt ? GetUInt32(table, i << 2, 1) : GetUInt16(table, i << 1, 1) << 1; } @@ -1729,11 +1749,13 @@ int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont** ttf) /*FOLD01*/ *ttf = t; return SF_OK; +#ifndef WIN32 cleanup: + if (fd != -1) close(fd); /*- t and t->fname have been allocated! */ free(t->fname); +#endif free(t); - if (fd != -1) close(fd); return ret; } @@ -1741,7 +1763,9 @@ void CloseTTFont(TrueTypeFont *ttf) /*FOLD01*/ { if (ttf->tag != TTFontClassTag) return; +#ifndef WIN32 munmap((char *) ttf->ptr, ttf->fsize); +#endif free(ttf->fname); free(ttf->goffsets); free(ttf->psname); @@ -1756,7 +1780,7 @@ void CloseTTFont(TrueTypeFont *ttf) /*FOLD01*/ return; } -int GetTTGlyphPoints(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArray) +int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray) { return GetTTGlyphOutline(ttf, glyphID, pointArray, 0, 0); } @@ -1764,9 +1788,9 @@ int GetTTGlyphPoints(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArra #ifdef NO_LIST static #endif -int GetTTGlyphComponents(TrueTypeFont *ttf, uint32 glyphID, list glyphlist) +int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist) { - byte *ptr, *glyf = getTable(ttf, O_glyf); + sal_uInt8 *ptr, *glyf = getTable(ttf, O_glyf); int n = 1; if (glyphID >= ttf->nglyphs) return 0; @@ -1775,7 +1799,7 @@ int GetTTGlyphComponents(TrueTypeFont *ttf, uint32 glyphID, list glyphlist) listAppend(glyphlist, (void *) glyphID); if (GetInt16(ptr, 0, 1) == -1) { - uint16 flags, index; + sal_uInt16 flags, index; ptr += 10; do { flags = GetUInt16(ptr, 0, 1); @@ -1805,13 +1829,13 @@ int GetTTGlyphComponents(TrueTypeFont *ttf, uint32 glyphID, list glyphlist) #ifndef NO_TYPE3 int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FOLD00*/ - uint16 *glyphArray, byte *encoding, int nGlyphs, + sal_uInt16 *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode) { ControlPoint *pa; PSPathElement *path; int i, j, r, n; - byte *table = getTable(ttf, O_head); + sal_uInt8 *table = getTable(ttf, O_head); TTGlyphMetrics metrics; int UPEm = ttf->unitsPerEm; @@ -1896,7 +1920,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO * All CRC-32 numbers are presented as hexadecimal numbers */ - fprintf(outf, h17, crc32(ttf->ptr, ttf->fsize), nGlyphs, crc32(glyphArray, nGlyphs * 2), crc32(encoding, nGlyphs)); + fprintf(outf, h17, rtl_crc32(0, ttf->ptr, ttf->fsize), nGlyphs, rtl_crc32(0, glyphArray, nGlyphs * 2), rtl_crc32(0, encoding, nGlyphs)); fprintf(outf, h13); fprintf(outf, h14, XUnits(UPEm, GetInt16(table, 36, 1)), XUnits(UPEm, GetInt16(table, 38, 1)), XUnits(UPEm, GetInt16(table, 40, 1)), XUnits(UPEm, GetInt16(table, 42, 1))); fprintf(outf, h15); @@ -1969,19 +1993,19 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO #ifndef NO_TTCR int CreateTTFromTTGlyphs(TrueTypeFont *ttf, const char *fname, - uint16 *glyphArray, - byte *encoding, + sal_uInt16 *glyphArray, + sal_uInt8 *encoding, int nGlyphs, int nNameRecs, NameRecord *nr, - uint32 flags) + sal_uInt32 flags) { TrueTypeCreator *ttcr; TrueTypeTable *head=0, *hhea=0, *maxp=0, *cvt=0, *prep=0, *glyf=0, *fpgm=0, *cmap=0, *name=0, *post = 0, *os2 = 0; - byte *p; + sal_uInt8 *p; int i; int res; - uint32 *gID; + sal_uInt32 *gID; TrueTypeCreatorNewEmpty(T_true, &ttcr); @@ -1993,10 +2017,10 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, NameRecord newname; int n = GetTTNameRecords(ttf, &names); int n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0; - byte *cp1; - byte suffix[32]; - uint32 c1 = crc32(glyphArray, nGlyphs * 2); - uint32 c2 = crc32(encoding, nGlyphs); + sal_uInt8 *cp1; + sal_uInt8 suffix[32]; + sal_uInt32 c1 = crc32(glyphArray, nGlyphs * 2); + sal_uInt32 c2 = crc32(encoding, nGlyphs); int len; snprintf(suffix, 31, "S%08X%08X-%d", c1, c2, nGlyphs); @@ -2007,10 +2031,10 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, memcpy(newname, names+i, sizeof(NameRecord)); newname.slen = name[i].slen + strlen(suffix); */ - const byte ptr[] = {0,'T',0,'r',0,'u',0,'e',0,'T',0,'y',0,'p',0,'e',0,'S',0,'u',0,'b',0,'s',0,'e',0,'t'}; + const sal_uInt8 ptr[] = {0,'T',0,'r',0,'u',0,'e',0,'T',0,'y',0,'p',0,'e',0,'S',0,'u',0,'b',0,'s',0,'e',0,'t'}; NameRecord n1 = {1, 0, 0, 6, 14, "(byte *) TrueTypeSubset"}; NameRecord n2 = {3, 1, 1033, 6, 28, 0}; - n2.sptr = (byte *) ptr; + n2.sptr = (sal_uInt8 *) ptr; name = TrueTypeTableNew_name(0, 0); nameAdd(name, &n1); nameAdd(name, &n2); @@ -2052,7 +2076,7 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, /** glyf **/ glyf = TrueTypeTableNew_glyf(); - gID = scalloc(nGlyphs, sizeof(uint32)); + gID = scalloc(nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < nGlyphs; i++) { gID[i] = glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); @@ -2118,18 +2142,18 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, #ifndef NO_TYPE42 -static GlyphOffsets *GlyphOffsetsNew(byte *sfntP) +static GlyphOffsets *GlyphOffsetsNew(sal_uInt8 *sfntP) { GlyphOffsets *res = smalloc(sizeof(GlyphOffsets)); - byte *loca; - uint16 i, numTables = GetUInt16(sfntP, 4, 1); - uint32 locaLen; - int16 indexToLocFormat; + sal_uInt8 *loca; + sal_uInt16 i, numTables = GetUInt16(sfntP, 4, 1); + sal_uInt32 locaLen; + sal_Int16 indexToLocFormat; for (i = 0; i < numTables; i++) { - uint32 tag = GetUInt32(sfntP + 12, 16 * i, 1); - uint32 off = GetUInt32(sfntP + 12, 16 * i + 8, 1); - uint32 len = GetUInt32(sfntP + 12, 16 * i + 12, 1); + sal_uInt32 tag = GetUInt32(sfntP + 12, 16 * i, 1); + sal_uInt32 off = GetUInt32(sfntP + 12, 16 * i + 8, 1); + sal_uInt32 len = GetUInt32(sfntP + 12, 16 * i + 12, 1); if (tag == T_loca) { loca = sfntP + off; @@ -2141,7 +2165,7 @@ static GlyphOffsets *GlyphOffsetsNew(byte *sfntP) res->nGlyphs = locaLen / ((indexToLocFormat == 1) ? 4 : 2); assert(res->nGlyphs != 0); - res->offs = scalloc(res->nGlyphs, sizeof(uint32)); + res->offs = scalloc(res->nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < res->nGlyphs; i++) { if (indexToLocFormat == 1) { @@ -2161,18 +2185,18 @@ static void GlyphOffsetsDispose(GlyphOffsets *_this) } } -static void DumpSfnts(FILE *outf, byte *sfntP) +static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP) { HexFmt *h = HexFmtNew(outf); - uint16 i, numTables = GetUInt16(sfntP, 4, 1); - uint32 j, *offs, *len; + sal_uInt16 i, numTables = GetUInt16(sfntP, 4, 1); + sal_uInt32 j, *offs, *len; GlyphOffsets *go = GlyphOffsetsNew(sfntP); - byte pad[] = {0,0,0,0}; /* zeroes */ + sal_uInt8 pad[] = {0,0,0,0}; /* zeroes */ assert(numTables <= 9); /* Type42 has 9 required tables */ - offs = scalloc(numTables, sizeof(uint32)); - len = scalloc(numTables, sizeof(uint32)); + offs = scalloc(numTables, sizeof(sal_uInt32)); + len = scalloc(numTables, sizeof(sal_uInt32)); fputs("/sfnts [", outf); HexFmtOpenString(h); @@ -2180,15 +2204,15 @@ static void DumpSfnts(FILE *outf, byte *sfntP) HexFmtBlockWrite(h, sfntP+12, 16 * numTables); /* stream out the Table Directory */ for (i=0; i<numTables; i++) { - uint32 tag = GetUInt32(sfntP + 12, 16 * i, 1); - uint32 off = GetUInt32(sfntP + 12, 16 * i + 8, 1); - uint32 len = GetUInt32(sfntP + 12, 16 * i + 12, 1); + sal_uInt32 tag = GetUInt32(sfntP + 12, 16 * i, 1); + sal_uInt32 off = GetUInt32(sfntP + 12, 16 * i + 8, 1); + sal_uInt32 len = GetUInt32(sfntP + 12, 16 * i + 12, 1); if (tag != T_glyf) { HexFmtBlockWrite(h, sfntP + off, len); } else { - byte *glyf = sfntP + off; - uint32 o, l; + sal_uInt8 *glyf = sfntP + off; + sal_uInt32 o, l; for (j = 0; j < go->nGlyphs - 1; j++) { o = go->offs[j]; l = go->offs[j + 1] - o; @@ -2208,24 +2232,24 @@ static void DumpSfnts(FILE *outf, byte *sfntP) int CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, - uint16 *glyphArray, - byte *encoding, + sal_uInt16 *glyphArray, + sal_uInt8 *encoding, int nGlyphs) { TrueTypeCreator *ttcr; TrueTypeTable *head=0, *hhea=0, *maxp=0, *cvt=0, *prep=0, *glyf=0, *fpgm=0; - byte *p; + sal_uInt8 *p; int i; int res; - uint32 ver, rev; - byte *headP; + sal_uInt32 ver, rev; + sal_uInt8 *headP; - byte *sfntP; - uint32 sfntLen; + sal_uInt8 *sfntP; + sal_uInt32 sfntLen; int UPEm = ttf->unitsPerEm; - uint16 *gID; + sal_uInt16 *gID; if (nGlyphs >= 256) return SF_GLYPHNUM; @@ -2268,10 +2292,10 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, /** glyf **/ glyf = TrueTypeTableNew_glyf(); - gID = scalloc(nGlyphs, sizeof(uint32)); + gID = scalloc(nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < nGlyphs; i++) { - gID[i] = glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); + gID[i] = (sal_uInt16)glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); } AddTable(ttcr, head); AddTable(ttcr, hhea); AddTable(ttcr, maxp); AddTable(ttcr, cvt); @@ -2301,14 +2325,14 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, for (i = 1; i<nGlyphs; i++) { fprintf(outf, "Encoding %d /glyph%d put\n", encoding[i], gID[i]); } - fprintf(outf, "/XUID [103 0 1 16#%08X %d 16#%08X 16#%08X] def\n", crc32(ttf->ptr, ttf->fsize), nGlyphs, crc32(glyphArray, nGlyphs * 2), crc32(encoding, nGlyphs)); + fprintf(outf, "/XUID [103 0 1 16#%08X %d 16#%08X 16#%08X] def\n", rtl_crc32(0, ttf->ptr, ttf->fsize), nGlyphs, rtl_crc32(0, glyphArray, nGlyphs * 2), rtl_crc32(0, encoding, nGlyphs)); DumpSfnts(outf, sfntP); /* dump charstrings */ fprintf(outf, "/CharStrings %d dict dup begin\n", nGlyphs); fprintf(outf, "/.notdef 0 def\n"); - for (i = 1; i < glyfCount(glyf); i++) { + for (i = 1; i < (int)glyfCount(glyf); i++) { fprintf(outf,"/glyph%d %d def\n", i, i); } fprintf(outf, "end readonly def\n"); @@ -2323,10 +2347,10 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, #ifndef NO_MAPPERS -int MapString(TrueTypeFont *ttf, uint16 *str, int nchars, uint16 *glyphArray, int bvertical) +int MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, int bvertical) { int i; - uint16 *cp; + sal_uInt16 *cp; if (ttf->cmapType == CMAP_NOT_USABLE ) return -1; if (!nchars) return 0; @@ -2340,7 +2364,7 @@ int MapString(TrueTypeFont *ttf, uint16 *str, int nchars, uint16 *glyphArray, in switch (ttf->cmapType) { case CMAP_MS_Symbol: if( ttf->mapper == getGlyph0 ) { - uint16 aChar; + sal_uInt16 aChar; for( i = 0; i < nchars; i++ ) { aChar = str[i]; if( ( aChar & 0xf000 ) == 0xf000 ) @@ -2373,7 +2397,7 @@ int MapString(TrueTypeFont *ttf, uint16 *str, int nchars, uint16 *glyphArray, in return nchars; } -uint16 MapChar(TrueTypeFont *ttf, uint16 ch, int bvertical) +sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, int bvertical) { switch (ttf->cmapType) { case CMAP_MS_Symbol: @@ -2406,13 +2430,13 @@ int DoesVerticalSubstitution( TrueTypeFont *ttf, int bvertical) #endif -TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, uint16 *glyphArray, int nGlyphs, int mode) +TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, int mode) { - byte *table; + sal_uInt8 *table; TTSimpleGlyphMetrics *res; int i; - uint16 glyphID; - int n; + sal_uInt16 glyphID; + sal_uInt32 n; int UPEm = ttf->unitsPerEm; if (mode == 0) { @@ -2449,10 +2473,10 @@ TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, uint16 *glyphAr } #ifndef NO_MAPPERS -TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont * ttf, uint16 firstChar, int nChars, int mode) +TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont * ttf, sal_uInt16 firstChar, int nChars, int mode) { TTSimpleGlyphMetrics *res = 0; - uint16 *str; + sal_uInt16 *str; int i, n; str = malloc(nChars * 2); @@ -2471,7 +2495,7 @@ TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont * ttf, uint16 firstCha void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info) { - byte *table; + sal_uInt8 *table; int UPEm = ttf->unitsPerEm; memset(info, 0, sizeof(TTGlobalFontInfo)); @@ -2536,7 +2560,7 @@ void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info) } } -void KernGlyphs(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int wmode, KernData *kern) +void KernGlyphs(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern) { int i; @@ -2551,12 +2575,12 @@ void KernGlyphs(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int wmode, KernD } } -GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, uint32 glyphID) +GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID) { - byte *glyf = getTable(ttf, O_glyf); - byte *hmtx = getTable(ttf, O_hmtx); - byte *ptr; - uint32 length; + sal_uInt8 *glyf = getTable(ttf, O_glyf); + sal_uInt8 *hmtx = getTable(ttf, O_hmtx); + sal_uInt8 *ptr; + sal_uInt32 length; GlyphData *d; ControlPoint *cp; int i, n, m; @@ -2582,7 +2606,7 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, uint32 glyphID) } d->glyphID = glyphID; - d->nbytes = (length + 1) & ~1; + d->nbytes = (sal_uInt16)((length + 1) & ~1); /* now calculate npoints and ncontours */ n = GetTTGlyphPoints(ttf, glyphID, &cp); @@ -2613,10 +2637,10 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, uint32 glyphID) int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr) { - byte *table = getTable(ttf, O_name); - uint16 n = GetUInt16(table, 2, 1); + sal_uInt8 *table = getTable(ttf, O_name); + sal_uInt16 n = GetUInt16(table, 2, 1); NameRecord *rec; - uint16 i; + sal_uInt16 i; *nr = 0; if (n == 0) return 0; @@ -2630,7 +2654,7 @@ int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr) rec[i].nameID = GetUInt16(table + 6, 6 + 12 * i, 1); rec[i].slen = GetUInt16(table + 6, 8 + 12 * i, 1); if (rec[i].slen) { - rec[i].sptr = (byte *) malloc(rec[i].slen); assert(rec[i].sptr != 0); + rec[i].sptr = (sal_uInt8 *) malloc(rec[i].slen); assert(rec[i].sptr != 0); memcpy(rec[i].sptr, table + GetUInt16(table, 4, 1) + GetUInt16(table + 6, 10 + 12 * i, 1), rec[i].slen); } else { rec[i].sptr = 0; @@ -2661,14 +2685,14 @@ int main(int ac, char **av) int r; /* Array of Unicode source characters */ - uint16 chars[2]; + sal_uInt16 chars[2]; /* Encoding vector maps character encoding to the ordinal number * of the glyph in the output file */ - byte encoding[2]; + sal_uInt8 encoding[2]; /* This array is for glyph IDs that source characters map to */ - uint16 g[2]; + sal_uInt16 g[2]; if (ac < 2) return 0; @@ -2711,11 +2735,11 @@ int main(int ac, char **av) int i, r; /* Array of Unicode source characters */ - uint16 glyphs[224]; + sal_uInt16 glyphs[224]; /* Encoding vector maps character encoding to the ordinal number * of the glyph in the output file */ - byte encoding[224]; + sal_uInt8 encoding[224]; @@ -2750,7 +2774,7 @@ int main(int ac, char **av) { TrueTypeFont *fnt; int i, r; - uint16 glyphs[224]; + sal_uInt16 glyphs[224]; TTSimpleGlyphMetrics *m; for (i=0; i<224; i++) { @@ -2882,7 +2906,7 @@ int main(int ac, char **av) int main(int ac, char **av) { TrueTypeFont *fnt; - uint16 g[224]; + sal_uInt16 g[224]; KernData d[223]; int r, i, k = 0; @@ -2924,8 +2948,8 @@ int main(int ac, char **av) TrueTypeFont *fnt; int r, i; - uint16 glyphs[256]; - byte encoding[256]; + sal_uInt16 glyphs[256]; + sal_uInt8 encoding[256]; for (i=0; i<256; i++) { glyphs[i] = 512 + i; @@ -3037,8 +3061,8 @@ int main(int ac, char **av) int main(int ac, char **av) { TrueTypeFont *fnt; - uint16 glyphArray[] = { 0, 98, 99, 22, 24, 25, 26, 27, 28, 29, 30, 31, 1270, 1289, 34}; - byte encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; + sal_uInt16 glyphArray[] = { 0, 98, 99, 22, 24, 25, 26, 27, 28, 29, 30, 31, 1270, 1289, 34}; + sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; int r; if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) { @@ -3061,11 +3085,11 @@ int main(int ac, char **av) { TrueTypeFont *fnt; /* - uint16 glyphArray[] = { 0, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}; - byte encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; + sal_uInt16 glyphArray[] = { 0, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}; + sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; */ - uint16 glyphArray[] = { 0, 6711, 6724, 11133, 11144, 14360, 26, 27, 28, 29, 30, 31, 1270, 1289, 34}; - byte encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; + sal_uInt16 glyphArray[] = { 0, 6711, 6724, 11133, 11144, 14360, 26, 27, 28, 29, 30, 31, 1270, 1289, 34}; + sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}; int r; if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) { diff --git a/psprint/source/fontsubset/sft.h b/psprint/source/fontsubset/sft.h index c40be8207621..f2bcf77d6220 100644 --- a/psprint/source/fontsubset/sft.h +++ b/psprint/source/fontsubset/sft.h @@ -2,9 +2,9 @@ * * $RCSfile: sft.h,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: hdu $ $Date: 2001-11-30 12:07:22 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: sft.h,v 1.6 2001-11-30 12:07:22 hdu Exp $ */ +/* $Id: sft.h,v 1.7 2002-08-02 12:11:23 pl Exp $ */ /** @@ -99,9 +99,14 @@ #ifndef __SUBFONT_H #define __SUBFONT_H +#ifdef UNX #include <sys/types.h> #include <unistd.h> +#endif #include <stdio.h> + +#include <sal/types.h> + #ifndef NO_LIST #include "list.h" #endif @@ -110,73 +115,20 @@ extern "C" { #endif -#ifdef __sparc -#ifndef G_BIG_ENDIAN -#define G_BIG_ENDIAN -#endif -#endif - -#if defined(__powerpc__) || defined(POWERPC) -#ifndef G_BIG_ENDIAN -#define G_BIG_ENDIAN -#endif -#endif - -#ifdef __i386 -#ifndef G_LITTLE_ENDIAN -#define G_LITTLE_ENDIAN -#endif -#endif - -#ifdef __mips -#ifndef G_BIG_ENDIAN -#define G_BIG_ENDIAN -#endif -#endif - -#if !defined(G_BIG_ENDIAN) && !defined(G_LITTLE_ENDIAN) -#error "Either G_BIG_ENDIAN or G_LITTLE_ENDIAN should be defined." -#endif - -#if defined(G_BIG_ENDIAN) && defined(G_LITTLE_ENDIAN) -#error "This is bizarre" -#endif - -#if 0 /* These should be defined in the makefile */ -#define DEBUG /* Generate debugging output */ -#define DEBUG2 /* More detailed debugging output */ -#define DEBUG3 /* Dump of TrueType outlines */ -#endif - - - - /*@{*/ #define false 0 /**< standard false value */ #define true 1 /**< standard true value */ /*@}*/ -/*- XXX These should be dynamically configured */ /*FOLD00*/ - typedef unsigned char byte; - typedef unsigned char uint8; - typedef signed char int8; - typedef unsigned short int uint16; - typedef short int int16; - - typedef unsigned int uint32; - typedef int int32; - typedef unsigned long long uint64; - typedef long long int64; - /*@{*/ - typedef int16 F2Dot14; /**< fixed: 2.14 */ - typedef int32 F16Dot16; /**< fixed: 16.16 */ + typedef sal_Int16 F2Dot14; /**< fixed: 2.14 */ + typedef sal_Int32 F16Dot16; /**< fixed: 16.16 */ /*@}*/ typedef struct { - uint16 s; - uint16 d; - } uint16pair; + sal_uInt16 s; + sal_uInt16 d; + } sal_uInt16pair; /** Return value of OpenTTFont() and CreateT3FromTTGlyphs() */ enum SFErrCodes { @@ -262,8 +214,8 @@ extern "C" { /** Structure used by GetTTSimpleGlyphMetrics() and GetTTSimpleCharMetrics() functions */ typedef struct { - uint16 adv; /**< advance width or height */ - int16 sb; /**< left or top sidebearing */ + sal_uInt16 adv; /**< advance width or height */ + sal_Int16 sb; /**< left or top sidebearing */ } TTSimpleGlyphMetrics; @@ -271,26 +223,26 @@ extern "C" { /** Structure used by the TrueType Creator and GetRawGlyphData() */ typedef struct { - uint32 glyphID; /**< glyph ID */ - uint16 nbytes; /**< number of bytes in glyph data */ - byte *ptr; /**< pointer to glyph data */ - uint16 aw; /**< advance width */ - int16 lsb; /**< left sidebearing */ - uint16 compflag; /**< 0- if non-composite, 1- otherwise */ - uint16 npoints; /**< number of points */ - uint16 ncontours; /**< number of contours */ + sal_uInt32 glyphID; /**< glyph ID */ + sal_uInt16 nbytes; /**< number of bytes in glyph data */ + sal_uInt8 *ptr; /**< pointer to glyph data */ + sal_uInt16 aw; /**< advance width */ + sal_Int16 lsb; /**< left sidebearing */ + sal_uInt16 compflag; /**< 0- if non-composite, 1- otherwise */ + sal_uInt16 npoints; /**< number of points */ + sal_uInt16 ncontours; /**< number of contours */ /* */ - uint32 newID; /**< used internally by the TTCR */ + sal_uInt32 newID; /**< used internally by the TTCR */ } GlyphData; /** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */ typedef struct { - uint16 platformID; /**< Platform ID */ - uint16 encodingID; /**< Platform-specific encoding ID */ - uint16 languageID; /**< Language ID */ - uint16 nameID; /**< Name ID */ - uint16 slen; /**< String length in bytes */ - byte *sptr; /**< Pointer to string data (not zero-terminated!) */ + sal_uInt16 platformID; /**< Platform ID */ + sal_uInt16 encodingID; /**< Platform-specific encoding ID */ + sal_uInt16 languageID; /**< Language ID */ + sal_uInt16 nameID; /**< Name ID */ + sal_uInt16 slen; /**< String length in bytes */ + sal_uInt8 *sptr; /**< Pointer to string data (not zero-terminated!) */ } NameRecord; @@ -299,7 +251,7 @@ extern "C" { typedef struct { char *family; /**< family name */ - uint16 *ufamily; /**< family name UCS2 */ + sal_uInt16 *ufamily; /**< family name UCS2 */ char *subfamily; /**< subfamily name */ char *psname; /**< PostScript name */ int weight; /**< value of WeightClass or 0 if can't be determined */ @@ -323,12 +275,12 @@ extern "C" { int winDescent; /**< descender metric for Windows */ int symbolEncoded; /**< 1: MS symbol encoded 0: not symbol encoded */ int rangeFlag; /**< if set to 1 Unicode Range flags are applicable */ - uint32 ur1; /**< bits 0 - 31 of Unicode Range flags */ - uint32 ur2; /**< bits 32 - 63 of Unicode Range flags */ - uint32 ur3; /**< bits 64 - 95 of Unicode Range flags */ - uint32 ur4; /**< bits 96 - 127 of Unicode Range flags */ - byte panose[10]; /**< PANOSE classification number */ - uint16 typeFlags; /**< type flags (copyright information) */ + sal_uInt32 ur1; /**< bits 0 - 31 of Unicode Range flags */ + sal_uInt32 ur2; /**< bits 32 - 63 of Unicode Range flags */ + sal_uInt32 ur3; /**< bits 64 - 95 of Unicode Range flags */ + sal_uInt32 ur4; /**< bits 96 - 127 of Unicode Range flags */ + sal_uInt8 panose[10]; /**< PANOSE classification number */ + sal_uInt16 typeFlags; /**< type flags (copyright information) */ } TTGlobalFontInfo; /** Structure used by KernGlyphs() */ @@ -340,12 +292,12 @@ extern "C" { /** ControlPoint structure used by GetTTGlyphPoints() */ typedef struct { - uint32 flags; /**< 00000000 00000000 e0000000 bbbbbbbb */ + sal_uInt32 flags; /**< 00000000 00000000 e0000000 bbbbbbbb */ /**< b - byte flags from the glyf array */ /**< e == 0 - regular point */ /**< e == 1 - end contour */ - int16 x; /**< X coordinate in EmSquare units */ - int16 y; /**< Y coordinate in EmSquare units */ + sal_Int16 x; /**< X coordinate in EmSquare units */ + sal_Int16 y; /**< Y coordinate in EmSquare units */ } ControlPoint; typedef struct _TrueTypeFont TrueTypeFont; @@ -367,12 +319,17 @@ extern "C" { /** * TrueTypeFont constructor. * Reads the font file and allocates the memory for the structure. + * on WIN32 the font has to be provided as a memory buffer and length * @param facenum - logical font number within a TTC file. This value is ignored * for TrueType fonts * @return value of SFErrCodes enum * @ingroup sft */ - int OpenTTFont(const char *fname, uint32 facenum, TrueTypeFont**); +#if defined WIN32 + int OpenTTFont(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); /*FOLD01*/ +#else + int OpenTTFont(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf); +#endif /** * TrueTypeFont destructor. Deallocates the memory. @@ -393,7 +350,7 @@ extern "C" { * @ingroup sft * */ - int GetTTGlyphPoints(TrueTypeFont *ttf, uint32 glyphID, ControlPoint **pointArray); + int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray); /** * Extracts raw glyph data from the 'glyf' table and returns it in an allocated @@ -407,7 +364,7 @@ extern "C" { * @ingroup sft * */ - GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, uint32 glyphID); + GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID); #ifndef NO_LIST /** @@ -425,7 +382,7 @@ extern "C" { * @ingroup sft * */ - int GetTTGlyphComponents(TrueTypeFont *ttf, uint32 glyphID, list glyphlist); + int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist); #endif /** @@ -470,7 +427,7 @@ extern "C" { * @ingroup sft * */ - int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, uint16 *glyphArray, byte *encoding, int nGlyphs, int wmode); + int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode); #endif #ifndef NO_TTCR @@ -496,12 +453,12 @@ extern "C" { */ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, const char *fname, - uint16 *glyphArray, - byte *encoding, + sal_uInt16 *glyphArray, + sal_uInt8 *encoding, int nGlyphs, int nNameRecs, NameRecord *nr, - uint32 flags); + sal_uInt32 flags); #endif #ifndef NO_TYPE42 @@ -528,8 +485,8 @@ extern "C" { int CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, - uint16 *glyphArray, - byte *encoding, + sal_uInt16 *glyphArray, + sal_uInt8 *encoding, int nGlyphs); #endif @@ -544,7 +501,7 @@ extern "C" { * @ingroup sft * */ - TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, uint16 *glyphArray, int nGlyphs, int mode); + TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, int mode); #ifndef NO_MAPPERS /** @@ -561,7 +518,7 @@ extern "C" { * @ingroup sft * */ - TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, uint16 firstChar, int nChars, int mode); + TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, sal_uInt16 firstChar, int nChars, int mode); /** * Maps a Unicode (UCS-2) string to a glyph array. Returns the number of glyphs in the array, @@ -577,11 +534,11 @@ extern "C" { * * glyphIDs of TrueType fonts are 2 byte positive numbers. glyphID of 0 denotes a missing * glyph and traditionally defaults to an empty square. - * glyphArray should be at least sizeof(uint16) * nchars bytes long. If glyphArray is NULL + * glyphArray should be at least sizeof(sal_uInt16) * nchars bytes long. If glyphArray is NULL * MapString() replaces the UCS-2 characters in str with glyphIDs. * @ingroup sft */ - int MapString(TrueTypeFont *ttf, uint16 *str, int nchars, uint16 *glyphArray, int bvertical); + int MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, int bvertical); /** * Maps a Unicode (UCS-2) character to a glyph ID and returns it. Missing glyph has @@ -592,7 +549,7 @@ extern "C" { * @return glyph ID, if the character is missing in the font, the return value is 0. * @ingroup sft */ - uint16 MapChar(TrueTypeFont *ttf, uint16 ch, int bvertical); + sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, int bvertical); /** * Returns 0 when the font does not substitute vertical glyphs @@ -628,7 +585,7 @@ extern "C" { * @ingroup sft * */ - void KernGlyphs(TrueTypeFont *ttf, uint16 *glyphs, int nglyphs, int wmode, KernData *kern); + void KernGlyphs(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern); /** * Returns nonzero if font is a symbol encoded font @@ -638,32 +595,32 @@ extern "C" { /*- private definitions */ /*FOLD00*/ struct _TrueTypeFont { - uint32 tag; - - char *fname; - off_t fsize; - byte *ptr; - - char *psname; - char *family; - uint16 *ufamily; - char *subfamily; - - uint32 ntables; - uint32 *goffsets; - int nglyphs; - int unitsPerEm; - int numberOfHMetrics; - int numOfLongVerMetrics; /* if this number is not 0, font has vertical metrics information */ - byte *cmap; - int cmapType; - uint16 (*mapper)(const byte *, uint16); /* character to glyphID translation function */ - void **tables; /* array of pointers to tables */ - uint32 *tlens; /* array of table lengths */ - int kerntype; /* Defined in the KernType enum */ - uint32 nkern; /* number of kern subtables */ - byte **kerntables; /* array of pointers to kern subtables */ - void *pGSubstitution; /* info provided by GSUB for UseGSUB() */ + sal_uInt32 tag; + + char *fname; + sal_Int32 fsize; + sal_uInt8 *ptr; + + char *psname; + char *family; + sal_uInt16 *ufamily; + char *subfamily; + + sal_uInt32 ntables; + sal_uInt32 *goffsets; + sal_uInt32 nglyphs; + sal_uInt32 unitsPerEm; + sal_uInt32 numberOfHMetrics; + sal_uInt32 numOfLongVerMetrics; /* if this number is not 0, font has vertical metrics information */ + sal_uInt8 *cmap; + int cmapType; + sal_uInt16 (*mapper)(const sal_uInt8 *, sal_uInt16); /* character to glyphID translation function */ + void **tables; /* array of pointers to tables */ + sal_uInt32 *tlens; /* array of table lengths */ + int kerntype; /* Defined in the KernType enum */ + sal_uInt32 nkern; /* number of kern subtables */ + sal_uInt8 **kerntables; /* array of pointers to kern subtables */ + void *pGSubstitution; /* info provided by GSUB for UseGSUB() */ }; #ifdef __cplusplus diff --git a/psprint/source/fontsubset/ttcr.c b/psprint/source/fontsubset/ttcr.c index 4b09ff43e9a5..750807ccb58b 100644 --- a/psprint/source/fontsubset/ttcr.c +++ b/psprint/source/fontsubset/ttcr.c @@ -2,9 +2,9 @@ * * $RCSfile: ttcr.c,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:38 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: ttcr.c,v 1.1.1.1 2001-05-08 11:45:38 pl Exp $ */ +/* $Id: ttcr.c,v 1.2 2002-08-02 12:11:24 pl Exp $ */ /* * TrueTypeCreator method implementation @@ -68,10 +68,7 @@ * */ -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <fcntl.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> @@ -94,9 +91,9 @@ #define T_cvt 0x63767420 typedef struct { - uint32 tag; - uint32 length; - byte *data; + sal_uInt32 tag; + sal_uInt32 length; + sal_uInt8 *data; } TableEntry; /* @@ -108,14 +105,14 @@ typedef struct { #define _inline static #endif -_inline uint32 mkTag(byte a, byte b, byte c, byte d) { +_inline sal_uInt32 mkTag(sal_uInt8 a, sal_uInt8 b, sal_uInt8 c, sal_uInt8 d) { return (a << 24) | (b << 16) | (c << 8) | d; } /*- Data access macros for data stored in big-endian or little-endian format */ -_inline int16 GetInt16(const byte *ptr, size_t offset, int bigendian) +_inline sal_Int16 GetInt16(const sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { - int16 t; + sal_Int16 t; assert(ptr != 0); if (bigendian) { @@ -127,9 +124,9 @@ _inline int16 GetInt16(const byte *ptr, size_t offset, int bigendian) return t; } -_inline uint16 GetUInt16(const byte *ptr, size_t offset, int bigendian) +_inline sal_uInt16 GetUInt16(const sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { - uint16 t; + sal_uInt16 t; assert(ptr != 0); if (bigendian) { @@ -141,9 +138,9 @@ _inline uint16 GetUInt16(const byte *ptr, size_t offset, int bigendian) return t; } -_inline int32 GetInt32(const byte *ptr, size_t offset, int bigendian) +_inline sal_Int32 GetInt32(const sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { - int32 t; + sal_Int32 t; assert(ptr != 0); if (bigendian) { @@ -157,9 +154,9 @@ _inline int32 GetInt32(const byte *ptr, size_t offset, int bigendian) return t; } -_inline uint32 GetUInt32(const byte *ptr, size_t offset, int bigendian) +_inline sal_uInt32 GetUInt32(const sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { - uint32 t; + sal_uInt32 t; assert(ptr != 0); @@ -175,7 +172,7 @@ _inline uint32 GetUInt32(const byte *ptr, size_t offset, int bigendian) } -_inline void PutInt16(int16 val, byte *ptr, size_t offset, int bigendian) +_inline void PutInt16(sal_Int16 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { assert(ptr != 0); @@ -189,7 +186,7 @@ _inline void PutInt16(int16 val, byte *ptr, size_t offset, int bigendian) } -_inline void PutUInt16(uint16 val, byte *ptr, size_t offset, int bigendian) +_inline void PutUInt16(sal_uInt16 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { assert(ptr != 0); @@ -204,39 +201,39 @@ _inline void PutUInt16(uint16 val, byte *ptr, size_t offset, int bigendian) } -_inline void PutUInt32(uint32 val, byte *ptr, size_t offset, int bigendian) +_inline void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { assert(ptr != 0); if (bigendian) { - ptr[offset] = (val >> 24) & 0xFF; - ptr[offset+1] = (val >> 16) & 0xFF; - ptr[offset+2] = (val >> 8) & 0xFF; - ptr[offset+3] = val & 0xFF; + ptr[offset] = (sal_uInt8)((val >> 24) & 0xFF); + ptr[offset+1] = (sal_uInt8)((val >> 16) & 0xFF); + ptr[offset+2] = (sal_uInt8)((val >> 8) & 0xFF); + ptr[offset+3] = (sal_uInt8)(val & 0xFF); } else { - ptr[offset+3] = (val >> 24) & 0xFF; - ptr[offset+2] = (val >> 16) & 0xFF; - ptr[offset+1] = (val >> 8) & 0xFF; - ptr[offset] = val & 0xFF; + ptr[offset+3] = (sal_uInt8)((val >> 24) & 0xFF); + ptr[offset+2] = (sal_uInt8)((val >> 16) & 0xFF); + ptr[offset+1] = (sal_uInt8)((val >> 8) & 0xFF); + ptr[offset] = (sal_uInt8)(val & 0xFF); } } -_inline void PutInt32(int32 val, byte *ptr, size_t offset, int bigendian) +_inline void PutInt32(sal_Int32 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { assert(ptr != 0); if (bigendian) { - ptr[offset] = (val >> 24) & 0xFF; - ptr[offset+1] = (val >> 16) & 0xFF; - ptr[offset+2] = (val >> 8) & 0xFF; - ptr[offset+3] = val & 0xFF; + ptr[offset] = (sal_uInt8)((val >> 24) & 0xFF); + ptr[offset+1] = (sal_uInt8)((val >> 16) & 0xFF); + ptr[offset+2] = (sal_uInt8)((val >> 8) & 0xFF); + ptr[offset+3] = (sal_uInt8)(val & 0xFF); } else { - ptr[offset+3] = (val >> 24) & 0xFF; - ptr[offset+2] = (val >> 16) & 0xFF; - ptr[offset+1] = (val >> 8) & 0xFF; - ptr[offset] = val & 0xFF; + ptr[offset+3] = (sal_uInt8)((val >> 24) & 0xFF); + ptr[offset+2] = (sal_uInt8)((val >> 16) & 0xFF); + ptr[offset+1] = (sal_uInt8)((val >> 8) & 0xFF); + ptr[offset] = (sal_uInt8)(val & 0xFF); } } @@ -264,24 +261,24 @@ static int NameRecordCompareF(const void *l, const void *r) } -static uint32 CheckSum(uint32 *ptr, uint32 length) +static sal_uInt32 CheckSum(sal_uInt32 *ptr, sal_uInt32 length) { - uint32 sum = 0; - uint32 *endptr = ptr + ((length + 3) & (uint32) ~3) / 4; + sal_uInt32 sum = 0; + sal_uInt32 *endptr = ptr + ((length + 3) & (sal_uInt32) ~3) / 4; while (ptr < endptr) sum += *ptr++; return sum; } -_inline void *smalloc(size_t size) +_inline void *smalloc(sal_uInt32 size) { void *res = malloc(size); assert(res != 0); return res; } -_inline void *scalloc(size_t n, size_t size) +_inline void *scalloc(sal_uInt32 n, sal_uInt32 size) { void *res = calloc(n, size); assert(res != 0); @@ -292,7 +289,7 @@ _inline void *scalloc(size_t n, size_t size) * Public functions */ -void TrueTypeCreatorNewEmpty(uint32 tag, TrueTypeCreator **_this) +void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this) { TrueTypeCreator *ptr = smalloc(sizeof(TrueTypeCreator)); @@ -318,7 +315,7 @@ int AddTable(TrueTypeCreator *_this, TrueTypeTable *table) return SF_OK; } -void RemoveTable(TrueTypeCreator *_this, uint32 tag) +void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag) { int done = 0; @@ -338,15 +335,15 @@ void RemoveTable(TrueTypeCreator *_this, uint32 tag) static void ProcessTables(TrueTypeCreator *); -int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) +int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) { - uint16 numTables, searchRange=1, entrySelector=0, rangeShift; - uint32 s, offset, checkSumAdjustment = 0; - uint32 *p; - byte *ttf; + sal_uInt16 numTables, searchRange=1, entrySelector=0, rangeShift; + sal_uInt32 s, offset, checkSumAdjustment = 0; + sal_uInt32 *p; + sal_uInt8 *ttf; int i=0, n; TableEntry *te; - byte *head; /* saved pointer to the head table data for checkSumAdjustment calculation */ + sal_uInt8 *head; /* saved pointer to the head table data for checkSumAdjustment calculation */ if ((n = listCount(_this->tables)) == 0) return SF_TTFORMAT; @@ -355,7 +352,7 @@ int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) /* ProcessTables() adds 'loca' and 'hmtx' */ n = listCount(_this->tables); - numTables = (uint16) n; + numTables = (sal_uInt16) n; te = scalloc(n, sizeof(TableEntry)); @@ -380,7 +377,7 @@ int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) s = offset = 12 + 16 * n; for (i = 0; i < n; i++) { - s += (te[i].length + 3) & (uint32) ~3; + s += (te[i].length + 3) & (sal_uInt32) ~3; /* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */ } @@ -396,7 +393,7 @@ int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) /* Table Directory */ for (i = 0; i < n; i++) { PutUInt32(te[i].tag, ttf + 12, 16 * i, 1); - PutUInt32(CheckSum((uint32 *) te[i].data, te[i].length), ttf + 12, 16 * i + 4, 1); + PutUInt32(CheckSum((sal_uInt32 *) te[i].data, te[i].length), ttf + 12, 16 * i + 4, 1); PutUInt32(offset, ttf + 12, 16 * i + 8, 1); PutUInt32(te[i].length, ttf + 12, 16 * i + 12, 1); @@ -404,15 +401,15 @@ int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) head = ttf + offset; } - memcpy(ttf+offset, te[i].data, (te[i].length + 3) & (uint32) ~3 ); - offset += (te[i].length + 3) & (uint32) ~3; + memcpy(ttf+offset, te[i].data, (te[i].length + 3) & (sal_uInt32) ~3 ); + offset += (te[i].length + 3) & (sal_uInt32) ~3; /* if ((te[i].length & 3) != 0) offset += (4 - (te[i].length & 3)) & 3; */ } free(te); - p = (uint32 *) ttf; - for (i = 0; i < s / 4; i++) checkSumAdjustment += p[i]; + p = (sal_uInt32 *) ttf; + for (i = 0; i < (int)s / 4; i++) checkSumAdjustment += p[i]; PutUInt32(0xB1B0AFBA - checkSumAdjustment, head, 8, 1); *ptr = ttf; @@ -423,22 +420,23 @@ int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length) int StreamToFile(TrueTypeCreator *_this, const char* fname) { - byte *ptr; - uint32 length; - int fd, r; + sal_uInt8 *ptr; + sal_uInt32 length; + int r; + FILE* fd; if (!fname) return SF_BADFILE; - if ((fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1) return SF_BADFILE; + if ((fd = fopen(fname, "wb")) == NULL) return SF_BADFILE; if ((r = StreamToMemory(_this, &ptr, &length)) != SF_OK) return r; - if (write(fd, ptr, length) != length) { + if (fwrite(ptr, 1, length, fd) != length) { r = SF_FILEIO; } else { r = SF_OK; } - close(fd); + fclose(fd); free(ptr); return r; } @@ -475,50 +473,50 @@ int StreamToFile(TrueTypeCreator *_this, const char* fname) #define CMAP_PAIR_INCR 500 typedef struct { - uint32 id; /* subtable ID (platform/encoding ID) */ - uint32 n; /* number of used translation pairs */ - uint32 m; /* number of allocated translation pairs */ - uint32 *xc; /* character array */ - uint32 *xg; /* glyph array */ + sal_uInt32 id; /* subtable ID (platform/encoding ID) */ + sal_uInt32 n; /* number of used translation pairs */ + sal_uInt32 m; /* number of allocated translation pairs */ + sal_uInt32 *xc; /* character array */ + sal_uInt32 *xg; /* glyph array */ } CmapSubTable; typedef struct { - uint32 n; /* number of used CMAP sub-tables */ - uint32 m; /* number of allocated CMAP sub-tables */ + sal_uInt32 n; /* number of used CMAP sub-tables */ + sal_uInt32 m; /* number of allocated CMAP sub-tables */ CmapSubTable *s; /* sotred array of sub-tables */ } table_cmap; typedef struct { - uint32 tag; - uint32 nbytes; - byte *ptr; + sal_uInt32 tag; + sal_uInt32 nbytes; + sal_uInt8 *ptr; } tdata_generic; typedef struct { - uint32 nbytes; /* number of bytes in loca table */ - byte *ptr; /* pointer to the data */ + sal_uInt32 nbytes; /* number of bytes in loca table */ + sal_uInt8 *ptr; /* pointer to the data */ } tdata_loca; typedef struct { - uint32 format; - uint32 italicAngle; - int16 underlinePosition; - int16 underlineThickness; - uint32 isFixedPitch; + sal_uInt32 format; + sal_uInt32 italicAngle; + sal_Int16 underlinePosition; + sal_Int16 underlineThickness; + sal_uInt32 isFixedPitch; void *ptr; /* format-specific pointer */ } tdata_post; /* allocate memory for a TT table */ -static byte *ttmalloc(uint32 nbytes) +static sal_uInt8 *ttmalloc(sal_uInt32 nbytes) { - uint32 n; - byte *res; + sal_uInt32 n; + sal_uInt8 *res; - n = (nbytes + 3) & (uint32) ~3; + n = (nbytes + 3) & (sal_uInt32) ~3; res = malloc(n); assert(res != 0); - bzero(res, n); + memset(res, 0, n); return res; } @@ -590,7 +588,7 @@ static void TrueTypeTableDispose_cmap(TrueTypeTable *_this) { table_cmap *t; CmapSubTable *s; - int i; + sal_uInt32 i; if (_this) { t = (table_cmap *) _this->data; @@ -636,7 +634,7 @@ static void TrueTypeTableDispose_post(TrueTypeTable *_this) /* destructor vtable */ static struct { - uint32 tag; + sal_uInt32 tag; void (*f)(TrueTypeTable *); } vtable1[] = { @@ -652,7 +650,7 @@ static struct { }; -static int GetRawData_generic(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_generic(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { assert(_this != 0); assert(_this->data != 0); @@ -665,25 +663,25 @@ static int GetRawData_generic(TrueTypeTable *_this, byte **ptr, uint32 *len, uin } -static int GetRawData_head(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_head(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { *len = TABLESIZE_head; - *ptr = (byte *) _this->data; + *ptr = (sal_uInt8 *) _this->data; *tag = T_head; return TTCR_OK; } -static int GetRawData_hhea(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_hhea(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { *len = TABLESIZE_hhea; - *ptr = (byte *) _this->data; + *ptr = (sal_uInt8 *) _this->data; *tag = T_hhea; return TTCR_OK; } -static int GetRawData_loca(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_loca(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { tdata_loca *p; @@ -700,21 +698,21 @@ static int GetRawData_loca(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 return TTCR_OK; } -static int GetRawData_maxp(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_maxp(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { *len = TABLESIZE_maxp; - *ptr = (byte *) _this->data; + *ptr = (sal_uInt8 *) _this->data; *tag = T_maxp; return TTCR_OK; } -static int GetRawData_glyf(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_glyf(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { - uint32 n, nbytes = 0; + sal_uInt32 n, nbytes = 0; list l = (list) _this->data; - /* uint16 curID = 0; */ /* to check if glyph IDs are sequential and start from zero */ - byte *p; + /* sal_uInt16 curID = 0; */ /* to check if glyph IDs are sequential and start from zero */ + sal_uInt8 *p; *ptr = 0; *len = 0; @@ -747,12 +745,12 @@ static int GetRawData_glyf(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 } /* cmap packers */ -static byte *PackCmapType0(CmapSubTable *s, uint32 *length) +static sal_uInt8 *PackCmapType0(CmapSubTable *s, sal_uInt32 *length) { - byte *ptr = smalloc(262); - byte *p = ptr + 6; - int i, j; - uint16 g; + sal_uInt8 *ptr = smalloc(262); + sal_uInt8 *p = ptr + 6; + sal_uInt32 i, j; + sal_uInt16 g; PutUInt16(0, ptr, 0, 1); PutUInt16(262, ptr, 2, 1); @@ -762,10 +760,10 @@ static byte *PackCmapType0(CmapSubTable *s, uint32 *length) g = 0; for (j = 0; j < s->n; j++) { if (s->xc[j] == i) { - g = (uint16) s->xg[j]; + g = (sal_uInt16) s->xg[j]; } } - p[i] = (byte) g; + p[i] = (sal_uInt8) g; } *length = 262; return ptr; @@ -773,30 +771,30 @@ static byte *PackCmapType0(CmapSubTable *s, uint32 *length) /* XXX it only handles Format 0 encoding tables */ -static byte *PackCmap(CmapSubTable *s, uint32 *length) +static sal_uInt8 *PackCmap(CmapSubTable *s, sal_uInt32 *length) { return PackCmapType0(s, length); } -static int GetRawData_cmap(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { table_cmap *t; - byte **subtables; - uint32 *sizes; /* of subtables */ - int i; - uint32 tlen = 0; - uint32 l; - uint32 cmapsize; - byte *cmap; - uint32 coffset; + sal_uInt8 **subtables; + sal_uInt32 *sizes; /* of subtables */ + sal_uInt32 i; + sal_uInt32 tlen = 0; + sal_uInt32 l; + sal_uInt32 cmapsize; + sal_uInt8 *cmap; + sal_uInt32 coffset; assert(_this != 0); t = (table_cmap *) _this->data; assert(t != 0); assert(t->n != 0); - subtables = scalloc(t->n, sizeof(byte *)); - sizes = scalloc(t->n, sizeof(uint32)); + subtables = scalloc(t->n, sizeof(sal_uInt8 *)); + sizes = scalloc(t->n, sizeof(sal_uInt32)); for (i = 0; i < t->n; i++) { subtables[i] = PackCmap(t->s+i, &l); @@ -808,12 +806,12 @@ static int GetRawData_cmap(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 _this->rawdata = cmap = ttmalloc(cmapsize); PutUInt16(0, cmap, 0, 1); - PutUInt16(t->n, cmap, 2, 1); + PutUInt16((sal_uInt16)t->n, cmap, 2, 1); coffset = 4 + t->n * 8; for (i = 0; i < t->n; i++) { - PutUInt16(t->s[i].id >> 16, cmap + 4, i * 8, 1); - PutUInt16(t->s[i].id & 0xFF, cmap + 4, 2 + i * 8, 1); + PutUInt16((sal_uInt16)(t->s[i].id >> 16), cmap + 4, i * 8, 1); + PutUInt16((sal_uInt16)(t->s[i].id & 0xFF), cmap + 4, 2 + i * 8, 1); PutUInt32(coffset, cmap + 4, 4 + i * 8, 1); memcpy(cmap + coffset, subtables[i], sizes[i]); free(subtables[i]); @@ -831,15 +829,15 @@ static int GetRawData_cmap(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 } -static int GetRawData_name(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { list l; NameRecord *nr; - int16 i=0, n; /* number of Name Records */ - byte *name; - uint16 nameLen; + sal_Int16 i=0, n; /* number of Name Records */ + sal_uInt8 *name; + sal_uInt16 nameLen; int stringLen = 0; - byte *p1, *p2; + sal_uInt8 *p1, *p2; *ptr = 0; *len = 0; @@ -873,7 +871,7 @@ static int GetRawData_name(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 PutUInt16(0, name, 0, 1); PutUInt16(n, name, 2, 1); - PutUInt16(6 + 12 * n, name, 4, 1); + PutUInt16((sal_uInt16)(6 + 12 * n), name, 4, 1); p1 = name + 6; p2 = p1 + 12 * n; @@ -884,7 +882,7 @@ static int GetRawData_name(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 PutUInt16(nr[i].languageID, p1, 4, 1); PutUInt16(nr[i].nameID, p1, 6, 1); PutUInt16(nr[i].slen, p1, 8, 1); - PutUInt16(p2 - (name + 6 + 12 * n), p1, 10, 1); + PutUInt16((sal_uInt16)(p2 - (name + 6 + 12 * n)), p1, 10, 1); memcpy(p2, nr[i].sptr, nr[i].slen); /* {int j; for(j=0; j<nr[i].slen; j++) printf("%c", nr[i].sptr[j]); printf("\n"); }; */ p2 += nr[i].slen; @@ -903,11 +901,11 @@ static int GetRawData_name(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 return TTCR_OK; } -static int GetRawData_post(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +static int GetRawData_post(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { tdata_post *p = (tdata_post *) _this->data; - byte *post = 0; - uint32 postLen = 0; + sal_uInt8 *post = 0; + sal_uInt32 postLen = 0; int ret; if (_this->rawdata) free(_this->rawdata); @@ -919,7 +917,7 @@ static int GetRawData_post(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 PutUInt32(p->italicAngle, post, 4, 1); PutUInt16(p->underlinePosition, post, 8, 1); PutUInt16(p->underlineThickness, post, 10, 1); - PutUInt16(p->isFixedPitch, post, 12, 1); + PutUInt16((sal_uInt16)p->isFixedPitch, post, 12, 1); ret = TTCR_OK; } else { fprintf(stderr, "Unrecognized format of a post table: %08X.\n", p->format); @@ -938,8 +936,8 @@ static int GetRawData_post(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 static struct { - uint32 tag; - int (*f)(TrueTypeTable *, byte **, uint32 *, uint32 *); + sal_uInt32 tag; + int (*f)(TrueTypeTable *, sal_uInt8 **, sal_uInt32 *, sal_uInt32 *); } vtable2[] = { {0, GetRawData_generic}, @@ -970,9 +968,9 @@ static struct { * */ -TrueTypeTable *TrueTypeTableNew(uint32 tag, - uint32 nbytes, - byte *ptr) +TrueTypeTable *TrueTypeTableNew(sal_uInt32 tag, + sal_uInt32 nbytes, + sal_uInt8 *ptr) { TrueTypeTable *table; tdata_generic *pdata; @@ -995,16 +993,16 @@ TrueTypeTable *TrueTypeTableNew(uint32 tag, return table; } -TrueTypeTable *TrueTypeTableNew_head(uint32 fontRevision, - uint16 flags, - uint16 unitsPerEm, - byte *created, - uint16 macStyle, - uint16 lowestRecPPEM, - int16 fontDirectionHint) +TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision, + sal_uInt16 flags, + sal_uInt16 unitsPerEm, + sal_uInt8 *created, + sal_uInt16 macStyle, + sal_uInt16 lowestRecPPEM, + sal_Int16 fontDirectionHint) { TrueTypeTable *table; - byte *ptr; + sal_uInt8 *ptr; assert(created != 0); @@ -1018,7 +1016,7 @@ TrueTypeTable *TrueTypeTableNew_head(uint32 fontRevision, PutUInt16(flags, ptr, 16, 1); PutUInt16(unitsPerEm, ptr, 18, 1); memcpy(ptr+20, created, 8); /* Created Long Date */ - bzero(ptr+28, 8); /* Modified Long Date */ + memset(ptr+28, 0, 8); /* Modified Long Date */ PutUInt16(macStyle, ptr, 44, 1); PutUInt16(lowestRecPPEM, ptr, 46, 1); PutUInt16(fontDirectionHint, ptr, 48, 1); @@ -1031,14 +1029,14 @@ TrueTypeTable *TrueTypeTableNew_head(uint32 fontRevision, return table; } -TrueTypeTable *TrueTypeTableNew_hhea(int16 ascender, - int16 descender, - int16 linegap, - int16 caretSlopeRise, - int16 caretSlopeRun) +TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender, + sal_Int16 descender, + sal_Int16 linegap, + sal_Int16 caretSlopeRise, + sal_Int16 caretSlopeRun) { TrueTypeTable *table; - byte *ptr; + sal_uInt8 *ptr; table = smalloc(sizeof(TrueTypeTable)); ptr = ttmalloc(TABLESIZE_hhea); @@ -1077,7 +1075,7 @@ TrueTypeTable *TrueTypeTableNew_loca(void) return table; } -TrueTypeTable *TrueTypeTableNew_maxp(byte *maxp, int size) +TrueTypeTable *TrueTypeTableNew_maxp(sal_uInt8 *maxp, int size) { TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); table->data = ttmalloc(TABLESIZE_maxp); @@ -1172,11 +1170,11 @@ TrueTypeTable *TrueTypeTableNew_name(int n, NameRecord *nr) return table; } -TrueTypeTable *TrueTypeTableNew_post(uint32 format, - uint32 italicAngle, - int16 underlinePosition, - int16 underlineThickness, - uint32 isFixedPitch) +TrueTypeTable *TrueTypeTableNew_post(sal_uInt32 format, + sal_uInt32 italicAngle, + sal_Int16 underlinePosition, + sal_Int16 underlineThickness, + sal_uInt32 isFixedPitch) { TrueTypeTable *table; tdata_post *post; @@ -1219,7 +1217,7 @@ void TrueTypeTableDispose(TrueTypeTable *_this) assert(!"Unknown TrueType table.\n"); } -int GetRawData(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) +int GetRawData(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { /* XXX do a binary search */ int i; @@ -1246,9 +1244,9 @@ int GetRawData(TrueTypeTable *_this, byte **ptr, uint32 *len, uint32 *tag) return TTCR_UNKNOWN; } -void cmapAdd(TrueTypeTable *table, uint32 id, uint32 c, uint32 g) +void cmapAdd(TrueTypeTable *table, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g) { - int i, found; + sal_uInt32 i, found; table_cmap *t; CmapSubTable *s; @@ -1291,17 +1289,17 @@ void cmapAdd(TrueTypeTable *table, uint32 id, uint32 c, uint32 g) s[i].id = id; s[i].n = 0; s[i].m = CMAP_PAIR_INIT; - s[i].xc = scalloc(CMAP_PAIR_INIT, sizeof(uint32)); - s[i].xg = scalloc(CMAP_PAIR_INIT, sizeof(uint32)); + s[i].xc = scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); + s[i].xg = scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); } if (s[i].n == s[i].m) { - uint32 *tmp1 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(uint32)); - uint32 *tmp2 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(uint32)); + sal_uInt32 *tmp1 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); + sal_uInt32 *tmp2 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); assert(tmp1 != 0); assert(tmp2 != 0); - memcpy(tmp1, s[i].xc, sizeof(uint32) * s[i].m); - memcpy(tmp2, s[i].xg, sizeof(uint32) * s[i].m); + memcpy(tmp1, s[i].xc, sizeof(sal_uInt32) * s[i].m); + memcpy(tmp2, s[i].xg, sizeof(sal_uInt32) * s[i].m); s[i].m += CMAP_PAIR_INCR; free(s[i].xc); free(s[i].xg); @@ -1314,10 +1312,10 @@ void cmapAdd(TrueTypeTable *table, uint32 id, uint32 c, uint32 g) s[i].n++; } -uint32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt) +sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt) { list l; - uint32 currentID; + sal_uInt32 currentID; int ret, n, ncomponents; list glyphlist; GlyphData *gd; @@ -1345,7 +1343,7 @@ uint32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt) listPositionAt(glyphlist, 1); /* glyphData->glyphID is always the first glyph on the list */ do { int found = 0; - currentID = (uint32) listCurrent(glyphlist); + currentID = (sal_uInt32) listCurrent(glyphlist); /* XXX expensive! should be rewritten with sorted arrays! */ listToFirst(l); do { @@ -1367,7 +1365,7 @@ uint32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt) return ret; } -uint32 glyfCount(const TrueTypeTable *table) +sal_uInt32 glyfCount(const TrueTypeTable *table) { assert(table != 0); assert(table->tag == T_glyf); @@ -1387,7 +1385,7 @@ void nameAdd(TrueTypeTable *table, NameRecord *nr) listAppend(l, NameRecordNewCopy(nr)); } -static TrueTypeTable *FindTable(TrueTypeCreator *tt, uint32 tag) +static TrueTypeTable *FindTable(TrueTypeCreator *tt, sal_uInt32 tag) { if (listIsEmpty(tt->tables)) return 0; @@ -1421,23 +1419,23 @@ static void ProcessTables(TrueTypeCreator *tt) { TrueTypeTable *glyf, *loca, *head, *maxp, *hhea; list glyphlist; - uint32 nGlyphs, locaLen = 0, glyfLen = 0; - int16 xMin = 0, yMin = 0, xMax = 0, yMax = 0; - int i = 0; - int16 indexToLocFormat; - byte *glyfPtr, *locaPtr, *hmtxPtr, *hheaPtr; - uint32 hmtxSize; - byte *p1, *p2; - uint16 maxPoints = 0, maxContours = 0, maxCompositePoints = 0, maxCompositeContours = 0; + sal_uInt32 nGlyphs, locaLen = 0, glyfLen = 0; + sal_Int16 xMin = 0, yMin = 0, xMax = 0, yMax = 0; + sal_uInt32 i = 0; + sal_Int16 indexToLocFormat; + sal_uInt8 *glyfPtr, *locaPtr, *hmtxPtr, *hheaPtr; + sal_uInt32 hmtxSize; + sal_uInt8 *p1, *p2; + sal_uInt16 maxPoints = 0, maxContours = 0, maxCompositePoints = 0, maxCompositeContours = 0; TTSimpleGlyphMetrics *met; int nlsb = 0; - uint32 *gid; /* array of old glyphIDs */ + sal_uInt32 *gid; /* array of old glyphIDs */ glyf = FindTable(tt, T_glyf); glyphlist = (list) glyf->data; nGlyphs = listCount(glyphlist); assert(nGlyphs != 0); - gid = scalloc(nGlyphs, sizeof(uint32)); + gid = scalloc(nGlyphs, sizeof(sal_uInt32)); RemoveTable(tt, T_loca); RemoveTable(tt, T_hmtx); @@ -1447,7 +1445,7 @@ static void ProcessTables(TrueTypeCreator *tt) listToFirst(glyphlist); do { GlyphData *gd = (GlyphData *) listCurrent(glyphlist); - int16 z; + sal_Int16 z; glyfLen += gd->nbytes; /* XXX if (gd->nbytes & 1) glyfLen++; */ @@ -1497,10 +1495,10 @@ static void ProcessTables(TrueTypeCreator *tt) GlyphData *gd = (GlyphData *) listCurrent(glyphlist); if (gd->compflag) { /* re-number all components */ - uint16 flags, index; - byte *ptr = gd->ptr + 10; + sal_uInt16 flags, index; + sal_uInt8 *ptr = gd->ptr + 10; do { - int j; + sal_uInt32 j; flags = GetUInt16(ptr, 0, 1); index = GetUInt16(ptr, 2, 1); /* XXX use the sorted array of old to new glyphID mapping and do a binary search */ @@ -1511,7 +1509,7 @@ static void ProcessTables(TrueTypeCreator *tt) } /* printf("X: %d -> %d.\n", index, j); */ - PutUInt16((uint16) j, ptr, 2, 1); + PutUInt16((sal_uInt16) j, ptr, 2, 1); ptr += 4; @@ -1538,7 +1536,7 @@ static void ProcessTables(TrueTypeCreator *tt) PutUInt32(p1 - glyfPtr, p2, 0, 1); p2 += 4; } else { - PutUInt16((p1 - glyfPtr) >> 1, p2, 0, 1); + PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0, 1); p2 += 2; } p1 += gd->nbytes; @@ -1554,7 +1552,7 @@ static void ProcessTables(TrueTypeCreator *tt) if (indexToLocFormat == 1) { PutUInt32(p1 - glyfPtr, p2, 0, 1); } else { - PutUInt16((p1 - glyfPtr) >> 1, p2, 0, 1); + PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0, 1); } glyf->rawdata = glyfPtr; @@ -1574,7 +1572,7 @@ static void ProcessTables(TrueTypeCreator *tt) maxp = FindTable(tt, T_maxp); - PutUInt16(nGlyphs, maxp->data, 4, 1); + PutUInt16((sal_uInt16)nGlyphs, maxp->data, 4, 1); PutUInt16(maxPoints, maxp->data, 6, 1); PutUInt16(maxContours, maxp->data, 8, 1); PutUInt16(maxCompositePoints, maxp->data, 10, 1); @@ -1597,7 +1595,7 @@ static void ProcessTables(TrueTypeCreator *tt) * Generate an htmx table and update hhea table */ hhea = FindTable(tt, T_hhea); assert(hhea != 0); - hheaPtr = (byte *) hhea->data; + hheaPtr = (sal_uInt8 *) hhea->data; if (nGlyphs > 2) { for (i = nGlyphs - 1; i > 0; i--) { if (met[i].adv != met[i-1].adv) break; @@ -1620,7 +1618,7 @@ static void ProcessTables(TrueTypeCreator *tt) } AddTable(tt, TrueTypeTableNew(T_hmtx, hmtxSize, hmtxPtr)); - PutUInt16(nGlyphs - nlsb, hheaPtr, 34, 1); + PutUInt16((sal_uInt16)(nGlyphs - nlsb), hheaPtr, 34, 1); free(hmtxPtr); free(met); } @@ -1629,7 +1627,7 @@ static void ProcessTables(TrueTypeCreator *tt) int main(void) { TrueTypeCreator *ttcr; - byte *t1, *t2, *t3, *t4, *t5, *t6, *t7; + sal_uInt8 *t1, *t2, *t3, *t4, *t5, *t6, *t7; TrueTypeCreatorNewEmpty(mkTag('t','r','u','e'), &ttcr); diff --git a/psprint/source/fontsubset/ttcr.h b/psprint/source/fontsubset/ttcr.h index 414b035cbe19..208b3ca1f351 100644 --- a/psprint/source/fontsubset/ttcr.h +++ b/psprint/source/fontsubset/ttcr.h @@ -2,9 +2,9 @@ * * $RCSfile: ttcr.h,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:38 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: ttcr.h,v 1.1.1.1 2001-05-08 11:45:38 pl Exp $ */ +/* $Id: ttcr.h,v 1.2 2002-08-02 12:11:25 pl Exp $ */ /** * @@ -83,15 +83,15 @@ extern "C" /* TrueType data types */ typedef struct { - uint16 aw; - int16 lsb; + sal_uInt16 aw; + sal_Int16 lsb; } longHorMetrics; /* A generic base class for all TrueType tables */ typedef struct { - uint32 tag; /* table tag */ - byte *rawdata; /* raw data allocated by GetRawData_*() */ - void *data; /* table specific data */ + sal_uInt32 tag; /* table tag */ + sal_uInt8 *rawdata; /* raw data allocated by GetRawData_*() */ + void *data; /* table specific data */ } TrueTypeTable; /** Error codes for most functions */ @@ -115,7 +115,7 @@ extern "C" * TrueTypeCreator constructor. * Allocates all internal structures. */ - void TrueTypeCreatorNewEmpty(uint32 tag, TrueTypeCreator **_this); + void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this); /** * TrueTypeCreator destructor. It calls destructors for all TrueTypeTables added to it. @@ -136,7 +136,7 @@ extern "C" * called with the second argument of 0. * @return value of SFErrCodes type */ - void RemoveTable(TrueTypeCreator *_this, uint32 tag); + void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag); @@ -146,7 +146,7 @@ extern "C" * is supposed to call free() on it. * @return value of SFErrCodes type */ - int StreamToMemory(TrueTypeCreator *_this, byte **ptr, uint32 *length); + int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length); /** * Writes a TrueType font generated by the TrueTypeCreator to a file @@ -175,7 +175,7 @@ extern "C" * */ - int GetRawData(TrueTypeTable *, byte **ptr, uint32 *len, uint32 *tag); + int GetRawData(TrueTypeTable *, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag); /** * @@ -185,9 +185,9 @@ extern "C" * and stores its length. This constructor is suitable for data that is not * supposed to be processed in any way, just written to the resulting TTF file. */ - TrueTypeTable *TrueTypeTableNew(uint32 tag, - uint32 nbytes, - byte *ptr); + TrueTypeTable *TrueTypeTableNew(sal_uInt32 tag, + sal_uInt32 nbytes, + sal_uInt8 *ptr); /** * Creates a new 'head' table for a TrueType font. @@ -195,23 +195,23 @@ extern "C" * rest of the tables in the TrueType font this table should be the last one added * to the font. */ - TrueTypeTable *TrueTypeTableNew_head(uint32 fontRevision, - uint16 flags, - uint16 unitsPerEm, - byte *created, - uint16 macStyle, - uint16 lowestRecPPEM, - int16 fontDirectionHint); + TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision, + sal_uInt16 flags, + sal_uInt16 unitsPerEm, + sal_uInt8 *created, + sal_uInt16 macStyle, + sal_uInt16 lowestRecPPEM, + sal_Int16 fontDirectionHint); /** * Creates a new 'hhea' table for a TrueType font. * Allocates memory for it and stores it in the hhea pointer. */ - TrueTypeTable *TrueTypeTableNew_hhea(int16 ascender, - int16 descender, - int16 linegap, - int16 caretSlopeRise, - int16 caretSlopeRun); + TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender, + sal_Int16 descender, + sal_Int16 linegap, + sal_Int16 caretSlopeRise, + sal_Int16 caretSlopeRun); /** * Creates a new empty 'loca' table for a TrueType font. @@ -226,7 +226,7 @@ extern "C" * size specifies the size of existing maxp table for * error-checking purposes */ - TrueTypeTable *TrueTypeTableNew_maxp(byte *maxp, int size); + TrueTypeTable *TrueTypeTableNew_maxp(sal_uInt8 *maxp, int size); /** * Creates a new empty 'glyf' table. @@ -249,11 +249,11 @@ extern "C" /** * Creates a new 'post' table of one of the supported formats */ - TrueTypeTable *TrueTypeTableNew_post(uint32 format, - uint32 italicAngle, - int16 underlinePosition, - int16 underlineThickness, - uint32 isFixedPitch); + TrueTypeTable *TrueTypeTableNew_post(sal_uInt32 format, + sal_uInt32 italicAngle, + sal_Int16 underlinePosition, + sal_Int16 underlineThickness, + sal_uInt32 isFixedPitch); /*------------------------------------------------------------------------------ @@ -266,7 +266,7 @@ extern "C" /** * Add a character/glyph pair to a cmap table */ - void cmapAdd(TrueTypeTable *, uint32 id, uint32 c, uint32 g); + void cmapAdd(TrueTypeTable *, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g); /** * Add a glyph to a glyf table. @@ -276,13 +276,13 @@ extern "C" * NOTE: This function does not duplicate GlyphData, so memory will be * deallocated in the table destructor */ - uint32 glyfAdd(TrueTypeTable *, GlyphData *glyphdata, TrueTypeFont *fnt); + sal_uInt32 glyfAdd(TrueTypeTable *, GlyphData *glyphdata, TrueTypeFont *fnt); /** * Query the number of glyphs currently stored in the 'glyf' table * */ - uint32 glyfCount(const TrueTypeTable *); + sal_uInt32 glyfCount(const TrueTypeTable *); /** * Add a Name Record to a name table. @@ -298,7 +298,7 @@ extern "C" */ struct _TrueTypeCreator { - uint32 tag; /**< TrueType file tag */ + sal_uInt32 tag; /**< TrueType file tag */ list tables; /**< List of table tags and pointers */ }; diff --git a/psprint/source/fontsubset/u2big5.inc b/psprint/source/fontsubset/u2big5.inc index a81b6e3a5c67..99e3451cbef9 100644 --- a/psprint/source/fontsubset/u2big5.inc +++ b/psprint/source/fontsubset/u2big5.inc @@ -2,9 +2,9 @@ * * $RCSfile: u2big5.inc,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:42 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -uint16pair xlat_1_3[13798] = { +sal_uInt16pair xlat_1_3[13798] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, {0x0030, 0x0030},{0x0031, 0x0031},{0x0032, 0x0032},{0x0033, 0x0033},{0x0034, 0x0034},{0x0035, 0x0035},{0x0036, 0x0036},{0x0037, 0x0037}, diff --git a/psprint/source/fontsubset/u2johab.inc b/psprint/source/fontsubset/u2johab.inc index ebe2b84c5405..da59962a8b9d 100644 --- a/psprint/source/fontsubset/u2johab.inc +++ b/psprint/source/fontsubset/u2johab.inc @@ -2,9 +2,9 @@ * * $RCSfile: u2johab.inc,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:48 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -uint16pair xlat_1_6[17141] = { +sal_uInt16pair xlat_1_6[17141] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, {0x0030, 0x0030},{0x0031, 0x0031},{0x0032, 0x0032},{0x0033, 0x0033},{0x0034, 0x0034},{0x0035, 0x0035},{0x0036, 0x0036},{0x0037, 0x0037}, diff --git a/psprint/source/fontsubset/u2prc.inc b/psprint/source/fontsubset/u2prc.inc index a7ffb0419755..3a9d637dc62e 100644 --- a/psprint/source/fontsubset/u2prc.inc +++ b/psprint/source/fontsubset/u2prc.inc @@ -2,9 +2,9 @@ * * $RCSfile: u2prc.inc,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:56 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -uint16pair xlat_1_4[24035] = { +sal_uInt16pair xlat_1_4[24035] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, {0x0030, 0x0030},{0x0031, 0x0031},{0x0032, 0x0032},{0x0033, 0x0033},{0x0034, 0x0034},{0x0035, 0x0035},{0x0036, 0x0036},{0x0037, 0x0037}, diff --git a/psprint/source/fontsubset/u2shiftjis.inc b/psprint/source/fontsubset/u2shiftjis.inc index 827655dfd36f..638ac7fb862d 100644 --- a/psprint/source/fontsubset/u2shiftjis.inc +++ b/psprint/source/fontsubset/u2shiftjis.inc @@ -2,9 +2,9 @@ * * $RCSfile: u2shiftjis.inc,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:45:59 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -uint16pair xlat_1_2[7484] = { +sal_uInt16pair xlat_1_2[7484] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, {0x0030, 0x0030},{0x0031, 0x0031},{0x0032, 0x0032},{0x0033, 0x0033},{0x0034, 0x0034},{0x0035, 0x0035},{0x0036, 0x0036},{0x0037, 0x0037}, diff --git a/psprint/source/fontsubset/u2wansung.inc b/psprint/source/fontsubset/u2wansung.inc index e6a0411797bc..1e21a1b3652e 100644 --- a/psprint/source/fontsubset/u2wansung.inc +++ b/psprint/source/fontsubset/u2wansung.inc @@ -2,9 +2,9 @@ * * $RCSfile: u2wansung.inc,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:46:02 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -uint16pair xlat_1_5[8319] = { +sal_uInt16pair xlat_1_5[8319] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, {0x0030, 0x0030},{0x0031, 0x0031},{0x0032, 0x0032},{0x0033, 0x0033},{0x0034, 0x0034},{0x0035, 0x0035},{0x0036, 0x0036},{0x0037, 0x0037}, diff --git a/psprint/source/fontsubset/xlat.c b/psprint/source/fontsubset/xlat.c index 5d189803e2b0..d2283151b200 100644 --- a/psprint/source/fontsubset/xlat.c +++ b/psprint/source/fontsubset/xlat.c @@ -2,9 +2,9 @@ * * $RCSfile: xlat.c,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:46:02 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: xlat.c,v 1.1.1.1 2001-05-08 11:46:02 pl Exp $ +/* $Id: xlat.c,v 1.2 2002-08-02 12:11:33 pl Exp $ * * Data translation from Unicode to MS encodings * If the host system provides this functionality @@ -80,10 +80,10 @@ #define MISSING_CODE 0 -static uint16 xlat(uint16pair p[], uint32 n, uint16 src) +static sal_uInt16 xlat(sal_uInt16pair p[], sal_uInt32 n, sal_uInt16 src) { int l = 0, r = n - 1, i; - uint16 t, res = MISSING_CODE; + sal_uInt16 t, res = MISSING_CODE; do { i = (l + r) >> 1; @@ -99,35 +99,35 @@ static uint16 xlat(uint16pair p[], uint32 n, uint16 src) return res; } -uint16 TranslateChar12(uint16 src) +sal_uInt16 TranslateChar12(sal_uInt16 src) { return xlat(xlat_1_2, sizeof(xlat_1_2) / sizeof(xlat_1_2[0]), src); } -uint16 TranslateChar13(uint16 src) +sal_uInt16 TranslateChar13(sal_uInt16 src) { return xlat(xlat_1_3, sizeof(xlat_1_3) / sizeof(xlat_1_3[0]), src); } -uint16 TranslateChar14(uint16 src) +sal_uInt16 TranslateChar14(sal_uInt16 src) { return xlat(xlat_1_4, sizeof(xlat_1_4) / sizeof(xlat_1_4[0]), src); } -uint16 TranslateChar15(uint16 src) +sal_uInt16 TranslateChar15(sal_uInt16 src) { return xlat(xlat_1_5, sizeof(xlat_1_5) / sizeof(xlat_1_5[0]), src); } -uint16 TranslateChar16(uint16 src) +sal_uInt16 TranslateChar16(sal_uInt16 src) { return xlat(xlat_1_6, sizeof(xlat_1_6) / sizeof(xlat_1_5[0]), src); } -void TranslateString12(uint16 *src, uint16 *dst, uint32 n) +void TranslateString12(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) { - int i; - uint16 lastS, lastD; + sal_uInt32 i; + sal_uInt16 lastS, lastD; if (n == 0) return; @@ -142,10 +142,10 @@ void TranslateString12(uint16 *src, uint16 *dst, uint32 n) } } -void TranslateString13(uint16 *src, uint16 *dst, uint32 n) +void TranslateString13(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) { - int i; - uint16 lastS, lastD; + sal_uInt32 i; + sal_uInt16 lastS, lastD; if (n == 0) return; @@ -160,10 +160,10 @@ void TranslateString13(uint16 *src, uint16 *dst, uint32 n) } } -void TranslateString14(uint16 *src, uint16 *dst, uint32 n) +void TranslateString14(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) { - int i; - uint16 lastS, lastD; + sal_uInt32 i; + sal_uInt16 lastS, lastD; if (n == 0) return; @@ -178,10 +178,10 @@ void TranslateString14(uint16 *src, uint16 *dst, uint32 n) } } -void TranslateString15(uint16 *src, uint16 *dst, uint32 n) +void TranslateString15(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) { - int i; - uint16 lastS, lastD; + sal_uInt32 i; + sal_uInt16 lastS, lastD; if (n == 0) return; @@ -196,10 +196,10 @@ void TranslateString15(uint16 *src, uint16 *dst, uint32 n) } } -void TranslateString16(uint16 *src, uint16 *dst, uint32 n) +void TranslateString16(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) { - int i; - uint16 lastS, lastD; + sal_uInt32 i; + sal_uInt16 lastS, lastD; if (n == 0) return; diff --git a/psprint/source/fontsubset/xlat.h b/psprint/source/fontsubset/xlat.h index 0cac47d108fb..7d15cd68a620 100644 --- a/psprint/source/fontsubset/xlat.h +++ b/psprint/source/fontsubset/xlat.h @@ -2,9 +2,9 @@ * * $RCSfile: xlat.h,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: pl $ $Date: 2001-05-08 11:46:02 $ + * last change: $Author: pl $ $Date: 2002-08-02 12:11:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -/* $Id: xlat.h,v 1.1.1.1 2001-05-08 11:46:02 pl Exp $ */ +/* $Id: xlat.h,v 1.2 2002-08-02 12:11:34 pl Exp $ */ /*[]---------------------------------------------------[]*/ /*| |*/ @@ -79,17 +79,17 @@ extern "C" { #include "sft.h" - uint16 TranslateChar12(uint16); - uint16 TranslateChar13(uint16); - uint16 TranslateChar14(uint16); - uint16 TranslateChar15(uint16); - uint16 TranslateChar16(uint16); + sal_uInt16 TranslateChar12(sal_uInt16); + sal_uInt16 TranslateChar13(sal_uInt16); + sal_uInt16 TranslateChar14(sal_uInt16); + sal_uInt16 TranslateChar15(sal_uInt16); + sal_uInt16 TranslateChar16(sal_uInt16); - void TranslateString12(uint16 *, uint16 *, uint32); - void TranslateString13(uint16 *, uint16 *, uint32); - void TranslateString14(uint16 *, uint16 *, uint32); - void TranslateString15(uint16 *, uint16 *, uint32); - void TranslateString16(uint16 *, uint16 *, uint32); + void TranslateString12(sal_uInt16 *, sal_uInt16 *, sal_uInt32); + void TranslateString13(sal_uInt16 *, sal_uInt16 *, sal_uInt32); + void TranslateString14(sal_uInt16 *, sal_uInt16 *, sal_uInt32); + void TranslateString15(sal_uInt16 *, sal_uInt16 *, sal_uInt32); + void TranslateString16(sal_uInt16 *, sal_uInt16 *, sal_uInt32); #ifdef __cplusplus } |