diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2021-10-17 00:15:04 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2021-10-17 14:04:29 +0200 |
commit | 3b922eb756d990c16944bbce42ae13142565a835 (patch) | |
tree | c4b19dcccbe453866f37e235e7b481eaec3f2c1f /svx/qa | |
parent | 4477baeba5aec71098f374cf0b4bd4591e048809 (diff) |
tdf#144988 correct font size in multiline Fontwork text
The error happened if ScaleX in TextPath is true. In that case the
original font size is used for rendering if possible. Only if a
paragraph is longer as its sub-path length, the rendered font size for
the whole text is reduced until the text fits. The error was, that in
case the first paragraph was too long and the second paragraph fits,
the fact that the first paragraph was too long was overwritten from
the factor for the second paragraph. That resulted in wrong position
and size of the text and overlapping characters.
The meaning of fScalingFactor is related to the usual case, where
ScaleX is false. Keeping original font size is not achieved by using
value 1 for fScalingFactor (which would be obvious), but the adaption
to case ScaleX==true is done in FitTextOutlinesToShapeOutlines() by
tweaking the width from the text bounding rectangle.
Change-Id: Icf5829018a83be0f1197304d17da10a88130f702
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123714
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx/qa')
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 24 | ||||
-rw-r--r-- | svx/qa/unit/data/tdf144988_Fontwork_FontSize.odp | bin | 0 -> 11169 bytes |
2 files changed, 24 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 5c4ea6914288..d4e7ff045fe1 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -127,6 +127,30 @@ void lcl_AssertRectEqualWithTolerance(std::string_view sInfo, const tools::Recta std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); } +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_Fontwork_rendering_font_size) +{ + // The tested position and height depend on dpi. + if (!IsDefaultDPI()) + return; + + // tdf#144988 In case ScaleX is true in property TextPath, the rendering font size should be + // reduced in case any of the paragraphs would be longer as its sub-path. That was wrong, if + // the first paragraph was too long and the second would fit. It resulted in wrong position + // and height and overlapping characters. + + OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf144988_Fontwork_FontSize.odp"; + mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + uno::Reference<drawing::XShape> xShape(getShape(0)); + SdrObjCustomShape& rSdrCustomShape( + static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); + + // Without the fix in place left|top, width x height was 1279|1279, 2815 x 2448. + // The expected values 1501|1777, 3941 x 1446 are only valid for 96dpi. + tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); + tools::Rectangle aExpected(Point(1501, 1777), Size(3941, 1446)); + lcl_AssertRectEqualWithTolerance("Wrong text rendering", aExpected, aBoundRect, 5); +} + CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) { // The tested positions depend on dpi. diff --git a/svx/qa/unit/data/tdf144988_Fontwork_FontSize.odp b/svx/qa/unit/data/tdf144988_Fontwork_FontSize.odp Binary files differnew file mode 100644 index 000000000000..943bc143ba0e --- /dev/null +++ b/svx/qa/unit/data/tdf144988_Fontwork_FontSize.odp |