+
+ OSStatus status = noErr ;
+
+ TECObjectRef ec;
+ status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault);
+ wxASSERT_MSG( status == noErr , "couldn't start converter" ) ;
+
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = text.Length() ;
+ ByteCount byteBufferLen = byteInLen *2 ;
+ char* buf = new char[byteBufferLen] ;
+
+ status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen,
+ (TextPtr)buf, byteBufferLen, &byteOutLen);
+
+ wxASSERT_MSG( status == noErr , "couldn't convert text" ) ;
+ status = TECDisposeConverter(ec);
+ wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ;
+
+ ATSUTextLayout atsuLayout ;
+ UniCharCount chars = byteOutLen / 2 ;
+ status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 ,
+ &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
+ wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" );
+
+ Fixed atsuAngle = IntToFixed( angle ) ;
+ ByteCount angleSize = sizeof(Fixed) ;
+ ATSUAttributeTag rotationTag = kATSULineRotationTag ;
+ ATSUAttributeValuePtr angleValue = &atsuAngle ;
+ status = ::ATSUSetLayoutControls(atsuLayout , 1 , &rotationTag , &angleSize , &angleValue ) ;
+
+ status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
+ IntToFixed(XLOG2DEVMAC(x) ) , IntToFixed(YLOG2DEVMAC(y) ) );
+ wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" );
+ Rect rect ;
+ status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
+ IntToFixed(XLOG2DEVMAC(x) ) , IntToFixed(YLOG2DEVMAC(y) ) , &rect );
+ wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" );
+
+ OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ;
+ CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
+ CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
+ ::ATSUDisposeTextLayout(atsuLayout);
+ delete[] buf ;