diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-08-08 22:08:37 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-14 21:10:24 +0200 |
commit | 3901e029bd39575f700e69a73818565d62226a23 (patch) | |
tree | 2851945d9b13ac071d1e21af53288f46125dbc32 /include/vcl | |
parent | cc54063b915a58db9133c919c151ec7e6209f4cd (diff) |
tdf#104921: Cleanup Kashida insertion logic
Communicate Kashida insertion positions in an explicit way.
Rest of LibreOffice communicate adjustments to character widths (e.g.
for justification or spacing) using so-called DX array. DX array is an
array of absolute character positions (e.g. DX[n] is the position after
character n from the start of the lines, and its widths is DX[n] -
DX[n-1]).
This DX array is modified also when Kashidas are inserted after a given
character for Arabic justification, by expanding its width. VCL would
use this to know where to insert the Kashidas and how many ones.
But because DX array is used for both widths adjustments and kashida
insertion, this turns out to be a source of bugs since VCL has tosecond
guess the DX array to find which is pure width adjustment and which also
involves Kashida insertion, and the heuristics it uses are fragile.
This change adds a second array of booleans that records where Kashida
is inserted and communicates it all the way from where Kashida insertion
is decoded in Writer and down to VCL layout.
This change passes the Kashida array only when it seems necessary (e.g.
during drawing but not when measuring text since the DX array is enough
in this case). Hopefully no places where Kashida insertion needs to be
passed down were missed.
A couple of glyph and layout flags that were used for old heuristics and
no longer needed and are removed.
This also fixes:
tdf#87731
tdf#106309
tdf#108604
tdf#112849
tdf#114257
tdf#127176
tdf#145647
tdf#146199
Change-Id: I4ed0850ef2fdc3e9143341afac649e7e7d463c39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138068
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl')
-rw-r--r-- | include/vcl/metaact.hxx | 11 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 12 | ||||
-rw-r--r-- | include/vcl/pdfwriter.hxx | 1 | ||||
-rw-r--r-- | include/vcl/rendercontext/SalLayoutFlags.hxx | 3 |
4 files changed, 20 insertions, 7 deletions
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index 37c3db3d9273..11caf48b2429 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -507,6 +507,7 @@ private: Point maStartPt; OUString maStr; std::vector<sal_Int32> maDXAry; + std::vector<sal_Bool> maKashidaAry; sal_Int32 mnIndex; sal_Int32 mnLen; @@ -516,10 +517,14 @@ public: MetaTextArrayAction(); MetaTextArrayAction( const MetaTextArrayAction& rAction ); MetaTextArrayAction( const Point& rStartPt, OUString aStr, - std::vector<sal_Int32> rDXAry, sal_Int32 nIndex, + std::vector<sal_Int32> rDXAry, + std::vector<sal_Bool> pKashidaAry, + sal_Int32 nIndex, sal_Int32 nLen ); MetaTextArrayAction( const Point& rStartPt, OUString aStr, - o3tl::span<const sal_Int32> pDXAry, sal_Int32 nIndex, + o3tl::span<const sal_Int32> pDXAry, + o3tl::span<const sal_Bool> pKashidaAry, + sal_Int32 nIndex, sal_Int32 nLen ); virtual void Execute( OutputDevice* pOut ) override; @@ -534,11 +539,13 @@ public: sal_Int32 GetIndex() const { return mnIndex; } sal_Int32 GetLen() const { return mnLen; } const std::vector<sal_Int32> & GetDXArray() const { return maDXAry; } + const std::vector<sal_Bool> & GetKashidaArray() const { return maKashidaAry; } void SetPoint(const Point& rPt) { maStartPt = rPt; } void SetText(const OUString& rStr) { maStr = rStr; } void SetIndex(sal_Int32 rIndex) { mnIndex = rIndex; } void SetLen(sal_Int32 rLen) { mnLen = rLen; } void SetDXArray(std::vector<sal_Int32> aArray); + void SetKashidaArray(std::vector<sal_Bool> aArray); }; class SAL_DLLPUBLIC_RTTI MetaStretchTextAction final : public MetaAction diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 2595415db1b5..af55ebd3d614 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -963,6 +963,7 @@ public: bool GetTextBoundRect( tools::Rectangle& rRect, const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, sal_uLong nLayoutWidth = 0, o3tl::span<const sal_Int32> pDXArray = {}, + o3tl::span<const sal_Bool> pKashidaArray = {}, const SalLayoutGlyphs* pGlyphs = nullptr ) const; tools::Rectangle ImplGetTextBoundRect( const SalLayout& ) const; @@ -973,12 +974,14 @@ public: bool GetTextOutlines( PolyPolyVector&, const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, - sal_uLong nLayoutWidth = 0, o3tl::span<const sal_Int32> pDXArray = {} ) const; + sal_uLong nLayoutWidth = 0, o3tl::span<const sal_Int32> pDXArray = {}, + o3tl::span<const sal_Bool> pKashidaArray = {} ) const; bool GetTextOutlines( basegfx::B2DPolyPolygonVector &rVector, const OUString& rStr, sal_Int32 nBase, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, - sal_uLong nLayoutWidth = 0, o3tl::span<const sal_Int32> pDXArray = {} ) const; + sal_uLong nLayoutWidth = 0, o3tl::span<const sal_Int32> pDXArray = {}, + o3tl::span<const sal_Bool> pKashidaArray = {} ) const; OUString GetEllipsisString( const OUString& rStr, tools::Long nMaxWidth, @@ -1044,6 +1047,7 @@ public: void DrawTextArray( const Point& rStartPt, const OUString& rStr, o3tl::span<const sal_Int32> pDXAry, + o3tl::span<const sal_Bool> pKashidaAry={}, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, SalLayoutFlags flags = SalLayoutFlags::NONE, @@ -1236,7 +1240,9 @@ public: std::unique_ptr<SalLayout> ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen, const Point& rLogicPos = Point(0,0), tools::Long nLogicWidth=0, - o3tl::span<const sal_Int32> pLogicDXArray={}, SalLayoutFlags flags = SalLayoutFlags::NONE, + o3tl::span<const sal_Int32> pLogicDXArray={}, + o3tl::span<const sal_Bool> pKashidaArray={}, + SalLayoutFlags flags = SalLayoutFlags::NONE, vcl::text::TextLayoutCache const* = nullptr, const SalLayoutGlyphs* pGlyphs = nullptr) const; diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 8764f3f49c8e..0c2cbb6294dd 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -764,6 +764,7 @@ The following structure describes the permissions used in PDF security FontLineStyle eOverline ); void DrawTextArray( const Point& rStartPt, const OUString& rStr, o3tl::span<const sal_Int32> pDXAry, + o3tl::span<const sal_Bool> pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen ); void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, diff --git a/include/vcl/rendercontext/SalLayoutFlags.hxx b/include/vcl/rendercontext/SalLayoutFlags.hxx index 68c26cadb48b..e8c5901d8528 100644 --- a/include/vcl/rendercontext/SalLayoutFlags.hxx +++ b/include/vcl/rendercontext/SalLayoutFlags.hxx @@ -30,13 +30,12 @@ enum class SalLayoutFlags DisableKerning = 0x0010, KerningAsian = 0x0020, Vertical = 0x0040, - KashidaJustification = 0x0800, ForFallback = 0x2000, GlyphItemsOnly = 0x4000, }; namespace o3tl { -template <> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6877> +template <> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6077> { }; } |