[Libreoffice] [PATCH] Fix Kashida justification when there is no Kashida glyph

Khaled Hosny khaledhosny at eglug.org
Sat Nov 26 10:27:03 PST 2011


If the font has no Kashida glyph (or if its width is <= 0) no Kashida
gets inserted but the place of Kashida would still be filled with blank
space (intercharacter) which is wrong.

This patch removes the "reasonable default" value of mnMinKashida which
makes no sense at all; either the font have a Kashida glyph and
mnMinKashida is set to its width or it doesn't and mnMinKashida is kept
0.

This value is then queried in sw and if <= 0 then there is no valid
Kashidas (the place of the return is arbitrary chosen by trial and
error; returning earlier in lcl_CheckKashidaPositions either always
disables Kasida justification or does not have any effect at all.)
---
 sw/source/core/text/itradj.cxx    |    4 ++++
 vcl/generic/glyphs/gcach_ftyp.cxx |    1 -
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index 19fb4d1..190cc4a 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -166,6 +166,10 @@ bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTxtSizeInfo& rInf, SwTxtIte
         xub_StrLen nKashidasInAttr = rSI.KashidaJustify ( 0, 0, nIdx, nNext - nIdx );
         if ( nKashidasInAttr )
         {
+            // Kashida glyph looks suspicious, skip Kashida justification
+            if ( rInf.GetOut()->GetMinKashida() <= 0 )
+                return false;
+
             xub_StrLen nKashidasDropped = 0;
             if ( !SwScriptInfo::IsArabicText( rInf.GetTxt(), nIdx, nNext - nIdx ) )
             {
diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 44d8958..49bac49 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -1099,7 +1099,6 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
 
     // initialize kashida width
     // TODO: what if there are different versions of this glyph available
-    rTo.mnMinKashida = rTo.mnAscent / 4; // a reasonable default
     const int nKashidaGlyphId = GetRawGlyphIndex( 0x0640 );
     if( nKashidaGlyphId )
     {
-- 
1.7.0.4



More information about the LibreOffice mailing list