diff options
author | Hossein <hossein@libreoffice.org> | 2021-09-02 18:29:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-09-03 09:37:37 +0200 |
commit | d25906087918c085239aac30fd72cb65aa7b9eb4 (patch) | |
tree | c15aa6a45d23d0e102ef89b6481d3654b66e280c /emfio/source/reader | |
parent | 9e7f07dc1378354a5228898e339f8336bbbb41f3 (diff) |
tdf#88163 Fix WMF font size
The problems in tdf#88163 can be categorized into two parts:
1. A regression which is caused by the commit
a9020e461803964a206d5551884b70717eed165c. The font size for text is
wrongly calculated for wmf files WITHOUT the placeable header.
2. A long-lasting bug that has existed from LO 3.5 (tested with
various LibreOffice versions from 3.5 to master). The font size for
text is wrongly calculated for wmf files WITH the placeable header.
This patch solves the first part. In this patch the way wmf is scaled
is changed using mnUnitsPerInch as a variable that controls the scale.
The previous method was dividing the left/right/top/bottom fields of
aPlaceableBound which caused the bad scaling of text.
The second problem still remains, and possibly can be solved by usign
the old scaling method that was previously used here (dividing pos
values of aPlaceableBound), but the scaling factor should be
calculated, which varies in different wmf files. More study should be
done to solve this part.
Values used for the example "visio_import_source.wmf" used in the test
WmfTest::testNonPlaceableWmf() are slightly changed, but the rendering
should not noticeably change, except the fix for the text font size.
A new test WmfTest::testTdf88163NonPlaceableWmf() is added which
checks for both font height and text boxes' positions. Font height
can depend on the exact font that is used for Roman in the platform,
so it vary between Linux, Windows and macOS. Thus, a range is used
for ensuring that the font height is correct.
By visual inspection, it is confirmed that this fix does not affect
fdo#74336 and the fix for it still works for attachment 93188.
Change-Id: I55bf38ba4345a0aa48c3e522976a2a5c32f7ec8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121272
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'emfio/source/reader')
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 82c6210acbbf..62f03fc8df25 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1470,11 +1470,8 @@ namespace emfio const double fMaxWidth = static_cast<double>(aMaxWidth); double fRatio = aPlaceableBound.GetWidth() / fMaxWidth; - aPlaceableBound = tools::Rectangle( - aPlaceableBound.Left() / fRatio, - aPlaceableBound.Top() / fRatio, - aPlaceableBound.Right() / fRatio, - aPlaceableBound.Bottom() / fRatio); + // changing mnUnitsPerInch as a tool to scale wmf + mnUnitsPerInch *= fRatio; SAL_INFO("emfio", "Placeable bounds " " left: " << aPlaceableBound.Left() << " top: " << aPlaceableBound.Top() |