summaryrefslogtreecommitdiff
path: root/canvas
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
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')
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx23
-rw-r--r--canvas/source/cairo/cairo_textlayout.hxx3
-rw-r--r--canvas/source/directx/dx_textlayout.cxx21
-rw-r--r--canvas/source/directx/dx_textlayout.hxx3
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx5
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.hxx1
-rw-r--r--canvas/source/opengl/ogl_canvashelper.cxx6
-rw-r--r--canvas/source/opengl/ogl_textlayout.cxx20
-rw-r--r--canvas/source/opengl/ogl_textlayout.hxx3
-rw-r--r--canvas/source/vcl/textlayout.cxx24
-rw-r--r--canvas/source/vcl/textlayout.hxx3
11 files changed, 107 insertions, 5 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;
diff --git a/canvas/source/directx/dx_textlayout.cxx b/canvas/source/directx/dx_textlayout.cxx
index 452b0d48e79c..e64dde596693 100644
--- a/canvas/source/directx/dx_textlayout.cxx
+++ b/canvas/source/directx/dx_textlayout.cxx
@@ -93,6 +93,26 @@ namespace dxcanvas
maLogicalAdvancements = aAdvancements;
}
+ uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return maKashidaPositions;
+ }
+
+ void SAL_CALL TextLayout::applyKashidaPositions( const uno::Sequence< sal_Bool >& aPositions )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if( aPositions.hasElements() && aPositions.getLength() != maText.Length )
+ {
+ SAL_WARN("canvas.directx", "TextLayout::applyKashidaPositions(): mismatching number of positions" );
+ throw lang::IllegalArgumentException("mismatching number of positions", getXWeak(), 1);
+ }
+
+ maKashidaPositions = aPositions;
+ }
+
geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -205,6 +225,7 @@ namespace dxcanvas
rOutputOffset,
maText,
maLogicalAdvancements,
+ maKashidaPositions,
mpFont,
mpFont->getFontMatrix(),
bAlphaSurface,
diff --git a/canvas/source/directx/dx_textlayout.hxx b/canvas/source/directx/dx_textlayout.hxx
index 24d37e2107a4..f0ae523e7b6a 100644
--- a/canvas/source/directx/dx_textlayout.hxx
+++ b/canvas/source/directx/dx_textlayout.hxx
@@ -61,6 +61,8 @@ namespace dxcanvas
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;
@@ -95,6 +97,7 @@ namespace dxcanvas
css::rendering::StringContext maText;
css::uno::Sequence< double > maLogicalAdvancements;
+ css::uno::Sequence< sal_Bool > maKashidaPositions;
CanvasFont::ImplRef mpFont;
sal_Int8 mnTextDirection;
};
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index 4b223d1cad0f..55956650ed82 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -68,6 +68,7 @@ namespace dxcanvas
const ::basegfx::B2ISize& rOutputOffset,
const css::rendering::StringContext& rText,
const css::uno::Sequence< double >& rLogicalAdvancements,
+ const css::uno::Sequence< sal_Bool >& rKashidaPositions,
const css::uno::Reference<
css::rendering::XCanvasFont >& rCanvasFont,
const css::geometry::Matrix2D& rFontMatrix,
@@ -213,11 +214,13 @@ namespace dxcanvas
for( sal_Int32 i=0; i<nLen; ++i )
DXArray.push_back(basegfx::fround(rLogicalAdvancements[i]));
+ o3tl::span<const sal_Bool> aKashidaArray(rKashidaPositions.getConstArray(), rKashidaPositions.getLength());
+
// draw the String
xVirtualDevice->DrawTextArray( aEmptyPoint,
aText,
DXArray,
- {},
+ aKashidaArray,
rText.StartPosition,
rText.Length,
bIsRTL ? SalLayoutFlags::BiDiRtl : SalLayoutFlags::NONE);
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.hxx b/canvas/source/directx/dx_textlayout_drawhelper.hxx
index 0db8fca69762..8e9383a8aee9 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.hxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.hxx
@@ -52,6 +52,7 @@ namespace dxcanvas
const ::basegfx::B2ISize& rOutputOffset,
const css::rendering::StringContext& rText,
const css::uno::Sequence< double >& rLogicalAdvancements,
+ const css::uno::Sequence< sal_Bool >& rKashidaPositions,
const css::uno::Reference<
css::rendering::XCanvasFont >& rCanvasFont,
const css::geometry::Matrix2D& rFontMatrix,
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index 1b84879b005c..606764a361b1 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -735,6 +735,9 @@ namespace oglcanvas
for( sal_Int32 i=0; i<nLen; ++i )
aDXArray.set(i, basegfx::fround(aLogicalAdvancements[i]));
+ uno::Sequence<sal_Bool> aKashidaPositions=xLayoutetText->queryKashidaPositions();
+ o3tl::span<const sal_Bool> aKashidaArray(aKashidaPositions.getConstArray(), aKashidaPositions.getLength());
+
// get the glyphs
pVDev->GetTextOutlines(rAct.maPolyPolys,
rTxt.Text,
@@ -742,7 +745,8 @@ namespace oglcanvas
rTxt.StartPosition,
rTxt.Length,
0,
- aDXArray);
+ aDXArray,
+ aKashidaArray);
}
else
{
diff --git a/canvas/source/opengl/ogl_textlayout.cxx b/canvas/source/opengl/ogl_textlayout.cxx
index 9c023fe9f409..4447aef5d828 100644
--- a/canvas/source/opengl/ogl_textlayout.cxx
+++ b/canvas/source/opengl/ogl_textlayout.cxx
@@ -73,6 +73,26 @@ namespace oglcanvas
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.ogl", "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 );
diff --git a/canvas/source/opengl/ogl_textlayout.hxx b/canvas/source/opengl/ogl_textlayout.hxx
index 1d6467d96bc1..d913ec3fb368 100644
--- a/canvas/source/opengl/ogl_textlayout.hxx
+++ b/canvas/source/opengl/ogl_textlayout.hxx
@@ -43,6 +43,8 @@ namespace oglcanvas
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;
@@ -59,6 +61,7 @@ namespace oglcanvas
private:
css::rendering::StringContext maText;
css::uno::Sequence< double > maLogicalAdvancements;
+ css::uno::Sequence< sal_Bool > maKashidaPositions;
CanvasFont::ImplRef mpFont;
sal_Int8 mnTextDirection;
};
diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx
index 34c154257f31..2d56d2f4f074 100644
--- a/canvas/source/vcl/textlayout.cxx
+++ b/canvas/source/vcl/textlayout.cxx
@@ -121,6 +121,7 @@ namespace vclcanvas
rendering::CompositeOperation::SOURCE);
KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, aViewState, aRenderState));
+ o3tl::span<const sal_Bool> aKashidaArray(maKashidaPositions.getArray(), maKashidaPositions.getLength());
std::vector< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence;
::basegfx::B2DPolyPolygonVector aOutlines;
@@ -131,7 +132,8 @@ namespace vclcanvas
maText.StartPosition,
maText.Length,
0,
- aOffsets))
+ aOffsets,
+ aKashidaArray))
{
aOutlineSequence.reserve(aOutlines.size());
sal_Int32 nIndex (0);
@@ -216,6 +218,23 @@ namespace vclcanvas
maLogicalAdvancements = aAdvancements;
}
+ uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
+ {
+ SolarMutexGuard aGuard;
+
+ return maKashidaPositions;
+ }
+
+ void SAL_CALL TextLayout::applyKashidaPositions( const uno::Sequence< sal_Bool >& aPositions )
+ {
+ SolarMutexGuard aGuard;
+
+ ENSURE_ARG_OR_THROW( !aPositions.hasElements() || aPositions.getLength() == maText.Length,
+ "TextLayout::applyKashidaPositions(): mismatching number of positions" );
+
+ maKashidaPositions = aPositions;
+ }
+
geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
{
SolarMutexGuard aGuard;
@@ -337,6 +356,7 @@ namespace vclcanvas
{
// TODO(P2): cache that
KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, viewState, renderState));
+ o3tl::span<const sal_Bool> aKashidaArray(maKashidaPositions.getConstArray(), maKashidaPositions.getLength());
// TODO(F3): ensure correct length and termination for DX
// array (last entry _must_ contain the overall width)
@@ -344,7 +364,7 @@ namespace vclcanvas
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/vcl/textlayout.hxx b/canvas/source/vcl/textlayout.hxx
index 84f5fe6cab91..998383cb029b 100644
--- a/canvas/source/vcl/textlayout.hxx
+++ b/canvas/source/vcl/textlayout.hxx
@@ -58,6 +58,8 @@ namespace vclcanvas
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;
@@ -89,6 +91,7 @@ namespace vclcanvas
css::rendering::StringContext maText;
css::uno::Sequence< double > maLogicalAdvancements;
+ css::uno::Sequence< sal_Bool > maKashidaPositions;
CanvasFont::Reference mpFont;
css::uno::Reference< css::rendering::XGraphicDevice> mxDevice;
OutDevProviderSharedPtr mpOutDevProvider;