Kaydet (Commit) 3a543f1f authored tarafından Khaled Hosny's avatar Khaled Hosny

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
üst df5e67e3
...@@ -71,6 +71,8 @@ public: ...@@ -71,6 +71,8 @@ public:
virtual bool GetCharWidths(DeviceCoordinate* pCharWidths) const override; virtual bool GetCharWidths(DeviceCoordinate* pCharWidths) const override;
virtual void ApplyDXArray(ImplLayoutArgs&) override; virtual void ApplyDXArray(ImplLayoutArgs&) override;
virtual bool IsKashidaPosValid(int nCharPos) const override;
}; };
#endif #endif
...@@ -500,6 +500,10 @@ bool CommonSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const ...@@ -500,6 +500,10 @@ bool CommonSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
// This decision is communicated to us in a very indirect way; by increasing // 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 // the width of the character after which Kashidas should be inserted by the
// desired amount. // desired amount.
//
// Writer eventually calls IsKashidaPosValid() to check whether it can insert a
// Kashida between two characters or not.
//
// Here we do: // Here we do:
// - In LayoutText() set KashidaJustification flag based on text script. // - In LayoutText() set KashidaJustification flag based on text script.
// - In ApplyDXArray(): // - In ApplyDXArray():
...@@ -634,3 +638,30 @@ void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) ...@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment