salgdi.cxx (24a22e85) | salgdi.cxx (e26449d3) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 5 unchanged lines hidden (view full) --- 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 5 unchanged lines hidden (view full) --- 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 |
22 23 | |
24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_vcl.hxx" 26 27#include "osl/file.hxx" 28#include "osl/process.h" 29 30#include "vos/mutex.hxx" 31 --- 9 unchanged lines hidden (view full) --- 41#include "vcl/sysdata.hxx" 42#include "vcl/svapp.hxx" 43 44#include "aqua/salconst.h" 45#include "aqua/salgdi.h" 46#include "aqua/salbmp.h" 47#include "aqua/salframe.h" 48#include "aqua/salcolorutils.hxx" | 22// MARKER(update_precomp.py): autogen include statement, do not remove 23#include "precompiled_vcl.hxx" 24 25#include "osl/file.hxx" 26#include "osl/process.h" 27 28#include "vos/mutex.hxx" 29 --- 9 unchanged lines hidden (view full) --- 39#include "vcl/sysdata.hxx" 40#include "vcl/svapp.hxx" 41 42#include "aqua/salconst.h" 43#include "aqua/salgdi.h" 44#include "aqua/salbmp.h" 45#include "aqua/salframe.h" 46#include "aqua/salcolorutils.hxx" |
47#ifdef USE_ATSU |
|
49#include "atsfonts.hxx" | 48#include "atsfonts.hxx" |
49#else // !USE_ATSU 50#include "ctfonts.hxx" 51#endif |
|
50 51#include "fontsubset.hxx" 52#include "impfont.hxx" 53#include "sallayout.hxx" 54#include "sft.hxx" 55 | 52 53#include "fontsubset.hxx" 54#include "impfont.hxx" 55#include "sallayout.hxx" 56#include "sft.hxx" 57 |
56 | |
57using namespace vcl; 58 | 58using namespace vcl; 59 |
59//typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included 60typedef std::vector<unsigned char> ByteVector; | 60// ======================================================================= |
61 | 61 |
62SystemFontList::~SystemFontList( void ) 63{} |
|
62 63// ======================================================================= 64 | 64 65// ======================================================================= 66 |
65ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, ATSUFontID nFontId ) 66: ImplFontData( rDFA, 0 ) 67, mnFontId( nFontId ) | 67ImplMacTextStyle::ImplMacTextStyle( const ImplFontSelectData& rReqFont ) 68: mpFontData( (ImplMacFontData*)rReqFont.mpFontData ) 69, mfFontScale( 1.0 ) 70, mfFontStretch( 1.0 ) 71, mfFontRotation( 0.0 ) 72{} 73 74// ----------------------------------------------------------------------- 75 76ImplMacTextStyle::~ImplMacTextStyle( void ) 77{} 78 79// ======================================================================= 80 81ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId ) 82: ImplFontData( rDFA, 0 ) 83, mnFontId( nFontId ) |
68, mpCharMap( NULL ) 69, mbOs2Read( false ) 70, mbHasOs2Table( false ) 71, mbCmapEncodingRead( false ) 72, mbHasCJKSupport( false ) 73{} 74 75// ----------------------------------------------------------------------- 76 | 84, mpCharMap( NULL ) 85, mbOs2Read( false ) 86, mbHasOs2Table( false ) 87, mbCmapEncodingRead( false ) 88, mbHasCJKSupport( false ) 89{} 90 91// ----------------------------------------------------------------------- 92 |
77ImplMacFontData::~ImplMacFontData() | 93ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc ) 94: ImplFontData( rSrc) 95, mnFontId( rSrc.mnFontId) 96, mpCharMap( rSrc.mpCharMap) 97, mbOs2Read( rSrc.mbOs2Read) 98, mbHasOs2Table( rSrc.mbHasOs2Table) 99, mbCmapEncodingRead( rSrc.mbCmapEncodingRead) 100, mbHasCJKSupport( rSrc.mbHasCJKSupport) |
78{ 79 if( mpCharMap ) | 101{ 102 if( mpCharMap ) |
80 mpCharMap->DeReference(); | 103 mpCharMap->AddReference(); |
81} 82 83// ----------------------------------------------------------------------- 84 | 104} 105 106// ----------------------------------------------------------------------- 107 |
85sal_IntPtr ImplMacFontData::GetFontId() const | 108ImplMacFontData::~ImplMacFontData() |
86{ | 109{ |
87 return (sal_IntPtr)mnFontId; | 110 if( mpCharMap ) 111 mpCharMap->DeReference(); |
88} 89 90// ----------------------------------------------------------------------- 91 | 112} 113 114// ----------------------------------------------------------------------- 115 |
92ImplFontData* ImplMacFontData::Clone() const | 116sal_IntPtr ImplMacFontData::GetFontId() const |
93{ | 117{ |
94 ImplMacFontData* pClone = new ImplMacFontData(*this); 95 if( mpCharMap ) 96 mpCharMap->AddReference(); 97 return pClone; | 118 return reinterpret_cast<sal_IntPtr>( mnFontId); |
98} 99 100// ----------------------------------------------------------------------- 101 102ImplFontEntry* ImplMacFontData::CreateFontInstance(ImplFontSelectData& rFSD) const 103{ | 119} 120 121// ----------------------------------------------------------------------- 122 123ImplFontEntry* ImplMacFontData::CreateFontInstance(ImplFontSelectData& rFSD) const 124{ |
104 return new ImplFontEntry(rFSD); | 125 return new ImplFontEntry(rFSD); |
105} 106 107// ----------------------------------------------------------------------- 108 | 126} 127 128// ----------------------------------------------------------------------- 129 |
109inline FourCharCode GetTag(const char aTagName[5]) 110{ 111 return (aTagName[0]<<24)+(aTagName[1]<<16)+(aTagName[2]<<8)+(aTagName[3]); 112} 113 | |
114static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} 115static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} 116 117const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const 118{ 119 // return the cached charmap 120 if( mpCharMap ) 121 return mpCharMap; 122 123 // set the default charmap 124 mpCharMap = ImplFontCharMap::GetDefaultMap(); 125 mpCharMap->AddReference(); 126 127 // get the CMAP byte size | 130static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} 131static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} 132 133const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const 134{ 135 // return the cached charmap 136 if( mpCharMap ) 137 return mpCharMap; 138 139 // set the default charmap 140 mpCharMap = ImplFontCharMap::GetDefaultMap(); 141 mpCharMap->AddReference(); 142 143 // get the CMAP byte size |
128 ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); 129 ByteCount nBufSize = 0; 130 OSStatus eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, 0, NULL, &nBufSize ); 131 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::GetImplFontCharMap : ATSFontGetTable1 failed!\n"); 132 if( eStatus != noErr ) | 144 // allocate a buffer for the CMAP raw data 145 const int nBufSize = GetFontTable( "cmap", NULL ); 146 DBG_ASSERT( (nBufSize > 0), "ImplMacFontData::GetImplFontCharMap : FontGetTable1 failed!\n"); 147 if( nBufSize <= 0 ) |
133 return mpCharMap; 134 | 148 return mpCharMap; 149 |
135 // allocate a buffer for the CMAP raw data 136 ByteVector aBuffer( nBufSize ); 137 | |
138 // get the CMAP raw data | 150 // get the CMAP raw data |
139 ByteCount nRawLength = 0; 140 eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength ); 141 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::GetImplFontCharMap : ATSFontGetTable2 failed!\n"); 142 if( eStatus != noErr ) | 151 ByteVector aBuffer( nBufSize ); 152 const int nRawSize = GetFontTable( "cmap", &aBuffer[0] ); 153 DBG_ASSERT( (nRawSize > 0), "ImplMacFontData::GetImplFontCharMap : ATSFontGetTable2 failed!\n"); 154 if( nRawSize <= 0 ) |
143 return mpCharMap; | 155 return mpCharMap; |
144 DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::GetImplFontCharMap : ByteCount mismatch!\n"); | 156 DBG_ASSERT( (nBufSize==nRawSize), "ImplMacFontData::GetImplFontCharMap : ByteCount mismatch!\n"); |
145 146 // parse the CMAP 147 CmapResult aCmapResult; | 157 158 // parse the CMAP 159 CmapResult aCmapResult; |
148 if( ParseCMAP( &aBuffer[0], nRawLength, aCmapResult ) ) | 160 if( ParseCMAP( &aBuffer[0], nRawSize, aCmapResult ) ) |
149 { 150 // create the matching charmap 151 mpCharMap->DeReference(); 152 mpCharMap = new ImplFontCharMap( aCmapResult ); 153 mpCharMap->AddReference(); 154 } 155 156 return mpCharMap; 157} 158 159// ----------------------------------------------------------------------- 160 161void ImplMacFontData::ReadOs2Table( void ) const 162{ 163 // read this only once per font 164 if( mbOs2Read ) 165 return; 166 mbOs2Read = true; | 161 { 162 // create the matching charmap 163 mpCharMap->DeReference(); 164 mpCharMap = new ImplFontCharMap( aCmapResult ); 165 mpCharMap->AddReference(); 166 } 167 168 return mpCharMap; 169} 170 171// ----------------------------------------------------------------------- 172 173void ImplMacFontData::ReadOs2Table( void ) const 174{ 175 // read this only once per font 176 if( mbOs2Read ) 177 return; 178 mbOs2Read = true; |
179 mbHasOs2Table = false; |
|
167 168 // prepare to get the OS/2 table raw data | 180 181 // prepare to get the OS/2 table raw data |
169 ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); 170 ByteCount nBufSize = 0; 171 OSStatus eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, 0, NULL, &nBufSize ); 172 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable1 failed!\n"); 173 if( eStatus != noErr ) | 182 const int nBufSize = GetFontTable( "OS/2", NULL ); 183 DBG_ASSERT( (nBufSize > 0), "ImplMacFontData::ReadOs2Table : FontGetTable1 failed!\n"); 184 if( nBufSize <= 0 ) |
174 return; 175 | 185 return; 186 |
176 // allocate a buffer for the OS/2 raw data 177 ByteVector aBuffer( nBufSize ); 178 | |
179 // get the OS/2 raw data | 187 // get the OS/2 raw data |
180 ByteCount nRawLength = 0; 181 eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength ); 182 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable2 failed!\n"); 183 if( eStatus != noErr ) | 188 ByteVector aBuffer( nBufSize ); 189 const int nRawSize = GetFontTable( "cmap", &aBuffer[0] ); 190 DBG_ASSERT( (nRawSize > 0), "ImplMacFontData::ReadOs2Table : ATSFontGetTable2 failed!\n"); 191 if( nRawSize <= 0 ) |
184 return; | 192 return; |
185 DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadOs2Table : ByteCount mismatch!\n"); | 193 DBG_ASSERT( (nBufSize == nRawSize), "ImplMacFontData::ReadOs2Table : ByteCount mismatch!\n"); |
186 mbHasOs2Table = true; 187 188 // parse the OS/2 raw data 189 // TODO: also analyze panose info, etc. 190 191 // check if the fonts needs the "CJK extra leading" heuristic 192 const unsigned char* pOS2map = &aBuffer[0]; | 194 mbHasOs2Table = true; 195 196 // parse the OS/2 raw data 197 // TODO: also analyze panose info, etc. 198 199 // check if the fonts needs the "CJK extra leading" heuristic 200 const unsigned char* pOS2map = &aBuffer[0]; |
193 const sal_uInt32 nVersion = GetUShort( pOS2map ); 194 if( nVersion >= 0x0001 ) 195 { 196 sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 ); 197 if( ulUnicodeRange2 & 0x2DF00000 ) 198 mbHasCJKSupport = true; 199 } | 201 const sal_uInt32 nVersion = GetUShort( pOS2map ); 202 if( nVersion >= 0x0001 ) 203 { 204 const sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 ); 205 if( ulUnicodeRange2 & 0x2DF00000 ) 206 mbHasCJKSupport = true; 207 } |
200} 201 202void ImplMacFontData::ReadMacCmapEncoding( void ) const 203{ | 208} 209 210void ImplMacFontData::ReadMacCmapEncoding( void ) const 211{ |
204 // read this only once per font 205 if( mbCmapEncodingRead ) 206 return; 207 mbCmapEncodingRead = true; | 212 // read this only once per font 213 if( mbCmapEncodingRead ) 214 return; 215 mbCmapEncodingRead = true; |
208 | 216 |
209 ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); 210 ByteCount nBufSize = 0; 211 OSStatus eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, 0, NULL, &nBufSize ); 212 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadMacCmapEncoding : ATSFontGetTable1 failed!\n"); 213 if( eStatus != noErr ) 214 return; | 217 const int nBufSize = GetFontTable( "cmap", NULL ); 218 if( nBufSize <= 0 ) 219 return; |
215 | 220 |
216 ByteVector aBuffer( nBufSize ); | 221 // get the CMAP raw data 222 ByteVector aBuffer( nBufSize ); 223 const int nRawSize = GetFontTable( "cmap", &aBuffer[0] ); 224 if( nRawSize < 24 ) 225 return; |
217 | 226 |
218 ByteCount nRawLength = 0; 219 eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength ); 220 DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadMacCmapEncoding : ATSFontGetTable2 failed!\n"); 221 if( eStatus != noErr ) 222 return; 223 DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadMacCmapEncoding : ByteCount mismatch!\n"); | 227 const unsigned char* pCmap = &aBuffer[0]; 228 if( GetUShort( pCmap ) != 0x0000 ) 229 return; |
224 | 230 |
225 const unsigned char* pCmap = &aBuffer[0]; 226 227 if (nRawLength < 24 ) 228 return; 229 if( GetUShort( pCmap ) != 0x0000 ) 230 return; 231 232 // check if the fonts needs the "CJK extra leading" heuristic 233 int nSubTables = GetUShort( pCmap + 2 ); 234 235 for( const unsigned char* p = pCmap + 4; --nSubTables >= 0; p += 8 ) 236 { 237 int nPlatform = GetUShort( p ); 238 if( nPlatform == kFontMacintoshPlatform ) { 239 int nEncoding = GetUShort (p + 2 ); 240 if( nEncoding == kFontJapaneseScript || 241 nEncoding == kFontTraditionalChineseScript || 242 nEncoding == kFontKoreanScript || 243 nEncoding == kFontSimpleChineseScript ) 244 { 245 mbHasCJKSupport = true; 246 break; 247 } 248 } 249 } | 231 // check if the fonts needs the "CJK extra leading" heuristic 232 int nSubTables = GetUShort( pCmap + 2 ); 233 for( const unsigned char* p = pCmap + 4; --nSubTables >= 0; p += 8 ) 234 { 235 int nPlatform = GetUShort( p ); 236 if( nPlatform == kFontMacintoshPlatform ) { 237 const int nEncoding = GetUShort (p + 2 ); 238 if( nEncoding == kFontJapaneseScript || 239 nEncoding == kFontTraditionalChineseScript || 240 nEncoding == kFontKoreanScript || 241 nEncoding == kFontSimpleChineseScript ) 242 { 243 mbHasCJKSupport = true; 244 break; 245 } 246 } 247 } |
250} 251 252// ----------------------------------------------------------------------- 253 254bool ImplMacFontData::HasCJKSupport( void ) const 255{ 256 ReadOs2Table(); | 248} 249 250// ----------------------------------------------------------------------- 251 252bool ImplMacFontData::HasCJKSupport( void ) const 253{ 254 ReadOs2Table(); |
257 if( !mbHasOs2Table ) 258 ReadMacCmapEncoding(); | 255 if( !mbHasOs2Table ) 256 ReadMacCmapEncoding(); |
259 260 return mbHasCJKSupport; 261} 262 263// ======================================================================= 264 265AquaSalGraphics::AquaSalGraphics() 266 : mpFrame( NULL ) --- 5 unchanged lines hidden (view full) --- 272 , mnHeight( 0 ) 273 , mnBitmapDepth( 0 ) 274 , mnRealDPIX( 0 ) 275 , mnRealDPIY( 0 ) 276 , mfFakeDPIScale( 1.0 ) 277 , mxClipPath( NULL ) 278 , maLineColor( COL_WHITE ) 279 , maFillColor( COL_BLACK ) | 257 258 return mbHasCJKSupport; 259} 260 261// ======================================================================= 262 263AquaSalGraphics::AquaSalGraphics() 264 : mpFrame( NULL ) --- 5 unchanged lines hidden (view full) --- 270 , mnHeight( 0 ) 271 , mnBitmapDepth( 0 ) 272 , mnRealDPIX( 0 ) 273 , mnRealDPIY( 0 ) 274 , mfFakeDPIScale( 1.0 ) 275 , mxClipPath( NULL ) 276 , maLineColor( COL_WHITE ) 277 , maFillColor( COL_BLACK ) |
280 , mpMacFontData( NULL ) 281 , mnATSUIRotation( 0 ) 282 , mfFontScale( 1.0 ) 283 , mfFontStretch( 1.0 ) | 278 , mpMacFontData( NULL ) 279 , mpMacTextStyle( NULL ) 280 , maTextColor( COL_BLACK ) |
284 , mbNonAntialiasedText( false ) 285 , mbPrinter( false ) 286 , mbVirDev( false ) 287 , mbWindow( false ) | 281 , mbNonAntialiasedText( false ) 282 , mbPrinter( false ) 283 , mbVirDev( false ) 284 , mbWindow( false ) |
288{ 289 // create the style object for font attributes 290 ATSUCreateStyle( &maATSUStyle ); 291} | 285{} |
292 293// ----------------------------------------------------------------------- 294 295AquaSalGraphics::~AquaSalGraphics() 296{ | 286 287// ----------------------------------------------------------------------- 288 289AquaSalGraphics::~AquaSalGraphics() 290{ |
297/* 298 if( mnUpdateGraphicsEvent ) 299 { 300 Application::RemoveUserEvent( mnUpdateGraphicsEvent ); 301 } 302*/ 303 CGPathRelease( mxClipPath ); 304 ATSUDisposeStyle( maATSUStyle ); | 291 CGPathRelease( mxClipPath ); |
305 | 292 |
293 delete mpMacTextStyle; 294 |
|
306 if( mpXorEmulation ) 307 delete mpXorEmulation; 308 309 if( mxLayer ) | 295 if( mpXorEmulation ) 296 delete mpXorEmulation; 297 298 if( mxLayer ) |
310 CGLayerRelease( mxLayer ); | 299 CGLayerRelease( mxLayer ); |
311 else if( mrContext && mbWindow ) 312 { 313 // destroy backbuffer bitmap context that we created ourself 314 CGContextRelease( mrContext ); 315 mrContext = NULL; | 300 else if( mrContext && mbWindow ) 301 { 302 // destroy backbuffer bitmap context that we created ourself 303 CGContextRelease( mrContext ); 304 mrContext = NULL; |
316 // memory is freed automatically by maOwnContextMemory | 305 // memory is freed automatically by maOwnContextMemory |
317 } 318} 319 320bool AquaSalGraphics::supportsOperation( OutDevSupportType eType ) const 321{ | 306 } 307} 308 309bool AquaSalGraphics::supportsOperation( OutDevSupportType eType ) const 310{ |
322 bool bRet = false; 323 switch( eType ) 324 { 325 case OutDevSupport_TransparentRect: 326 case OutDevSupport_B2DClip: 327 case OutDevSupport_B2DDraw: 328 bRet = true; 329 break; 330 default: break; 331 } 332 return bRet; | 311 bool bRet = false; 312 switch( eType ) 313 { 314 case OutDevSupport_TransparentRect: 315 case OutDevSupport_B2DClip: 316 case OutDevSupport_B2DDraw: 317 bRet = true; 318 break; 319 default: 320 break; 321 } 322 return bRet; |
333} 334 335// ======================================================================= 336 337void AquaSalGraphics::updateResolution() 338{ 339 DBG_ASSERT( mbWindow, "updateResolution on inappropriate graphics" ); 340 --- 1253 unchanged lines hidden (view full) --- 1594 1595 CGContextBeginPath( mrContext ); 1596 CGContextAddRect( mrContext, aRect ); 1597 CGContextDrawPath( mrContext, kCGPathFill ); 1598 1599 // restore state 1600 CGContextRestoreGState(mrContext); 1601 RefreshRect( aRect ); | 323} 324 325// ======================================================================= 326 327void AquaSalGraphics::updateResolution() 328{ 329 DBG_ASSERT( mbWindow, "updateResolution on inappropriate graphics" ); 330 --- 1253 unchanged lines hidden (view full) --- 1584 1585 CGContextBeginPath( mrContext ); 1586 CGContextAddRect( mrContext, aRect ); 1587 CGContextDrawPath( mrContext, kCGPathFill ); 1588 1589 // restore state 1590 CGContextRestoreGState(mrContext); 1591 RefreshRect( aRect ); |
1602 return true; | 1592 return true; |
1603} 1604 1605// ----------------------------------------------------------------------- 1606 1607void AquaSalGraphics::SetTextColor( SalColor nSalColor ) 1608{ | 1593} 1594 1595// ----------------------------------------------------------------------- 1596 1597void AquaSalGraphics::SetTextColor( SalColor nSalColor ) 1598{ |
1609 RGBColor color; 1610 color.red = (unsigned short) ( SALCOLOR_RED(nSalColor) * 65535.0 / 255.0 ); 1611 color.green = (unsigned short) ( SALCOLOR_GREEN(nSalColor) * 65535.0 / 255.0 ); 1612 color.blue = (unsigned short) ( SALCOLOR_BLUE(nSalColor) * 65535.0 / 255.0 ); 1613 1614 ATSUAttributeTag aTag = kATSUColorTag; 1615 ByteCount aValueSize = sizeof( color ); 1616 ATSUAttributeValuePtr aValue = &color; 1617 1618 OSStatus err = ATSUSetAttributes( maATSUStyle, 1, &aTag, &aValueSize, &aValue ); 1619 DBG_ASSERT( (err==noErr), "AquaSalGraphics::SetTextColor() : Could not set font attributes!\n"); 1620 if( err != noErr ) 1621 return; | 1599 maTextColor = RGBAColor( nSalColor ); 1600 if( mpMacTextStyle) 1601 mpMacTextStyle->SetTextColor( maTextColor ); |
1622} 1623 1624// ----------------------------------------------------------------------- 1625 | 1602} 1603 1604// ----------------------------------------------------------------------- 1605 |
1626void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel ) | 1606void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int /*nFallbackLevel*/ ) |
1627{ | 1607{ |
1628 (void)nFallbackLevel; // glyph-fallback on ATSU is done differently -> no fallback level 1629 1630 // get the ATSU font metrics (in point units) 1631 // of the font that has eventually been size-limited 1632 1633 ATSUFontID fontId; 1634 OSStatus err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(ATSUFontID), &fontId, 0 ); 1635 DBG_ASSERT( (err==noErr), "AquaSalGraphics::GetFontMetric() : could not get font id\n"); 1636 1637 ATSFontMetrics aMetrics; 1638 ATSFontRef rFont = FMGetATSFontRefFromFont( fontId ); 1639 err = ATSFontGetHorizontalMetrics ( rFont, kATSOptionFlagsDefault, &aMetrics ); 1640 DBG_ASSERT( (err==noErr), "AquaSalGraphics::GetFontMetric() : could not get font metrics\n"); 1641 if( err != noErr ) 1642 return; 1643 1644 // all ATS fonts are scalable fonts 1645 pMetric->mbScalableFont = true; 1646 // TODO: check if any kerning is possible 1647 pMetric->mbKernableFont = true; 1648 1649 // convert into VCL font metrics (in unscaled pixel units) 1650 1651 Fixed ptSize; 1652 err = ATSUGetAttribute( maATSUStyle, kATSUSizeTag, sizeof(Fixed), &ptSize, 0); 1653 DBG_ASSERT( (err==noErr), "AquaSalGraphics::GetFontMetric() : could not get font size\n"); 1654 const double fPointSize = Fix2X( ptSize ); 1655 1656 // convert quartz units to pixel units 1657 // please see the comment in AquaSalGraphics::SetFont() for details 1658 const double fPixelSize = (mfFontScale * mfFakeDPIScale * fPointSize); 1659 pMetric->mnAscent = static_cast<long>(+aMetrics.ascent * fPixelSize + 0.5); 1660 pMetric->mnDescent = static_cast<long>(-aMetrics.descent * fPixelSize + 0.5); 1661 const long nExtDescent = static_cast<long>((-aMetrics.descent + aMetrics.leading) * fPixelSize + 0.5); 1662 pMetric->mnExtLeading = nExtDescent - pMetric->mnDescent; 1663 pMetric->mnIntLeading = 0; 1664 // ATSFontMetrics.avgAdvanceWidth is obsolete, so it is usually set to zero 1665 // since ImplFontMetricData::mnWidth is only used for stretching/squeezing fonts 1666 // setting this width to the pixel height of the fontsize is good enough 1667 // it also makes the calculation of the stretch factor simple 1668 pMetric->mnWidth = static_cast<long>(mfFontStretch * fPixelSize + 0.5); | 1608 mpMacTextStyle->GetFontMetric( mfFakeDPIScale, *pMetric ); |
1669} 1670 1671// ----------------------------------------------------------------------- 1672 1673sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* ) 1674{ 1675 return 0; 1676} --- 66 unchanged lines hidden (view full) --- 1743// return bBrandSuccess && bBaseSuccess; 1744 return bBaseSuccess; 1745} 1746 1747void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) 1748{ 1749 DBG_ASSERT( pFontList, "AquaSalGraphics::GetDevFontList(NULL) !"); 1750 | 1609} 1610 1611// ----------------------------------------------------------------------- 1612 1613sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* ) 1614{ 1615 return 0; 1616} --- 66 unchanged lines hidden (view full) --- 1683// return bBrandSuccess && bBaseSuccess; 1684 return bBaseSuccess; 1685} 1686 1687void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) 1688{ 1689 DBG_ASSERT( pFontList, "AquaSalGraphics::GetDevFontList(NULL) !"); 1690 |
1751 AddLocalTempFontDirs(); | 1691 AddLocalTempFontDirs(); |
1752 1753 // The idea is to cache the list of system fonts once it has been generated. 1754 // SalData seems to be a good place for this caching. However we have to 1755 // carefully make the access to the font list thread-safe. If we register 1756 // a font-change event handler to update the font list in case fonts have 1757 // changed on the system we have to lock access to the list. The right | 1692 1693 // The idea is to cache the list of system fonts once it has been generated. 1694 // SalData seems to be a good place for this caching. However we have to 1695 // carefully make the access to the font list thread-safe. If we register 1696 // a font-change event handler to update the font list in case fonts have 1697 // changed on the system we have to lock access to the list. The right |
1758 // way to do that is the solar mutex since GetDevFontList is protected 1759 // through it as should be all event handlers | 1698 // way to do that is the solar mutex since GetDevFontList is protected 1699 // through it as should be all event handlers |
1760 1761 SalData* pSalData = GetSalData(); | 1700 1701 SalData* pSalData = GetSalData(); |
1762 if (pSalData->mpFontList == NULL) 1763 pSalData->mpFontList = new SystemFontList(); | 1702#ifdef USE_ATSU 1703 SystemFontList* GetAtsFontList(void); // forward declaration 1704 if( !pSalData->mpFontList ) 1705 pSalData->mpFontList = GetAtsFontList(); 1706#else 1707 SystemFontList* GetCoretextFontList(void); // forward declaration 1708 if( !pSalData->mpFontList ) 1709 pSalData->mpFontList = GetCoretextFontList(); 1710#endif // DISABLE_ATSUI |
1764 1765 // Copy all ImplFontData objects contained in the SystemFontList 1766 pSalData->mpFontList->AnnounceFonts( *pFontList ); 1767} 1768 1769// ----------------------------------------------------------------------- 1770 1771bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*, --- 33 unchanged lines hidden (view full) --- 1805 1806 // TODO: ATSFontDeactivate( oContainer ) when fonts are no longer needed 1807 // TODO: register new ImplMacFontdata in pFontList 1808 return true; 1809} 1810 1811// ----------------------------------------------------------------------- 1812 | 1711 1712 // Copy all ImplFontData objects contained in the SystemFontList 1713 pSalData->mpFontList->AnnounceFonts( *pFontList ); 1714} 1715 1716// ----------------------------------------------------------------------- 1717 1718bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*, --- 33 unchanged lines hidden (view full) --- 1752 1753 // TODO: ATSFontDeactivate( oContainer ) when fonts are no longer needed 1754 // TODO: register new ImplMacFontdata in pFontList 1755 return true; 1756} 1757 1758// ----------------------------------------------------------------------- 1759 |
1813// callbacks from ATSUGlyphGetCubicPaths() fore GetGlyphOutline() 1814struct GgoData { basegfx::B2DPolygon maPolygon; basegfx::B2DPolyPolygon* mpPolyPoly; }; 1815 1816static OSStatus GgoLineToProc( const Float32Point* pPoint, void* pData ) 1817{ 1818 basegfx::B2DPolygon& rPolygon = static_cast<GgoData*>(pData)->maPolygon; 1819 const basegfx::B2DPoint aB2DPoint( pPoint->x, pPoint->y ); 1820 rPolygon.append( aB2DPoint ); 1821 return noErr; 1822} 1823 1824static OSStatus GgoCurveToProc( const Float32Point* pCP1, const Float32Point* pCP2, 1825 const Float32Point* pPoint, void* pData ) 1826{ 1827 basegfx::B2DPolygon& rPolygon = static_cast<GgoData*>(pData)->maPolygon; 1828 const sal_uInt32 nPointCount = rPolygon.count(); 1829 const basegfx::B2DPoint aB2DControlPoint1( pCP1->x, pCP1->y ); 1830 rPolygon.setNextControlPoint( nPointCount-1, aB2DControlPoint1 ); 1831 const basegfx::B2DPoint aB2DEndPoint( pPoint->x, pPoint->y ); 1832 rPolygon.append( aB2DEndPoint ); 1833 const basegfx::B2DPoint aB2DControlPoint2( pCP2->x, pCP2->y ); 1834 rPolygon.setPrevControlPoint( nPointCount, aB2DControlPoint2 ); 1835 return noErr; 1836} 1837 1838static OSStatus GgoClosePathProc( void* pData ) 1839{ 1840 GgoData* pGgoData = static_cast<GgoData*>(pData); 1841 basegfx::B2DPolygon& rPolygon = pGgoData->maPolygon; 1842 if( rPolygon.count() > 0 ) 1843 pGgoData->mpPolyPoly->append( rPolygon ); 1844 rPolygon.clear(); 1845 return noErr; 1846} 1847 1848static OSStatus GgoMoveToProc( const Float32Point* pPoint, void* pData ) 1849{ 1850 GgoClosePathProc( pData ); 1851 OSStatus eStatus = GgoLineToProc( pPoint, pData ); 1852 return eStatus; 1853} 1854 1855bool AquaSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) 1856{ 1857 GgoData aGgoData; 1858 aGgoData.mpPolyPoly = &rPolyPoly; 1859 rPolyPoly.clear(); 1860 1861 ATSUStyle rATSUStyle = maATSUStyle; // TODO: handle glyph fallback when CWS pdffix02 is integrated 1862 OSStatus eGgoStatus = noErr; 1863 OSStatus eStatus = ATSUGlyphGetCubicPaths( rATSUStyle, aGlyphId, 1864 GgoMoveToProc, GgoLineToProc, GgoCurveToProc, GgoClosePathProc, 1865 &aGgoData, &eGgoStatus ); 1866 if( (eStatus != noErr) ) // TODO: why is (eGgoStatus!=noErr) when curves are involved? 1867 return false; 1868 1869 GgoClosePathProc( &aGgoData ); 1870 if( mfFontScale != 1.0 ) { 1871 rPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(+mfFontScale, +mfFontScale)); 1872 } 1873 return true; 1874} 1875 1876// ----------------------------------------------------------------------- 1877 | |
1878long AquaSalGraphics::GetGraphicsWidth() const 1879{ 1880 long w = 0; 1881 if( mrContext && (mbWindow || mbVirDev) ) 1882 { 1883 w = mnWidth; 1884 } 1885 --- 5 unchanged lines hidden (view full) --- 1891 1892 return w; 1893} 1894 1895// ----------------------------------------------------------------------- 1896 1897bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) 1898{ | 1760long AquaSalGraphics::GetGraphicsWidth() const 1761{ 1762 long w = 0; 1763 if( mrContext && (mbWindow || mbVirDev) ) 1764 { 1765 w = mnWidth; 1766 } 1767 --- 5 unchanged lines hidden (view full) --- 1773 1774 return w; 1775} 1776 1777// ----------------------------------------------------------------------- 1778 1779bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) 1780{ |
1899 ATSUStyle rATSUStyle = maATSUStyle; // TODO: handle glyph fallback 1900 ATSGlyphScreenMetrics aGlyphMetrics; 1901 GlyphID nAtsGlyphId = aGlyphId; 1902 OSStatus eStatus = ATSUGlyphGetScreenMetrics( rATSUStyle, 1903 1, &nAtsGlyphId, 0, FALSE, !mbNonAntialiasedText, &aGlyphMetrics ); 1904 if( eStatus != noErr ) 1905 return false; | 1781 const bool bRC = mpMacTextStyle->GetGlyphBoundRect( aGlyphId, rRect ); 1782 return bRC; 1783} |
1906 | 1784 |
1907 const long nMinX = (long)(+aGlyphMetrics.topLeft.x * mfFontScale - 0.5); 1908 const long nMaxX = (long)(aGlyphMetrics.width * mfFontScale + 0.5) + nMinX; 1909 const long nMinY = (long)(-aGlyphMetrics.topLeft.y * mfFontScale - 0.5); 1910 const long nMaxY = (long)(aGlyphMetrics.height * mfFontScale + 0.5) + nMinY; 1911 rRect = Rectangle( nMinX, nMinY, nMaxX, nMaxY ); 1912 return true; | 1785// ----------------------------------------------------------------------- 1786 1787bool AquaSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) 1788{ 1789 const bool bRC = mpMacTextStyle->GetGlyphOutline( aGlyphId, rPolyPoly ); 1790 return bRC; |
1913} 1914 1915// ----------------------------------------------------------------------- 1916 1917void AquaSalGraphics::GetDevFontSubstList( OutputDevice* ) 1918{ 1919 // nothing to do since there are no device-specific fonts on Aqua 1920} 1921 1922// ----------------------------------------------------------------------- 1923 1924void AquaSalGraphics::DrawServerFontLayout( const ServerFontLayout& ) | 1791} 1792 1793// ----------------------------------------------------------------------- 1794 1795void AquaSalGraphics::GetDevFontSubstList( OutputDevice* ) 1796{ 1797 // nothing to do since there are no device-specific fonts on Aqua 1798} 1799 1800// ----------------------------------------------------------------------- 1801 1802void AquaSalGraphics::DrawServerFontLayout( const ServerFontLayout& ) |
1925{ 1926} | 1803{} |
1927 1928// ----------------------------------------------------------------------- 1929 1930sal_uInt16 AquaSalGraphics::SetFont( ImplFontSelectData* pReqFont, int /*nFallbackLevel*/ ) 1931{ | 1804 1805// ----------------------------------------------------------------------- 1806 1807sal_uInt16 AquaSalGraphics::SetFont( ImplFontSelectData* pReqFont, int /*nFallbackLevel*/ ) 1808{ |
1932 if( !pReqFont ) 1933 { 1934 ATSUClearStyle( maATSUStyle ); | 1809 // release the text style 1810 delete mpMacTextStyle; 1811 mpMacTextStyle = NULL; 1812 1813 // handle NULL request meaning: release-font-resources request 1814 if( !pReqFont ) 1815 { |
1935 mpMacFontData = NULL; | 1816 mpMacFontData = NULL; |
1936 return 0; 1937 } | 1817 return 0; 1818 } |
1938 | 1819 |
1939 // store the requested device font entry 1940 const ImplMacFontData* pMacFont = static_cast<const ImplMacFontData*>( pReqFont->mpFontData ); 1941 mpMacFontData = pMacFont; | 1820 // update the text style 1821 mpMacFontData = static_cast<const ImplMacFontData*>( pReqFont->mpFontData ); 1822 mpMacTextStyle = mpMacFontData->CreateMacTextStyle( *pReqFont ); 1823 mpMacTextStyle->SetTextColor( maTextColor ); |
1942 | 1824 |
1943 // convert pixel units (as seen by upper layers) to typographic point units 1944 double fScaledAtsHeight = pReqFont->mfExactHeight; 1945 // avoid Fixed16.16 overflows by limiting the ATS font size 1946 static const float fMaxAtsHeight = 144.0; 1947 if( fScaledAtsHeight <= fMaxAtsHeight ) 1948 mfFontScale = 1.0; 1949 else 1950 { 1951 mfFontScale = fScaledAtsHeight / fMaxAtsHeight; 1952 fScaledAtsHeight = fMaxAtsHeight; 1953 } 1954 Fixed fFixedSize = FloatToFixed( fScaledAtsHeight ); 1955 // enable bold-emulation if needed 1956 Boolean bFakeBold = FALSE; 1957 if( (pReqFont->GetWeight() >= WEIGHT_BOLD) 1958 && (pMacFont->GetWeight() < WEIGHT_SEMIBOLD) ) 1959 bFakeBold = TRUE; 1960 // enable italic-emulation if needed 1961 Boolean bFakeItalic = FALSE; 1962 if( ((pReqFont->GetSlant() == ITALIC_NORMAL) || (pReqFont->GetSlant() == ITALIC_OBLIQUE)) 1963 && !((pMacFont->GetSlant() == ITALIC_NORMAL) || (pMacFont->GetSlant() == ITALIC_OBLIQUE)) ) 1964 bFakeItalic = TRUE; 1965 1966 // enable/disable antialiased text 1967 mbNonAntialiasedText = pReqFont->mbNonAntialiased; 1968 UInt32 nStyleRenderingOptions = kATSStyleNoOptions; 1969 if( pReqFont->mbNonAntialiased ) 1970 nStyleRenderingOptions |= kATSStyleNoAntiAliasing; 1971 1972 // set horizontal/vertical mode 1973 ATSUVerticalCharacterType aVerticalCharacterType = kATSUStronglyHorizontal; 1974 if( pReqFont->mbVertical ) 1975 aVerticalCharacterType = kATSUStronglyVertical; 1976 1977 // prepare ATS-fontid as type matching to the kATSUFontTag request 1978 ATSUFontID nFontID = static_cast<ATSUFontID>(pMacFont->GetFontId()); 1979 1980 // update ATSU style attributes with requested font parameters 1981 // TODO: no need to set styles which are already defaulted 1982 1983 const ATSUAttributeTag aTag[] = 1984 { 1985 kATSUFontTag, 1986 kATSUSizeTag, 1987 kATSUQDBoldfaceTag, 1988 kATSUQDItalicTag, 1989 kATSUStyleRenderingOptionsTag, 1990 kATSUVerticalCharacterTag 1991 }; 1992 1993 const ByteCount aValueSize[] = 1994 { 1995 sizeof(ATSUFontID), 1996 sizeof(fFixedSize), 1997 sizeof(bFakeBold), 1998 sizeof(bFakeItalic), 1999 sizeof(nStyleRenderingOptions), 2000 sizeof(aVerticalCharacterType) 2001 }; 2002 2003 const ATSUAttributeValuePtr aValue[] = 2004 { 2005 &nFontID, 2006 &fFixedSize, 2007 &bFakeBold, 2008 &bFakeItalic, 2009 &nStyleRenderingOptions, 2010 &aVerticalCharacterType 2011 }; 2012 2013 static const int nTagCount = sizeof(aTag) / sizeof(*aTag); 2014 OSStatus eStatus = ATSUSetAttributes( maATSUStyle, nTagCount, 2015 aTag, aValueSize, aValue ); 2016 // reset ATSUstyle if there was an error 2017 if( eStatus != noErr ) 2018 { 2019 DBG_WARNING( "AquaSalGraphics::SetFont() : Could not set font attributes!\n"); 2020 ATSUClearStyle( maATSUStyle ); 2021 mpMacFontData = NULL; 2022 return 0; 2023 } 2024 2025 // prepare font stretching 2026 const ATSUAttributeTag aMatrixTag = kATSUFontMatrixTag; 2027 if( (pReqFont->mnWidth == 0) || (pReqFont->mnWidth == pReqFont->mnHeight) ) 2028 { 2029 mfFontStretch = 1.0; 2030 ATSUClearAttributes( maATSUStyle, 1, &aMatrixTag ); 2031 } 2032 else 2033 { 2034 mfFontStretch = (float)pReqFont->mnWidth / pReqFont->mnHeight; 2035 CGAffineTransform aMatrix = CGAffineTransformMakeScale( mfFontStretch, 1.0F ); 2036 const ATSUAttributeValuePtr aAttr = &aMatrix; 2037 const ByteCount aMatrixBytes = sizeof(aMatrix); 2038 eStatus = ATSUSetAttributes( maATSUStyle, 1, &aMatrixTag, &aMatrixBytes, &aAttr ); 2039 DBG_ASSERT( (eStatus==noErr), "AquaSalGraphics::SetFont() : Could not set font matrix\n"); 2040 } 2041 2042 // prepare font rotation 2043 mnATSUIRotation = FloatToFixed( pReqFont->mnOrientation / 10.0 ); 2044 2045#if OSL_DEBUG_LEVEL > 3 2046 fprintf( stderr, "SetFont to (\"%s\", \"%s\", fontid=%d) for (\"%s\" \"%s\" weight=%d, slant=%d size=%dx%d orientation=%d)\n", 2047 ::rtl::OUStringToOString( pMacFont->GetFamilyName(), RTL_TEXTENCODING_UTF8 ).getStr(), 2048 ::rtl::OUStringToOString( pMacFont->GetStyleName(), RTL_TEXTENCODING_UTF8 ).getStr(), 2049 (int)nFontID, 2050 ::rtl::OUStringToOString( pReqFont->GetFamilyName(), RTL_TEXTENCODING_UTF8 ).getStr(), 2051 ::rtl::OUStringToOString( pReqFont->GetStyleName(), RTL_TEXTENCODING_UTF8 ).getStr(), 2052 pReqFont->GetWeight(), 2053 pReqFont->GetSlant(), 2054 pReqFont->mnHeight, 2055 pReqFont->mnWidth, 2056 pReqFont->mnOrientation); | 1825#if (OSL_DEBUG_LEVEL > 3) 1826 fprintf( stderr, "SetFont to (\"%s\", \"%s\", fontid=%d) for (\"%s\" \"%s\" weight=%d, slant=%d size=%dx%d orientation=%d)\n", 1827 ::rtl::OUStringToOString( mpMacFontData->GetFamilyName(), RTL_TEXTENCODING_UTF8 ).getStr(), 1828 ::rtl::OUStringToOString( mpMacFontData->GetStyleName(), RTL_TEXTENCODING_UTF8 ).getStr(), 1829 (int)pMacFont->GetFontId(), 1830 ::rtl::OUStringToOString( mpMacFontData->GetFamilyName(), RTL_TEXTENCODING_UTF8 ).getStr(), 1831 ::rtl::OUStringToOString( mpMacFontData->GetStyleName(), RTL_TEXTENCODING_UTF8 ).getStr(), 1832 pReqFont->GetWeight(), 1833 pReqFont->GetSlant(), 1834 pReqFont->mnHeight, 1835 pReqFont->mnWidth, 1836 pReqFont->mnOrientation); |
2057#endif 2058 2059 return 0; 2060} 2061 2062// ----------------------------------------------------------------------- 2063 | 1837#endif 1838 1839 return 0; 1840} 1841 1842// ----------------------------------------------------------------------- 1843 |
1844SalLayout* AquaSalGraphics::GetTextLayout( ImplLayoutArgs& /*rArgs*/, int /*nFallbackLevel*/ ) 1845{ 1846 SalLayout* pSalLayout = mpMacTextStyle->GetTextLayout(); 1847 return pSalLayout; 1848} 1849 1850// ----------------------------------------------------------------------- 1851 |
|
2064const ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const 2065{ 2066 if( !mpMacFontData ) 2067 return ImplFontCharMap::GetDefaultMap(); 2068 2069 return mpMacFontData->GetImplFontCharMap(); 2070} 2071 2072// ----------------------------------------------------------------------- 2073 2074// fake a SFNT font directory entry for a font table 2075// see http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html#Directory | 1852const ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const 1853{ 1854 if( !mpMacFontData ) 1855 return ImplFontCharMap::GetDefaultMap(); 1856 1857 return mpMacFontData->GetImplFontCharMap(); 1858} 1859 1860// ----------------------------------------------------------------------- 1861 1862// fake a SFNT font directory entry for a font table 1863// see http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html#Directory |
2076static void FakeDirEntry( FourCharCode eFCC, ByteCount nOfs, ByteCount nLen, | 1864static void FakeDirEntry( const char aTag[5], ByteCount nOfs, ByteCount nLen, |
2077 const unsigned char* /*pData*/, unsigned char*& rpDest ) 2078{ 2079 // write entry tag | 1865 const unsigned char* /*pData*/, unsigned char*& rpDest ) 1866{ 1867 // write entry tag |
2080 rpDest[ 0] = (char)(eFCC >> 24); 2081 rpDest[ 1] = (char)(eFCC >> 16); 2082 rpDest[ 2] = (char)(eFCC >> 8); 2083 rpDest[ 3] = (char)(eFCC >> 0); | 1868 rpDest[ 0] = aTag[0]; 1869 rpDest[ 1] = aTag[1]; 1870 rpDest[ 2] = aTag[2]; 1871 rpDest[ 3] = aTag[3]; |
2084 // TODO: get entry checksum and write it | 1872 // TODO: get entry checksum and write it |
2085 // not too important since the subsetter doesn't care currently 2086 // for( pData+nOfs ... pData+nOfs+nLen ) | 1873 // not too important since the subsetter doesn't care currently 1874 // for( pData+nOfs ... pData+nOfs+nLen ) |
2087 // write entry offset 2088 rpDest[ 8] = (char)(nOfs >> 24); 2089 rpDest[ 9] = (char)(nOfs >> 16); 2090 rpDest[10] = (char)(nOfs >> 8); 2091 rpDest[11] = (char)(nOfs >> 0); 2092 // write entry length 2093 rpDest[12] = (char)(nLen >> 24); 2094 rpDest[13] = (char)(nLen >> 16); 2095 rpDest[14] = (char)(nLen >> 8); 2096 rpDest[15] = (char)(nLen >> 0); 2097 // advance to next entry 2098 rpDest += 16; 2099} 2100 | 1875 // write entry offset 1876 rpDest[ 8] = (char)(nOfs >> 24); 1877 rpDest[ 9] = (char)(nOfs >> 16); 1878 rpDest[10] = (char)(nOfs >> 8); 1879 rpDest[11] = (char)(nOfs >> 0); 1880 // write entry length 1881 rpDest[12] = (char)(nLen >> 24); 1882 rpDest[13] = (char)(nLen >> 16); 1883 rpDest[14] = (char)(nLen >> 8); 1884 rpDest[15] = (char)(nLen >> 0); 1885 // advance to next entry 1886 rpDest += 16; 1887} 1888 |
1889// fake a TTF or CFF font as directly accessing font file is not possible 1890// when only the fontid is known. This approach also handles *.dfont fonts. |
|
2101static bool GetRawFontData( const ImplFontData* pFontData, 2102 ByteVector& rBuffer, bool* pJustCFF ) 2103{ 2104 const ImplMacFontData* pMacFont = static_cast<const ImplMacFontData*>(pFontData); | 1891static bool GetRawFontData( const ImplFontData* pFontData, 1892 ByteVector& rBuffer, bool* pJustCFF ) 1893{ 1894 const ImplMacFontData* pMacFont = static_cast<const ImplMacFontData*>(pFontData); |
2105 const ATSUFontID nFontId = static_cast<ATSUFontID>(pMacFont->GetFontId()); 2106 ATSFontRef rFont = FMGetATSFontRefFromFont( nFontId ); | |
2107 | 1895 |
2108 ByteCount nCffLen = 0; 2109 OSStatus eStatus = ATSFontGetTable( rFont, GetTag("CFF "), 0, 0, NULL, &nCffLen); | 1896 // short circuit for CFF-only fonts 1897 const int nCffSize = pMacFont->GetFontTable( "CFF ", NULL); |
2110 if( pJustCFF != NULL ) 2111 { | 1898 if( pJustCFF != NULL ) 1899 { |
2112 *pJustCFF = (eStatus == noErr) && (nCffLen > 0); 2113 if( *pJustCFF ) | 1900 *pJustCFF = (nCffSize > 0); 1901 if( *pJustCFF) |
2114 { | 1902 { |
2115 rBuffer.resize( nCffLen ); 2116 eStatus = ATSFontGetTable( rFont, GetTag("CFF "), 0, nCffLen, (void*)&rBuffer[0], &nCffLen); 2117 if( (eStatus != noErr) || (nCffLen <= 0) ) | 1903 rBuffer.resize( nCffSize); 1904 const int nCffRead = pMacFont->GetFontTable( "CFF ", &rBuffer[0]); 1905 if( nCffRead != nCffSize) |
2118 return false; 2119 return true; 2120 } 2121 } 2122 2123 // get font table availability and size in bytes | 1906 return false; 1907 return true; 1908 } 1909 } 1910 1911 // get font table availability and size in bytes |
2124 ByteCount nHeadLen = 0; 2125 eStatus = ATSFontGetTable( rFont, GetTag("head"), 0, 0, NULL, &nHeadLen); 2126 if( (eStatus != noErr) || (nHeadLen <= 0) ) | 1912 const int nHeadSize = pMacFont->GetFontTable( "head", NULL); 1913 if( nHeadSize <= 0) |
2127 return false; | 1914 return false; |
2128 ByteCount nMaxpLen = 0; 2129 eStatus = ATSFontGetTable( rFont, GetTag("maxp"), 0, 0, NULL, &nMaxpLen); 2130 if( (eStatus != noErr) || (nMaxpLen <= 0) ) | 1915 const int nMaxpSize = pMacFont->GetFontTable( "maxp", NULL); 1916 if( nMaxpSize <= 0) |
2131 return false; | 1917 return false; |
2132 ByteCount nCmapLen = 0; 2133 eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, 0, NULL, &nCmapLen); 2134 if( (eStatus != noErr) || (nCmapLen <= 0) ) | 1918 const int nCmapSize = pMacFont->GetFontTable( "cmap", NULL); 1919 if( nCmapSize <= 0) |
2135 return false; | 1920 return false; |
2136 ByteCount nNameLen = 0; 2137 eStatus = ATSFontGetTable( rFont, GetTag("name"), 0, 0, NULL, &nNameLen); 2138 if( (eStatus != noErr) || (nNameLen <= 0) ) | 1921 const int nNameSize = pMacFont->GetFontTable( "name", NULL); 1922 if( nNameSize <= 0) |
2139 return false; | 1923 return false; |
2140 ByteCount nHheaLen = 0; 2141 eStatus = ATSFontGetTable( rFont, GetTag("hhea"), 0, 0, NULL, &nHheaLen); 2142 if( (eStatus != noErr) || (nHheaLen <= 0) ) | 1924 const int nHheaSize = pMacFont->GetFontTable( "hhea", NULL); 1925 if( nHheaSize <= 0) |
2143 return false; | 1926 return false; |
2144 ByteCount nHmtxLen = 0; 2145 eStatus = ATSFontGetTable( rFont, GetTag("hmtx"), 0, 0, NULL, &nHmtxLen); 2146 if( (eStatus != noErr) || (nHmtxLen <= 0) ) | 1927 const int nHmtxSize = pMacFont->GetFontTable( "hmtx", NULL); 1928 if( nHmtxSize <= 0) |
2147 return false; 2148 | 1929 return false; 1930 |
2149 // get the glyph outline tables 2150 ByteCount nLocaLen = 0; 2151 ByteCount nGlyfLen = 0; 2152 if( (eStatus != noErr) || (nCffLen <= 0) ) | 1931 // get the ttf-glyf outline tables 1932 int nLocaSize = 0; 1933 int nGlyfSize = 0; 1934 if( nCffSize <= 0) |
2153 { | 1935 { |
2154 eStatus = ATSFontGetTable( rFont, GetTag("loca"), 0, 0, NULL, &nLocaLen); 2155 if( (eStatus != noErr) || (nLocaLen <= 0) ) | 1936 nLocaSize = pMacFont->GetFontTable( "loca", NULL); 1937 if( nLocaSize <= 0) |
2156 return false; | 1938 return false; |
2157 eStatus = ATSFontGetTable( rFont, GetTag("glyf"), 0, 0, NULL, &nGlyfLen); 2158 if( (eStatus != noErr) || (nGlyfLen <= 0) ) | 1939 nGlyfSize = pMacFont->GetFontTable( "glyf", NULL); 1940 if( nGlyfSize <= 0) |
2159 return false; 2160 } 2161 | 1941 return false; 1942 } 1943 |
2162 ByteCount nPrepLen=0, nCvtLen=0, nFpgmLen=0; 2163 if( nGlyfLen ) // TODO: reduce PDF size by making hint subsetting optional | 1944 int nPrepSize = 0, nCvtSize = 0, nFpgmSize = 0; 1945 if( nGlyfSize) // TODO: reduce PDF size by making hint subsetting optional |
2164 { | 1946 { |
2165 eStatus = ATSFontGetTable( rFont, GetTag("prep"), 0, 0, NULL, &nPrepLen); 2166 eStatus = ATSFontGetTable( rFont, GetTag("cvt "), 0, 0, NULL, &nCvtLen); 2167 eStatus = ATSFontGetTable( rFont, GetTag("fpgm"), 0, 0, NULL, &nFpgmLen); | 1947 nPrepSize = pMacFont->GetFontTable( "prep", NULL); 1948 nCvtSize = pMacFont->GetFontTable( "cvt ", NULL); 1949 nFpgmSize = pMacFont->GetFontTable( "fpgm", NULL); |
2168 } 2169 2170 // prepare a byte buffer for a fake font 2171 int nTableCount = 7; | 1950 } 1951 1952 // prepare a byte buffer for a fake font 1953 int nTableCount = 7; |
2172 nTableCount += (nPrepLen>0) + (nCvtLen>0) + (nFpgmLen>0) + (nGlyfLen>0); 2173 const ByteCount nFdirLen = 12 + 16*nTableCount; 2174 ByteCount nTotalLen = nFdirLen; 2175 nTotalLen += nHeadLen + nMaxpLen + nNameLen + nCmapLen; 2176 if( nGlyfLen ) 2177 nTotalLen += nLocaLen + nGlyfLen; | 1954 nTableCount += (nPrepSize>0) + (nCvtSize>0) + (nFpgmSize>0) + (nGlyfSize>0); 1955 const ByteCount nFdirSize = 12 + 16*nTableCount; 1956 ByteCount nTotalSize = nFdirSize; 1957 nTotalSize += nHeadSize + nMaxpSize + nNameSize + nCmapSize; 1958 if( nGlyfSize ) 1959 nTotalSize += nLocaSize + nGlyfSize; |
2178 else | 1960 else |
2179 nTotalLen += nCffLen; 2180 nTotalLen += nHheaLen + nHmtxLen; 2181 nTotalLen += nPrepLen + nCvtLen + nFpgmLen; 2182 rBuffer.resize( nTotalLen ); | 1961 nTotalSize += nCffSize; 1962 nTotalSize += nHheaSize + nHmtxSize; 1963 nTotalSize += nPrepSize + nCvtSize + nFpgmSize; 1964 rBuffer.resize( nTotalSize ); |
2183 2184 // fake a SFNT font directory header 2185 if( nTableCount < 16 ) 2186 { 2187 int nLog2 = 0; 2188 while( (nTableCount >> nLog2) > 1 ) ++nLog2; 2189 rBuffer[ 1] = 1; // Win-TTF style scaler 2190 rBuffer[ 5] = nTableCount; // table count 2191 rBuffer[ 7] = nLog2*16; // searchRange 2192 rBuffer[ 9] = nLog2; // entrySelector 2193 rBuffer[11] = (nTableCount-nLog2)*16; // rangeShift 2194 } 2195 2196 // get font table raw data and update the fake directory entries | 1965 1966 // fake a SFNT font directory header 1967 if( nTableCount < 16 ) 1968 { 1969 int nLog2 = 0; 1970 while( (nTableCount >> nLog2) > 1 ) ++nLog2; 1971 rBuffer[ 1] = 1; // Win-TTF style scaler 1972 rBuffer[ 5] = nTableCount; // table count 1973 rBuffer[ 7] = nLog2*16; // searchRange 1974 rBuffer[ 9] = nLog2; // entrySelector 1975 rBuffer[11] = (nTableCount-nLog2)*16; // rangeShift 1976 } 1977 1978 // get font table raw data and update the fake directory entries |
2197 ByteCount nOfs = nFdirLen; | 1979 ByteCount nOfs = nFdirSize; |
2198 unsigned char* pFakeEntry = &rBuffer[12]; | 1980 unsigned char* pFakeEntry = &rBuffer[12]; |
2199 eStatus = ATSFontGetTable( rFont, GetTag("cmap"), 0, nCmapLen, (void*)&rBuffer[nOfs], &nCmapLen); 2200 FakeDirEntry( GetTag("cmap"), nOfs, nCmapLen, &rBuffer[0], pFakeEntry ); 2201 nOfs += nCmapLen; 2202 if( nCvtLen ) { 2203 eStatus = ATSFontGetTable( rFont, GetTag("cvt "), 0, nCvtLen, (void*)&rBuffer[nOfs], &nCvtLen); 2204 FakeDirEntry( GetTag("cvt "), nOfs, nCvtLen, &rBuffer[0], pFakeEntry ); 2205 nOfs += nCvtLen; | 1981 if( nCmapSize != pMacFont->GetFontTable( "cmap", &rBuffer[nOfs])) 1982 return false; 1983 FakeDirEntry( "cmap", nOfs, nCmapSize, &rBuffer[0], pFakeEntry ); 1984 nOfs += nCmapSize; 1985 if( nCvtSize ) { 1986 if( nCvtSize != pMacFont->GetFontTable( "cvt ", &rBuffer[nOfs])) 1987 return false; 1988 FakeDirEntry( "cvt ", nOfs, nCvtSize, &rBuffer[0], pFakeEntry ); 1989 nOfs += nCvtSize; |
2206 } | 1990 } |
2207 if( nFpgmLen ) { 2208 eStatus = ATSFontGetTable( rFont, GetTag("fpgm"), 0, nFpgmLen, (void*)&rBuffer[nOfs], &nFpgmLen); 2209 FakeDirEntry( GetTag("fpgm"), nOfs, nFpgmLen, &rBuffer[0], pFakeEntry ); 2210 nOfs += nFpgmLen; | 1991 if( nFpgmSize ) { 1992 if( nFpgmSize != pMacFont->GetFontTable( "fpgm", &rBuffer[nOfs])) 1993 return false; 1994 FakeDirEntry( "fpgm", nOfs, nFpgmSize, &rBuffer[0], pFakeEntry ); 1995 nOfs += nFpgmSize; |
2211 } | 1996 } |
2212 if( nCffLen ) { 2213 eStatus = ATSFontGetTable( rFont, GetTag("CFF "), 0, nCffLen, (void*)&rBuffer[nOfs], &nCffLen); 2214 FakeDirEntry( GetTag("CFF "), nOfs, nCffLen, &rBuffer[0], pFakeEntry ); 2215 nOfs += nGlyfLen; | 1997 if( nCffSize ) { 1998 if( nCffSize != pMacFont->GetFontTable( "CFF ", &rBuffer[nOfs])) 1999 return false; 2000 FakeDirEntry( "CFF ", nOfs, nCffSize, &rBuffer[0], pFakeEntry ); 2001 nOfs += nGlyfSize; |
2216 } else { | 2002 } else { |
2217 eStatus = ATSFontGetTable( rFont, GetTag("glyf"), 0, nGlyfLen, (void*)&rBuffer[nOfs], &nGlyfLen); 2218 FakeDirEntry( GetTag("glyf"), nOfs, nGlyfLen, &rBuffer[0], pFakeEntry ); 2219 nOfs += nGlyfLen; 2220 eStatus = ATSFontGetTable( rFont, GetTag("loca"), 0, nLocaLen, (void*)&rBuffer[nOfs], &nLocaLen); 2221 FakeDirEntry( GetTag("loca"), nOfs, nLocaLen, &rBuffer[0], pFakeEntry ); 2222 nOfs += nLocaLen; | 2003 if( nGlyfSize != pMacFont->GetFontTable( "glyf", &rBuffer[nOfs])) 2004 return false; 2005 FakeDirEntry( "glyf", nOfs, nGlyfSize, &rBuffer[0], pFakeEntry ); 2006 nOfs += nGlyfSize; 2007 if( nLocaSize != pMacFont->GetFontTable( "loca", &rBuffer[nOfs])) 2008 return false; 2009 FakeDirEntry( "loca", nOfs, nLocaSize, &rBuffer[0], pFakeEntry ); 2010 nOfs += nLocaSize; |
2223 } | 2011 } |
2224 eStatus = ATSFontGetTable( rFont, GetTag("head"), 0, nHeadLen, (void*)&rBuffer[nOfs], &nHeadLen); 2225 FakeDirEntry( GetTag("head"), nOfs, nHeadLen, &rBuffer[0], pFakeEntry ); 2226 nOfs += nHeadLen; 2227 eStatus = ATSFontGetTable( rFont, GetTag("hhea"), 0, nHheaLen, (void*)&rBuffer[nOfs], &nHheaLen); 2228 FakeDirEntry( GetTag("hhea"), nOfs, nHheaLen, &rBuffer[0], pFakeEntry ); 2229 nOfs += nHheaLen; 2230 eStatus = ATSFontGetTable( rFont, GetTag("hmtx"), 0, nHmtxLen, (void*)&rBuffer[nOfs], &nHmtxLen); 2231 FakeDirEntry( GetTag("hmtx"), nOfs, nHmtxLen, &rBuffer[0], pFakeEntry ); 2232 nOfs += nHmtxLen; 2233 eStatus = ATSFontGetTable( rFont, GetTag("maxp"), 0, nMaxpLen, (void*)&rBuffer[nOfs], &nMaxpLen); 2234 FakeDirEntry( GetTag("maxp"), nOfs, nMaxpLen, &rBuffer[0], pFakeEntry ); 2235 nOfs += nMaxpLen; 2236 eStatus = ATSFontGetTable( rFont, GetTag("name"), 0, nNameLen, (void*)&rBuffer[nOfs], &nNameLen); 2237 FakeDirEntry( GetTag("name"), nOfs, nNameLen, &rBuffer[0], pFakeEntry ); 2238 nOfs += nNameLen; 2239 if( nPrepLen ) { 2240 eStatus = ATSFontGetTable( rFont, GetTag("prep"), 0, nPrepLen, (void*)&rBuffer[nOfs], &nPrepLen); 2241 FakeDirEntry( GetTag("prep"), nOfs, nPrepLen, &rBuffer[0], pFakeEntry ); 2242 nOfs += nPrepLen; | 2012 if( nHeadSize != pMacFont->GetFontTable( "head", &rBuffer[nOfs])) 2013 return false; 2014 FakeDirEntry( "head", nOfs, nHeadSize, &rBuffer[0], pFakeEntry ); 2015 nOfs += nHeadSize; 2016 if( nHheaSize != pMacFont->GetFontTable( "hhea", &rBuffer[nOfs])) 2017 return false; 2018 FakeDirEntry( "hhea", nOfs, nHheaSize, &rBuffer[0], pFakeEntry ); 2019 nOfs += nHheaSize; 2020 if( nHmtxSize != pMacFont->GetFontTable( "hmtx", &rBuffer[nOfs])) 2021 return false; 2022 FakeDirEntry( "hmtx", nOfs, nHmtxSize, &rBuffer[0], pFakeEntry ); 2023 nOfs += nHmtxSize; 2024 if( nMaxpSize != pMacFont->GetFontTable( "maxp", &rBuffer[nOfs])) 2025 return false; 2026 FakeDirEntry( "maxp", nOfs, nMaxpSize, &rBuffer[0], pFakeEntry ); 2027 nOfs += nMaxpSize; 2028 if( nNameSize != pMacFont->GetFontTable( "name", &rBuffer[nOfs])) 2029 return false; 2030 FakeDirEntry( "name", nOfs, nNameSize, &rBuffer[0], pFakeEntry ); 2031 nOfs += nNameSize; 2032 if( nPrepSize ) { 2033 if( nPrepSize != pMacFont->GetFontTable( "prep", &rBuffer[nOfs])) 2034 return false; 2035 FakeDirEntry( "prep", nOfs, nPrepSize, &rBuffer[0], pFakeEntry ); 2036 nOfs += nPrepSize; |
2243 } 2244 | 2037 } 2038 |
2245 DBG_ASSERT( (nOfs==nTotalLen), "AquaSalGraphics::CreateFontSubset (nOfs!=nTotalLen)"); | 2039 DBG_ASSERT( (nOfs==nTotalSize), "AquaSalGraphics::CreateFontSubset (nOfs!=nTotalSize)"); |
2246 | 2040 |
2247 return sal_True; | 2041 return true; |
2248} 2249 2250sal_Bool AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, 2251 const ImplFontData* pFontData, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding, 2252 sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo ) 2253{ 2254 // TODO: move more of the functionality here into the generic subsetter code 2255 --- 9 unchanged lines hidden (view full) --- 2265 bool bCffOnly = false; 2266 if( !GetRawFontData( pFontData, aBuffer, &bCffOnly ) ) 2267 return sal_False; 2268 2269 // handle CFF-subsetting 2270 if( bCffOnly ) 2271 { 2272 // provide the raw-CFF data to the subsetter | 2042} 2043 2044sal_Bool AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, 2045 const ImplFontData* pFontData, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding, 2046 sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo ) 2047{ 2048 // TODO: move more of the functionality here into the generic subsetter code 2049 --- 9 unchanged lines hidden (view full) --- 2059 bool bCffOnly = false; 2060 if( !GetRawFontData( pFontData, aBuffer, &bCffOnly ) ) 2061 return sal_False; 2062 2063 // handle CFF-subsetting 2064 if( bCffOnly ) 2065 { 2066 // provide the raw-CFF data to the subsetter |
2273 ByteCount nCffLen = aBuffer.size(); | 2067 const ByteCount nCffLen = aBuffer.size(); |
2274 rInfo.LoadFont( FontSubsetInfo::CFF_FONT, &aBuffer[0], nCffLen ); 2275 2276 // NOTE: assuming that all glyphids requested on Aqua are fully translated 2277 2278 // make the subsetter provide the requested subset 2279 FILE* pOutFile = fopen( aToFile.GetBuffer(), "wb" ); 2280 bool bRC = rInfo.CreateFontSubset( FontSubsetInfo::TYPE1_PFB, pOutFile, NULL, 2281 pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); --- 11 unchanged lines hidden (view full) --- 2293 if( nRC != SF_OK ) 2294 return sal_False; 2295 2296 // get details about the subsetted font 2297 TTGlobalFontInfo aTTInfo; 2298 ::GetTTGlobalFontInfo( pSftFont, &aTTInfo ); 2299 rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; 2300 rInfo.m_aPSName = String( aTTInfo.psname, RTL_TEXTENCODING_UTF8 ); | 2068 rInfo.LoadFont( FontSubsetInfo::CFF_FONT, &aBuffer[0], nCffLen ); 2069 2070 // NOTE: assuming that all glyphids requested on Aqua are fully translated 2071 2072 // make the subsetter provide the requested subset 2073 FILE* pOutFile = fopen( aToFile.GetBuffer(), "wb" ); 2074 bool bRC = rInfo.CreateFontSubset( FontSubsetInfo::TYPE1_PFB, pOutFile, NULL, 2075 pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); --- 11 unchanged lines hidden (view full) --- 2087 if( nRC != SF_OK ) 2088 return sal_False; 2089 2090 // get details about the subsetted font 2091 TTGlobalFontInfo aTTInfo; 2092 ::GetTTGlobalFontInfo( pSftFont, &aTTInfo ); 2093 rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; 2094 rInfo.m_aPSName = String( aTTInfo.psname, RTL_TEXTENCODING_UTF8 ); |
2301 rInfo.m_aFontBBox = Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ), | 2095 rInfo.m_aFontBBox = Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ), |
2302 Point( aTTInfo.xMax, aTTInfo.yMax ) ); | 2096 Point( aTTInfo.xMax, aTTInfo.yMax ) ); |
2303 rInfo.m_nCapHeight = aTTInfo.yMax; // Well ... | 2097 rInfo.m_nCapHeight = aTTInfo.yMax; // Well ... |
2304 rInfo.m_nAscent = aTTInfo.winAscent; 2305 rInfo.m_nDescent = aTTInfo.winDescent; 2306 // mac fonts usually do not have an OS2-table 2307 // => get valid ascent/descent values from other tables 2308 if( !rInfo.m_nAscent ) 2309 rInfo.m_nAscent = +aTTInfo.typoAscender; 2310 if( !rInfo.m_nAscent ) 2311 rInfo.m_nAscent = +aTTInfo.ascender; 2312 if( !rInfo.m_nDescent ) 2313 rInfo.m_nDescent = +aTTInfo.typoDescender; 2314 if( !rInfo.m_nDescent ) 2315 rInfo.m_nDescent = -aTTInfo.descender; 2316 2317 // subset glyphs and get their properties 2318 // take care that subset fonts require the NotDef glyph in pos 0 2319 int nOrigCount = nGlyphCount; | 2098 rInfo.m_nAscent = aTTInfo.winAscent; 2099 rInfo.m_nDescent = aTTInfo.winDescent; 2100 // mac fonts usually do not have an OS2-table 2101 // => get valid ascent/descent values from other tables 2102 if( !rInfo.m_nAscent ) 2103 rInfo.m_nAscent = +aTTInfo.typoAscender; 2104 if( !rInfo.m_nAscent ) 2105 rInfo.m_nAscent = +aTTInfo.ascender; 2106 if( !rInfo.m_nDescent ) 2107 rInfo.m_nDescent = +aTTInfo.typoDescender; 2108 if( !rInfo.m_nDescent ) 2109 rInfo.m_nDescent = -aTTInfo.descender; 2110 2111 // subset glyphs and get their properties 2112 // take care that subset fonts require the NotDef glyph in pos 0 2113 int nOrigCount = nGlyphCount; |
2320 sal_uInt16 aShortIDs[ 256 ]; | 2114 sal_uInt16 aShortIDs[ 256 ]; |
2321 sal_uInt8 aTempEncs[ 256 ]; 2322 2323 int nNotDef = -1; 2324 for( int i = 0; i < nGlyphCount; ++i ) 2325 { 2326 aTempEncs[i] = pEncoding[i]; 2327 sal_GlyphId aGlyphId( pGlyphIds[i] & GF_IDXMASK); 2328 if( pGlyphIds[i] & GF_ISCHAR ) --- 55 unchanged lines hidden (view full) --- 2384 2385void AquaSalGraphics::GetGlyphWidths( const ImplFontData* pFontData, bool bVertical, 2386 Int32Vector& rGlyphWidths, Ucs2UIntMap& rUnicodeEnc ) 2387{ 2388 rGlyphWidths.clear(); 2389 rUnicodeEnc.clear(); 2390 2391 if( pFontData->IsSubsettable() ) | 2115 sal_uInt8 aTempEncs[ 256 ]; 2116 2117 int nNotDef = -1; 2118 for( int i = 0; i < nGlyphCount; ++i ) 2119 { 2120 aTempEncs[i] = pEncoding[i]; 2121 sal_GlyphId aGlyphId( pGlyphIds[i] & GF_IDXMASK); 2122 if( pGlyphIds[i] & GF_ISCHAR ) --- 55 unchanged lines hidden (view full) --- 2178 2179void AquaSalGraphics::GetGlyphWidths( const ImplFontData* pFontData, bool bVertical, 2180 Int32Vector& rGlyphWidths, Ucs2UIntMap& rUnicodeEnc ) 2181{ 2182 rGlyphWidths.clear(); 2183 rUnicodeEnc.clear(); 2184 2185 if( pFontData->IsSubsettable() ) |
2392 { | 2186 { |
2393 ByteVector aBuffer; 2394 if( !GetRawFontData( pFontData, aBuffer, NULL ) ) 2395 return; 2396 2397 // TODO: modernize psprint's horrible fontsubset C-API 2398 // this probably only makes sense after the switch to another SCM 2399 // that can preserve change history after file renames 2400 --- 63 unchanged lines hidden (view full) --- 2464 } 2465} 2466 2467// ----------------------------------------------------------------------- 2468 2469const Ucs2SIntMap* AquaSalGraphics::GetFontEncodingVector( 2470 const ImplFontData*, const Ucs2OStrMap** /*ppNonEncoded*/ ) 2471{ | 2187 ByteVector aBuffer; 2188 if( !GetRawFontData( pFontData, aBuffer, NULL ) ) 2189 return; 2190 2191 // TODO: modernize psprint's horrible fontsubset C-API 2192 // this probably only makes sense after the switch to another SCM 2193 // that can preserve change history after file renames 2194 --- 63 unchanged lines hidden (view full) --- 2258 } 2259} 2260 2261// ----------------------------------------------------------------------- 2262 2263const Ucs2SIntMap* AquaSalGraphics::GetFontEncodingVector( 2264 const ImplFontData*, const Ucs2OStrMap** /*ppNonEncoded*/ ) 2265{ |
2472 return NULL; | 2266 return NULL; |
2473} 2474 2475// ----------------------------------------------------------------------- 2476 2477const void* AquaSalGraphics::GetEmbedFontData( const ImplFontData*, 2478 const sal_Ucs* /*pUnicodes*/, 2479 sal_Int32* /*pWidths*/, 2480 FontSubsetInfo&, 2481 long* /*pDataLen*/ ) 2482{ | 2267} 2268 2269// ----------------------------------------------------------------------- 2270 2271const void* AquaSalGraphics::GetEmbedFontData( const ImplFontData*, 2272 const sal_Ucs* /*pUnicodes*/, 2273 sal_Int32* /*pWidths*/, 2274 FontSubsetInfo&, 2275 long* /*pDataLen*/ ) 2276{ |
2483 return NULL; | 2277 return NULL; |
2484} 2485 2486// ----------------------------------------------------------------------- 2487 2488void AquaSalGraphics::FreeEmbedFontData( const void* pData, long /*nDataLen*/ ) 2489{ | 2278} 2279 2280// ----------------------------------------------------------------------- 2281 2282void AquaSalGraphics::FreeEmbedFontData( const void* pData, long /*nDataLen*/ ) 2283{ |
2490 // TODO: implementing this only makes sense when the implementation of | 2284 // TODO: implementing this only makes sense when the implementation of |
2491 // AquaSalGraphics::GetEmbedFontData() returns non-NULL 2492 (void)pData; 2493 DBG_ASSERT( (pData!=NULL), "AquaSalGraphics::FreeEmbedFontData() is not implemented\n"); 2494} 2495 2496// ----------------------------------------------------------------------- 2497 2498SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const 2499{ 2500 SystemFontData aSysFontData; | 2285 // AquaSalGraphics::GetEmbedFontData() returns non-NULL 2286 (void)pData; 2287 DBG_ASSERT( (pData!=NULL), "AquaSalGraphics::FreeEmbedFontData() is not implemented\n"); 2288} 2289 2290// ----------------------------------------------------------------------- 2291 2292SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const 2293{ 2294 SystemFontData aSysFontData; |
2501 OSStatus err; | |
2502 aSysFontData.nSize = sizeof( SystemFontData ); 2503 | 2295 aSysFontData.nSize = sizeof( SystemFontData ); 2296 |
2297#ifdef USE_ATSU |
|
2504 // NOTE: Native ATSU font fallbacks are used, not the VCL fallbacks. 2505 ATSUFontID fontId; | 2298 // NOTE: Native ATSU font fallbacks are used, not the VCL fallbacks. 2299 ATSUFontID fontId; |
2300 OSStatus err; |
|
2506 err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(fontId), &fontId, 0 ); 2507 if (err) fontId = 0; 2508 aSysFontData.aATSUFontID = (void *) fontId; 2509 2510 Boolean bFbold; 2511 err = ATSUGetAttribute( maATSUStyle, kATSUQDBoldfaceTag, sizeof(bFbold), &bFbold, 0 ); 2512 if (err) bFbold = FALSE; 2513 aSysFontData.bFakeBold = (bool) bFbold; --- 5 unchanged lines hidden (view full) --- 2519 2520 ATSUVerticalCharacterType aVerticalCharacterType; 2521 err = ATSUGetAttribute( maATSUStyle, kATSUVerticalCharacterTag, sizeof(aVerticalCharacterType), &aVerticalCharacterType, 0 ); 2522 if (!err && aVerticalCharacterType == kATSUStronglyVertical) { 2523 aSysFontData.bVerticalCharacterType = true; 2524 } else { 2525 aSysFontData.bVerticalCharacterType = false; 2526 } | 2301 err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(fontId), &fontId, 0 ); 2302 if (err) fontId = 0; 2303 aSysFontData.aATSUFontID = (void *) fontId; 2304 2305 Boolean bFbold; 2306 err = ATSUGetAttribute( maATSUStyle, kATSUQDBoldfaceTag, sizeof(bFbold), &bFbold, 0 ); 2307 if (err) bFbold = FALSE; 2308 aSysFontData.bFakeBold = (bool) bFbold; --- 5 unchanged lines hidden (view full) --- 2314 2315 ATSUVerticalCharacterType aVerticalCharacterType; 2316 err = ATSUGetAttribute( maATSUStyle, kATSUVerticalCharacterTag, sizeof(aVerticalCharacterType), &aVerticalCharacterType, 0 ); 2317 if (!err && aVerticalCharacterType == kATSUStronglyVertical) { 2318 aSysFontData.bVerticalCharacterType = true; 2319 } else { 2320 aSysFontData.bVerticalCharacterType = false; 2321 } |
2322#endif // USE_ATSU |
|
2527 2528 aSysFontData.bAntialias = !mbNonAntialiasedText; 2529 2530 return aSysFontData; 2531} 2532 2533// ----------------------------------------------------------------------- 2534 --- 213 unchanged lines hidden (view full) --- 2748 // TODO: not needed for last update 2749 memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(sal_uLong) ); 2750 2751 // TODO: return FALSE if target was not changed 2752 return true; 2753} 2754 2755// ======================================================================= | 2323 2324 aSysFontData.bAntialias = !mbNonAntialiasedText; 2325 2326 return aSysFontData; 2327} 2328 2329// ----------------------------------------------------------------------- 2330 --- 213 unchanged lines hidden (view full) --- 2544 // TODO: not needed for last update 2545 memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(sal_uLong) ); 2546 2547 // TODO: return FALSE if target was not changed 2548 return true; 2549} 2550 2551// ======================================================================= |
2756 | |