summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-11-11 19:38:16 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-11-11 19:43:09 +0200
commit553cfda502a1516673233e409f91372766da6c4d (patch)
tree177206232fce42326d7885fa7377f4af628a0036
parent8d8f31d38fcc951df16d23b3c17c396bca7a4659 (diff)
tdf#103871: Set Kashida flag per glyph
When we are shaping mixed script text, the Kashida flag would be set based on which script come last, which makes no sense of course. I just left an XXX note yesterday, and I hit the bug today already in a friend’s document! Change-Id: Ic996fd886f30f4385185eccd214b5648f7248262
-rw-r--r--vcl/inc/sallayout.hxx4
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx17
2 files changed, 10 insertions, 11 deletions
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 6f21064f0371..805b3e2569b0 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -316,12 +316,14 @@ public:
enum {
IS_IN_CLUSTER = 0x001,
IS_RTL_GLYPH = 0x002,
- IS_DIACRITIC = 0x004
+ IS_DIACRITIC = 0x004,
+ ALLOW_KASHIDA = 0X010
};
bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); }
bool IsRTLGlyph() const { return ((mnFlags & IS_RTL_GLYPH) != 0); }
bool IsDiacritic() const { return ((mnFlags & IS_DIACRITIC) != 0); }
+ bool AllowKashida() const { return ((mnFlags & ALLOW_KASHIDA) != 0); }
};
typedef std::list<GlyphItem> GlyphList;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 047f845ba27d..a6536f1bfb77 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -353,7 +353,6 @@ void CommonSalLayout::DrawText(SalGraphics& rSalGraphics) const
bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
{
hb_face_t* pHbFace = hb_font_get_face(mpHbFont);
- hb_script_t aHbScript = HB_SCRIPT_INVALID;
int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos);
Reserve(nGlyphCapacity);
@@ -462,7 +461,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
int nMinRunPos = aSubRun.mnMin;
int nEndRunPos = aSubRun.mnEnd;
int nRunLen = nEndRunPos - nMinRunPos;
- aHbScript = aSubRun.maScript;
OString sLanguage = msLanguage;
if (sLanguage.isEmpty())
@@ -549,6 +547,12 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
if (bDiacritic)
nGlyphFlags |= GlyphItem::IS_DIACRITIC;
+ if ((aSubRun.maScript == HB_SCRIPT_ARABIC) || (aSubRun.maScript == HB_SCRIPT_SYRIAC))
+ {
+ nGlyphFlags |= GlyphItem::ALLOW_KASHIDA;
+ rArgs.mnFlags |= SalLayoutFlags::KashidaJustification;
+ }
+
DeviceCoordinate nAdvance, nXOffset, nYOffset;
if (aSubRun.maDirection == HB_DIRECTION_TTB)
{
@@ -583,13 +587,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
// XXX: why?
SortGlyphItems();
- // determine need for kashida justification
- // XXX: This assumes all the text is in the same script, which is not
- // guaranteed. The flag should be per glyph.
- if ((rArgs.mpDXArray || rArgs.mnLayoutWidth)
- && ((aHbScript == HB_SCRIPT_ARABIC) || (aHbScript == HB_SCRIPT_SYRIAC)))
- rArgs.mnFlags |= SalLayoutFlags::KashidaJustification;
-
return true;
}
@@ -675,7 +672,7 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
DeviceCoordinate nDiff = pNewCharWidths[nCharPos] - pOldCharWidths[nCharPos];
// nDiff > 1 to ignore rounding errors.
- if (bKashidaJustify && nDiff > 1)
+ if (bKashidaJustify && m_GlyphItems[i].AllowKashida() && nDiff > 1)
pKashidas[i] = nDiff;
// Adjust the width of the first glyph belonging to current character.