vcl/inc/sallayout.hxx | 8 +++++++- vcl/source/gdi/CommonSalLayout.cxx | 17 +++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-)
New commits: commit 553cfda502a1516673233e409f91372766da6c4d Author: Khaled Hosny <[email protected]> Date: Fri Nov 11 19:38:16 2016 +0200 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 diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 6f21064..805b3e2 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 047f845..a6536f1 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. commit 8d8f31d38fcc951df16d23b3c17c396bca7a4659 Author: Khaled Hosny <[email protected]> Date: Fri Nov 11 19:08:45 2016 +0200 FALLBACK_MASK flag is unused Use also sensible values for the rest. Change-Id: Ia772746cffe8c1e6d9d4aa4051b7b9df6d2e7ac8 diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 2a76e11..6f21064 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -313,7 +313,11 @@ public: maGlyphId(aGlyphId), maLinearPos(rLinearPos) {} - enum{ FALLBACK_MASK=0xFF, IS_IN_CLUSTER=0x100, IS_RTL_GLYPH=0x200, IS_DIACRITIC=0x400 }; + enum { + IS_IN_CLUSTER = 0x001, + IS_RTL_GLYPH = 0x002, + IS_DIACRITIC = 0x004 + }; bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); } bool IsRTLGlyph() const { return ((mnFlags & IS_RTL_GLYPH) != 0); }
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
