summaryrefslogtreecommitdiff
path: root/canvas/source/cairo
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-06-18 17:35:32 +0300
committerخالد حسني <khaled@libreoffice.org>2023-06-18 22:01:53 +0200
commit68a4f005bc3e74d847e82dddf3237137cf3a1648 (patch)
tree3712971edf90e5fb753369a6874093a9e90c73d7 /canvas/source/cairo
parent94bf26798bb973c7df26e2aa841099bb9cbaf3cb (diff)
tdf#155810: Pass Kashida insertion positions through canvas
This was missed in: commit 3901e029bd39575f700e69a73818565d62226a23 Author: Khaled Hosny <khaled@aliftype.com> Date: Mon Aug 8 22:08:37 2022 +0200 tdf#104921: Cleanup Kashida insertion logic The width adjustment passed through, but Kashida insertion positions didn’t, leaving gaps in place of Kashidas when canvas is used (apparently canvas is only used for slideshow). Change-Id: I25ff30f10cc46a5c87bda2f3936df26b2fc926b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153234 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'canvas/source/cairo')
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx23
-rw-r--r--canvas/source/cairo/cairo_textlayout.hxx3
2 files changed, 25 insertions, 1 deletions
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 955a180330d4..ff12a6092c13 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -131,6 +131,26 @@ namespace cairocanvas
maLogicalAdvancements = aAdvancements;
}
+ uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
+ {
+ std::unique_lock aGuard( m_aMutex );
+
+ return maKashidaPositions;
+ }
+
+ void SAL_CALL TextLayout::applyKashidaPositions( const uno::Sequence< sal_Bool >& aPositions )
+ {
+ std::unique_lock aGuard( m_aMutex );
+
+ if( aPositions.hasElements() && aPositions.getLength() != maText.Length )
+ {
+ SAL_WARN("canvas.cairo", "TextLayout::applyKashidaPositions(): mismatching number of positions" );
+ throw lang::IllegalArgumentException("mismatching number of positions", getXWeak(), 1);
+ }
+
+ maKashidaPositions = aPositions;
+ }
+
geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
{
std::unique_lock aGuard( m_aMutex );
@@ -263,8 +283,9 @@ namespace cairocanvas
if (maLogicalAdvancements.hasElements())
{
KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, viewState, renderState));
+ o3tl::span<const sal_Bool> aKashidaArray(maKashidaPositions.getConstArray(), maKashidaPositions.getLength());
- rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets, {},
+ rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets, aKashidaArray,
::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition),
::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) );
}
diff --git a/canvas/source/cairo/cairo_textlayout.hxx b/canvas/source/cairo/cairo_textlayout.hxx
index ad9f3466081a..ed8265e8b391 100644
--- a/canvas/source/cairo/cairo_textlayout.hxx
+++ b/canvas/source/cairo/cairo_textlayout.hxx
@@ -60,6 +60,8 @@ namespace cairocanvas
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures( ) override;
virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements( ) override;
virtual void SAL_CALL applyLogicalAdvancements( const css::uno::Sequence< double >& aAdvancements ) override;
+ virtual css::uno::Sequence< sal_Bool > SAL_CALL queryKashidaPositions( ) override;
+ virtual void SAL_CALL applyKashidaPositions( const css::uno::Sequence< sal_Bool >& aPositions ) override;
virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds( ) override;
virtual double SAL_CALL justify( double nSize ) override;
virtual double SAL_CALL combinedJustify( const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > >& aNextLayouts, double nSize ) override;
@@ -94,6 +96,7 @@ namespace cairocanvas
private:
css::rendering::StringContext maText;
css::uno::Sequence< double > maLogicalAdvancements;
+ css::uno::Sequence< sal_Bool > maKashidaPositions;
CanvasFont::Reference mpFont;
SurfaceProviderRef mpRefDevice;
sal_Int8 mnTextDirection;