Bug 142997 - [EMF+] stringAlignmentHorizontalOffset is incorrect for StringFormat StringAlign set to 'center' or 'far'
Summary: [EMF+] stringAlignmentHorizontalOffset is incorrect for StringFormat StringAl...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+ Master
Hardware: All All
: medium normal
Assignee: Bartosz
URL:
Whiteboard: target:7.3.0 target:7.2.0.0.beta2
Keywords:
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
 
Reported: 2021-06-23 04:13 UTC by Valek Filippov
Modified: 2021-07-02 21:47 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
EMF sample with a set of StringAlign values (1.67 KB, image/x-emf)
2021-06-23 04:15 UTC, Valek Filippov
Details
Screenshot of the sample opened in MS Paint (top) and LO7.3alpha (bottom) (11.71 KB, image/png)
2021-06-23 04:17 UTC, Valek Filippov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Valek Filippov 2021-06-23 04:13:43 UTC
Description:
LO calculates incorrect value for stringAlignmentHorizontalOffset.
It seems to become worse with larger font sizes.

Steps to Reproduce:
Open attached EMF sample.

Actual Results:
LO draws "H Align center H" and "H Align far HHHH" lines progressively shifted to the left from their expected positions.

Expected Results:
'Align center' string should be centered, 'Align far' string should be right aligned with the 'scale'.


Reproducible: Always


User Profile Reset: No



Additional Info:
Minified from AOO i#74168.

Calculation happens here:
https://github.com/LibreOffice/core/blob/master/drawinglayer/source/tools/emfphelperdata.cxx#L1578:L1586
Comment 1 Valek Filippov 2021-06-23 04:15:03 UTC
Created attachment 173095 [details]
EMF sample with a set of StringAlign values
Comment 2 Valek Filippov 2021-06-23 04:17:29 UTC
Created attachment 173096 [details]
Screenshot of the sample opened in MS Paint (top) and LO7.3alpha (bottom)
Comment 3 Roman Kuznetsov 2021-06-24 13:16:37 UTC
confirm in

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: de7356c2e0cb099fac396808b5a86a0393b48e5f
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Vulkan; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded
Comment 4 Commit Notification 2021-07-01 21:51:02 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/574dc1e8ff6ea4214fefd91216fca5146a4ff13e

EMF+ tdf#142995 tdf#142997 tdf#143076 Add alignment support for DrawString

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2021-07-02 10:51:33 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/b19b08e51163e949ba4aa656196ebb554ca879a2

EMF+ tdf#142995 tdf#142997 tdf#143076 Add alignment support for DrawString

It will be available in 7.2.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.