summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-10-10 00:54:00 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-10-18 20:41:32 +0200
commit3a543f1f57aed3beba8879ed46e1f92f657151cb (patch)
tree3595989f3a96c90977cf5417552414d2da05b3ae /vcl
parentdf5e67e3801f673da5f7d8b8608e386fef3a3e8b (diff)
Validate Kashida positions in CommonSalLayout
Currently checks only for ligatures, but that is a big improvement over al code that didn’t do any validation except on Windows. Change-Id: I035248f4ccc23134ea27b40c2dd6197130749f14
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/CommonSalLayout.hxx2
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx31
2 files changed, 33 insertions, 0 deletions
diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index dfd58fed0d50..f9bc4e3fbbf2 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -71,6 +71,8 @@ public:
virtual bool GetCharWidths(DeviceCoordinate* pCharWidths) const override;
virtual void ApplyDXArray(ImplLayoutArgs&) override;
+
+ virtual bool IsKashidaPosValid(int nCharPos) const override;
};
#endif
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index cc97e7026102..7bda1cf49d28 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -500,6 +500,10 @@ bool CommonSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
// This decision is communicated to us in a very indirect way; by increasing
// the width of the character after which Kashidas should be inserted by the
// desired amount.
+//
+// Writer eventually calls IsKashidaPosValid() to check whether it can insert a
+// Kashida between two characters or not.
+//
// Here we do:
// - In LayoutText() set KashidaJustification flag based on text script.
// - In ApplyDXArray():
@@ -634,3 +638,30 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
}
}
}
+
+bool CommonSalLayout::IsKashidaPosValid(int nCharPos) const
+{
+ for (auto pIter = m_GlyphItems.begin(); pIter != m_GlyphItems.end(); ++pIter)
+ {
+ if (pIter->mnCharPos == nCharPos)
+ {
+ // Search backwards for previous glyph belonging to a different
+ // character. We are looking backwards because we are dealing with
+ // RTL glyphs, which will be in visual order.
+ for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.begin(); --pPrev)
+ {
+ if (pPrev->mnCharPos != nCharPos)
+ {
+ // Check if the found glyph belongs to the next character,
+ // otherwise the current glyph will be a ligature which is
+ // invalid kashida position.
+ if (pPrev->mnCharPos == (nCharPos + 1))
+ return true;
+ break;
+ }
+ }
+ }
+ }
+
+ return false;
+}