[PATCH 1/3] Don't hard code joining type of Arabic characters

Khaled Hosny khaledhosny at eglug.org
Wed Aug 31 14:58:51 PDT 2011


The joining type is defined in the Unicode character database, so we
should query that property instead of hard coding some code points.
---
 sw/source/core/text/porlay.cxx |   30 +++++-------------------------
 1 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 1ce9da3..95e638a 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -147,15 +147,10 @@ sal_Bool isFeChar ( xub_Unicode cCh )
 {
    return ( cCh == 0x641 || ( cCh >= 0x6A1 && cCh <= 0x6A6 ) );
 }
+
 sal_Bool isTransparentChar ( xub_Unicode cCh )
 {
-    return ( ( cCh >= 0x610 && cCh <= 0x61A ) ||
-            ( cCh >= 0x64B && cCh <= 0x65E ) ||
-            ( cCh == 0x670 ) ||
-            ( cCh >= 0x6D6 && cCh <= 0x6DC ) ||
-            ( cCh >= 0x6DF && cCh <= 0x6E4 ) ||
-            ( cCh >= 0x6E7 && cCh <= 0x6E8 ) ||
-            ( cCh >= 0x6EA && cCh <= 0x6ED ));
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_TYPE ) == U_JT_TRANSPARENT;
 }
 
 /*************************************************************************
@@ -178,28 +173,13 @@ sal_Bool lcl_IsLigature( xub_Unicode cCh, xub_Unicode cNextCh )
 
 sal_Bool lcl_ConnectToPrev( xub_Unicode cCh, xub_Unicode cPrevCh )
 {
-    // Alef, Dal, Thal, Reh, Zain, and Waw do not connect to the left
-    // Uh, there seem to be some more characters that are not connectable
-    // to the left. So we look for the characters that are actually connectable
-    // to the left. Here is the complete list of WH:
-
-    // (hennerdrewes):
-    // added lam forms 0x06B5..0x06B8
-    // added 0x6FA..0x6FC, according to unicode documentation, although not present in my fonts
-    // added heh goal 0x6C1
-    sal_Bool bRet = 0x628 == cPrevCh ||
-                    ( 0x62A <= cPrevCh && cPrevCh <= 0x62E ) ||
-                  ( 0x633 <= cPrevCh && cPrevCh <= 0x647 ) ||
-                      0x649 == cPrevCh || // Alef Maksura does connect !!!
-                      0x64A == cPrevCh ||
-                    ( 0x678 <= cPrevCh && cPrevCh <= 0x687 ) ||
-                  ( 0x69A <= cPrevCh && cPrevCh <= 0x6C1 ) ||
-                  ( 0x6C3 <= cPrevCh && cPrevCh <= 0x6D3 ) ||
-                  ( 0x6FA <= cPrevCh && cPrevCh <= 0x6FC )  ;
+    const int32_t nJoiningType = u_getIntPropertyValue( cPrevCh, UCHAR_JOINING_TYPE );
+    sal_Bool bRet = nJoiningType != U_JT_RIGHT_JOINING && nJoiningType != U_JT_NON_JOINING;
 
     // check for ligatures cPrevChar + cChar
     if( bRet )
         bRet = !lcl_IsLigature( cPrevCh, cCh );
+
     return bRet;
 }
 
-- 
1.7.0.4


--MGYHOYXEY6WxJCY8
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="0002-Use-Unicode-Joining_Group.patch"



More information about the LibreOffice mailing list