[Libreoffice-commits] core.git: 2 commits - vcl/source vcl/unx

Khaled Hosny khaledhosny at eglug.org
Tue Oct 11 13:59:26 UTC 2016


 vcl/source/gdi/sallayout.cxx            |    4 ----
 vcl/unx/generic/glyphs/gcach_layout.cxx |   30 +++++++++++-------------------
 2 files changed, 11 insertions(+), 23 deletions(-)

New commits:
commit f48cbaac0a2a7278f366a3b0118b399c0a938a44
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Oct 11 14:53:06 2016 +0200

    tdf#103103: Many Arabic fonts dont render correctly
    
    Revert the remaining bits of 1da9b4c24e806ad2447b4a656e2a7192755bb6a8,
    the rest was reverted in 6323e6628668849438e6e19ba7ad2c6598263261.
    
    This break many assumptions made by GenericSalLayout::ApplyDXArray().
    
    Change-Id: I25fbafe06032ab1e8860df6c5932a7157575aa32

diff --git a/vcl/unx/generic/glyphs/gcach_layout.cxx b/vcl/unx/generic/glyphs/gcach_layout.cxx
index 38d7e84..46420cb 100644
--- a/vcl/unx/generic/glyphs/gcach_layout.cxx
+++ b/vcl/unx/generic/glyphs/gcach_layout.cxx
@@ -21,7 +21,6 @@
 #include <sallayout.hxx>
 #include <salgdi.hxx>
 #include <scrptrun.h>
-#include <limits>
 
 #include <i18nlangtag/mslangid.hxx>
 
@@ -309,16 +308,14 @@ static unsigned int unicodeDecomposeCompatibility(hb_unicode_funcs_t* /*ufuncs*/
 {
     return 0;
 }
-#endif
 
 static hb_unicode_funcs_t* getUnicodeFuncs()
 {
     static hb_unicode_funcs_t* ufuncs = hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
-#if !HB_VERSION_ATLEAST(1, 1, 0)
     hb_unicode_funcs_set_decompose_compatibility_func(ufuncs, unicodeDecomposeCompatibility, nullptr, nullptr);
-#endif
     return ufuncs;
 }
+#endif
 
 class HbLayoutEngine : public ServerFontLayoutEngine
 {
@@ -492,8 +489,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
                 nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */
 
             hb_buffer_t *pHbBuffer = hb_buffer_create();
-            static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
 #if !HB_VERSION_ATLEAST(1, 1, 0)
+            static hb_unicode_funcs_t* pHbUnicodeFuncs = getUnicodeFuncs();
             hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs);
 #endif
             hb_buffer_set_direction(pHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: HB_DIRECTION_LTR);
@@ -503,9 +500,6 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
             hb_buffer_add_utf16(
                 pHbBuffer, reinterpret_cast<uint16_t const *>(pStr), nLength,
                 nMinRunPos, nRunLen);
-#if HB_VERSION_ATLEAST(0, 9, 42)
-            hb_buffer_set_cluster_level(pHbBuffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
-#endif
             hb_shape(pHbFont, pHbBuffer, nullptr, 0);
 
             int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
@@ -554,12 +548,15 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
                 //   but usually harmless), so we try to sniff what HarfBuzz thinks
                 //   about this glyph by checking if it gives it a zero advance
                 //   width.
-                // * If the font has no GDEF table, we then check the unicode class
-                //   of the glyph. If it is a non spacing mark then the glyph is a
-                //   diacritic. This is only done if the HarfBuzz version is >= 0.9.42
-                //   Else, we fallback to setting bDiacritic to true if the x advance
-                //   of the glyph is zero. This maybe wrong in some cases but needs to
-                //   be kept until the base version of HarfBuzz can be updated.
+                // * If the font has no GDEF table, we just check if the glyph has
+                //   zero advance width, but this is stupid and can be wrong. A
+                //   better way would to check the character's Unicode combining
+                //   class, but unfortunately HarfBuzz gives combining marks the
+                //   cluster value of its base character, so nCharPos will be
+                //   pointing to the wrong character (but HarfBuzz might change
+                //   this in the future).
+                //   Newer versions of HarfBuzz can control this behaviour with
+                //   hb_buffer_set_cluster_level().
                 bool bDiacritic = false;
                 if (hb_ot_layout_has_glyph_classes(mpHbFace))
                 {
@@ -570,14 +567,9 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
                 }
                 else
                 {
-#if HB_VERSION_ATLEAST(0, 9, 42)
-                    if(hb_unicode_general_category (pHbUnicodeFuncs, aChar) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
-                        bDiacritic = true;
-#else
                     // the font lacks GDEF table
                     if (pHbPositions[i].x_advance == 0)
                         bDiacritic = true;
-#endif
                 }
 
                 if (bDiacritic)
commit faddf2aefd5874b2bbd6c3b7bbed0812de911f47
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Oct 11 15:11:58 2016 +0200

    Revert "Hack to make Arabic subtending marks work"
    
    This reverts commit 983e03a7d81c0ab24782b28ab899452fa6fd99ac.
    
    Fixes part of tdf#103103.
    
    Change-Id: Ib9026044b19b353e8156bc039a4a84fdeb1ec415

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index ea16f4f..8aaefbf 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1031,10 +1031,6 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
                 nDelta += nDiff;
             }
 
-            // Hack to make Arabic subtending marks work e.g. in Amiri.
-            if (nNewClusterWidth != nOldClusterWidth && nNewClusterWidth == 0)
-                m_GlyphItems[i].maLinearPos.X() += m_GlyphItems[i].mnXOffset;
-
             nNewPos += nNewClusterWidth;
         }
 


More information about the Libreoffice-commits mailing list