summaryrefslogtreecommitdiff
path: root/include/vcl
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-05-07 02:43:00 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-05-22 19:20:38 +0200
commitab0a4543cab77ae0c7c0a79feb8aebab71163dd7 (patch)
tree8b9f0fc175c41eb719865f69674bbfe65a1e0df9 /include/vcl
parentd1ddd136a1b0e452492464d58715eaec144fd811 (diff)
tdf#124116 Correct Writer text shaping across formatting changes
Previously, Writer performed shaping for each span of text separately. In certain situations, this caused incorrect glyph use, or incorrect glyph positioning. This change updates Writer so it will also consider neighboring text while performing shaping. This change resolves the outstanding duplicates filed against tdf#61444. As a side effect, this change also fixes tdf#134226. In addition to the shaping fix, this change implements rendering for individually-styled glyphs, which is required to fix tdf#71956. However, this change does not implement diacritic selection, which is also required for that issue. Change-Id: Iab4774ffaab5ad6113778c54d02cb260a70c1010 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167699 Reviewed-by: Jonathan Clark <jonathan@libreoffice.org> Tested-by: Jenkins
Diffstat (limited to 'include/vcl')
-rw-r--r--include/vcl/glyphitemcache.hxx5
-rw-r--r--include/vcl/metaact.hxx15
-rw-r--r--include/vcl/outdev.hxx27
-rw-r--r--include/vcl/pdfwriter.hxx8
-rw-r--r--include/vcl/rendercontext/SalLayoutFlags.hxx3
-rw-r--r--include/vcl/vcllayout.hxx2
6 files changed, 41 insertions, 19 deletions
diff --git a/include/vcl/glyphitemcache.hxx b/include/vcl/glyphitemcache.hxx
index ffe9bb7eb0c4..79f05e606550 100644
--- a/include/vcl/glyphitemcache.hxx
+++ b/include/vcl/glyphitemcache.hxx
@@ -53,6 +53,11 @@ public:
const OUString& text, sal_Int32 nIndex, sal_Int32 nLen,
tools::Long nLogicWidth = 0,
const vcl::text::TextLayoutCache* layoutCache = nullptr);
+ const SalLayoutGlyphs* GetLayoutGlyphs(const VclPtr<const OutputDevice>& outputDevice,
+ const OUString& text, sal_Int32 nIndex, sal_Int32 nLen,
+ sal_Int32 nDrawMinCharPos, sal_Int32 nDrawEndCharPos,
+ tools::Long nLogicWidth = 0,
+ const vcl::text::TextLayoutCache* layoutCache = nullptr);
void clear();
/// Normally, we cannot cache glyphs when doing font fallback, because the font fallbacks
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 71869689dc55..79a91a629783 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -510,6 +510,8 @@ private:
std::vector<sal_Bool> maKashidaAry;
sal_Int32 mnIndex;
sal_Int32 mnLen;
+ sal_Int32 mnLayoutContextIndex = -1;
+ sal_Int32 mnLayoutContextLen = -1;
SAL_DLLPRIVATE virtual ~MetaTextArrayAction() override;
@@ -526,6 +528,9 @@ public:
std::span<const sal_Bool> pKashidaAry,
sal_Int32 nIndex,
sal_Int32 nLen );
+ MetaTextArrayAction(const Point& rStartPt, OUString aStr, KernArraySpan pDXAry,
+ std::span<const sal_Bool> pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen,
+ sal_Int32 nLayoutContextIndex, sal_Int32 nLayoutContextLen);
SAL_DLLPRIVATE virtual void Execute( OutputDevice* pOut ) override;
@@ -538,12 +543,22 @@ public:
const OUString& GetText() const { return maStr; }
sal_Int32 GetIndex() const { return mnIndex; }
sal_Int32 GetLen() const { return mnLen; }
+ sal_Int32 GetLayoutContextIndex() const { return mnLayoutContextIndex; }
+ sal_Int32 GetLayoutContextLen() const { return mnLayoutContextLen; }
const KernArray& 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 SetLayoutContextIndex(sal_Int32 nLayoutContextIndex)
+ {
+ mnLayoutContextIndex = nLayoutContextIndex;
+ }
+ void SetLayoutContextLen(sal_Int32 nLayoutContextLen)
+ {
+ mnLayoutContextLen = nLayoutContextLen;
+ }
SAL_DLLPRIVATE void SetDXArray(KernArray aArray);
SAL_DLLPRIVATE void SetKashidaArray(std::vector<sal_Bool> aArray);
};
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 6dbb9acf7f32..347d5bb82226 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1160,11 +1160,12 @@ public:
// i60594
// validate kashida positions against the current font
// returns count of invalid kashida positions
- sal_Int32 ValidateKashidas( const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen,
- sal_Int32 nKashCount, // number of suggested kashida positions (in)
- const sal_Int32* pKashidaPos, // suggested kashida positions (in)
- sal_Int32* pKashidaPosDropped // invalid kashida positions (out)
- ) const;
+ sal_Int32
+ ValidateKashidas(const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen, sal_Int32 nPartIdx,
+ sal_Int32 nPartLen,
+ std::span<const sal_Int32> pKashidaPos, // suggested kashida positions (in)
+ std::vector<sal_Int32>* pKashidaPosDropped // invalid kashida positions (out)
+ ) const;
static void BeginFontSubstitution();
static void EndFontSubstitution();
@@ -1235,14 +1236,14 @@ public:
SAL_DLLPRIVATE void ReMirror( vcl::Region &rRegion ) const;
SAL_DLLPRIVATE bool ImplIsRecordLayout() const;
virtual bool HasMirroredGraphics() const;
- std::unique_ptr<SalLayout>
- ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
- const Point& rLogicPos = Point(0,0), tools::Long nLogicWidth=0,
- KernArraySpan aKernArray = KernArraySpan(),
- std::span<const sal_Bool> pKashidaArray={},
- SalLayoutFlags flags = SalLayoutFlags::NONE,
- vcl::text::TextLayoutCache const* = nullptr,
- const SalLayoutGlyphs* pGlyphs = nullptr) const;
+ std::unique_ptr<SalLayout> ImplLayout(
+ const OUString&, sal_Int32 nIndex, sal_Int32 nLen, const Point& rLogicPos = Point(0, 0),
+ tools::Long nLogicWidth = 0, KernArraySpan aKernArray = KernArraySpan(),
+ std::span<const sal_Bool> pKashidaArray = {}, SalLayoutFlags flags = SalLayoutFlags::NONE,
+ vcl::text::TextLayoutCache const* = nullptr, const SalLayoutGlyphs* pGlyphs = nullptr,
+ std::optional<sal_Int32> nDrawOriginCluster = std::nullopt,
+ std::optional<sal_Int32> nDrawMinCharPos = std::nullopt,
+ std::optional<sal_Int32> nDrawEndCharPos = std::nullopt) const;
SAL_DLLPRIVATE vcl::text::ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
double nPixelWidth,
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index f4599154e465..34d44525b4d4 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -790,11 +790,9 @@ The following structure describes the permissions used in PDF security
FontStrikeout eStrikeout,
FontLineStyle eUnderline,
FontLineStyle eOverline );
- void DrawTextArray( const Point& rStartPt, const OUString& rStr,
- KernArraySpan aKernArray,
- std::span<const sal_Bool> pKashidaAry,
- sal_Int32 nIndex,
- sal_Int32 nLen );
+ void DrawTextArray(const Point& rStartPt, const OUString& rStr, KernArraySpan aKernArray,
+ std::span<const sal_Bool> pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen,
+ sal_Int32 nLayoutContextIndex, sal_Int32 nLayoutContextLen);
void DrawStretchText( const Point& rStartPt, sal_Int32 nWidth,
const OUString& rStr,
sal_Int32 nIndex, sal_Int32 nLen );
diff --git a/include/vcl/rendercontext/SalLayoutFlags.hxx b/include/vcl/rendercontext/SalLayoutFlags.hxx
index 576a4abd8fbd..3424fa2a1de4 100644
--- a/include/vcl/rendercontext/SalLayoutFlags.hxx
+++ b/include/vcl/rendercontext/SalLayoutFlags.hxx
@@ -33,10 +33,11 @@ enum class SalLayoutFlags
DisableLigatures = 0x0200,
ForFallback = 0x2000,
GlyphItemsOnly = 0x4000,
+ UnclusteredGlyphs = 0x8000,
};
namespace o3tl
{
-template <> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6277>
+template <> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0xE277>
{
};
}
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index 9370c69ded2e..58ca11b876ef 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -137,6 +137,8 @@ private:
protected:
int mnMinCharPos;
int mnEndCharPos;
+ int mnDrawMinCharPos = std::numeric_limits<int>::min();
+ int mnDrawEndCharPos = std::numeric_limits<int>::max();
LanguageTag maLanguageTag;
Degree10 mnOrientation;