Bug 101686 - Text render changes to RTL depending on zoom level
Summary: Text render changes to RTL depending on zoom level
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: RTL-CTL
  Show dependency treegraph
 
Reported: 2016-08-23 14:06 UTC by Jacobo Aragunde Pérez
Modified: 2023-06-01 00:00 UTC (History)
3 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.