Bug 145322 - Writer: All characters rotate when printing a vertical writing page
Summary: Writer: All characters rotate when printing a vertical writing page
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.0.4 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.4.0 target:7.3.0.0.beta2 tar...
Keywords: bibisected, bisected, regression
Depends on:
Blocks: CJK Vertical-Text
  Show dependency treegraph
 
Reported: 2021-10-26 13:32 UTC by Shinji Enoki
Modified: 2022-06-12 12:12 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Sample vertical document (14.01 KB, application/vnd.oasis.opendocument.text)
2021-10-26 13:34 UTC, Shinji Enoki
Details
Comparison of print results (143.73 KB, image/png)
2021-10-26 13:41 UTC, Shinji Enoki
Details
Comparison of print results (357.18 KB, image/png)
2021-10-26 13:45 UTC, Shinji Enoki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shinji Enoki 2021-10-26 13:32:42 UTC
Description:
When printing a vertical writing document, the characters is rotated 90 degrees to the right.
This happens in Writer vertical writing documents.
It doesn't change even if Skia setting is turned off.



Steps to Reproduce:
1. Start Writer
2. Input Japanese charactors
3. Select menu [Format]-[Page Style] 
4. Click Page tab, Select "Right-to-Left(vertical)" in Text direction, click "OK"
5. Select menu [File]-[Print]
6. Selct "Microsoft Print ot PDF", click "Print"
7. Check the PDF file 

If you open the sample file, start from step 6

Actual Results:
All characters rotate

Expected Results:
Those characters do not rotate


Reproducible: Always


User Profile Reset: No



Additional Info:
Reproduced in the following version:

Version: 7.2.2.2 (x64) / LibreOffice Community
Build ID: 02b2acce88a210515b4a5bb2e46cbfb63fe97d56
CPU threads: 2; OS: Windows 10.0 Build 17763; UI render: default; VCL: win
Locale: ja-JP (ja_JP); UI: en-US
Calc: threaded

Version: 7.2.0.4 (x64) / LibreOffice Community
Build ID: 9a9c6381e3f7a62afc1329bd359cc48accb6435b
CPU threads: 2; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: threaded


Not reproduced in the following versions:

Version: 7.1.6.2 (x64) / LibreOffice Community
Build ID: 0e133318fcee89abacd6a7d077e292f1145735c3
CPU threads: 2; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: threaded
Comment 1 Shinji Enoki 2021-10-26 13:34:32 UTC
Created attachment 175924 [details]
Sample vertical document
Comment 2 Shinji Enoki 2021-10-26 13:41:05 UTC
Created attachment 175925 [details]
Comparison of print results

Comparison of print results between 7.2.2 and 7.1.6
Comment 3 Shinji Enoki 2021-10-26 13:45:17 UTC
Created attachment 175926 [details]
Comparison of print results

The screenshot I attached was small, so I will attach it again
Comment 4 JO3EMC 2021-10-26 16:20:13 UTC
Reproduced.

Version: 7.2.2.2 (x64) / LibreOffice Community
Build ID: 02b2acce88a210515b4a5bb2e46cbfb63fe97d56
CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: default; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL
Comment 5 JO3EMC 2021-10-26 16:29:27 UTC
Also, reproduced with 7.2.1 and 7.2.3.

Version: 7.2.1.2 (x64) / LibreOffice Community
Build ID: 87b77fad49947c1441b67c559c339af8f3517e22
CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: Skia/Vulkan; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL

Version: 7.2.3.0.0+ (x64) / LibreOffice Community
Build ID: e2e2262e35278a12e716fef3cd61145047ef8680
CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: default; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL


Didn't reproduced with 7.1.6.
Comment 6 Aron Budea 2021-10-26 17:44:56 UTC
Bibisected to the following commit using repo bibisect-win64-7.2. I assume it's more of an implementation error on the side of DWriteTextRenderer that this commit switched to. Adding CC: to Mark Hung.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=5686c1aca40beb9514d40c86b4a3780a8a1334ba
author		Mark Hung <marklh9@gmail.com>	2021-05-02 14:45:45 +0800
committer	Mark Hung <marklh9@gmail.com>	2021-05-10 21:14:09 +0200

vcl: use DWriteTextRenderer for vertical writing.
Comment 7 himajin100000 2021-11-21 13:12:51 UTC Comment hidden (obsolete)
Comment 8 himajin100000 2021-11-21 13:19:25 UTC Comment hidden (obsolete)
Comment 9 himajin100000 2021-11-21 14:26:58 UTC
seems I was wrong. need to rethink.
Comment 10 Mark Hung 2021-11-22 01:04:27 UTC
@himajin100000

Printing in vertical layout always uses ExTextOutRenderer[1]. That is, it uses ancient, magical, messy Win32 API, ExtTextOutW, to render the text.

To render CJK upright text in vertical writing with ExtTextOutW, one has to prepend a '@' to the font name and call CreateFontIndirectW to create a different font. But for some other characters, one needs to create different font with altered escapement and orientation to force 90 degree rotation. Those were removed in bibisected fault commit[2]. 

Even if the commit is reverted, I still don't know how to make offset correct for ExtTextOutW. Positions from HarfBuzz doesn't work well with ExtTextOutW.

More correct way other than tweaking the position by experiments:
- Make DWriteTextOutRednerer works with a printing DC, maybe by create a compatible DC and bitbliting it, or create command list feature introduce in Windows8.
- Make Skia works with printing. Check with Luboš Luňák, maybe he has an idea how to print on SKia.
- Treat different logical font created with CreateFontIndirectW(), as fallback font. ( i.e. Glyphs that needs a force rotated font has to be renered in fallback layout with the rotated font. )

Non of them are easy for me, but I'll try to come out a commit that revert[2], that at least improves character orienation.

[1] https://opengrok.libreoffice.org/xref/core/vcl/win/gdi/winlayout.cxx?r=677434a5#276
[2] https://cgit.freedesktop.org/libreoffice/core/commit/?id=5686c1aca40beb9514d40c86b4a3780a8a1334ba
[3] https://docs.microsoft.com/en-us/windows/win32/direct2d/printing-and-command-lists
Comment 11 Commit Notification 2021-12-07 09:53:36 UTC
Mark Hung committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6720e9569d7ab6c20616ec6b97e5d4a56948908b

tdf#145322, tdf#144378 fix printing for vertical writing

It will be available in 7.4.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 12 Commit Notification 2021-12-09 12:01:31 UTC
Mark Hung committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/3c2836972613ff418d76306d958a8ef85ff18afe

tdf#145322, tdf#144378 fix printing for vertical writing

It will be available in 7.3.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.
Comment 13 Commit Notification 2021-12-11 16:57:13 UTC
Mark Hung committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/25b77b4a684695e8948c8a97902c8e9de80b446e

tdf#145322, tdf#144378 fix printing for vertical writing

It will be available in 7.2.5.

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 14 JO3EMC 2022-04-06 06:46:06 UTC
It's late, but I'll report it.
It seems to be resolved in 7.3.2 and 7.2.6.
Even at 7.4.0.