Index: inc/salgdi.h =================================================================== RCS file: /cvs/gsl/vcl/aqua/inc/salgdi.h,v retrieving revision 1.28.112.36 diff -u -r1.28.112.36 salgdi.h --- inc/salgdi.h 27 Jun 2007 18:01:40 -0000 1.28.112.36 +++ inc/salgdi.h 28 Jun 2007 16:48:10 -0000 @@ -78,6 +78,7 @@ ImplFontCharMap* GetImplFontCharMap() const; bool HasChar(sal_uInt32 cChar) const; + bool ReadOs2Table(std::vector& rBuffer) const; private: const ATSUFontID mnFontId; @@ -171,6 +172,7 @@ void RefreshRect(float lX, float lY, float lWidth, float lHeight); void SetState(); + bool ReadOs2Table ( std::vector& rBuffer ); virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight ); // draw --> LineColor and FillColor and RasterOp and ClipRegion Index: source/gdi/salgdi.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/salgdi.cxx,v retrieving revision 1.59.112.68 diff -u -r1.59.112.68 salgdi.cxx --- source/gdi/salgdi.cxx 28 Jun 2007 11:57:11 -0000 1.59.112.68 +++ source/gdi/salgdi.cxx 28 Jun 2007 16:48:11 -0000 @@ -167,6 +167,31 @@ return mpCharMap; } +bool ImplMacFontData::ReadOs2Table(std::vector &rBuffer) const +{ + ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); + ByteCount nBufSize = 0; + OSStatus eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, 0, NULL, &nBufSize ); + DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable1 failed!\n"); + if( eStatus != noErr ) + return false; + + // allocate a buffer for the OS/2 raw data + rBuffer.resize( nBufSize ); + + // get the OS/2 raw data + ByteCount nRawLength = 0; + eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, nBufSize, (void*)&rBuffer[0], &nRawLength ); + DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable2 failed!\n"); + if( eStatus != noErr ) + return false; + DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadOs2Table : ByteCount mismatch!\n"); + + // parse the OS/2 + return true; +} + + // ======================================================================= AquaSalGraphics::AquaSalGraphics() @@ -1130,6 +1155,8 @@ } // ----------------------------------------------------------------------- +static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} +static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) { @@ -1166,6 +1193,36 @@ // setting this width to the pixel height of the fontsize is good enough // it also makes the calculation of the stretch factor simple pMetric->mnWidth = fPixelSize + 0.5; + + + ByteVector aBuffer; + if( !ReadOs2Table( aBuffer ) ) + return; + unsigned char* pOS2map = &aBuffer[0]; + sal_uInt32 nVersion = GetUShort( pOS2map ); + bool bHasCJKSupport = false; + if (nVersion >= 0x0001) + { + sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 ); + if (ulUnicodeRange2 & 0x2DF00000) + bHasCJKSupport = true; + } + + if ( bHasCJKSupport ) + { + // for Asian fonts hack + pMetric->mnIntLeading += pMetric->mnExtLeading; + + const long nHalfTmpExtLeading = pMetric->mnExtLeading / 2; + const long nOtherHalfTmpExtLeading = pMetric->mnExtLeading - nHalfTmpExtLeading; + + long nCJKExtLeading = static_cast(0.30 * (pMetric->mnAscent + pMetric->mnDescent)); + nCJKExtLeading -= pMetric->mnExtLeading; + pMetric->mnExtLeading = (nCJKExtLeading > 0) ? nCJKExtLeading : 0; + + pMetric->mnAscent += nHalfTmpExtLeading; + pMetric->mnDescent += nOtherHalfTmpExtLeading; + } } // ----------------------------------------------------------------------- @@ -1460,6 +1517,16 @@ // ----------------------------------------------------------------------- +bool AquaSalGraphics::ReadOs2Table( std::vector& rBuffer ) +{ + if( !mpMacFontData ) + return false; + + return mpMacFontData->ReadOs2Table( rBuffer ); +} + +// ----------------------------------------------------------------------- + // fake a SFNT font directory entry for a font table // see http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html#Directory static void FakeDirEntry( FourCharCode eFCC, ByteCount nOfs, ByteCount nLen,