[Libreoffice-commits] core.git: vcl/coretext
Khaled Hosny
khaledhosny at eglug.org
Sun Jun 16 08:46:06 PDT 2013
vcl/coretext/ctfonts.cxx | 39 +++++++++++++++++----------------------
vcl/coretext/ctfonts.hxx | 17 +++++++++++++++++
vcl/coretext/ctlayout.cxx | 12 ++++++++++++
vcl/coretext/salgdi2.cxx | 1 -
4 files changed, 46 insertions(+), 23 deletions(-)
New commits:
commit eb04af85a7f928564d29c4400d5c0ff1828f4304
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Fri Jun 14 19:06:34 2013 +0200
Fix PDF export with fallback fonts in Core Text
We need to pass the real font used to layout the glyphs in case it
differs from the requested font, otherwise we end with garbage in PDF
files.
Change-Id: I9caa8e60429e45ee864f5347fd9392f5e440864e
Reviewed-on: https://gerrit.libreoffice.org/4299
Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>
Tested-by: Khaled Hosny <khaledhosny at eglug.org>
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 19e3256..3dcfe4f 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -36,22 +36,6 @@
// =======================================================================
-// CoreText specific physically available font face
-class CTFontData
-: public ImplMacFontData
-{
-public:
- explicit CTFontData( const ImplDevFontAttributes&, sal_IntPtr nFontId );
- virtual ~CTFontData( void );
- virtual PhysicalFontFace* Clone( void ) const;
-
- virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const;
- virtual ImplFontEntry* CreateFontInstance( /*const*/ FontSelectPattern& ) const;
- virtual int GetFontTable( const char pTagName[5], unsigned char* ) const;
-};
-
-// =======================================================================
-
class CTFontList
: public SystemFontList
{
@@ -337,10 +321,8 @@ int CTFontData::GetFontTable( const char pTagName[5], unsigned char* pResultBuf
// =======================================================================
-static void CTFontEnumCallBack( const void* pValue, void* pContext )
+ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool* bFontEnabled )
{
- CTFontDescriptorRef pFD = static_cast<CTFontDescriptorRef>(pValue);
-
// all CoreText fonts are device fonts that can rotate just fine
ImplDevFontAttributes rDFA;
rDFA.mbOrientation = true;
@@ -368,9 +350,12 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
rDFA.SetStyleName( GetOUString( pStyleName ) );
// get font-enabled status
- int bFontEnabled = FALSE;
- CFNumberRef pFontEnabled = (CFNumberRef)CTFontDescriptorCopyAttribute( pFD, kCTFontEnabledAttribute );
- CFNumberGetValue( pFontEnabled, kCFNumberIntType, &bFontEnabled );
+ if( bFontEnabled ) {
+ int bEnabled = FALSE;
+ CFNumberRef pEnabled = (CFNumberRef)CTFontDescriptorCopyAttribute( pFD, kCTFontEnabledAttribute );
+ CFNumberGetValue( pEnabled, kCFNumberIntType, &bEnabled );
+ *bFontEnabled = bEnabled;
+ }
// get font attributes
CFDictionaryRef pAttrDict = (CFDictionaryRef)CTFontDescriptorCopyAttribute( pFD, kCTFontTraitsAttribute );
@@ -429,6 +414,16 @@ 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 );
+ return rDFA;
+}
+
+static void CTFontEnumCallBack( const void* pValue, void* pContext )
+{
+ CTFontDescriptorRef pFD = static_cast<CTFontDescriptorRef>(pValue);
+
+ bool bFontEnabled;
+ ImplDevFontAttributes rDFA = DevFontFromCTFontDescriptor( pFD, &bFontEnabled );
+
if( bFontEnabled)
{
const sal_IntPtr nFontId = (sal_IntPtr)pValue;
diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx
index 1430c36..605a2c1 100644
--- a/vcl/coretext/ctfonts.hxx
+++ b/vcl/coretext/ctfonts.hxx
@@ -46,4 +46,21 @@ private:
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
};
+// CoreText specific physically available font face
+class CTFontData
+: public ImplMacFontData
+{
+public:
+ explicit CTFontData( const ImplDevFontAttributes&, sal_IntPtr nFontId );
+ explicit CTFontData( CTFontDescriptorRef pFontDesc );
+ virtual ~CTFontData( void );
+ virtual PhysicalFontFace* Clone( void ) const;
+
+ virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const;
+ virtual ImplFontEntry* CreateFontInstance( /*const*/ FontSelectPattern& ) const;
+ virtual int GetFontTable( const char pTagName[5], unsigned char* ) const;
+};
+
+SystemFontList* GetCoretextFontList(void);
+ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef, bool* );
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 89ecf09..5fbcef1 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -294,6 +294,18 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
}
const PhysicalFontFace* pFallbackFont = NULL;
+ if( pFallbackFonts ) {
+ CFDictionaryRef pRunAttributes = CTRunGetAttributes( pGlyphRun );
+ CTFontRef pRunFont = (CTFontRef)CFDictionaryGetValue( pRunAttributes, kCTFontAttributeName );
+
+ CFDictionaryRef pAttributes = mpTextStyle->GetStyleDict();
+ CTFontRef pFont = (CTFontRef)CFDictionaryGetValue( pAttributes, kCTFontAttributeName );
+ if ( !CFEqual( pRunFont, pFont ) ) {
+ CTFontDescriptorRef pFontDesc = CTFontCopyFontDescriptor( pRunFont );
+ ImplDevFontAttributes rDevFontAttr = DevFontFromCTFontDescriptor( pFontDesc, NULL );
+ pFallbackFont = new CTFontData( rDevFontAttr, (sal_IntPtr)pFontDesc );
+ }
+ }
// get the details for each interesting glyph
// TODO: handle nLen>1
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 9180c32..97d1889 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -399,7 +399,6 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList )
// through it as should be all event handlers
SalData* pSalData = GetSalData();
- SystemFontList* GetCoretextFontList(void); // forward declaration
if( !pSalData->mpFontList )
pSalData->mpFontList = GetCoretextFontList();
More information about the Libreoffice-commits
mailing list