summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-06-02 12:43:36 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-06-02 23:28:30 +0200
commitb1454f3754a82a701b3d531a2b7d11bc4b4b942f (patch)
treea91a950e5e0edba8cae35220b467f1573e997b37
parentfc03cf7277e5de50817b7c7d85332aecde1993ab (diff)
Get the new Core Text code to compile
Change-Id: I592158bd60afcbe756c6f0e11aa69a44768a0985
-rw-r--r--vcl/Library_vcl.mk7
-rw-r--r--vcl/coretext/ctfonts.cxx89
-rw-r--r--vcl/coretext/ctfonts.hxx2
-rw-r--r--vcl/coretext/ctlayout.cxx10
-rw-r--r--vcl/coretext/salgdi2.cxx38
-rw-r--r--vcl/inc/coretext/salgdi2.h4
6 files changed, 48 insertions, 102 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index dfaecc7c7c47..178f528f875a 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -353,10 +353,9 @@ vcl_quartz_code= \
vcl/quartz/utils \
vcl_coretext_code= \
- vcl/coretext/salcoretextfontutils \
- vcl/coretext/salcoretextlayout \
- vcl/coretext/salcoretextstyle \
- vcl/coretext/salgdi \
+ vcl/coretext/ctfonts \
+ vcl/coretext/ctlayout \
+ vcl/coretext/salgdi2 \
# GUIBASE specific stuff
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 5eb2d3465ea5..e6cf65bd331a 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -19,8 +19,7 @@
*
*************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
+#include <boost/unordered_map.hpp>
#include "impfont.hxx"
#include "outfont.hxx"
@@ -29,6 +28,7 @@
#include "aqua/salinst.h"
#include "aqua/saldata.hxx"
#include "coretext/salgdi2.h"
+#include "quartz/utils.h"
#include "ctfonts.hxx"
#include "basegfx/polygon/b2dpolygon.hxx"
@@ -47,10 +47,10 @@ class CTFontData
public:
explicit CTFontData( const ImplDevFontAttributes&, sal_IntPtr nFontId );
virtual ~CTFontData( void );
- virtual ImplFontData* Clone( void ) const;
+ virtual PhysicalFontFace* Clone( void ) const;
- virtual ImplMacTextStyle* CreateMacTextStyle( const ImplFontSelectData& ) const;
- virtual ImplFontEntry* CreateFontInstance( /*const*/ ImplFontSelectData& ) const;
+ virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const;
+ virtual ImplFontEntry* CreateFontInstance( /*const*/ FontSelectPattern& ) const;
virtual int GetFontTable( const char pTagName[5], unsigned char* ) const;
};
@@ -73,18 +73,18 @@ private:
CTFontCollectionRef mpCTFontCollection;
CFArrayRef mpCTFontArray;
- typedef std::hash_map<sal_IntPtr,CTFontData*> CTFontContainer;
+ typedef boost::unordered_map<sal_IntPtr,CTFontData*> CTFontContainer;
CTFontContainer maFontContainer;
};
// =======================================================================
-CTTextStyle::CTTextStyle( const ImplFontSelectData& rFSD )
+CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
: ImplMacTextStyle( rFSD )
, mpStyleDict( NULL )
{
mpFontData = (CTFontData*)rFSD.mpFontData;
- const ImplFontSelectData* const pReqFont = &rFSD;
+ const FontSelectPattern* const pReqFont = &rFSD;
double fScaledFontHeight = pReqFont->mfExactHeight;
#if 0 // TODO: does CoreText need font size limiting???
@@ -264,13 +264,8 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
void CTTextStyle::SetTextColor( const RGBAColor& rColor )
{
-#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
CGColorRef pCGColor = CGColorCreateGenericRGB( rColor.GetRed(),
rColor.GetGreen(), rColor.GetBlue(), rColor.GetAlpha() );
-#else // for builds on OSX 10.4 SDK
- const CGColorSpaceRef pCGColorSpace = GetSalData()->mxRGBSpace;
- CGColorRef pCGColor = CGColorCreate( pCGColorSpace, rColor.AsArray() );
-#endif
CFDictionarySetValue( mpStyleDict, kCTForegroundColorAttributeName, pCGColor );
CFRelease( pCGColor);
}
@@ -290,21 +285,21 @@ CTFontData::~CTFontData( void )
// -----------------------------------------------------------------------
-ImplFontData* CTFontData::Clone( void ) const
+PhysicalFontFace* CTFontData::Clone( void ) const
{
return new CTFontData( *this);
}
// -----------------------------------------------------------------------
-ImplMacTextStyle* CTFontData::CreateMacTextStyle( const ImplFontSelectData& rFSD ) const
+ImplMacTextStyle* CTFontData::CreateMacTextStyle( const FontSelectPattern& rFSD ) const
{
return new CTTextStyle( rFSD);
}
// -----------------------------------------------------------------------
-ImplFontEntry* CTFontData::CreateFontInstance( /*const*/ ImplFontSelectData& rFSD ) const
+ImplFontEntry* CTFontData::CreateFontInstance( /*const*/ FontSelectPattern& rFSD ) const
{
return new ImplFontEntry( rFSD);
}
@@ -352,12 +347,12 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
rDFA.mnQuality = 0;
// reset the font attributes
- rDFA.meFamily = FAMILY_DONTKNOW;
- rDFA.mePitch = PITCH_VARIABLE;
- rDFA.meWidthType = WIDTH_NORMAL;
- rDFA.meWeight = WEIGHT_NORMAL;
- rDFA.meItalic = ITALIC_NONE;
- rDFA.mbSymbolFlag = false;
+ rDFA.SetFamilyType( FAMILY_DONTKNOW );
+ rDFA.SetPitch( PITCH_VARIABLE );
+ rDFA.SetWidthType( WIDTH_NORMAL );
+ rDFA.SetWeight( WEIGHT_NORMAL );
+ rDFA.SetItalic( ITALIC_NONE );
+ rDFA.SetSymbolFlag( false );
// all scalable fonts on this platform are subsettable
rDFA.mbEmbeddable = false;
@@ -366,10 +361,10 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
// get font name
// TODO: use kCTFontDisplayNameAttribute instead???
CFStringRef pFamilyName = (CFStringRef)CTFontDescriptorCopyAttribute( pFD, kCTFontFamilyNameAttribute );
- rDFA.maName = GetOUString( pFamilyName );
+ rDFA.SetFamilyName( GetOUString( pFamilyName ) );
// get font style
CFStringRef pStyleName = (CFStringRef)CTFontDescriptorCopyAttribute( pFD, kCTFontStyleNameAttribute );
- rDFA.maStyleName = GetOUString( pStyleName );
+ rDFA.SetStyleName( GetOUString( pStyleName ) );
// get font-enabled status
int bFontEnabled = FALSE;
@@ -385,7 +380,7 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
CFNumberRef pSymbolNum = NULL;
if( CFDictionaryGetValueIfPresent( pAttrDict, kCTFontSymbolicTrait, (const void**)&pSymbolNum ) ) {
CFNumberGetValue( pSymbolNum, kCFNumberSInt64Type, &nSymbolTrait );
- rDFA.mbSymbolFlag = ((nSymbolTrait & kCTFontClassMaskTrait) == kCTFontSymbolicClass);
+ rDFA.SetSymbolFlag( ((nSymbolTrait & kCTFontClassMaskTrait) == kCTFontSymbolicClass) );
}
// get the font weight
@@ -402,14 +397,14 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
if( nInt < WEIGHT_THIN )
nInt = WEIGHT_THIN;
}
- rDFA.meWeight = (FontWeight)nInt;
+ rDFA.SetWeight( (FontWeight)nInt );
// get the font slant
double fSlant = 0;
CFNumberRef pSlantNum = (CFNumberRef)CFDictionaryGetValue( pAttrDict, kCTFontSlantTrait );
CFNumberGetValue( pSlantNum, kCFNumberDoubleType, &fSlant );
if( fSlant >= 0.035 )
- rDFA.meItalic = ITALIC_NORMAL;
+ rDFA.SetItalic( ITALIC_NORMAL );
// get width trait
double fWidth = 0;
@@ -425,7 +420,7 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
if( nInt < WIDTH_ULTRA_CONDENSED )
nInt = WIDTH_ULTRA_CONDENSED;
}
- rDFA.meWidthType = (FontWidth)nInt;
+ rDFA.SetWidthType( (FontWidth)nInt );
// release the attribute dict that we had copied
CFRelease( pAttrDict );
@@ -433,44 +428,6 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
// TODO? also use the HEAD table if available to get more attributes
// CFDataRef CTFontCopyTable( CTFontRef, kCTFontTableHead, /*kCTFontTableOptionNoOptions*/kCTFontTableOptionExcludeSynthetic );
-#if (OSL_DEBUG_LEVEL >= 1)
- // update font attributes using the font's postscript name
- ImplDevFontAttributes rDFA2;
- CTFontRef pFont = CTFontCreateWithFontDescriptor( pFD, 0.0, NULL );
- CFStringRef pPSName = CTFontCopyPostScriptName( pFont );
- const String aPSName = GetOUString( pPSName );
-
- rDFA2.mbSymbolFlag = false;
- rDFA2.mePitch = PITCH_VARIABLE;
- rDFA2.meWidthType = WIDTH_NORMAL;
- rDFA2.meWeight = WEIGHT_NORMAL;
- rDFA2.meItalic = ITALIC_NONE;
-
- UpdateAttributesFromPSName( aPSName, rDFA2 );
- CFRelease( pPSName );
- CFRelease( pFont );
-
- // show the font details and compare the CTFontDescriptor vs. PSName traits
- char cMatch = (rDFA.mbSymbolFlag==rDFA2.mbSymbolFlag);
- cMatch &= (rDFA.meWeight==rDFA2.meWeight);
- cMatch &= ((rDFA.meItalic==ITALIC_NONE) == (rDFA2.meItalic==ITALIC_NONE));
- cMatch &= (rDFA.meWidthType==rDFA2.meWidthType);
- cMatch = cMatch ? '.' : '#';
-
- char aFN[256], aSN[256];
- CFStringGetCString( pFamilyName, aFN, sizeof(aFN), kCFStringEncodingUTF8 );
- CFStringGetCString( pStyleName, aSN, sizeof(aSN), kCFStringEncodingUTF8 );
-
- const ByteString aPSCName( aPSName, RTL_TEXTENCODING_UTF8 );
- const char* aPN = aPSCName.GetBuffer();
- printf("\tCTFont_%d%x%d%d_%c_%d%x%d%d ena=%d s=%02d b=%+.2f i=%+.2f w=%+.2f (\"%s\", \"%s\", \"%s\")\n",
- (int)rDFA.mbSymbolFlag,(int)rDFA.meWeight,(int)rDFA.meItalic,(int)rDFA.meWidthType,
- cMatch,
- (int)rDFA2.mbSymbolFlag,(int)rDFA2.meWeight,(int)rDFA2.meItalic,(int)rDFA2.meWidthType,
- bFontEnabled,
- (int)(nSymbolTrait>>kCTFontClassMaskShift),fWeight,fSlant,fWidth,aFN,aSN,aPN);
-#endif // (OSL_DEBUG_LEVEL >= 1)
-
if( bFontEnabled)
{
const sal_IntPtr nFontId = (sal_IntPtr)pValue;
diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx
index c62c1f963fca..ec2e6e7a9f43 100644
--- a/vcl/coretext/ctfonts.hxx
+++ b/vcl/coretext/ctfonts.hxx
@@ -30,7 +30,7 @@ class CTTextStyle
: public ImplMacTextStyle
{
public:
- explicit CTTextStyle( const ImplFontSelectData& );
+ explicit CTTextStyle( const FontSelectPattern& );
virtual ~CTTextStyle( void );
virtual SalLayout* GetTextLayout( void ) const;
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index d232910a41c3..30da812c88fc 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -47,7 +47,7 @@ public:
virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
- const ImplFontData* GetFallbackFontData( sal_GlyphId ) const;
+ const PhysicalFontFace* GetFallbackFontData( sal_GlyphId ) const;
virtual void InitFont( void) const;
virtual void MoveGlyph( int nStart, long nNewXPos );
@@ -396,7 +396,7 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
// -----------------------------------------------------------------------
-int CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+int CTLayout::GetTextBreak( long nMaxWidth, long /*nCharExtra*/, int nFactor ) const
{
if( !mpCTLine )
return STRING_LEN;
@@ -469,9 +469,9 @@ void CTLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
void CTLayout::DropGlyph( int /*nStart*/ ) {}
void CTLayout::Simplify( bool /*bIsBase*/ ) {}
-// get the ImplFontData for a glyph fallback font
+// get the PhysicalFontFace for a glyph fallback font
// for a glyphid that was returned by CTLayout::GetNextGlyphs()
-const ImplFontData* CTLayout::GetFallbackFontData( sal_GlyphId /*nGlyphId*/ ) const
+const PhysicalFontFace* CTLayout::GetFallbackFontData( sal_GlyphId /*nGlyphId*/ ) const
{
#if 0
// check if any fallback fonts were needed
@@ -484,7 +484,7 @@ const ImplFontData* CTLayout::GetFallbackFontData( sal_GlyphId /*nGlyphId*/ ) co
pFallbackFont = mpFallbackInfo->GetFallbackFontData( nFallbackLevel );
#else
// let CoreText's font cascading handle glyph fallback
- const ImplFontData* pFallbackFont = NULL;
+ const PhysicalFontFace* pFallbackFont = NULL;
#endif
return pFallbackFont;
}
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index c118440d4779..74c906f52f3b 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -36,7 +36,7 @@
#include "vcl/sysdata.hxx"
#include "vcl/svapp.hxx"
-#include "aqua/atsui/salgdi.h"
+#include "coretext/salgdi2.h"
#include "aqua/salframe.h"
#ifdef ENABLE_CORETEXT
#include "ctfonts.hxx"
@@ -65,7 +65,7 @@ SystemFontList::~SystemFontList( void )
// =======================================================================
-ImplMacTextStyle::ImplMacTextStyle( const ImplFontSelectData& rReqFont )
+ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
: mpFontData( (ImplMacFontData*)rReqFont.mpFontData )
, mfFontScale( 1.0 )
, mfFontStretch( 1.0 )
@@ -80,7 +80,7 @@ ImplMacTextStyle::~ImplMacTextStyle( void )
// =======================================================================
ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc )
-: ImplFontData( rSrc )
+: PhysicalFontFace( rSrc )
, mnFontId( rSrc.mnFontId )
, mpCharMap( rSrc.mpCharMap )
, mbOs2Read( rSrc.mbOs2Read )
@@ -95,7 +95,7 @@ ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc )
// -----------------------------------------------------------------------
ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId )
-: ImplFontData( rDFA, 0 )
+: PhysicalFontFace( rDFA, 0 )
, mnFontId( nFontId )
, mpCharMap( NULL )
, mbOs2Read( false )
@@ -132,12 +132,6 @@ ImplFontEntry* ImplMacFontData::CreateFontInstance(FontSelectPattern& rFSD) cons
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]);}
-#if MACOSX_SDK_VERSION >= 1070
-extern "C" {
-extern ATSFontRef FMGetATSFontRefFromFont(FMFont iFont);
-}
-#endif
-
const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
{
// return the cached charmap
@@ -186,33 +180,29 @@ bool ImplMacFontData::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabi
}
mbFontCapabilitiesRead = true;
+ int nBufSize = 0;
// prepare to get the GSUB table raw data
- ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId );
- ByteCount nBufSize = 0;
- OSStatus eStatus;
- eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, 0, NULL, &nBufSize );
- if( eStatus == noErr )
+ nBufSize = GetFontTable( "GSUB", NULL );
+ if( nBufSize > 0 )
{
// allocate a buffer for the GSUB raw data
ByteVector aBuffer( nBufSize );
// get the GSUB raw data
- ByteCount nRawLength = 0;
- eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength );
- if( eStatus == noErr )
+ const int nRawLength = GetFontTable( "GSUB", &aBuffer[0] );
+ if( nRawLength > 0 )
{
const unsigned char* pGSUBTable = &aBuffer[0];
vcl::getTTScripts(maFontCapabilities.maGSUBScriptTags, pGSUBTable, nRawLength);
}
}
- eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, 0, NULL, &nBufSize );
- if( eStatus == noErr )
+ nBufSize = GetFontTable( "OS/2", NULL );
+ if( nBufSize > 0 )
{
- // allocate a buffer for the GSUB raw data
+ // allocate a buffer for the OS/2 raw data
ByteVector aBuffer( nBufSize );
// get the OS/2 raw data
- ByteCount nRawLength = 0;
- eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength );
- if( eStatus == noErr )
+ const int nRawLength = GetFontTable( "OS/2", &aBuffer[0] );
+ if( nRawLength > 0 )
{
const unsigned char* pOS2Table = &aBuffer[0];
vcl::getTTCoverage(
diff --git a/vcl/inc/coretext/salgdi2.h b/vcl/inc/coretext/salgdi2.h
index 86d5fc9f516f..90fb594b9e8c 100644
--- a/vcl/inc/coretext/salgdi2.h
+++ b/vcl/inc/coretext/salgdi2.h
@@ -62,7 +62,7 @@ public:
virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const;
virtual sal_IntPtr GetFontId() const;
- virtual ImplMacTextStyle* CreateMacTextStyle( const ImplFontSelectData& ) const = 0;
+ virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const = 0;
virtual int GetFontTable( const char pTagName[5], unsigned char* ) const = 0;
const ImplFontCharMap* GetImplFontCharMap() const;
@@ -92,7 +92,7 @@ private:
class ImplMacTextStyle
{
public:
- explicit ImplMacTextStyle( const ImplFontSelectData& );
+ explicit ImplMacTextStyle( const FontSelectPattern& );
virtual ~ImplMacTextStyle( void );
virtual SalLayout* GetTextLayout( void ) const = 0;