sd/qa/unit/data/pdf/textshear.pdf |binary sd/qa/unit/export-tests.cxx | 21 +++++++++++++++++++++ svx/source/svdraw/svdpdf.cxx | 12 +++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-)
New commits: commit 86be931b61e3360a25643b964dbc0c3f4db0f1c3 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 22 09:45:07 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Oct 26 12:07:51 2025 +0100 matrix shear used to create an italic effect extract shear and express as a text angle and add to italic angle. Change-Id: I7dc8a74a9125b1e41bc12023af9d787f09929d29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192830 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192989 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sd/qa/unit/data/pdf/textshear.pdf b/sd/qa/unit/data/pdf/textshear.pdf new file mode 100644 index 000000000000..6c8d63598078 Binary files /dev/null and b/sd/qa/unit/data/pdf/textshear.pdf differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 1eb3b00f6adb..b90b911529db 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1277,6 +1277,27 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfPatternFill) "@draw:fill-image-name='Bitmap_20_1']"); } +CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfTextShear) +{ + auto pPdfium = vcl::pdf::PDFiumLibrary::get(); + if (!pPdfium) + return; + UsePdfium aGuard; + + loadFromFile(u"pdf/textshear.pdf"); + + setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"); + save(u"OpenDocument Drawing Flat XML"_ustr); + + xmlDocUniquePtr pXmlDoc = parseExportedFile(); + + // Ensure the Lato font style is italic, seen as regular before improvement to take + // text shear into account. + assertXPath(pXmlDoc, + "/office:document/office:automatic-styles/style:style[@style:name='P2']/" + "style:text-properties[@style:font-name='Lato' and @fo:font-style='italic']"); +} + CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedText) { createSdDrawDoc("objectwithtext.fodg"); diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index ff9346c005a3..9b3f3132c1ed 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1899,7 +1899,17 @@ void ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con if (!sFontName.isEmpty()) aFnt.SetFamilyName(sFontName); - const int italicAngle = pPageObject->getFontAngle(); + int italicAngle = pPageObject->getFontAngle(); + { + // Decompose matrix to inspect shear + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aMatrix.decompose(aScale, aTranslate, fRotate, fShearX); + int nTextRotation = basegfx::fround(basegfx::rad2deg<1>(atan(fShearX))); + // Add this additional shear to the reported italic angle, where + // rotation to the right is negative + italicAngle += -nTextRotation; + } aFnt.SetItalic(italicAngle == 0 ? ITALIC_NONE : (italicAngle < 0 ? ITALIC_NORMAL : ITALIC_OBLIQUE)); aFnt.SetWeight(eFontWeight);
