[libreoffice/f15/master] Resolves: rhbz#680460 honour lcdfilter and subpixeling

Caolan McNamara caolanm at fedoraproject.org
Wed Mar 16 15:53:25 UTC 2011


commit 84b38332f461d3634d25b1f46c18f2ad615adbbc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 16 15:53:14 2011 +0000

    Resolves: rhbz#680460 honour lcdfilter and subpixeling

 ...z-680460-don-t-bother-with-an-interim-Fon.patch |   91 ++++++
 ...z-680460-reorganize-this-to-make-it-inher.patch |  320 ++++++++++++++++++++
 ...bz-680460-honour-lcdfilter-subpixeling-et.patch |  226 ++++++++++++++
 ...o_ft_font_face_create_for_pattern-wrapper.patch |   50 +++
 libreoffice.spec                                   |   14 +-
 5 files changed, 700 insertions(+), 1 deletions(-)
---
diff --git a/0001-Related-rhbz-680460-don-t-bother-with-an-interim-Fon.patch b/0001-Related-rhbz-680460-don-t-bother-with-an-interim-Fon.patch
new file mode 100644
index 0000000..ade0c91
--- /dev/null
+++ b/0001-Related-rhbz-680460-don-t-bother-with-an-interim-Fon.patch
@@ -0,0 +1,91 @@
+From cc8f350a5829405832af1177fd32de7c41c30724 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Wed, 16 Mar 2011 14:18:42 +0000
+Subject: [PATCH] Related: rhbz#680460 don't bother with an interim FontSet
+
+I can't see why bother adding it to a FontSet and then
+throw away the fontset, why not just use the pattern
+directly and throw it away afterwards directly.
+---
+ vcl/unx/source/fontmanager/fontconfig.cxx |   63 +++++++++++++----------------
+ 1 files changed, 28 insertions(+), 35 deletions(-)
+
+diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx
+index 3c2f636..92632c7 100644
+--- a/vcl/unx/source/fontmanager/fontconfig.cxx
++++ b/vcl/unx/source/fontmanager/fontconfig.cxx
+@@ -1130,43 +1130,36 @@ ImplFontOptions* PrintFontManager::getFontOptions(
+     FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult );
+     if( pResult )
+     {
+-        FcFontSet* pSet = rWrapper.FcFontSetCreate();
+-        rWrapper.FcFontSetAdd( pSet, pResult );
+-        if( pSet->nfont > 0 )
++        FcResult eEmbeddedBitmap = rWrapper.FcPatternGetBool(pResult,
++            FC_EMBEDDED_BITMAP, 0, &embitmap);
++        FcResult eAntialias = rWrapper.FcPatternGetBool(pResult,
++            FC_ANTIALIAS, 0, &antialias);
++        FcResult eAutoHint = rWrapper.FcPatternGetBool(pResult,
++            FC_AUTOHINT, 0, &autohint);
++        FcResult eHinting = rWrapper.FcPatternGetBool(pResult,
++            FC_HINTING, 0, &hinting);
++        /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger(pResult,
++            FC_HINT_STYLE, 0, &hintstyle);
++        rWrapper.FcPatternDestroy(pResult);
++
++        pOptions = new ImplFontOptions;
++
++        if( eEmbeddedBitmap == FcResultMatch )
++            pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
++        if( eAntialias == FcResultMatch )
++            pOptions->meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE;
++        if( eAutoHint == FcResultMatch )
++            pOptions->meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE;
++        if( eHinting == FcResultMatch )
++            pOptions->meHinting = hinting ? HINTING_TRUE : HINTING_FALSE;
++        switch (hintstyle)
+         {
+-            FcResult eEmbeddedBitmap = rWrapper.FcPatternGetBool(pSet->fonts[0],
+-                FC_EMBEDDED_BITMAP, 0, &embitmap);
+-            FcResult eAntialias = rWrapper.FcPatternGetBool(pSet->fonts[0],
+-                FC_ANTIALIAS, 0, &antialias);
+-            FcResult eAutoHint = rWrapper.FcPatternGetBool(pSet->fonts[0], 
+-                FC_AUTOHINT, 0, &autohint);
+-            FcResult eHinting = rWrapper.FcPatternGetBool(pSet->fonts[0], 
+-                FC_HINTING, 0, &hinting);
+-            /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger( pSet->fonts[0],
+-                FC_HINT_STYLE, 0, &hintstyle);
+-
+-            pOptions = new ImplFontOptions;
+-         
+-            if( eEmbeddedBitmap == FcResultMatch )
+-                pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
+-            if( eAntialias == FcResultMatch )
+-                pOptions->meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE;
+-            if( eAutoHint == FcResultMatch )
+-                pOptions->meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE;
+-            if( eHinting == FcResultMatch )
+-                pOptions->meHinting = hinting ? HINTING_TRUE : HINTING_FALSE;
+-            switch (hintstyle)
+-            {
+-                case FC_HINT_NONE:   pOptions->meHintStyle = HINT_NONE; break;
+-                case FC_HINT_SLIGHT: pOptions->meHintStyle = HINT_SLIGHT; break;
+-                case FC_HINT_MEDIUM: pOptions->meHintStyle = HINT_MEDIUM; break;
+-                default: // fall through
+-                case FC_HINT_FULL:   pOptions->meHintStyle = HINT_FULL; break;
+-            }
++            case FC_HINT_NONE:   pOptions->meHintStyle = HINT_NONE; break;
++            case FC_HINT_SLIGHT: pOptions->meHintStyle = HINT_SLIGHT; break;
++            case FC_HINT_MEDIUM: pOptions->meHintStyle = HINT_MEDIUM; break;
++            default: // fall through
++            case FC_HINT_FULL:   pOptions->meHintStyle = HINT_FULL; break;
+         }
+-        // info: destroying the pSet destroys pResult implicitly
+-        // since pResult was "added" to pSet
+-        rWrapper.FcFontSetDestroy( pSet );
+     }
+ 
+     // cleanup
+-- 
+1.7.4.1
+
diff --git a/0001-Related-rhbz-680460-reorganize-this-to-make-it-inher.patch b/0001-Related-rhbz-680460-reorganize-this-to-make-it-inher.patch
new file mode 100644
index 0000000..997f78e
--- /dev/null
+++ b/0001-Related-rhbz-680460-reorganize-this-to-make-it-inher.patch
@@ -0,0 +1,320 @@
+From d83bc4d9921afd31f1afddc52f39951bb686e60a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Thu, 10 Mar 2011 15:59:44 +0000
+Subject: [PATCH] Related: rhbz#680460 reorganize this to make it inheritable
+
+---
+ vcl/inc/vcl/fontmanager.hxx               |    2 +-
+ vcl/inc/vcl/glyphcache.hxx                |    5 +--
+ vcl/inc/vcl/impfont.hxx                   |   25 ++++++++++-----------
+ vcl/source/glyphs/gcach_ftyp.cxx          |   18 ++++++++++-----
+ vcl/source/glyphs/gcach_ftyp.hxx          |    4 ++-
+ vcl/source/glyphs/glyphcache.cxx          |    3 +-
+ vcl/unx/source/fontmanager/fontconfig.cxx |   32 ++++++++++++++--------------
+ vcl/unx/source/gdi/salgdi3.cxx            |   17 ++++++---------
+ 8 files changed, 55 insertions(+), 51 deletions(-)
+
+diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
+index 6c76eea..103cd92 100644
+--- a/vcl/inc/vcl/fontmanager.hxx
++++ b/vcl/inc/vcl/fontmanager.hxx
+@@ -733,7 +733,7 @@ public:
+     false else
+      */
+     bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
+-    bool getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*), ImplFontOptions& rResult ) const;
++    ImplFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*)) const;
+ 
+     rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes,
+         const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight,
+diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx
+index 8714697..1c03759 100644
+--- a/vcl/inc/vcl/glyphcache.hxx
++++ b/vcl/inc/vcl/glyphcache.hxx
+@@ -187,7 +187,7 @@ public:
+     virtual bool                TestFont() const            { return true; }
+     virtual void*               GetFtFace() const { return 0; }
+     virtual int                 GetLoadFlags() const { return 0; }
+-    virtual void                SetFontOptions( const ImplFontOptions&) {}
++    virtual void                SetFontOptions( const ImplFontOptions*) {}
+     virtual bool                NeedsArtificialBold() const { return false; }
+     virtual bool                NeedsArtificialItalic() const { return false; }
+ 
+@@ -266,9 +266,8 @@ class VCL_DLLPUBLIC ImplServerFontEntry : public ImplFontEntry
+ {
+ private:
+     ServerFont*    mpServerFont;
+-    ImplFontOptions maFontOptions;
++    ImplFontOptions* mpFontOptions;
+     bool           mbGotFontOptions;
+-    bool           mbValidFontOptions;
+ 
+ public:
+                    ImplServerFontEntry( ImplFontSelectData& );
+diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx
+index b7a0368..fa8a837 100644
+--- a/vcl/inc/vcl/impfont.hxx
++++ b/vcl/inc/vcl/impfont.hxx
+@@ -135,7 +135,7 @@ public:
+ };
+ 
+ // ------------------
+-// - ImplFontHints -
++// - ImplFontOptions -
+ // ------------------
+ 
+ class ImplFontOptions
+@@ -154,19 +154,18 @@ public:
+         meHinting(HINTING_DONTKNOW), 
+         meHintStyle(HINT_SLIGHT)
+     {}
+-    ImplFontOptions( FontEmbeddedBitmap eEmbeddedBitmap, FontAntiAlias eAntiAlias, 
+-        FontAutoHint eAutoHint, FontHinting eHinting, FontHintStyle eHintStyle) :
+-        meEmbeddedBitmap(eEmbeddedBitmap), 
+-        meAntiAlias(eAntiAlias), 
+-        meAutoHint(eAutoHint), 
+-        meHinting(eHinting), 
+-        meHintStyle(eHintStyle)
++    virtual ~ImplFontOptions()
+     {}
+-    FontAutoHint GetUseAutoHint() const { return meAutoHint; }
+-    FontHintStyle GetHintStyle() const { return meHintStyle; }
+-    bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
+-    bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
+-    bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
++    FontAutoHint GetUseAutoHint() const
++        { return meAutoHint; }
++    FontHintStyle GetHintStyle() const
++        { return meHintStyle; }
++    bool DontUseEmbeddedBitmaps() const
++        { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
++    bool DontUseAntiAlias() const
++        { return meAntiAlias == ANTIALIAS_FALSE; }
++    bool DontUseHinting() const
++        { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
+ };
+ 
+ // -------------------
+diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
+index 2db53a5..2236bad 100644
+--- a/vcl/source/glyphs/gcach_ftyp.cxx
++++ b/vcl/source/glyphs/gcach_ftyp.cxx
+@@ -768,6 +768,7 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn
+     mpFontInfo( pFI ),
+     maFaceFT( NULL ),
+     maSizeFT( NULL ),
++    mpFontOptions( NULL ),
+     mbFaceOk( false ),
+     maRecodeConverter( NULL ),
+     mpLayoutEngine( NULL )
+@@ -913,9 +914,14 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn
+         mnLoadFlags |= FT_LOAD_NO_BITMAP;
+ }
+ 
+-void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions)
++void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions)
+ {
+-    FontAutoHint eHint = rFontOptions.GetUseAutoHint();
++    mpFontOptions = pFontOptions;
++
++    if (!mpFontOptions)
++        return;
++
++    FontAutoHint eHint = mpFontOptions->GetUseAutoHint();
+     if( eHint == AUTOHINT_DONTKNOW )
+         eHint = mbUseGamma ? AUTOHINT_TRUE : AUTOHINT_FALSE;
+ 
+@@ -926,11 +932,11 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions)
+         mnLoadFlags |= FT_LOAD_NO_HINTING;
+     mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334#
+ 
+-    if( rFontOptions.DontUseAntiAlias() )
++    if( mpFontOptions->DontUseAntiAlias() )
+       mnPrioAntiAlias = 0;
+-    if( rFontOptions.DontUseEmbeddedBitmaps() )
++    if( mpFontOptions->DontUseEmbeddedBitmaps() )
+       mnPrioEmbedded = 0;
+-    if( rFontOptions.DontUseHinting() )
++    if( mpFontOptions->DontUseHinting() )
+       mnPrioAutoHint = 0;
+ 
+ #if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
+@@ -942,7 +948,7 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions)
+     if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103))
+     {
+        mnLoadFlags |= FT_LOAD_TARGET_NORMAL;
+-       switch( rFontOptions.GetHintStyle() )
++       switch( mpFontOptions->GetHintStyle() )
+        {
+            case HINT_NONE:
+                 mnLoadFlags |= FT_LOAD_NO_HINTING;
+diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
+index cf2284c..6069388 100644
+--- a/vcl/source/glyphs/gcach_ftyp.hxx
++++ b/vcl/source/glyphs/gcach_ftyp.hxx
+@@ -186,7 +186,7 @@ public:
+     virtual int                 GetFontFaceNum() const { return mpFontInfo->GetFaceNum(); }
+     virtual bool                TestFont() const;
+     virtual void*               GetFtFace() const;
+-    virtual void                SetFontOptions( const ImplFontOptions&);
++    virtual void                SetFontOptions( const ImplFontOptions*);
+     virtual int                 GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); }
+     virtual bool                NeedsArtificialBold() const { return mbArtBold; }
+     virtual bool                NeedsArtificialItalic() const { return mbArtItalic; }
+@@ -233,6 +233,8 @@ private:
+     FT_FaceRec_*                maFaceFT;
+     FT_SizeRec_*                maSizeFT;
+ 
++    const ImplFontOptions*      mpFontOptions;
++
+     bool                        mbFaceOk;
+     bool			mbArtItalic;
+     bool			mbArtBold;
+diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx
+index 8ad5a87..9668a50 100644
+--- a/vcl/source/glyphs/glyphcache.cxx
++++ b/vcl/source/glyphs/glyphcache.cxx
+@@ -522,8 +522,8 @@ bool ServerFont::IsGlyphInvisible( int nGlyphIndex )
+ ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD )
+ :   ImplFontEntry( rFSD )
+ ,   mpServerFont( NULL )
++,   mpFontOptions( NULL )
+ ,   mbGotFontOptions( false )
+-,   mbValidFontOptions( false )
+ {}
+ 
+ // -----------------------------------------------------------------------
+@@ -531,6 +531,7 @@ ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD )
+ ImplServerFontEntry::~ImplServerFontEntry()
+ {
+     // TODO: remove the ServerFont here instead of in the GlyphCache
++    delete mpFontOptions;
+ }
+ 
+ // =======================================================================
+diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx
+index 0dd5260..3c2f636 100644
+--- a/vcl/unx/source/fontmanager/fontconfig.cxx
++++ b/vcl/unx/source/fontmanager/fontconfig.cxx
+@@ -1093,17 +1093,17 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName,
+     return aName;
+ }
+ 
+-bool PrintFontManager::getFontOptions( 
+-    const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*),
+-    ImplFontOptions& rOptions) const
++ImplFontOptions* PrintFontManager::getFontOptions(
++    const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*)) const
+ {
+ #ifndef ENABLE_FONTCONFIG
+-    return false;
++    return NULL;
+ #else // ENABLE_FONTCONFIG
+     FontCfgWrapper& rWrapper = FontCfgWrapper::get();
+     if( ! rWrapper.isValid() )
+-        return false;
++        return NULL;
+ 
++    ImplFontOptions *pOptions = NULL;
+     FcConfig* pConfig = rWrapper.FcConfigGetCurrent();
+     FcPattern* pPattern = rWrapper.FcPatternCreate();
+ 
+@@ -1144,22 +1144,24 @@ bool PrintFontManager::getFontOptions(
+                 FC_HINTING, 0, &hinting);
+             /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger( pSet->fonts[0],
+                 FC_HINT_STYLE, 0, &hintstyle);
++
++            pOptions = new ImplFontOptions;
+          
+             if( eEmbeddedBitmap == FcResultMatch )
+-                rOptions.meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
++                pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
+             if( eAntialias == FcResultMatch )
+-                rOptions.meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE;
++                pOptions->meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE;
+             if( eAutoHint == FcResultMatch )
+-                rOptions.meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE;
++                pOptions->meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE;
+             if( eHinting == FcResultMatch )
+-                rOptions.meHinting = hinting ? HINTING_TRUE : HINTING_FALSE;
++                pOptions->meHinting = hinting ? HINTING_TRUE : HINTING_FALSE;
+             switch (hintstyle)
+             {
+-                case FC_HINT_NONE:   rOptions.meHintStyle = HINT_NONE; break;
+-                case FC_HINT_SLIGHT: rOptions.meHintStyle = HINT_SLIGHT; break;
+-                case FC_HINT_MEDIUM: rOptions.meHintStyle = HINT_MEDIUM; break;
++                case FC_HINT_NONE:   pOptions->meHintStyle = HINT_NONE; break;
++                case FC_HINT_SLIGHT: pOptions->meHintStyle = HINT_SLIGHT; break;
++                case FC_HINT_MEDIUM: pOptions->meHintStyle = HINT_MEDIUM; break;
+                 default: // fall through
+-                case FC_HINT_FULL:   rOptions.meHintStyle = HINT_FULL; break;
++                case FC_HINT_FULL:   pOptions->meHintStyle = HINT_FULL; break;
+             }
+         }
+         // info: destroying the pSet destroys pResult implicitly
+@@ -1170,9 +1172,7 @@ bool PrintFontManager::getFontOptions(
+     // cleanup
+     rWrapper.FcPatternDestroy( pPattern );
+ 
+-    // TODO: return true only if non-default font options are set
+-    const bool bOK = (pResult != NULL);
+-    return bOK;
++    return pOptions;
+ #endif
+ }
+ 
+diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
+index 9834028..6de93fe 100644
+--- a/vcl/unx/source/gdi/salgdi3.cxx
++++ b/vcl/unx/source/gdi/salgdi3.cxx
+@@ -632,22 +632,21 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev
+     return false;
+ }
+ 
++ImplFontOptions* GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize);
++
+ void ImplServerFontEntry::HandleFontOptions( void )
+ {
+-    bool GetFCFontOptions( const ImplFontAttributes&, int nSize, ImplFontOptions& );
+-
+     if( !mpServerFont )
+         return;
+     if( !mbGotFontOptions )
+     {
+         // get and cache the font options
+         mbGotFontOptions = true;
+-        mbValidFontOptions = GetFCFontOptions( *maFontSelData.mpFontData,
+-            maFontSelData.mnHeight, maFontOptions );
++        mpFontOptions = GetFCFontOptions( *maFontSelData.mpFontData,
++            maFontSelData.mnHeight );
+     }
+     // apply the font options
+-    if( mbValidFontOptions )
+-        mpServerFont->SetFontOptions( maFontOptions );
++    mpServerFont->SetFontOptions( mpFontOptions );
+ }
+ 
+ //--------------------------------------------------------------------------
+@@ -1636,8 +1635,7 @@ void cairosubcallback( void* pPattern )
+     rCairo.ft_font_options_substitute( pFontOptions, pPattern );
+ }
+ 
+-bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize,
+-    ImplFontOptions& rFontOptions)
++ImplFontOptions* GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize)
+ {
+     // TODO: get rid of these insane enum-conversions
+     // e.g. by using the classic vclenum values inside VCL
+@@ -1734,8 +1732,7 @@ bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize,
+     }
+ 
+     const psp::PrintFontManager& rPFM = psp::PrintFontManager::get();
+-    bool bOK = rPFM.getFontOptions( aInfo, nSize, cairosubcallback, rFontOptions);
+-    return bOK;
++    return rPFM.getFontOptions(aInfo, nSize, cairosubcallback);
+ }
+ 
+ // ----------------------------------------------------------------------------
+-- 
+1.7.4.1
+
diff --git a/0001-Resolves-rhbz-680460-honour-lcdfilter-subpixeling-et.patch b/0001-Resolves-rhbz-680460-honour-lcdfilter-subpixeling-et.patch
new file mode 100644
index 0000000..3f94dfe
--- /dev/null
+++ b/0001-Resolves-rhbz-680460-honour-lcdfilter-subpixeling-et.patch
@@ -0,0 +1,226 @@
+From 5aab60551b825b3ad283f19263f3ce549c725055 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Wed, 16 Mar 2011 15:47:14 +0000
+Subject: [PATCH] Resolves: rhbz#680460 honour lcdfilter, subpixeling etc.
+
+---
+ vcl/inc/vcl/glyphcache.hxx                |    1 +
+ vcl/inc/vcl/impfont.hxx                   |    2 +
+ vcl/source/glyphs/gcach_ftyp.cxx          |    5 +++
+ vcl/source/glyphs/gcach_ftyp.hxx          |    1 +
+ vcl/unx/source/fontmanager/fontconfig.cxx |   41 +++++++++++++++++++++++++---
+ vcl/unx/source/gdi/salgdi3.cxx            |   20 ++++++++++----
+ 6 files changed, 59 insertions(+), 11 deletions(-)
+
+diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx
+index 1c03759..035fd5c 100644
+--- a/vcl/inc/vcl/glyphcache.hxx
++++ b/vcl/inc/vcl/glyphcache.hxx
+@@ -188,6 +188,7 @@ public:
+     virtual void*               GetFtFace() const { return 0; }
+     virtual int                 GetLoadFlags() const { return 0; }
+     virtual void                SetFontOptions( const ImplFontOptions*) {}
++    virtual const ImplFontOptions* GetFontOptions() const { return 0; }
+     virtual bool                NeedsArtificialBold() const { return false; }
+     virtual bool                NeedsArtificialItalic() const { return false; }
+ 
+diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx
+index fa8a837..ed9c35c 100644
+--- a/vcl/inc/vcl/impfont.hxx
++++ b/vcl/inc/vcl/impfont.hxx
+@@ -166,6 +166,8 @@ public:
+         { return meAntiAlias == ANTIALIAS_FALSE; }
+     bool DontUseHinting() const
+         { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
++    virtual void *GetPattern(void * /*pFace*/) const
++        { return NULL; }
+ };
+ 
+ // -------------------
+diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
+index a6a13da..8c46009 100644
+--- a/vcl/source/glyphs/gcach_ftyp.cxx
++++ b/vcl/source/glyphs/gcach_ftyp.cxx
+@@ -967,6 +967,11 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions)
+         mnLoadFlags |= FT_LOAD_NO_BITMAP;
+ }
+ 
++const ImplFontOptions* FreetypeServerFont::GetFontOptions() const
++{
++    return mpFontOptions;
++}
++
+ // -----------------------------------------------------------------------
+ 
+ bool FreetypeServerFont::TestFont() const
+diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
+index 6069388..1df8253 100644
+--- a/vcl/source/glyphs/gcach_ftyp.hxx
++++ b/vcl/source/glyphs/gcach_ftyp.hxx
+@@ -187,6 +187,7 @@ public:
+     virtual bool                TestFont() const;
+     virtual void*               GetFtFace() const;
+     virtual void                SetFontOptions( const ImplFontOptions*);
++    virtual const ImplFontOptions*    GetFontOptions() const;
+     virtual int                 GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); }
+     virtual bool                NeedsArtificialBold() const { return mbArtBold; }
+     virtual bool                NeedsArtificialItalic() const { return mbArtItalic; }
+diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx
+index 92632c7..7b792d3 100644
+--- a/vcl/unx/source/fontmanager/fontconfig.cxx
++++ b/vcl/unx/source/fontmanager/fontconfig.cxx
+@@ -56,6 +56,9 @@ using namespace psp;
+         #define FC_HINT_MEDIUM 2
+         #define FC_HINT_FULL   3
+     #endif
++    #ifndef FC_FT_FACE
++        #define FC_FT_FACE "ftface"
++    #endif
+ #else
+     typedef void FcConfig;
+     typedef void FcObjectSet;
+@@ -141,6 +144,7 @@ class FontCfgWrapper
+     FcBool                    (*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*);
+     FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
+     FT_UInt         (*m_pFcFreeTypeCharIndex)(FT_Face,FcChar32);
++    FcBool          (*m_pFcPatternAddFTFace)(FcPattern*,const char*,const FT_Face);
+ 
+     oslGenericFunction loadSymbol( const char* );
+     void addFontSet( FcSetName );
+@@ -257,10 +261,14 @@ public:
+     { return m_pFcPatternAddBool( pPattern, pObject, nValue ); }
+     FcBool FcPatternAddCharSet(FcPattern* pPattern,const char* pObject,const FcCharSet*pCharSet)
+     { return m_pFcPatternAddCharSet(pPattern,pObject,pCharSet); }
+-
+     FT_UInt FcFreeTypeCharIndex( FT_Face face, FcChar32 ucs4 )
+     { return m_pFcFreeTypeCharIndex ? m_pFcFreeTypeCharIndex( face, ucs4 ) : 0; }
+-
++    FcBool FcPatternAddFTFace( FcPattern* pPattern, const char* pObject, const FT_Face nValue )
++    {
++        return m_pFcPatternAddFTFace
++            ? m_pFcPatternAddFTFace( pPattern, pObject, nValue )
++            : false;
++    }
+ public:
+     FcResult LocalizedElementFromPattern(FcPattern* pPattern, FcChar8 **family,
+                                          const char *elementtype, const char *elementlangtype);
+@@ -372,6 +380,8 @@ FontCfgWrapper::FontCfgWrapper()
+         loadSymbol( "FcPatternAddString" );
+     m_pFcFreeTypeCharIndex = (FT_UInt(*)(FT_Face,FcChar32))
+         loadSymbol( "FcFreeTypeCharIndex" );
++    m_pFcPatternAddFTFace = (FcBool(*)(FcPattern*,const char*,const FT_Face))
++        loadSymbol( "FcPatternAddFTFace" );
+ 
+     m_nFcVersion = FcGetVersion();
+ #if (OSL_DEBUG_LEVEL > 1)
+@@ -1093,6 +1103,26 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName,
+     return aName;
+ }
+ 
++class FontConfigFontOptions : public ImplFontOptions
++{
++public:
++    FontConfigFontOptions() : mpPattern(0) {}
++    ~FontConfigFontOptions()
++    {
++        FontCfgWrapper& rWrapper = FontCfgWrapper::get();
++        if( rWrapper.isValid() )
++            rWrapper.FcPatternDestroy( mpPattern );
++    }
++    virtual void *GetPattern(void * face) const
++    {
++        FontCfgWrapper& rWrapper = FontCfgWrapper::get();
++        if( rWrapper.isValid() )
++            rWrapper.FcPatternAddFTFace(mpPattern, FC_FT_FACE, static_cast<FT_Face>(face));
++        return mpPattern;
++    }
++    FcPattern* mpPattern;
++};
++
+ ImplFontOptions* PrintFontManager::getFontOptions(
+     const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*)) const
+ {
+@@ -1103,7 +1133,7 @@ ImplFontOptions* PrintFontManager::getFontOptions(
+     if( ! rWrapper.isValid() )
+         return NULL;
+ 
+-    ImplFontOptions *pOptions = NULL;
++    FontConfigFontOptions* pOptions = NULL;
+     FcConfig* pConfig = rWrapper.FcConfigGetCurrent();
+     FcPattern* pPattern = rWrapper.FcPatternCreate();
+ 
+@@ -1140,9 +1170,10 @@ ImplFontOptions* PrintFontManager::getFontOptions(
+             FC_HINTING, 0, &hinting);
+         /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger(pResult,
+             FC_HINT_STYLE, 0, &hintstyle);
+-        rWrapper.FcPatternDestroy(pResult);
+ 
+-        pOptions = new ImplFontOptions;
++        pOptions = new FontConfigFontOptions;
++
++        pOptions->mpPattern = pResult;
+ 
+         if( eEmbeddedBitmap == FcResultMatch )
+             pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
+diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
+index 6de93fe..a0bef90 100644
+--- a/vcl/unx/source/gdi/salgdi3.cxx
++++ b/vcl/unx/source/gdi/salgdi3.cxx
+@@ -89,7 +89,6 @@ struct cairo_surface_t;
+ struct cairo_t;
+ struct cairo_font_face_t;
+ typedef void* FT_Face;
+-typedef void* FcPattern;
+ struct cairo_matrix_t {
+     double xx; double yx;
+     double xy; double yy;
+@@ -742,7 +741,7 @@ private:
+     void (*mp_clip)(cairo_t*);
+     void (*mp_rectangle)(cairo_t*, double, double, double, double);
+     cairo_font_face_t * (*mp_ft_font_face_create_for_ft_face)(FT_Face, int);
+-    cairo_font_face_t * (*mp_ft_font_face_create_for_pattern)(FcPattern*);
++    cairo_font_face_t * (*mp_ft_font_face_create_for_pattern)(void*);
+     void (*mp_set_font_face)(cairo_t *, cairo_font_face_t *);
+     void (*mp_font_face_destroy)(cairo_font_face_t *);
+     void (*mp_matrix_init_identity)(cairo_matrix_t *);
+@@ -772,8 +771,12 @@ public:
+         { (*mp_rectangle)(cr, x, y, width, height); }
+     cairo_font_face_t* ft_font_face_create_for_ft_face(FT_Face face, int load_flags)
+         { return (*mp_ft_font_face_create_for_ft_face)(face, load_flags); }
+-    cairo_font_face_t* ft_font_face_create_for_pattern(FcPattern *pattern)
+-        { return (*mp_ft_font_face_create_for_pattern)(pattern); }
++    cairo_font_face_t* ft_font_face_create_for_pattern(void *pattern)
++    {
++        return mp_ft_font_face_create_for_pattern
++            ? (*mp_ft_font_face_create_for_pattern)(pattern)
++            : NULL;
++    }
+     void set_font_face(cairo_t *cr, cairo_font_face_t *font_face)
+         { (*mp_set_font_face)(cr, font_face); }
+     void font_face_destroy(cairo_font_face_t *font_face)
+@@ -847,7 +850,7 @@ CairoWrapper::CairoWrapper()
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_rectangle" );
+     mp_ft_font_face_create_for_ft_face = (cairo_font_face_t * (*)(FT_Face, int))
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_ft_face" );
+-    mp_ft_font_face_create_for_pattern = (cairo_font_face_t * (*)(FcPattern*))
++    mp_ft_font_face_create_for_pattern = (cairo_font_face_t * (*)(void*))
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_pattern" );
+     mp_set_font_face = (void (*)(cairo_t *, cairo_font_face_t *))
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_set_font_face" );
+@@ -1016,7 +1019,12 @@ void X11SalGraphics::DrawCairoAAFontString( const ServerFontLayout& rLayout )
+     font_face = (cairo_font_face_t*)m_aCairoFontsCache.FindCachedFont(pId);
+     if (!font_face)
+     {
+-        font_face = rCairo.ft_font_face_create_for_ft_face(pId, rFont.GetLoadFlags());
++        const ImplFontOptions *pOptions = rFont.GetFontOptions();
++        void *pPattern = pOptions ? pOptions->GetPattern(pId) : NULL;
++        if (pPattern)
++            font_face = rCairo.ft_font_face_create_for_pattern(pPattern);
++        if (!font_face)
++            font_face = rCairo.ft_font_face_create_for_ft_face(pId, rFont.GetLoadFlags());
+         m_aCairoFontsCache.CacheFont(font_face, pId);
+     }
+ 
+-- 
+1.7.4.1
+
diff --git a/0001-add-cairo_ft_font_face_create_for_pattern-wrapper.patch b/0001-add-cairo_ft_font_face_create_for_pattern-wrapper.patch
new file mode 100644
index 0000000..a378635
--- /dev/null
+++ b/0001-add-cairo_ft_font_face_create_for_pattern-wrapper.patch
@@ -0,0 +1,50 @@
+From 28e6caab0a9c04b306f723fb3390332f5ef94a61 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Thu, 10 Mar 2011 13:54:58 +0000
+Subject: [PATCH] add cairo_ft_font_face_create_for_pattern wrapper
+
+---
+ vcl/unx/source/gdi/salgdi3.cxx |    6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
+index 3056f92..9834028 100644
+--- a/vcl/unx/source/gdi/salgdi3.cxx
++++ b/vcl/unx/source/gdi/salgdi3.cxx
+@@ -89,6 +89,7 @@ struct cairo_surface_t;
+ struct cairo_t;
+ struct cairo_font_face_t;
+ typedef void* FT_Face;
++typedef void* FcPattern;
+ struct cairo_matrix_t {
+     double xx; double yx;
+     double xy; double yy;
+@@ -742,6 +743,7 @@ private:
+     void (*mp_clip)(cairo_t*);
+     void (*mp_rectangle)(cairo_t*, double, double, double, double);
+     cairo_font_face_t * (*mp_ft_font_face_create_for_ft_face)(FT_Face, int);
++    cairo_font_face_t * (*mp_ft_font_face_create_for_pattern)(FcPattern*);
+     void (*mp_set_font_face)(cairo_t *, cairo_font_face_t *);
+     void (*mp_font_face_destroy)(cairo_font_face_t *);
+     void (*mp_matrix_init_identity)(cairo_matrix_t *);
+@@ -771,6 +773,8 @@ public:
+         { (*mp_rectangle)(cr, x, y, width, height); }
+     cairo_font_face_t* ft_font_face_create_for_ft_face(FT_Face face, int load_flags)
+         { return (*mp_ft_font_face_create_for_ft_face)(face, load_flags); }
++    cairo_font_face_t* ft_font_face_create_for_pattern(FcPattern *pattern)
++        { return (*mp_ft_font_face_create_for_pattern)(pattern); }
+     void set_font_face(cairo_t *cr, cairo_font_face_t *font_face)
+         { (*mp_set_font_face)(cr, font_face); }
+     void font_face_destroy(cairo_font_face_t *font_face)
+@@ -844,6 +848,8 @@ CairoWrapper::CairoWrapper()
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_rectangle" );
+     mp_ft_font_face_create_for_ft_face = (cairo_font_face_t * (*)(FT_Face, int))
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_ft_face" );
++    mp_ft_font_face_create_for_pattern = (cairo_font_face_t * (*)(FcPattern*))
++        osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_pattern" );
+     mp_set_font_face = (void (*)(cairo_t *, cairo_font_face_t *))
+         osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_set_font_face" );
+     mp_font_face_destroy = (void (*)(cairo_font_face_t *))
+-- 
+1.7.4.1
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 45fd41e..75a15a3 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -28,7 +28,7 @@
 Summary:        Free Software Productivity Suite
 Name:           libreoffice
 Version:        3.3.1.2
-Release:        9%{?dist}
+Release:        10%{?dist}
 License:        LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and (CDDL or GPLv2) and Public Domain
 Group:          Applications/Productivity
 URL:            http://www.documentfoundation.org/develop
@@ -124,6 +124,10 @@ Patch36: 0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch
 Patch37: 0001-Related-rhbz-684477-make-sure-this-is-thread-safe.patch
 Patch38: 0001-Resolves-rhbz-684620-crash-with-NULL-pTableBox.patch
 Patch39: libreoffice-fdo33947.sd.print.crash.patch
+Patch40: 0001-add-cairo_ft_font_face_create_for_pattern-wrapper.patch
+Patch41: 0001-Related-rhbz-680460-reorganize-this-to-make-it-inher.patch
+Patch42: 0001-Related-rhbz-680460-don-t-bother-with-an-interim-Fon.patch
+Patch43: 0001-Resolves-rhbz-680460-honour-lcdfilter-subpixeling-et.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -766,6 +770,11 @@ mv -f redhat.soc extras/source/palettes/standard.soc
 %patch37 -p1 -b .rhbz684477-make-sure-this-is-thread-safe.patch
 %patch38 -p1 -b .rhbz684620-crash-with-NULL-pTableBox.patch
 %patch39 -p1 -b .fdo33947.sd.print.crash.patch
+%patch40 -p1 -b .add-cairo_ft_font_face_create_for_pattern-wrapper.patch
+%patch41 -p1 -b .rhbz680460-reorganize-this-to-make-it-inher.patch
+%patch42 -p1 -b .rhbz680460-don-t-bother-with-an-interim-Fon.patch
+%patch43 -p1 -b .rhbz680460-honour-lcdfilter-subpixeling-et.patch
+
 touch scripting/source/pyprov/delzip
 touch scripting/util/provider/beanshell/delzip
 touch scripting/util/provider/javascript/delzip
@@ -2111,6 +2120,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
 %{basisinstdir}/program/kde-open-url
 
 %changelog
+* Wed Mar 16 2011 Caolán McNamara <caolanm at redhat.com> 3.3.1.2-10
+- Resolves: rhbz#680460 honour lcdfilter and subpixeling
+
 * Tue Mar 15 2011 Caolán McNamara <caolanm at redhat.com> 3.3.1.2-9
 - Resolves: fdo#33947 sd print crash
 


More information about the scm-commits mailing list