[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - svx/source vcl/inc vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 17 08:07:20 UTC 2019


 svx/source/sdr/contact/viewcontactofsdrpathobj.cxx |   10 +++++++---
 vcl/inc/unx/glyphcache.hxx                         |    6 ++++++
 vcl/unx/generic/gdi/cairotextrender.cxx            |   20 ++++++++++++++++++++
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx     |   20 ++++++++++++++++++++
 4 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit 628c3e8eae7985aa5dfb3467c66246c8ff9a4315
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 4 10:57:06 2019 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Sep 17 10:06:54 2019 +0200

    tdf#127189 FreeType <= 2.8 will fail to render stretched horizontal brace...
    
    glyphs in starmath at a fairly low stretch ratio. The failure will set
    CAIRO_STATUS_FREETYPE_ERROR on the surface which cannot be cleared, so all
    further painting to the surface fails.
    
    This appears fixed in 2.9 with
    https://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=91015cb41d8f56777f93394f5a60914bc0c0f330
    "Improve complex rendering at high ppem"
    
    Change-Id: I8cbf8347ccd29beda4057b14f2e68678f6030bf4
    Reviewed-on: https://gerrit.libreoffice.org/78590
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/79032
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 59811d6a144a..26f0f8bced22 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -117,6 +117,12 @@ public:
 
     FreetypeFontInstance*   GetFontInstance() const { return mpFontInstance.get(); }
 
+    // tdf#127189 FreeType <= 2.8 will fail to render stretched horizontal brace glyphs
+    // in starmath at a fairly low stretch ratio. This appears fixed in 2.9 with
+    // https://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=91015cb41d8f56777f93394f5a60914bc0c0f330
+    // "Improve complex rendering at high ppem"
+    static bool             AlmostHorizontalDrainsRenderingPool();
+
 private:
     friend class GlyphCache;
     friend class FreetypeFontInstance;
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index c8956d02226b..deb956dbb82d 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -205,6 +205,22 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
     if (nWidth == 0 || nHeight == 0)
         return;
 
+    int nRatio = nWidth * 10 / nHeight;
+    if (nRatio > 100 && rFSD.maTargetName == "OpenSymbol" && FreetypeFont::AlmostHorizontalDrainsRenderingPool())
+    {
+        // tdf#127189 FreeType <= 2.8 will fail to render stretched horizontal
+        // brace glyphs in starmath at a fairly low stretch ratio. The failure
+        // will set CAIRO_STATUS_FREETYPE_ERROR on the surface which cannot be
+        // cleared, so all further painting to the surface fails.
+
+        // This appears fixed in >= freetype 2.9
+
+        // Restrict this bodge to a stretch ratio > ~10 of the OpenSymbol font
+        // where it has been seen in practice.
+        SAL_WARN("vcl", "rendering text would fail with stretch ratio of: " << nRatio << ", with FreeType <= 2.8");
+        return;
+    }
+
     /*
      * It might be ideal to cache surface and cairo context between calls and
      * only destroy it when the drawable changes, but to do that we need to at
@@ -331,6 +347,10 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
 
         cairo_set_font_matrix(cr, &m);
         cairo_show_glyphs(cr, &cairo_glyphs[nStartIndex], nLen);
+        if (cairo_status(cr) != CAIRO_STATUS_SUCCESS)
+        {
+            SAL_WARN("vcl", "rendering text failed with stretch ratio of: " << nRatio << ", " << cairo_status_to_string(cairo_status(cr)));
+        }
 
 #if OSL_DEBUG_LEVEL > 2
         //draw origin
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 42bf6d0a98b9..b1e4badb73b5 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -282,6 +282,26 @@ void GlyphCache::InitFreetype()
     (void)vclFontFileList::get();
 }
 
+namespace
+{
+    bool DoesAlmostHorizontalDrainRenderingPool()
+    {
+        FT_Int nMajor, nMinor, nPatch;
+        FT_Library_Version(aLibFT, &nMajor, &nMinor, &nPatch);
+        if (nMajor > 2)
+            return false;
+        if (nMajor == 2 && nMinor <= 8)
+            return true;
+        return false;
+    }
+}
+
+bool FreetypeFont::AlmostHorizontalDrainsRenderingPool()
+{
+    static bool bAlmostHorizontalDrainsRenderingPool = DoesAlmostHorizontalDrainRenderingPool();
+    return bAlmostHorizontalDrainsRenderingPool;
+}
+
 FT_Face FreetypeFont::GetFtFace() const
 {
     FT_Activate_Size( maSizeFT );
commit fdeba1b4c389aa27effdaea6ff57b232149098e6
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Sep 5 19:09:09 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Sep 17 10:06:39 2019 +0200

    tdf#126184 Use max paper dimensions to calculate clip region
    
    Assuming at least A4 for the page size isn't enough if
    e.g. A2 or larger is used, so too much was clipped in that case.
    
    Therefore, use the the maximum paper width/height instead, which
    is 6 m by default. This is still far from the 19 km that caused
    tdf#63955 and I cannot reproduce tdf#63955 with that new limit.
    
    A big thanks to Regina Henschel for the great analysis in
    tdf#126184!
    
    (Side note: Comments 18 and 19 in tdf#63955 suggest to do the whole
     clipping elsewhere, so if anybody wants to take a look at this...)
    
    Change-Id: Iccacad621675df6c7b4477182d7332c4a3d67139
    Reviewed-on: https://gerrit.libreoffice.org/78690
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit 1dccd6814f1fe7a06f3168d01d18d347269cd3c1)
    Reviewed-on: https://gerrit.libreoffice.org/78759
    (cherry picked from commit 859f49294ad95d3a6596e135e550253155d6517b)
    Reviewed-on: https://gerrit.libreoffice.org/78790
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    Reviewed-on: https://gerrit.libreoffice.org/79033
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
index 9005b67a3fb4..b9f3950772f2 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
@@ -19,6 +19,7 @@
 
 
 #include <sdr/contact/viewcontactofsdrpathobj.hxx>
+#include <svtools/optionsdrawinglayer.hxx>
 #include <svx/svdopath.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
@@ -104,11 +105,14 @@ namespace sdr
                 //would not over flow into a tiny clip region
                 if (nPageWidth < SAL_MAX_INT32/2 && nPageHeight < SAL_MAX_INT32/2)
                 {
-                    //But, see tdf#97276 and tdf#98366. Don't clip too much if the
+                    //But, see tdf#97276, tdf#126184 and tdf#98366. Don't clip too much if the
                     //underlying page dimension is unknown or a paste document
                     //where the page sizes use the odd default of 10x10
-                    nPageWidth = std::max<sal_Int32>(21000, nPageWidth);
-                    nPageHeight = std::max<sal_Int32>(29700, nPageHeight);
+                    const SvtOptionsDrawinglayer aDrawinglayerOpt;
+                    const sal_Int32 nMaxPaperWidth = aDrawinglayerOpt.GetMaximumPaperWidth() * 1000;
+                    const sal_Int32 nMaxPaperHeight = aDrawinglayerOpt.GetMaximumPaperHeight() * 1000;
+                    nPageWidth = std::max<sal_Int32>(nPageWidth, nMaxPaperWidth);
+                    nPageHeight = std::max<sal_Int32>(nPageHeight, nMaxPaperHeight);
                     basegfx::B2DRange aClipRange(-nPageWidth, -nPageHeight,
                                                  nPageWidth*2, nPageHeight*2);
 


More information about the Libreoffice-commits mailing list