From 089398e51409458c5438c49fb347e4f09d9c09dc Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 18 Apr 2024 13:18:37 +0500 Subject: [PATCH] Return double from OutputDevice::GetTextArray And introduce GetTextWidth / GetTextHeight variants returning double. It allows to avoid premature rounding. At least in one case - testTdf145111_anchor_in_Fontwork - it allowed to make the test DPI-independent (at least in my testing on Windows, using 125, 150, and 175% UI scaling). Change-Id: I973d2c729ec6bb7114b4f99b9027f1ead7c1d061 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166237 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../extras/xshape/data/reference/fdo75075.xml | 736 ++++++++--------- .../data/reference/property-mapping-bar.xml | 546 ++++++------- .../xshape/data/reference/tdf149204.xml | 116 +-- .../xshape/data/reference/tdf150832.xml | 428 +++++----- .../xshape/data/reference/tdf151424.xml | 468 +++++------ .../xshape/data/reference/tdf90839-1.xml | 86 +- .../xshape/data/reference/tdf90839-2.xml | 64 +- .../xshape/data/reference/tdf90839-3.xml | 64 +- .../xshape/data/reference/tdf90839-4.xml | 64 +- .../xshape/data/reference/testChart.xml | 750 +++++++++--------- .../source/processor2d/vclprocessor2d.cxx | 4 +- editeng/source/items/svxfont.cxx | 4 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 2 +- filter/source/svg/svgwriter.cxx | 2 +- include/vcl/outdev.hxx | 9 +- sc/qa/uitest/chart/chartDataLabels.py | 4 +- sc/qa/uitest/chart/chartLegend.py | 4 +- sd/qa/unit/layout-tests.cxx | 10 +- sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 4 +- svx/qa/unit/customshapes.cxx | 18 +- toolkit/source/awt/vclxfont.cxx | 2 +- vcl/qa/cppunit/complextext.cxx | 28 +- vcl/qa/cppunit/text.cxx | 4 +- vcl/source/filter/wmf/emfwr.cxx | 2 +- vcl/source/filter/wmf/wmfwr.cxx | 2 +- vcl/source/outdev/map.cxx | 29 + vcl/source/outdev/text.cxx | 31 +- vcl/source/text/textlayout.cxx | 4 +- 28 files changed, 1763 insertions(+), 1722 deletions(-) diff --git a/chart2/qa/extras/xshape/data/reference/fdo75075.xml b/chart2/qa/extras/xshape/data/reference/fdo75075.xml index fe8cb00cf178..6f401aa41edd 100644 --- a/chart2/qa/extras/xshape/data/reference/fdo75075.xml +++ b/chart2/qa/extras/xshape/data/reference/fdo75075.xml @@ -14,9 +14,9 @@ - + - + @@ -25,12 +25,12 @@ - + - + @@ -39,18 +39,18 @@ - + - + - + - + - + @@ -59,125 +59,125 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - + + + + + + + + + @@ -194,81 +194,81 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -281,159 +281,159 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -511,19 +511,19 @@ - + - + - - + + @@ -533,88 +533,88 @@ - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -684,19 +684,19 @@ - + - + - - + + @@ -706,30 +706,30 @@ - + - + - + - + - + - + @@ -739,29 +739,29 @@ - - - - - + + + + + - - + + - + - + @@ -771,29 +771,29 @@ - - - - - + + + + + - - + + - + - + @@ -803,29 +803,29 @@ - - - - - + + + + + - - + + - + - + @@ -835,29 +835,29 @@ - - - - - + + + + + - - + + - + - + @@ -867,45 +867,45 @@ - - - - - + + + + + - - + + - + - + - + - + - + @@ -938,16 +938,16 @@ - + - + - - + + @@ -957,28 +957,28 @@ - + - + - + - + - - + + @@ -988,28 +988,28 @@ - + - + - + - + - - + + @@ -1019,28 +1019,28 @@ - + - + - + - + - - + + @@ -1050,35 +1050,35 @@ - + - + - + - + - + - + @@ -1087,21 +1087,21 @@ - + - + - + - + @@ -1110,12 +1110,12 @@ - + - + @@ -1124,12 +1124,12 @@ - + - + @@ -1138,12 +1138,12 @@ - + - + @@ -1152,37 +1152,37 @@ - + - + - + - + - + - + - + @@ -1191,12 +1191,12 @@ - + - + @@ -1205,12 +1205,12 @@ - + - + @@ -1219,12 +1219,12 @@ - + - + @@ -1233,12 +1233,12 @@ - + - + @@ -1247,21 +1247,21 @@ - + - + - + - + @@ -1270,12 +1270,12 @@ - + - + @@ -1284,12 +1284,12 @@ - + - + @@ -1298,12 +1298,12 @@ - + - + @@ -1312,12 +1312,12 @@ - + - + @@ -1326,12 +1326,12 @@ - + - + @@ -1340,12 +1340,12 @@ - + - + @@ -1354,12 +1354,12 @@ - + - + @@ -1368,12 +1368,12 @@ - + - + @@ -1382,21 +1382,21 @@ - + - + - + - + @@ -1405,12 +1405,12 @@ - + - + @@ -1419,12 +1419,12 @@ - + - + @@ -1433,12 +1433,12 @@ - + - + @@ -1447,12 +1447,12 @@ - + - + @@ -1461,12 +1461,12 @@ - + - + @@ -1475,12 +1475,12 @@ - + - + @@ -1489,12 +1489,12 @@ - + - + @@ -1503,42 +1503,42 @@ - + - + - + - + - + - + - + @@ -1547,16 +1547,16 @@ - + - + - + - + @@ -1565,12 +1565,12 @@ - + - + @@ -1579,30 +1579,30 @@ - + - + - + - + - + - + @@ -1611,19 +1611,19 @@ - + - + - - + + @@ -1633,26 +1633,26 @@ - + - + - + - + @@ -1661,12 +1661,12 @@ - + - + @@ -1675,14 +1675,14 @@ - + - + diff --git a/chart2/qa/extras/xshape/data/reference/property-mapping-bar.xml b/chart2/qa/extras/xshape/data/reference/property-mapping-bar.xml index 6e28467c19b8..a64c984797bf 100644 --- a/chart2/qa/extras/xshape/data/reference/property-mapping-bar.xml +++ b/chart2/qa/extras/xshape/data/reference/property-mapping-bar.xml @@ -14,9 +14,9 @@ - + - + @@ -25,12 +25,12 @@ - + - + @@ -39,18 +39,18 @@ - + - + - + - + - + @@ -59,116 +59,116 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + + + + + + @@ -184,73 +184,73 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -263,143 +263,143 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -469,19 +469,19 @@ - + - + - - + + @@ -491,30 +491,30 @@ - + - + - + - + - + - + @@ -524,29 +524,29 @@ - - - - - + + + + + - - + + - + - + @@ -556,29 +556,29 @@ - - - - - + + + + + - - + + - + - + @@ -588,29 +588,29 @@ - - - - - + + + + + - - + + - + - + @@ -620,38 +620,38 @@ - - - - - + + + + + - - + + - + - + - + - + @@ -661,29 +661,29 @@ - + - - + + - - + + - + - + @@ -693,29 +693,29 @@ - - - - - + + + + + - - + + - + - + @@ -725,29 +725,29 @@ - - - - - + + + + + - - + + - + - + @@ -757,61 +757,61 @@ - - - - - + + + + + - - + + - + - + - + - + - + - + - + - + @@ -820,12 +820,12 @@ - + - + @@ -834,12 +834,12 @@ - + - + @@ -848,12 +848,12 @@ - + - + @@ -862,21 +862,21 @@ - + - + - + - + @@ -885,12 +885,12 @@ - + - + @@ -899,12 +899,12 @@ - + - + @@ -913,12 +913,12 @@ - + - + @@ -927,12 +927,12 @@ - + - + @@ -941,12 +941,12 @@ - + - + @@ -955,12 +955,12 @@ - + - + @@ -969,12 +969,12 @@ - + - + @@ -983,42 +983,42 @@ - + - + - + - + - + - + - + @@ -1027,16 +1027,16 @@ - + - + - + - + @@ -1045,12 +1045,12 @@ - + - + @@ -1059,30 +1059,30 @@ - + - + - + - + - + - + @@ -1091,12 +1091,12 @@ - + - + @@ -1105,26 +1105,26 @@ - + - + - + - + @@ -1133,12 +1133,12 @@ - + - + @@ -1147,14 +1147,14 @@ - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf149204.xml b/chart2/qa/extras/xshape/data/reference/tdf149204.xml index 5e157983d0d8..b14a27418d0a 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf149204.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf149204.xml @@ -47,15 +47,15 @@ - + - + - + - + - + @@ -64,30 +64,30 @@ - + - + - + - + - + - + @@ -96,30 +96,30 @@ - + - + - + - + - + - + @@ -128,35 +128,35 @@ - + - + - + - + - + @@ -175,7 +175,7 @@ - + @@ -184,14 +184,14 @@ - + - + - + @@ -200,16 +200,16 @@ - + - + - + - + @@ -218,12 +218,12 @@ - + - + @@ -232,30 +232,30 @@ - + - + - + - + - + - + @@ -264,12 +264,12 @@ - + - + @@ -278,30 +278,30 @@ - + - + - + - + - + - + @@ -310,12 +310,12 @@ - + - + @@ -324,26 +324,26 @@ - + - + - + - + @@ -352,12 +352,12 @@ - + - + @@ -366,12 +366,12 @@ - + - + @@ -380,14 +380,14 @@ - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf150832.xml b/chart2/qa/extras/xshape/data/reference/tdf150832.xml index 66730ab8504c..83750aea2054 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf150832.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf150832.xml @@ -14,9 +14,9 @@ - + - + @@ -25,12 +25,12 @@ - + - + @@ -39,18 +39,18 @@ - + - + - + - + - + @@ -59,116 +59,116 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + + + + + + @@ -184,49 +184,49 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + @@ -235,91 +235,91 @@ - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -357,19 +357,19 @@ - + - + - - + + @@ -379,30 +379,30 @@ - + - + - + - + - + - + @@ -412,29 +412,29 @@ - - - - - + + + + + - - + + - + - + @@ -444,29 +444,29 @@ - - - - - + + + + + - - + + - + - + @@ -477,8 +477,8 @@ - - + + @@ -486,28 +486,28 @@ - - + + - + - + - + - + @@ -517,29 +517,29 @@ - - - - - + + + + + - - + + - + - + @@ -549,29 +549,29 @@ - - - - - + + + + + - - + + - + - + @@ -581,61 +581,61 @@ - - - - - + + + + + - - + + - + - + - + - + - + - + - + - + @@ -644,12 +644,12 @@ - + - + @@ -658,12 +658,12 @@ - + - + @@ -672,21 +672,21 @@ - + - + - + - + @@ -695,12 +695,12 @@ - + - + @@ -709,12 +709,12 @@ - + - + @@ -723,12 +723,12 @@ - + - + @@ -737,12 +737,12 @@ - + - + @@ -751,12 +751,12 @@ - + - + @@ -765,12 +765,12 @@ - + - + @@ -779,12 +779,12 @@ - + - + @@ -793,42 +793,42 @@ - + - + - + - + - + - + - + @@ -837,16 +837,16 @@ - + - + - + - + @@ -855,12 +855,12 @@ - + - + @@ -869,30 +869,30 @@ - + - + - + - + - + - + @@ -901,12 +901,12 @@ - + - + @@ -915,26 +915,26 @@ - + - + - + - + @@ -943,12 +943,12 @@ - + - + @@ -957,14 +957,14 @@ - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf151424.xml b/chart2/qa/extras/xshape/data/reference/tdf151424.xml index c1aafbbd6a6d..eb37ef78c090 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf151424.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf151424.xml @@ -14,9 +14,9 @@ - + - + @@ -25,12 +25,12 @@ - + - + @@ -39,18 +39,18 @@ - + - + - + - + - + @@ -59,41 +59,41 @@ - + - + - + - + - + - + - - + + - - - - - - - + + + + + + + @@ -112,42 +112,42 @@ - + - + - + - + - + - + - - - - - - - + + + + + + + @@ -162,40 +162,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -217,19 +217,19 @@ - + - + - - + + @@ -239,40 +239,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -294,19 +294,19 @@ - + - + - - + + @@ -316,40 +316,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -371,19 +371,19 @@ - + - + - - + + @@ -393,40 +393,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -448,19 +448,19 @@ - + - + - - + + @@ -470,40 +470,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -525,19 +525,19 @@ - + - + - - + + @@ -547,40 +547,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -602,19 +602,19 @@ - + - + - - + + @@ -624,40 +624,40 @@ - + - + - + - + - - + + - - + + - - + + - - + + @@ -679,19 +679,19 @@ - + - + - - + + @@ -701,44 +701,44 @@ - + - + - + - + - + - + - + - - - - - - - + + + + + + + @@ -753,42 +753,42 @@ - + - + - + - + - + - + - - - - - - - + + + + + + + @@ -803,51 +803,51 @@ - + - + - + - + - + - + - + - + - + @@ -856,12 +856,12 @@ - + - + @@ -870,12 +870,12 @@ - + - + @@ -884,12 +884,12 @@ - + - + @@ -898,12 +898,12 @@ - + - + @@ -912,12 +912,12 @@ - + - + @@ -926,21 +926,21 @@ - + - + - + - + @@ -949,12 +949,12 @@ - + - + @@ -963,42 +963,42 @@ - + - + - + - + - + - + - + @@ -1007,16 +1007,16 @@ - + - + - + - + @@ -1025,19 +1025,19 @@ - + - + - - + + @@ -1047,30 +1047,30 @@ - + - + - + - + - + - + @@ -1079,19 +1079,19 @@ - + - + - - + + @@ -1101,26 +1101,26 @@ - + - + - + - + @@ -1129,12 +1129,12 @@ - + - + @@ -1143,14 +1143,14 @@ - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf90839-1.xml b/chart2/qa/extras/xshape/data/reference/tdf90839-1.xml index 94258a1b351d..46d075a06020 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf90839-1.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf90839-1.xml @@ -14,7 +14,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -39,12 +39,12 @@ - + - + @@ -175,15 +175,15 @@ - + - + - + - + - + @@ -192,21 +192,21 @@ - - + + - - + + - + - + @@ -215,21 +215,21 @@ - - + + - - + + - + - + @@ -238,21 +238,21 @@ - + - + - + - + @@ -261,21 +261,21 @@ - - + + - - + + - + - + @@ -284,49 +284,49 @@ - - + + - - + + - - + + - - + + - - + + - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf90839-2.xml b/chart2/qa/extras/xshape/data/reference/tdf90839-2.xml index 5a639abb0b53..9daee4752d08 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf90839-2.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf90839-2.xml @@ -14,7 +14,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -39,12 +39,12 @@ - + - + @@ -175,15 +175,15 @@ - + - + - + - + - + @@ -192,21 +192,21 @@ - + - + - + - + @@ -215,21 +215,21 @@ - + - + - + - + @@ -238,21 +238,21 @@ - + - + - + - + @@ -261,21 +261,21 @@ - + - + - + - + @@ -284,49 +284,49 @@ - + - + - + - + - + - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf90839-3.xml b/chart2/qa/extras/xshape/data/reference/tdf90839-3.xml index 863778e30c0b..d19a18c1980d 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf90839-3.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf90839-3.xml @@ -14,7 +14,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -39,12 +39,12 @@ - + - + @@ -175,15 +175,15 @@ - + - + - + - + - + @@ -192,21 +192,21 @@ - + - + - + - + @@ -215,21 +215,21 @@ - + - + - + - + @@ -238,21 +238,21 @@ - + - + - + - + @@ -261,21 +261,21 @@ - + - + - + - + @@ -284,49 +284,49 @@ - + - + - + - + - + - + - + diff --git a/chart2/qa/extras/xshape/data/reference/tdf90839-4.xml b/chart2/qa/extras/xshape/data/reference/tdf90839-4.xml index 7078cc6a26a3..79bd4392962e 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf90839-4.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf90839-4.xml @@ -14,7 +14,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -39,12 +39,12 @@ - + - + @@ -175,15 +175,15 @@ - + - + - + - + - + @@ -192,21 +192,21 @@ - + - + - + - + @@ -215,21 +215,21 @@ - + - + - + - + @@ -238,21 +238,21 @@ - + - + - + - + @@ -261,21 +261,21 @@ - + - + - + - + @@ -284,49 +284,49 @@ - + - + - + - + - + - + - + diff --git a/chart2/qa/extras/xshape/data/reference/testChart.xml b/chart2/qa/extras/xshape/data/reference/testChart.xml index ad64e5f3b69d..f86dfe0b996b 100644 --- a/chart2/qa/extras/xshape/data/reference/testChart.xml +++ b/chart2/qa/extras/xshape/data/reference/testChart.xml @@ -14,9 +14,9 @@ - + - + @@ -25,12 +25,12 @@ - + - + @@ -39,18 +39,18 @@ - + - + - + - + - + @@ -59,107 +59,107 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - - - - - - - + + + + + + + @@ -174,57 +174,57 @@ - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + @@ -235,20 +235,20 @@ - - + + - - + + - - + + - - + + @@ -261,143 +261,143 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -459,19 +459,19 @@ - + - + - - + + @@ -481,30 +481,30 @@ - + - + - + - + - + - + @@ -514,29 +514,29 @@ - - - - - + + + + + - - + + - + - + @@ -546,11 +546,11 @@ - - - - - + + + + + @@ -563,12 +563,12 @@ - + - + @@ -578,29 +578,29 @@ - - - - - + + + + + - - + + - + - + @@ -610,29 +610,29 @@ - - - - - + + + + + - - + + - + - + @@ -642,11 +642,11 @@ - - - - - + + + + + @@ -659,21 +659,21 @@ - + - + - + - + @@ -683,139 +683,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -828,44 +700,172 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + @@ -874,12 +874,12 @@ - + - + @@ -888,12 +888,12 @@ - + - + @@ -902,12 +902,12 @@ - + - + @@ -916,12 +916,12 @@ - + - + @@ -930,21 +930,21 @@ - + - + - + - + @@ -953,12 +953,12 @@ - + - + @@ -967,12 +967,12 @@ - + - + @@ -981,12 +981,12 @@ - + - + @@ -995,12 +995,12 @@ - + - + @@ -1009,12 +1009,12 @@ - + - + @@ -1023,12 +1023,12 @@ - + - + @@ -1037,42 +1037,42 @@ - + - + - + - + - + - + - + @@ -1081,16 +1081,16 @@ - + - + - + - + @@ -1099,12 +1099,12 @@ - + - + @@ -1113,30 +1113,30 @@ - + - + - + - + - + - + @@ -1145,12 +1145,12 @@ - + - + @@ -1159,26 +1159,26 @@ - + - + - + - + @@ -1187,12 +1187,12 @@ - + - + @@ -1201,14 +1201,14 @@ - + - + diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 8a960be8009d..a65a295d5758 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -337,8 +337,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( { tools::Long nWidthToFill = rTextCandidate.getWidthToFill(); - tools::Long nWidth - = mpOutputDevice->GetTextArray(rTextCandidate.getText(), &aDXArray, 0, 1); + tools::Long nWidth = basegfx::fround( + mpOutputDevice->GetTextArray(rTextCandidate.getText(), &aDXArray, 0, 1)); sal_Int32 nChars = 2; if (nWidth) nChars = nWidthToFill / nWidth; diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index a4367de4680e..db229190a403 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -38,7 +38,7 @@ static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, { const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen); - return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, true, nullptr, layoutGlyphs); + return basegfx::fround(pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, true, nullptr, layoutGlyphs)); } SvxFont::SvxFont() @@ -719,7 +719,7 @@ void SvxDoGetCapitalSize::Do( const OUString &_rTxt, const sal_Int32 _nIdx, if (pDXAry) { KernArray aKernArray; - aPartSize.setWidth(pOut->GetTextArray(_rTxt, &aKernArray, _nIdx, _nLen)); + aPartSize.setWidth(basegfx::fround(pOut->GetTextArray(_rTxt, &aKernArray, _nIdx, _nLen))); assert(pDXAry->get_factor() == aKernArray.get_factor()); auto& dest = pDXAry->get_subunit_array(); sal_Int32 nStart = dest.empty() ? 0 : dest.back(); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index a00351178065..53bfed56c5f2 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -1433,7 +1433,7 @@ CPPUNIT_TEST_FIXTURE(Test, testExtTextOutOpaqueAndClipWMF) assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/polypolygoncolor", "color"_ostr, "#ff8000"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/polypolygoncolor/polypolygon", - "path"_ostr, "m1067 1067h1296v473h-1296z"); + "path"_ostr, "m1067 1067h1317v473h-1317z"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/textsimpleportion", "text"_ostr, "OOOO"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/textsimpleportion", diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 5d6fa5a2c854..b7b9d741ebef 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2679,7 +2679,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText, } else { - aNormSize = Size( mpVDev->GetTextArray( rText, &aTmpArray ), 0 ); + aNormSize = Size(basegfx::fround(mpVDev->GetTextArray(rText, &aTmpArray)), 0); } // if text is rotated, set transform matrix at new g element diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 3211ed368989..5ed43d0cf299 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1035,12 +1035,16 @@ public: tools::Long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, vcl::text::TextLayoutCache const* = nullptr, SalLayoutGlyphs const*const pLayoutCache = nullptr) const; + double GetTextWidthDouble(const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::text::TextLayoutCache const* = nullptr, + SalLayoutGlyphs const* const pLayoutCache = nullptr) const; /** Height where any character of the current font fits; in logic coordinates. See also GetTextBoundRect() for more explanation + code examples. */ tools::Long GetTextHeight() const; + double GetTextHeightDouble() const; float approximate_digit_width() const; void DrawTextArray( const Point& rStartPt, const OUString& rStr, @@ -1050,7 +1054,7 @@ public: sal_Int32 nLen, SalLayoutFlags flags = SalLayoutFlags::NONE, const SalLayoutGlyphs* pLayoutCache = nullptr); - tools::Long GetTextArray( const OUString& rStr, KernArray* pDXAry, + double GetTextArray( const OUString& rStr, KernArray* pDXAry, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, bool bCaret = false, vcl::text::TextLayoutCache const* = nullptr, SalLayoutGlyphs const*const pLayoutCache = nullptr) const; @@ -1827,6 +1831,9 @@ private: */ SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel( tools::Long nY ) const; + SAL_DLLPRIVATE double ImplDevicePixelToLogicWidthDouble(double nWidth) const; + SAL_DLLPRIVATE double ImplDevicePixelToLogicHeightDouble(double nHeight) const; + /** @name Native Widget Rendering functions These all just call through to the private mpGraphics functions of the same name. diff --git a/sc/qa/uitest/chart/chartDataLabels.py b/sc/qa/uitest/chart/chartDataLabels.py index e619f0e6625b..da94cde5fa87 100644 --- a/sc/qa/uitest/chart/chartDataLabels.py +++ b/sc/qa/uitest/chart/chartDataLabels.py @@ -272,7 +272,7 @@ class chartDataLabels(UITestCase): with self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: - self.assertEqual("0.74", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("0.73", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("2.82", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) # Use OK button in order to test tdf#137165 @@ -283,7 +283,7 @@ class chartDataLabels(UITestCase): with self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: # Check the position has changed after moving the label using the arrows keys - self.assertEqual("0.64", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("0.63", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("2.72", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) diff --git a/sc/qa/uitest/chart/chartLegend.py b/sc/qa/uitest/chart/chartLegend.py index cf13dc97f5ce..7294331f489e 100644 --- a/sc/qa/uitest/chart/chartLegend.py +++ b/sc/qa/uitest/chart/chartLegend.py @@ -88,7 +88,7 @@ class chartLegend(UITestCase): xLegends.executeAction("SELECT", tuple()) with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: - self.assertEqual("4.61", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("4.59", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("1.54", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) @@ -96,7 +96,7 @@ class chartLegend(UITestCase): # Check the position has changed after moving the label using the arrows keys with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: - self.assertEqual("4.51", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("4.49", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("1.44", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) def test_Tdf147394(self): diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 6aaed8b55ab4..1735f6574be3 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -109,10 +109,10 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf128212) xmlDocUniquePtr pXmlDoc = load("pptx/tdf128212.pptx"); // Without the fix in place, this test would have failed with - // - Expected: 7793 + // - Expected: 7795 // - Actual : 12068 - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray"_ostr, "x"_ostr, "4521"); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray"_ostr, "y"_ostr, "7793"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray"_ostr, "x"_ostr, "4523"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray"_ostr, "y"_ostr, "7795"); } CPPUNIT_TEST_FIXTURE(SdLayoutTest, testColumnsLayout) @@ -316,10 +316,10 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testFitToFrameTextFitting) assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]"_ostr, "x"_ostr, "0"); assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]"_ostr, "y"_ostr, "406"); assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray"_ostr, "first"_ostr, - "110"); + "114"); #ifndef _WIN32 // Windows seems to differ in text layouting, so ignore for now assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray"_ostr, "last"_ostr, - "6981"); + "6984"); #endif } diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index 35b32640b510..bd1fe98ce631 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -653,7 +653,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL("3546, 3174, 738, 402"_ostr, + CPPUNIT_ASSERT_EQUAL("3545, 3174, 740, 402"_ostr, mpCallbackRecorder->m_aSearchResultSelection[0]); // Search next @@ -679,7 +679,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL("3546, 3174, 738, 402"_ostr, + CPPUNIT_ASSERT_EQUAL("3545, 3174, 740, 402"_ostr, mpCallbackRecorder->m_aSearchResultSelection[0]); } diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index f8df68fb3138..27848c6a23c0 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -426,18 +426,14 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_Fontwork_rendering_font_siz static_cast(*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. + // The expected values 1501|1777, 3947 x 1446 are only valid for 96dpi. tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); - tools::Rectangle aExpected(Point(1501, 1777), Size(3941, 1446)); + tools::Rectangle aExpected(Point(1501, 1777), Size(3947, 1446)); CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aExpected, aBoundRect, 5); } CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) { - // The tested positions depend on dpi. - if (!IsDefaultDPI()) - return; - // tdf#145004 In case ScaleX is true in property TextPath, SDRTEXTVERTADJUST is // evaluated and should shift the Fontwork text. That did not work for // 'Top-Left' and 'Bottom-Left'. @@ -451,10 +447,9 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) SdrObjCustomShape& rSdrCustomShape( static_cast(*SdrObject::getSdrObjectFromXShape(xShape))); - // Without the fix in place top was 2295, but should be 2908 for 96dpi. - // Was 2184, should be 2886 for 120dpi. + // Without the fix in place top was 2295, but should be 2900. tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(2908), aBoundRect.Top(), 5); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(2900), aBoundRect.Top(), 5); } { // Second shape has anchor set to Bottom-Left, which shifts Fontwork text up. @@ -462,10 +457,9 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) SdrObjCustomShape& rSdrCustomShape( static_cast(*SdrObject::getSdrObjectFromXShape(xShape))); - // Without the fix in place top was 10294, but should be 9508 for 96dpi. - // Was 10184, should be 9481 for 120dpi. + // Without the fix in place top was 10294, but should be 9500. tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(9508), aBoundRect.Top(), 5); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(9500), aBoundRect.Top(), 5); } } diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index 01e7aaae7944..47fad780d73b 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -153,7 +153,7 @@ sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, css::uno::Sequence vcl::Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); KernArray aDXA; - nRet = pOutDev->GetTextArray( str, &aDXA ); + nRet = basegfx::fround(pOutDev->GetTextArray(str, &aDXA)); rDXArray.realloc(aDXA.size()); sal_Int32* pArray = rDXArray.getArray(); for (size_t i = 0, nLen = aDXA.size(); i < nLen; ++i) diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index 8a847def8763..f7cc6393b02c 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -86,7 +86,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testArabic) 3899, 4550, 5119, 5689, 5689, 6307, 6925, 8484, 9135, 9705, 10927, 10927, 11497, 12595, 12595 }; KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aOneTwoThree, &aCharWidths); + tools::Long nTextWidth = basegfx::fround(pOutDev->GetTextArray(aOneTwoThree, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); // this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73 @@ -267,7 +267,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) // and the next ones are all zero width. nRefTextWidth = 3611; aRefCharWidths = { 1168, 1168, 1819, 2389, 3611, 3611 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -275,7 +275,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 584, 1168, 1819, 2389, 3000, 3611 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -284,7 +284,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) // component count. aText = u"لَاَ بلَاَ"_ustr; aRefCharWidths = { 584, 584, 1168, 1168, 1819, 2389, 3000, 3000, 3611, 3611 }; - nTextWidth2 = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth2 = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aCharWidths[0], aCharWidths[1]); CPPUNIT_ASSERT_EQUAL(aCharWidths[2], aCharWidths[3]); CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]); @@ -301,7 +301,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) // and the next ones are all zero width. nRefTextWidth = 8493; aRefCharWidths = { 1290, 1290, 1941, 3231, 3231, 3882, 5862, 5862, 5862, 6513, 8493, 8493, 8493 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -309,7 +309,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 645, 1290, 1941, 2586, 3231, 3882, 4542, 5202, 5862, 6513, 7173, 7833, 8493 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -340,7 +340,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) // and the next ones are all zero width. nRefTextWidth = 1710; aRefCharWidths= { 582, 582, 842, 1111, 1710, 1710 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -348,7 +348,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 291, 582, 842, 1111, 1410, 1710 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -357,7 +357,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) // component count. aText = u"لَاَ بلَاَ"_ustr; aRefCharWidths = { 291, 291, 582, 582, 842, 1111, 1410, 1410, 1710, 1710 }; - nTextWidth2 = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth2 = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aCharWidths[0], aCharWidths[1]); CPPUNIT_ASSERT_EQUAL(aCharWidths[2], aCharWidths[3]); CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]); @@ -379,7 +379,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) nRefTextWidth = 5996; aRefCharWidths = { 519, 519, 811, 1606, 1606, 1606, 1898, 2439, 2439, 2731, 3544, 3544, 3544, 3836, 4634, 4634, 4926, 5996, 5996, 5996 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/false)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -388,7 +388,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) // components. aRefCharWidths = { 269, 519, 811, 1080, 1348, 1606, 1898, 2171, 2439, 2731, 3004, 3278, 3544, 3836, 4138, 4634, 4926, 5199, 5494, 5996 }; - nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true); + nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/true)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); @@ -410,7 +410,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048) tools::Long nRefTextWidth(5495); KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths); + tools::Long nTextWidth = basegfx::fround(pOutDev->GetTextArray(aText, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); @@ -443,7 +443,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048_2) // get an compare the default text array KernArray aCharWidths; - auto nTextWidth = pOutDev->GetTextArray(u"ع a ع"_ustr, &aCharWidths); + auto nTextWidth = basegfx::fround(pOutDev->GetTextArray(u"ع a ع"_ustr, &aCharWidths)); // Text width should always be equal to the width of the last glyph in the // kern array. @@ -514,7 +514,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testMixedCJKLatinScript_glyph_advanceme tools::Long nRefTextWidth = 704; std::vector aRefCharWidths = { 72, 144, 190, 236, 259, 305, 333, 379, 425, 474, 523, 551, 567, 612, 658, 704 }; KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aTestScript, &aCharWidths); + tools::Long nTextWidth = basegfx::fround(pOutDev->GetTextArray(aTestScript, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx index 371783759b65..776522641f1e 100644 --- a/vcl/qa/cppunit/text.cxx +++ b/vcl/qa/cppunit/text.cxx @@ -237,7 +237,7 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextFontSpecificKerning) tools::Long nRefTextWidth = 2671; std::vector aRefCharWidths = { 1270, 2671 }; KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aAV, &aCharWidths); + tools::Long nTextWidth = basegfx::fround(pOutDev->GetTextArray(aAV, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths.get_subunit_array()[0]); CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths.get_subunit_array()[1]); @@ -286,7 +286,7 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextNoKerning) tools::Long nRefTextWidth = 2802; std::vector aRefCharWidths = { 1401, 2802 }; KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aAV, &aCharWidths); + tools::Long nTextWidth = basegfx::fround(pOutDev->GetTextArray(aAV, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths.get_subunit_array()[0]); CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths.get_subunit_array()[1]); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index cecdb98d8407..3b349b9f70ac 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -882,7 +882,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, K } else { - nNormWidth = maVDev->GetTextArray( rText, &aOwnArray ); + nNormWidth = basegfx::fround(maVDev->GetTextArray(rText, &aOwnArray)); pDX = aOwnArray; } diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index ecd4ce5f7fb2..f3e0ae81c9a0 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1198,7 +1198,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) pVirDev->SetFont( aSrcFont ); const sal_Int32 nLen = aTemp.getLength(); KernArray aDXAry; - const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr ); + const sal_Int32 nNormSize = basegfx::fround(pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr )); if (nLen && nNormSize == 0) { OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 8707805eb1c2..5f6f7cfc7268 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -259,6 +259,19 @@ static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, tools::Long return n; } +static double ImplPixelToLogicDouble(double n, tools::Long nDPI, tools::Long nMapNum, + tools::Long nMapDenom) +{ + assert(nDPI > 0); + if (nMapNum == 0) + return 0; + + n *= nMapDenom; + n /= nDPI; + n /= nMapNum; + return n; +} + tools::Long OutputDevice::ImplLogicXToDevicePixel( tools::Long nX ) const { if ( !mbMap ) @@ -301,6 +314,14 @@ tools::Long OutputDevice::ImplDevicePixelToLogicWidth( tools::Long nWidth ) cons return ImplPixelToLogic(nWidth, mnDPIX, maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX); } +SAL_DLLPRIVATE double OutputDevice::ImplDevicePixelToLogicWidthDouble(double nWidth) const +{ + if (!mbMap) + return nWidth; + + return ImplPixelToLogicDouble(nWidth, mnDPIX, maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX); +} + tools::Long OutputDevice::ImplDevicePixelToLogicHeight( tools::Long nHeight ) const { if ( !mbMap ) @@ -309,6 +330,14 @@ tools::Long OutputDevice::ImplDevicePixelToLogicHeight( tools::Long nHeight ) co return ImplPixelToLogic(nHeight, mnDPIY, maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY); } +double OutputDevice::ImplDevicePixelToLogicHeightDouble(double nHeight) const +{ + if (!mbMap) + return nHeight; + + return ImplPixelToLogicDouble(nHeight, mnDPIY, maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY); +} + Point OutputDevice::ImplLogicToDevicePixel( const Point& rLogicPt ) const { if ( !mbMap ) diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 961c095e01f9..2ed9dc9a820e 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -642,11 +642,15 @@ tools::Long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const { + double nWidth = GetTextWidthDouble(rStr, nIndex, nLen, pLayoutCache, pSalLayoutCache); + return basegfx::fround(nWidth); +} - tools::Long nWidth = GetTextArray( rStr, nullptr, nIndex, - nLen, false, pLayoutCache, pSalLayoutCache ); - - return nWidth; +double OutputDevice::GetTextWidthDouble(const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen, + vcl::text::TextLayoutCache const* const pLayoutCache, + SalLayoutGlyphs const* const pSalLayoutCache) const +{ + return GetTextArray(rStr, nullptr, nIndex, nLen, false, pLayoutCache, pSalLayoutCache); } tools::Long OutputDevice::GetTextHeight() const @@ -662,6 +666,16 @@ tools::Long OutputDevice::GetTextHeight() const return nHeight; } +double OutputDevice::GetTextHeightDouble() const +{ + if (!InitFont()) + return 0; + + tools::Long nHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent; + + return ImplDevicePixelToLogicHeightDouble(nHeight); +} + float OutputDevice::approximate_char_width() const { //note pango uses "The quick brown fox jumps over the lazy dog." for english @@ -710,7 +724,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr, mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, pKashidaAry, nIndex, nLen, flags ); } -tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernArray, +double OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernArray, sal_Int32 nIndex, sal_Int32 nLen, bool bCaret, vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const @@ -768,7 +782,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernAr if (mbMap) { for (int i = 0; i < nLen; ++i) - (*pDXPixelArray)[i] = ImplDevicePixelToLogicWidth((*pDXPixelArray)[i] * nSubPixelFactor); + (*pDXPixelArray)[i] = ImplDevicePixelToLogicWidthDouble((*pDXPixelArray)[i] * nSubPixelFactor); } else if (nSubPixelFactor) { @@ -784,10 +798,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernAr (*pDXAry)[i] = basegfx::fround((*pDXPixelArray)[i]); } - if (mbMap) - nWidth = ImplDevicePixelToLogicWidth( nWidth ); - - return basegfx::fround(nWidth); + return ImplDevicePixelToLogicWidthDouble(nWidth); } void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretXArray, diff --git a/vcl/source/text/textlayout.cxx b/vcl/source/text/textlayout.cxx index 7f69c1726fe1..d43549a589d3 100644 --- a/vcl/source/text/textlayout.cxx +++ b/vcl/source/text/textlayout.cxx @@ -486,7 +486,7 @@ namespace vcl tools::Long DefaultTextLayout::GetTextArray( const OUString& _rText, KernArray* _pDXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength, bool bCaret ) const { - return m_rTargetDevice.GetTextArray( _rText, _pDXArray, _nStartIndex, _nLength, bCaret ); + return basegfx::fround(m_rTargetDevice.GetTextArray( _rText, _pDXArray, _nStartIndex, _nLength, bCaret )); } sal_Int32 DefaultTextLayout::GetTextBreak( const OUString& _rText, tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const @@ -594,7 +594,7 @@ namespace vcl return 0; // retrieve the character widths from the reference device - tools::Long nTextWidth = m_rReferenceDevice.GetTextArray( _rText, _pDXAry, _nStartIndex, _nLength, bCaret ); + tools::Long nTextWidth = basegfx::fround(m_rReferenceDevice.GetTextArray( _rText, _pDXAry, _nStartIndex, _nLength, bCaret )); #if OSL_DEBUG_LEVEL > 1 if ( _pDXAry ) {