Bug 101686 - Text render changes to RTL depending on zoom level
Summary: Text render changes to RTL depending on zoom level
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Jonathan Clark
URL:
Whiteboard: target:25.2.0 target:24.8.0.2
Keywords:
: 125986 (view as bug list)
Depends on:
Blocks: RTL
  Show dependency treegraph
 
Reported: 2016-08-23 14:06 UTC by Jacobo Aragunde Pérez
Modified: 2024-08-05 14:42 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Incorrect rendering example with zoom >75 (120.07 KB, image/png)
2016-08-23 14:06 UTC, Jacobo Aragunde Pérez
Details
Correct rendering example with zoom <=75 (114.31 KB, image/png)
2016-08-23 14:06 UTC, Jacobo Aragunde Pérez
Details
Test document (55.50 KB, application/msword)
2016-08-23 14:08 UTC, Jacobo Aragunde Pérez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jacobo Aragunde Pérez 2016-08-23 14:06:33 UTC
Created attachment 126987 [details]
Incorrect rendering example with zoom >75

With attached sample, the three text boxes on the top of the document are rendered left-to-right or right-to-left depending on the zoom level. See attached screenshots.

Version: 5.2.0.4.0+
Build ID: 883df5accee144490a48aeae5f128a397b7c0dd9
CPU Threads: 4; OS Version: Linux 4.6; UI Render: default; 
Locale: en-US (en_US.UTF-8)
Comment 1 Jacobo Aragunde Pérez 2016-08-23 14:06:59 UTC
Created attachment 126988 [details]
Correct rendering example with zoom <=75
Comment 2 Jacobo Aragunde Pérez 2016-08-23 14:08:01 UTC
Created attachment 126989 [details]
Test document
Comment 3 Jacobo Aragunde Pérez 2016-08-23 14:11:14 UTC
Bug can be reproduced in 4.4.5.2, changing version field.
Comment 4 Buovjaga 2016-09-20 19:36:06 UTC
Confirmed.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.3.0.0.alpha0+
Build ID: 5c8ad526447934a5eae94fa5f40584083a874d9f
CPU Threads: 8; OS Version: Linux 4.7; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on September 19th 2016

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 5 Xisco Faulí 2017-09-29 08:47:56 UTC Comment hidden (obsolete)
Comment 6 Jacobo Aragunde Pérez 2017-10-05 15:48:05 UTC
Bug can still be reproduced, but conditions have changed a bit; now the document is properly rendered with a 200% zoom level or with a value <50%, but the text boxes on the header change to RTL with other zoom values.

Version: 5.3.6.1
Build ID: 5.3.6.1-5.fc26
CPU Threads: 4; OS Version: Linux 4.12; UI Render: default; VCL: gtk3; Layout Engine: new; 
Locale: es-ES (en_US.UTF-8); Calc: group
Comment 7 QA Administrators 2018-10-06 02:50:26 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2020-10-06 03:44:18 UTC Comment hidden (obsolete)
Comment 9 Jacobo Aragunde Pérez 2020-10-06 07:27:12 UTC
Still reproducible.

Version: 6.3.6.2
Build ID: 6.3.6.2-4.fc31
CPU threads: 8; OS: Linux 5.8; UI render: default; VCL: gtk3; 
Locale: es-ES (en_US.UTF-8); UI-Language: en-US
Calc: threaded
Comment 10 ⁨خالد حسني⁩ 2023-05-31 09:50:17 UTC
I tried to debug this. My findings so far:

* The default paragraph style has direction set to right to left, setting it to
  left to right or inherit fixes the issue.
* For some reason the frames are sometimes RTL and some times LTR and it changes
  with zoom level.
* For some other reason, when frame is RTL we force the text to be RTL and skip BiDi algorithm altogether. This sounds wrong and the following patch fixes the issue, but it might be breaking something else (though I can’t imagine a legitimate case to force text to be RTL this way, to be honest):

diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index dd436e0358c6..fe07341dcc57 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -292,8 +292,8 @@ void SwTextSizeInfo::CtorInitTextSizeInfo( OutputDevice* pRenderContext, SwTextF
     // Set default layout mode ( LTR or RTL ).
     if ( m_pFrame->IsRightToLeft() )
     {
-        m_pOut->SetLayoutMode( vcl::text::ComplexTextLayoutFlags::BiDiStrong | vcl::text::ComplexTextLayoutFlags::BiDiRtl );
-        m_pRef->SetLayoutMode( vcl::text::ComplexTextLayoutFlags::BiDiStrong | vcl::text::ComplexTextLayoutFlags::BiDiRtl );
+        m_pOut->SetLayoutMode( vcl::text::ComplexTextLayoutFlags::BiDiStrong );
+        m_pRef->SetLayoutMode( vcl::text::ComplexTextLayoutFlags::BiDiStrong );
         m_nDirection = DIR_RIGHT2LEFT;
     }
     else
Comment 11 ⁨خالد حسني⁩ 2023-06-01 00:00:35 UTC
I tried the simple thing https://gerrit.libreoffice.org/c/core/+/152420 but it broke Arabic text, so more digging is needed.
Comment 12 Commit Notification 2024-07-03 19:05:34 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/71b7313aa2324b8f7da2026e7b7c2d1c942b497c

tdf#101686 Writer textbox direction changes depending on zoom

It will be available in 25.2.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 13 Xisco Faulí 2024-07-24 06:53:33 UTC
Verified in

Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a7de9cc5e89cd0d0c2f6363b2c0cc265c528b121
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

@Jonathan, thanks for fixing this issue!!
Comment 14 Commit Notification 2024-07-24 10:05:10 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/041f8afceba0331a2c64004dfcf840c6122812b5

tdf#101686 Writer textbox direction changes depending on zoom

It will be available in 24.8.0.2.

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 15 Jacobo Aragunde Pérez 2024-07-24 10:24:39 UTC
An old bug bites the dust! Congratulations to everyone involved!
Comment 16 Gabor Kelemen (allotropia) 2024-08-05 14:42:14 UTC
*** Bug 125986 has been marked as a duplicate of this bug. ***