[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - 3 commits - include/vcl svx/source sw/qa vcl/headless vcl/inc vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 28 13:35:18 UTC 2018


 include/vcl/settings.hxx                  |    3 +++
 svx/source/unodraw/UnoGraphicExporter.cxx |   14 ++++++++++++++
 sw/qa/extras/htmlexport/htmlexport.cxx    |   11 +++++++++++
 vcl/headless/svptext.cxx                  |    2 +-
 vcl/inc/textrender.hxx                    |    2 +-
 vcl/inc/unx/cairotextrender.hxx           |    2 +-
 vcl/source/app/settings.cxx               |   19 +++++++++++++++++++
 vcl/unx/generic/gdi/cairotextrender.cxx   |   17 +++++++++++++++--
 vcl/unx/generic/gdi/font.cxx              |    2 +-
 9 files changed, 66 insertions(+), 6 deletions(-)

New commits:
commit f114a573a782a265539ac75137aa80bba33560c2
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Fri Jul 27 17:40:31 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Tue Aug 28 14:56:29 2018 +0200

    tdf#118966 vcl: add a flag to determine if AA of fonts is used from the system
    
    This is on by default (as there are loads of vcl users who expect font
    AA working even if the default is off and they don't enable it), but the
    svx UnoGraphicExporter disables it to make everyone happy.
    
    The reason in practice AA was on by default is that the gtk backend uses
    the system settings in GtkInstance::GetCairoFontOptions() (and not the
    AA setting from the UI), and lclGetSystemTextAntiAliasMode() does the
    same on Windows (at least in the direct write case). So now these
    defaults again have higher priority than leaving the vcl-level default
    unchanged.
    
    Reviewed-on: https://gerrit.libreoffice.org/58199
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit e6538f5bdd876911ea30f84a6512c03908e620fd)
    
    Conflicts:
            svx/source/unodraw/UnoGraphicExporter.cxx
            vcl/source/app/settings.cxx
    
    Change-Id: I81267c0b036211525ac02d3282fa89d75510f4a8

diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 097605e7c251..67ba3cf5185b 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -409,6 +409,9 @@ public:
     void                            SetUseSystemUIFonts( bool bUseSystemUIFonts );
     bool                            GetUseSystemUIFonts() const;
 
+    void SetUseFontAAFromSystem(bool bUseFontAAFromSystem);
+    bool GetUseFontAAFromSystem() const;
+
     void                            SetUseFlatBorders( bool bUseFlatBorders );
     bool                            GetUseFlatBorders() const;
 
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index 2d9bd17bfb67..d28bc91f5841 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -1023,12 +1023,26 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
 
     SvtOptionsDrawinglayer aOptions;
     bool bAntiAliasing = aOptions.IsAntiAliasing();
+    AllSettings aAllSettings = Application::GetSettings();
+    StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
+    bool bUseFontAAFromSystem = aStyleSettings.GetUseFontAAFromSystem();
     if (aSettings.meAntiAliasing != TRISTATE_INDET)
+    {
         // This is safe to do globally as we own the solar mutex.
         aOptions.SetAntiAliasing(aSettings.meAntiAliasing == TRISTATE_TRUE);
+        // Opt in to have AA affect font rendering as well.
+        aStyleSettings.SetUseFontAAFromSystem(false);
+        aAllSettings.SetStyleSettings(aStyleSettings);
+        Application::SetSettings(aAllSettings);
+    }
     sal_uInt16 nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? GRFILTER_OK : GRFILTER_FILTERERROR;
     if (aSettings.meAntiAliasing != TRISTATE_INDET)
+    {
         aOptions.SetAntiAliasing(bAntiAliasing);
+        aStyleSettings.SetUseFontAAFromSystem(bUseFontAAFromSystem);
+        aAllSettings.SetStyleSettings(aStyleSettings);
+        Application::SetSettings(aAllSettings);
+    }
 
     if( nStatus == GRFILTER_OK )
     {
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 4887a283977b..83139fe648a7 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -171,6 +171,11 @@ struct ImplStyleData
     StyleSettingsOptions            mnOptions;
     bool                            mbHighContrast;
     bool                            mbUseSystemUIFonts;
+    /**
+     * Disabling AA doesn't actually disable AA of fonts, instead it is taken
+     * from system settings.
+     */
+    bool mbUseFontAAFromSystem;
     bool                            mbAutoMnemonic;
     TriState                        meUseImagesInMenus;
     bool                            mnUseFlatBorders;
@@ -647,6 +652,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
     mnOptions                   = rData.mnOptions;
     mbHighContrast              = rData.mbHighContrast;
     mbUseSystemUIFonts          = rData.mbUseSystemUIFonts;
+    mbUseFontAAFromSystem       = rData.mbUseFontAAFromSystem;
     mnUseFlatBorders            = rData.mnUseFlatBorders;
     mnUseFlatMenus              = rData.mnUseFlatMenus;
     mbAutoMnemonic              = rData.mbAutoMnemonic;
@@ -755,6 +761,7 @@ void ImplStyleData::SetStandardStyles()
     mnTearOffTitleHeight        = 8;
     mbHighContrast              = false;
     mbUseSystemUIFonts          = true;
+    mbUseFontAAFromSystem = true;
     mnUseFlatBorders            = false;
     mnUseFlatMenus              = false;
     mbPreferredUseImagesInMenus = true;
@@ -1435,6 +1442,17 @@ StyleSettings::GetUseSystemUIFonts() const
     return mxData->mbUseSystemUIFonts;
 }
 
+void StyleSettings::SetUseFontAAFromSystem(bool bUseFontAAFromSystem)
+{
+    CopyData();
+    mxData->mbUseFontAAFromSystem = bUseFontAAFromSystem;
+}
+
+bool StyleSettings::GetUseFontAAFromSystem() const
+{
+    return mxData->mbUseFontAAFromSystem;
+}
+
 void
 StyleSettings::SetUseFlatBorders( bool bUseFlatBorders )
 {
@@ -2294,6 +2312,7 @@ bool StyleSettings::operator ==( const StyleSettings& rSet ) const
          (mxData->mnAntialiasedMin          == rSet.mxData->mnAntialiasedMin)           &&
          (mxData->mbHighContrast            == rSet.mxData->mbHighContrast)             &&
          (mxData->mbUseSystemUIFonts        == rSet.mxData->mbUseSystemUIFonts)         &&
+         (mxData->mbUseFontAAFromSystem     == rSet.mxData->mbUseFontAAFromSystem)      &&
          (mxData->mnUseFlatBorders          == rSet.mxData->mnUseFlatBorders)           &&
          (mxData->mnUseFlatMenus            == rSet.mxData->mnUseFlatMenus)             &&
          (mxData->maFaceColor               == rSet.mxData->maFaceColor)                &&
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index bb2a879539d9..1cc2e08205b8 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -214,8 +214,11 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout, const SalGr
     ImplSVData* pSVData = ImplGetSVData();
     if (const cairo_font_options_t* pFontOptions = pSVData->mpDefInst->GetCairoFontOptions())
     {
-        if (!rGraphics.getAntiAliasB2DDraw())
+        const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+        if (!rStyleSettings.GetUseFontAAFromSystem() && !rGraphics.getAntiAliasB2DDraw())
         {
+            // Disable font AA in case global AA setting is supposed to affect
+            // font rendering (not the default) and AA is disabled.
             cairo_font_options_t* pOptions = cairo_font_options_copy(pFontOptions);
             cairo_font_options_set_antialias(pOptions, CAIRO_ANTIALIAS_NONE);
             cairo_set_font_options(cr, pOptions);
commit b01d9664434ce84c33d2d50b9f9c1fd543633330
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Jul 26 09:06:21 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Tue Aug 28 14:47:46 2018 +0200

    vcl cairo text renderer: support non-AA text
    
    Non-AA lines were already working, but text was always anti-aliased.
    
    (Use-case is reference bitmaps in a testsuite, where AA just makes it
    harder to determine if the expected and actual rendering output match.)
    
    Reviewed-on: https://gerrit.libreoffice.org/58035
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit 3ecd8f19a91ed7141304a2080fb11612b5ff30b3)
    
    Conflicts:
            vcl/inc/textrender.hxx
            vcl/inc/unx/cairotextrender.hxx
            vcl/unx/generic/gdi/cairotextrender.cxx
    
    Change-Id: I7c5ab4c80675e1a523d67b71f3cd3cbc9c6416c3

diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index 3751a0f217e7..be71233fdf3f 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -108,7 +108,7 @@ SalLayout* SvpSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
 
 void SvpSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
 {
-    m_aTextRenderImpl.DrawTextLayout(rLayout);
+    m_aTextRenderImpl.DrawTextLayout(rLayout, *this);
 }
 
 void SvpSalGraphics::SetTextColor( SalColor nSalColor )
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index ebcb7a081f7c..dce8d03b5bb5 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -62,7 +62,7 @@ public:
     virtual bool                    GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) = 0;
     virtual bool                    GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) = 0;
     virtual SalLayout*              GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0;
-    virtual void                    DrawTextLayout(const CommonSalLayout&) = 0;
+    virtual void                    DrawTextLayout(const CommonSalLayout&, const SalGraphics&) = 0;
 #if ENABLE_CAIRO_CANVAS
     virtual SystemFontData          GetSysFontData( int nFallbackLevel ) const = 0;
 #endif // ENABLE_CAIRO_CANVAS
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 2e6d1a57d63e..e39aa8fa6660 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -78,7 +78,7 @@ public:
     virtual bool                GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
     virtual bool                GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
     virtual SalLayout*          GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
-    virtual void                DrawTextLayout(const CommonSalLayout&) override;
+    virtual void                DrawTextLayout(const CommonSalLayout&, const SalGraphics&) override;
 #if ENABLE_CAIRO_CANVAS
     virtual SystemFontData      GetSysFontData( int nFallbackLevel ) const override;
 #endif
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index c1b4ff193679..bb2a879539d9 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -164,7 +164,7 @@ namespace
     }
 }
 
-void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout)
+void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout, const SalGraphics& rGraphics)
 {
     const FreetypeFont& rFont = rLayout.getFontData();
 
@@ -213,7 +213,17 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout)
 
     ImplSVData* pSVData = ImplGetSVData();
     if (const cairo_font_options_t* pFontOptions = pSVData->mpDefInst->GetCairoFontOptions())
-        cairo_set_font_options(cr, pFontOptions);
+    {
+        if (!rGraphics.getAntiAliasB2DDraw())
+        {
+            cairo_font_options_t* pOptions = cairo_font_options_copy(pFontOptions);
+            cairo_font_options_set_antialias(pOptions, CAIRO_ANTIALIAS_NONE);
+            cairo_set_font_options(cr, pOptions);
+            cairo_font_options_destroy(pOptions);
+        }
+        else
+            cairo_set_font_options(cr, pFontOptions);
+    }
 
     double nDX, nDY;
     getSurfaceOffset(nDX, nDY);
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 2e8dd081cf35..5f535e1f1423 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -55,7 +55,7 @@ X11SalGraphics::GetFontGC()
 
 void X11SalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
 {
-    mxTextRenderImpl->DrawTextLayout(rLayout);
+    mxTextRenderImpl->DrawTextLayout(rLayout, *this);
 }
 
 const FontCharMapRef X11SalGraphics::GetFontCharMap() const
commit d88285bc2d2f97d1e673051f4730dd0f30b4a0de
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Jul 18 11:35:20 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Tue Aug 28 14:42:40 2018 +0200

    sw HTML export: fix writing transparent images
    
    It is possible ImpGraphic::ImplSetPrepared() should handle this
    directly, though.
    
    Reviewed-on: https://gerrit.libreoffice.org/57623
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 6af1637d0cf85566ca8482cc284669c4968ae977)
    
    Conflicts:
            sw/qa/extras/htmlexport/htmlexport.cxx
            sw/source/filter/html/htmlflywriter.cxx
    
    Change-Id: I1a020a45eaded140493d7207f8e0e0dfe551cc88

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 9f2accc8482f..ac4a7e825de9 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -589,6 +589,17 @@ DECLARE_HTMLEXPORT_TEST(testList, "list.html")
     CPPUNIT_ASSERT(aStream.indexOf("<li>") != -1);
 }
 
+DECLARE_HTMLEXPORT_TEST(testTransparentImage, "transparent-image.odt")
+{
+    htmlDocPtr pDoc = parseHtml(maTempFile);
+    CPPUNIT_ASSERT(pDoc);
+
+    OUString aSource = getXPath(pDoc, "/html/body/p/img", "src");
+    OUString aMessage = "src attribute is: " + aSource;
+    // This was a jpeg, transparency was lost.
+    CPPUNIT_ASSERT_MESSAGE(aMessage.toUtf8().getStr(), aSource.endsWith(".gif"));
+}
+
 DECLARE_HTMLEXPORT_TEST(testTransparentImageReqIf, "transparent-image.odt")
 {
     SvMemoryStream aStream;


More information about the Libreoffice-commits mailing list