Index: oo_cvs/vcl/source/glyphs/gcach_ftyp.cxx =================================================================== RCS file: /cvs/oo/gsl/vcl/source/glyphs/gcach_ftyp.cxx,v retrieving revision 1.69 diff -u -3 -p -r1.69 gcach_ftyp.cxx --- oo_cvs/vcl/source/glyphs/gcach_ftyp.cxx 2002/01/02 10:38:06 1.69 +++ oo_cvs/vcl/source/glyphs/gcach_ftyp.cxx 2002/06/17 14:37:50 @@ -104,6 +104,13 @@ #include "freetype/internal/sfnt.h" #include "freetype/internal/ftstream.h" +// Freetype versions < 2.1 used different stream macro names +#ifndef FT_NEXT_USHORT +#define FT_NEXT_USHORT NEXT_UShort +#define FT_NEXT_SHORT NEXT_Short +#define FT_NEXT_LONG NEXT_Long +#endif + #include #include #include @@ -1200,29 +1207,29 @@ ULONG FreetypeServerFont::GetKernPairs( ImplKernPairData aKernPair; const FT_Byte* pBuffer = pKern; - USHORT nVersion = NEXT_UShort( pBuffer ); - USHORT nTableCnt = NEXT_UShort( pBuffer ); + USHORT nVersion = FT_NEXT_USHORT( pBuffer ); + USHORT nTableCnt = FT_NEXT_USHORT( pBuffer ); if( nVersion != 0 ) // ignore Apple's versions for now nTableCnt = 0; for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) { - USHORT nSubVersion = NEXT_UShort( pBuffer ); - USHORT nSubLength = NEXT_UShort( pBuffer ); - USHORT nSubCoverage = NEXT_UShort( pBuffer ); + USHORT nSubVersion = FT_NEXT_USHORT( pBuffer ); + USHORT nSubLength = FT_NEXT_USHORT( pBuffer ); + USHORT nSubCoverage = FT_NEXT_USHORT( pBuffer ); if( (nSubCoverage&0x03) != 0x01 ) // no interest in minimum info here continue; switch( nSubCoverage >> 8 ) { case 0: // version 0, kerning format 0 { - USHORT nPairs = NEXT_UShort( pBuffer ); + USHORT nPairs = FT_NEXT_USHORT( pBuffer ); pBuffer += 6; // skip search hints aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); for( int i = 0; i < nPairs; ++i ) { - aKernPair.mnChar1 = NEXT_UShort( pBuffer ); - aKernPair.mnChar2 = NEXT_UShort( pBuffer ); - /*long nUnscaledKern=*/ NEXT_Short( pBuffer ); + aKernPair.mnChar1 = FT_NEXT_USHORT( pBuffer ); + aKernPair.mnChar2 = FT_NEXT_USHORT( pBuffer ); + /*long nUnscaledKern=*/ FT_NEXT_SHORT( pBuffer ); aKernGlyphVector.push_back( aKernPair ); } } @@ -1231,18 +1238,18 @@ ULONG FreetypeServerFont::GetKernPairs( case 2: // version 0, kerning format 2 { const FT_Byte* pSubTable = pBuffer; - /*USHORT nRowWidth =*/ NEXT_UShort( pBuffer ); - USHORT nOfsLeft = NEXT_UShort( pBuffer ); - USHORT nOfsRight = NEXT_UShort( pBuffer ); - USHORT nOfsArray = NEXT_UShort( pBuffer ); + /*USHORT nRowWidth =*/ FT_NEXT_USHORT( pBuffer ); + USHORT nOfsLeft = FT_NEXT_USHORT( pBuffer ); + USHORT nOfsRight = FT_NEXT_USHORT( pBuffer ); + USHORT nOfsArray = FT_NEXT_USHORT( pBuffer ); const FT_Byte* pTmp = pSubTable + nOfsLeft; - USHORT nFirstLeft = NEXT_UShort( pTmp ); - USHORT nLastLeft = NEXT_UShort( pTmp ) + nFirstLeft - 1; + USHORT nFirstLeft = FT_NEXT_USHORT( pTmp ); + USHORT nLastLeft = FT_NEXT_USHORT( pTmp ) + nFirstLeft - 1; pTmp = pSubTable + nOfsRight; - USHORT nFirstRight = NEXT_UShort( pTmp ); - USHORT nLastRight = NEXT_UShort( pTmp ) + nFirstRight - 1; + USHORT nFirstRight = FT_NEXT_USHORT( pTmp ); + USHORT nLastRight = FT_NEXT_USHORT( pTmp ) + nFirstRight - 1; ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); @@ -1253,7 +1260,7 @@ ULONG FreetypeServerFont::GetKernPairs( aKernPair.mnChar1 = nLeft; for( int nRight = 0; nRight < nLastRight; ++nRight ) { - if( NEXT_Short( pTmp ) != 0 ) + if( FT_NEXT_SHORT( pTmp ) != 0 ) { aKernPair.mnChar2 = nRight; aKernGlyphVector.push_back( aKernPair ); @@ -1531,10 +1538,10 @@ bool FreetypeServerFont::ApplyGSUB( cons // parse GSUB header const FT_Byte* pGsubHeader = pGsubBase; - const ULONG nVersion = NEXT_Long( pGsubHeader ); - const USHORT nOfsScriptList = NEXT_UShort( pGsubHeader ); - const USHORT nOfsFeatureTable = NEXT_UShort( pGsubHeader ); - const USHORT nOfsLookupList = NEXT_UShort( pGsubHeader ); + const ULONG nVersion = FT_NEXT_LONG( pGsubHeader ); + const USHORT nOfsScriptList = FT_NEXT_USHORT( pGsubHeader ); + const USHORT nOfsFeatureTable = FT_NEXT_USHORT( pGsubHeader ); + const USHORT nOfsLookupList = FT_NEXT_USHORT( pGsubHeader ); typedef std::vector UshortList; UshortList aFeatureIndexList; @@ -1542,22 +1549,22 @@ bool FreetypeServerFont::ApplyGSUB( cons // parse Script Table const FT_Byte* pScriptHeader = pGsubBase + nOfsScriptList; - const USHORT nCntScript = NEXT_UShort( pScriptHeader ); + const USHORT nCntScript = FT_NEXT_USHORT( pScriptHeader ); for( USHORT nScriptIndex = 0; nScriptIndex < nCntScript; ++nScriptIndex ) { - const ULONG nTag = NEXT_Long( pScriptHeader ); // e.g. hani/arab/kana/hang - const USHORT nOfsScriptTable= NEXT_UShort( pScriptHeader ); + const ULONG nTag = FT_NEXT_LONG( pScriptHeader ); // e.g. hani/arab/kana/hang + const USHORT nOfsScriptTable= FT_NEXT_USHORT( pScriptHeader ); if( (nTag != nRequestedScript) && (nRequestedScript != 0) ) continue; const FT_Byte* pScriptTable = pGsubBase + nOfsScriptList + nOfsScriptTable; - const USHORT nDefaultLangsysOfs = NEXT_UShort( pScriptTable ); - const USHORT nCntLangSystem = NEXT_UShort( pScriptTable ); + const USHORT nDefaultLangsysOfs = FT_NEXT_USHORT( pScriptTable ); + const USHORT nCntLangSystem = FT_NEXT_USHORT( pScriptTable ); USHORT nLangsysOffset = 0; for( USHORT nLangsysIndex = 0; nLangsysIndex < nCntLangSystem; ++nLangsysIndex ) { - const ULONG nTag = NEXT_Long( pScriptTable ); // e.g. KOR/ZHS/ZHT/JAN - const USHORT nOffset= NEXT_UShort( pScriptTable ); + const ULONG nTag = FT_NEXT_LONG( pScriptTable ); // e.g. KOR/ZHS/ZHT/JAN + const USHORT nOffset= FT_NEXT_USHORT( pScriptTable ); if( (nTag != nRequestedLangsys) && (nRequestedLangsys != 0) ) continue; nLangsysOffset = nOffset; @@ -1567,13 +1574,13 @@ bool FreetypeServerFont::ApplyGSUB( cons if( (nDefaultLangsysOfs != 0) && (nDefaultLangsysOfs != nLangsysOffset) ) { const FT_Byte* pLangSys = pGsubBase + nOfsScriptList + nOfsScriptTable + nDefaultLangsysOfs; - const USHORT nLookupOrder = NEXT_UShort( pLangSys ); - const USHORT nReqFeatureIdx = NEXT_UShort( pLangSys ); - const USHORT nCntFeature = NEXT_UShort( pLangSys ); + const USHORT nLookupOrder = FT_NEXT_USHORT( pLangSys ); + const USHORT nReqFeatureIdx = FT_NEXT_USHORT( pLangSys ); + const USHORT nCntFeature = FT_NEXT_USHORT( pLangSys ); aFeatureIndexList.push_back( nReqFeatureIdx ); for( USHORT i = 0; i < nCntFeature; ++i ) { - const USHORT nFeatureIndex = NEXT_UShort( pLangSys ); + const USHORT nFeatureIndex = FT_NEXT_USHORT( pLangSys ); aFeatureIndexList.push_back( nFeatureIndex ); } } @@ -1581,13 +1588,13 @@ bool FreetypeServerFont::ApplyGSUB( cons if( nLangsysOffset != 0 ) { const FT_Byte* pLangSys = pGsubBase + nOfsScriptList + nOfsScriptTable + nLangsysOffset; - const USHORT nLookupOrder = NEXT_UShort( pLangSys ); - const USHORT nReqFeatureIdx = NEXT_UShort( pLangSys ); - const USHORT nCntFeature = NEXT_UShort( pLangSys ); + const USHORT nLookupOrder = FT_NEXT_USHORT( pLangSys ); + const USHORT nReqFeatureIdx = FT_NEXT_USHORT( pLangSys ); + const USHORT nCntFeature = FT_NEXT_USHORT( pLangSys ); aFeatureIndexList.push_back( nReqFeatureIdx ); for( USHORT i = 0; i < nCntFeature; ++i ) { - const USHORT nFeatureIndex = NEXT_UShort( pLangSys ); + const USHORT nFeatureIndex = FT_NEXT_USHORT( pLangSys ); aFeatureIndexList.push_back( nFeatureIndex ); } } @@ -1601,11 +1608,11 @@ bool FreetypeServerFont::ApplyGSUB( cons // parse Feature Table const FT_Byte* pFeatureHeader = pGsubBase + nOfsFeatureTable; - const USHORT nCntFeature = NEXT_UShort( pFeatureHeader ); + const USHORT nCntFeature = FT_NEXT_USHORT( pFeatureHeader ); for( USHORT nFeatureIndex = 0; nFeatureIndex < nCntFeature; ++nFeatureIndex ) { - const ULONG nTag = NEXT_Long( pFeatureHeader ); // e.g. locl/vert/trad/smpl/liga/fina/... - const USHORT nOffset= NEXT_UShort( pFeatureHeader ); + const ULONG nTag = FT_NEXT_LONG( pFeatureHeader ); // e.g. locl/vert/trad/smpl/liga/fina/... + const USHORT nOffset= FT_NEXT_USHORT( pFeatureHeader ); // feature (required && (requested || available))? if( (aFeatureIndexList[0] != nFeatureIndex) @@ -1614,10 +1621,10 @@ bool FreetypeServerFont::ApplyGSUB( cons continue; const FT_Byte* pFeatureTable = pGsubBase + nOfsFeatureTable + nOffset; - const USHORT nCntLookups = NEXT_UShort( pFeatureTable ); + const USHORT nCntLookups = FT_NEXT_USHORT( pFeatureTable ); for( USHORT i = 0; i < nCntLookups; ++i ) { - const USHORT nLookupIndex = NEXT_UShort( pFeatureTable ); + const USHORT nLookupIndex = FT_NEXT_USHORT( pFeatureTable ); aLookupIndexList.push_back( nLookupIndex ); } if( nCntLookups == 0 ) //### hack needed by Mincho/Gothic/Mingliu/Simsun/... @@ -1626,10 +1633,10 @@ bool FreetypeServerFont::ApplyGSUB( cons // parse Lookup List const FT_Byte* pLookupHeader = pGsubBase + nOfsLookupList; - const USHORT nCntLookupTable = NEXT_UShort( pLookupHeader ); + const USHORT nCntLookupTable = FT_NEXT_USHORT( pLookupHeader ); for( USHORT nLookupIdx = 0; nLookupIdx < nCntLookupTable; ++nLookupIdx ) { - const USHORT nOffset = NEXT_UShort( pLookupHeader ); + const USHORT nOffset = FT_NEXT_USHORT( pLookupHeader ); if( std::count( aLookupIndexList.begin(), aLookupIndexList.end(), nLookupIdx ) ) aLookupOffsetList.push_back( nOffset ); } @@ -1639,9 +1646,9 @@ bool FreetypeServerFont::ApplyGSUB( cons { const USHORT nOfsLookupTable = *it; const FT_Byte* pLookupTable = pGsubBase + nOfsLookupList + nOfsLookupTable; - const USHORT eLookupType = NEXT_UShort( pLookupTable ); - const USHORT eLookupFlag = NEXT_UShort( pLookupTable ); - const USHORT nCntLookupSubtable = NEXT_UShort( pLookupTable ); + const USHORT eLookupType = FT_NEXT_USHORT( pLookupTable ); + const USHORT eLookupFlag = FT_NEXT_USHORT( pLookupTable ); + const USHORT nCntLookupSubtable = FT_NEXT_USHORT( pLookupTable ); // TODO: switch( eLookupType ) if( eLookupType != 1 ) // TODO: once we go beyond SingleSubst @@ -1649,28 +1656,28 @@ bool FreetypeServerFont::ApplyGSUB( cons for( USHORT nSubTableIdx = 0; nSubTableIdx < nCntLookupSubtable; ++nSubTableIdx ) { - const USHORT nOfsSubLookupTable = NEXT_UShort( pLookupTable ); + const USHORT nOfsSubLookupTable = FT_NEXT_USHORT( pLookupTable ); const FT_Byte* pSubLookup = pGsubBase + nOfsLookupList + nOfsLookupTable + nOfsSubLookupTable; - const USHORT nFmtSubstitution = NEXT_UShort( pSubLookup ); - const USHORT nOfsCoverage = NEXT_UShort( pSubLookup ); + const USHORT nFmtSubstitution = FT_NEXT_USHORT( pSubLookup ); + const USHORT nOfsCoverage = FT_NEXT_USHORT( pSubLookup ); typedef std::pair GlyphSubst; typedef std::vector SubstVector; SubstVector aSubstVector; const FT_Byte* pCoverage = pGsubBase + nOfsLookupList + nOfsLookupTable + nOfsSubLookupTable + nOfsCoverage; - const USHORT nFmtCoverage = NEXT_UShort( pCoverage ); + const USHORT nFmtCoverage = FT_NEXT_USHORT( pCoverage ); switch( nFmtCoverage ) { case 1: // Coverage Format 1 { - const USHORT nCntGlyph = NEXT_UShort( pCoverage ); + const USHORT nCntGlyph = FT_NEXT_USHORT( pCoverage ); aSubstVector.reserve( nCntGlyph ); for( USHORT i = 0; i < nCntGlyph; ++i ) { - const USHORT nGlyphId = NEXT_UShort( pCoverage ); + const USHORT nGlyphId = FT_NEXT_USHORT( pCoverage ); aSubstVector.push_back( GlyphSubst( nGlyphId, 0 ) ); } } @@ -1678,12 +1685,12 @@ bool FreetypeServerFont::ApplyGSUB( cons case 2: // Coverage Format 2 { - const USHORT nCntRange = NEXT_UShort( pCoverage ); + const USHORT nCntRange = FT_NEXT_USHORT( pCoverage ); for( int i = nCntRange; --i >= 0; ) { - const USHORT nGlyph0 = NEXT_UShort( pCoverage ); - const USHORT nGlyph1 = NEXT_UShort( pCoverage ); - const USHORT nCovIdx = NEXT_UShort( pCoverage ); + const USHORT nGlyph0 = FT_NEXT_USHORT( pCoverage ); + const USHORT nGlyph1 = FT_NEXT_USHORT( pCoverage ); + const USHORT nCovIdx = FT_NEXT_USHORT( pCoverage ); for( USHORT j = nGlyph0; j <= nGlyph1; ++j ) aSubstVector.push_back( GlyphSubst( j + nCovIdx, 0 ) ); } @@ -1697,7 +1704,7 @@ bool FreetypeServerFont::ApplyGSUB( cons { case 1: // Single Substitution Format 1 { - const USHORT nDeltaGlyphId = NEXT_UShort( pSubLookup ); + const USHORT nDeltaGlyphId = FT_NEXT_USHORT( pSubLookup ); for(; it != aSubstVector.end(); ++it ) (*it).second = (*it).first + nDeltaGlyphId; } @@ -1705,10 +1712,10 @@ bool FreetypeServerFont::ApplyGSUB( cons case 2: // Single Substitution Format 2 { - const USHORT nCntGlyph = NEXT_UShort( pSubLookup ); + const USHORT nCntGlyph = FT_NEXT_USHORT( pSubLookup ); for( int i = nCntGlyph; (it != aSubstVector.end()) && (--i>=0); ++it ) { - const USHORT nGlyphId = NEXT_UShort( pSubLookup ); + const USHORT nGlyphId = FT_NEXT_USHORT( pSubLookup ); (*it).second = nGlyphId; } }