[libreoffice] Resolves: rhbz#968892 block entire grapheme together for glyph fallback

Caolán McNamara caolanm at fedoraproject.org
Tue Jun 4 15:19:05 UTC 2013


commit d9629dea622e0cf649097079292fa64a7506fc77
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 4 16:18:44 2013 +0100

    Resolves: rhbz#968892 block entire grapheme together for glyph fallback

 ...bz-968892-force-render-full-grapheme-with.patch |  143 ++++++++++++++++++++
 libreoffice.spec                                   |    7 +-
 2 files changed, 149 insertions(+), 1 deletions(-)
---
diff --git a/0001-Resolves-rhbz-968892-force-render-full-grapheme-with.patch b/0001-Resolves-rhbz-968892-force-render-full-grapheme-with.patch
new file mode 100644
index 0000000..d2847d1
--- /dev/null
+++ b/0001-Resolves-rhbz-968892-force-render-full-grapheme-with.patch
@@ -0,0 +1,143 @@
+From 78f93c2ef1acd324c289286fe3c13a429340839b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Tue, 4 Jun 2013 15:48:23 +0100
+Subject: [PATCH] Resolves: rhbz#968892 force render full grapheme with
+ fallback font
+
+Change-Id: I5bb98c61d047e69d74666261b2c489d80f344502
+---
+ vcl/generic/glyphs/gcach_layout.cxx | 61 ++++++++++++++++++++++---------------
+ vcl/inc/generic/glyphcache.hxx      |  5 +++
+ 2 files changed, 42 insertions(+), 24 deletions(-)
+
+diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
+index 4fd4cf4..3c3c6de 100644
+--- a/vcl/generic/glyphs/gcach_layout.cxx
++++ b/vcl/generic/glyphs/gcach_layout.cxx
+@@ -41,6 +41,10 @@
+ #include <unicode/uscript.h>
+ #include <unicode/ubidi.h>
+ 
++#include <com/sun/star/lang/XMultiServiceFactory.hpp>
++#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
++#include <comphelper/processfactory.hxx>
++
+ // =======================================================================
+ // layout implementation for ServerFont
+ // =======================================================================
+@@ -90,23 +94,42 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
+     }
+ }
+ 
+-// =======================================================================
+-
+-static bool lcl_CharIsJoiner(sal_Unicode cChar)
++void ServerFontLayout::setNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nCharPos,
++    bool bRightToLeft)
+ {
+-    return ((cChar == 0x200C) || (cChar == 0x200D));
+-}
++    if (nCharPos < 0)
++        return;
+ 
+-static bool needPreviousCode(sal_Unicode cChar)
+-{
+-    return lcl_CharIsJoiner(cChar) || U16_IS_LEAD(cChar);
+-}
++    using namespace ::com::sun::star;
+ 
+-static bool needNextCode(sal_Unicode cChar)
+-{
+-    return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
++    if (!mxBreak.is())
++    {
++        uno::Reference< lang::XMultiServiceFactory > xFactory =
++            comphelper::getProcessServiceFactory();
++        mxBreak = uno::Reference< i18n::XBreakIterator >(xFactory->createInstance(
++            "com.sun.star.i18n.BreakIterator"), uno::UNO_QUERY);
++    }
++
++    LanguageTag aLangTag(rArgs.meLanguage);
++    lang::Locale aLocale(aLangTag.getLocale());
++
++    //if position nCharPos is missing in the font, grab the entire grapheme and
++    //mark all glyphs as missing so the whole thing is rendered with the same
++    //font
++    OUString aRun(rArgs.mpStr);
++    sal_Int32 nDone;
++    sal_Int32 nGraphemeStartPos =
++        mxBreak->previousCharacters(aRun, nCharPos, aLocale,
++            i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
++    sal_Int32 nGraphemeEndPos =
++        mxBreak->nextCharacters(aRun, nCharPos, aLocale,
++            i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
++
++    rArgs.NeedFallback(nGraphemeStartPos, nGraphemeEndPos, bRightToLeft);
+ }
+ 
++// =======================================================================
++
+ std::ostream &operator <<(std::ostream& s, ServerFont* pFont)
+ {
+ #ifndef SAL_LOG_INFO
+@@ -401,9 +424,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
+             // if needed request glyph fallback by updating LayoutArgs
+             if (!nGlyphIndex)
+             {
+-                if (nCharPos >= 0)
+-                    rArgs.NeedFallback(nCharPos, bRightToLeft);
+-
++                rLayout.setNeedFallback(rArgs, nCharPos, bRightToLeft);
+                 if (SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags)
+                     continue;
+             }
+@@ -1006,15 +1027,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
+             // if needed request glyph fallback by updating LayoutArgs
+             if( !nGlyphIndex )
+             {
+-                if( nCharPos >= 0 )
+-                {
+-                    rArgs.NeedFallback( nCharPos, bRightToLeft );
+-                    if ( (nCharPos > 0) && needPreviousCode(rArgs.mpStr[nCharPos-1]) )
+-                        rArgs.NeedFallback( nCharPos-1, bRightToLeft );
+-                    else if ( (nCharPos + 1 < nEndRunPos) && needNextCode(rArgs.mpStr[nCharPos+1]) )
+-                        rArgs.NeedFallback( nCharPos+1, bRightToLeft );
+-                }
+-
++                rLayout.setNeedFallback(rArgs, nCharPos, bRightToLeft);
+                 if( SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags )
+                     continue;
+             }
+diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
+index a7363f9..d6cdee1 100644
+--- a/vcl/inc/generic/glyphcache.hxx
++++ b/vcl/inc/generic/glyphcache.hxx
+@@ -37,6 +37,7 @@ class ImplFontOptions;
+ #include <boost/unordered_map.hpp>
+ #include <boost/unordered_set.hpp>
+ #include <boost/shared_ptr.hpp>
++#include <com/sun/star/i18n/XBreakIterator.hpp>
+ 
+ namespace basegfx { class B2DPolyPolygon; }
+ 
+@@ -311,6 +312,7 @@ class VCL_DLLPUBLIC ServerFontLayout : public GenericSalLayout
+ {
+ private:
+     ServerFont&     mrServerFont;
++    com::sun::star::uno::Reference<com::sun::star::i18n::XBreakIterator> mxBreak;
+ 
+     // enforce proper copy semantic
+     SAL_DLLPRIVATE  ServerFontLayout( const ServerFontLayout& );
+@@ -323,6 +325,9 @@ public:
+     virtual bool    LayoutText( ImplLayoutArgs& );
+     virtual void    AdjustLayout( ImplLayoutArgs& );
+     virtual void    DrawText( SalGraphics& ) const;
++    void            setNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nIndex,
++                        bool bRightToLeft);
++
+     ServerFont&     GetServerFont() const   { return mrServerFont; }
+ };
+ 
+-- 
+1.8.1.4
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 4e74183..92dad94 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -43,7 +43,7 @@ Summary:        Free Software Productivity Suite
 Name:           libreoffice
 Epoch:          1
 Version:        %{libo_version}.0
-Release:        4%{?libo_prerelease}%{?dist}
+Release:        5%{?libo_prerelease}%{?dist}
 License:        (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic and MPLv2.0
 Group:          Applications/Productivity
 URL:            http://www.documentfoundation.org/develop
@@ -252,6 +252,7 @@ Patch19: 0001-fix-syntax-errors-in-python-wizards.patch
 Patch20: 0001-don-t-run-autogen.sh-if-building-from-tarballs.patch
 Patch21: 0001-autosize-the-frame-direction-listbox.patch
 Patch22: 0001-setting-max-line-count-should-allow-extra-values-to-.patch
+Patch23: 0001-Resolves-rhbz-968892-force-render-full-grapheme-with.patch
 
 %define instdir %{_libdir}
 %define baseinstdir %{instdir}/libreoffice
@@ -993,6 +994,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
 %patch20 -p1 -b .don-t-run-autogen.sh-if-building-from-tarballs.patch
 %patch21 -p1 -b .autosize-the-frame-direction-listbox.patch
 %patch22 -p1 -b .setting-max-line-count-should-allow-extra-values-to-.patch
+%patch23 -p1 -b .rhbz-968892-force-render-full-grapheme-with.patch
 
 # TODO: check this
 # these are horribly incomplete--empty translations and copied english
@@ -2056,6 +2058,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
 %endif
 
 %changelog
+* Tue Jun 04 2013 Caolán McNamara <caolanm at redhat.com> - 1:4.1.0.0-5.beta1
+- Resolves: rhbz#968892 block entire grapheme together for glyph fallback
+
 * Fri May 31 2013 Caolán McNamara <caolanm at redhat.com> - 1:4.1.0.0-4.beta1
 - Resolves: rhbz#968976 fix dropdown list autosizing
 


More information about the scm-commits mailing list