Bug 134193 - sm Formula editor does not support RTL-CTL localized presentation markup, just content markup of formulas
Summary: sm Formula editor does not support RTL-CTL localized presentation markup, jus...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Formula-Editor RTL-CTL
  Show dependency treegraph
 
Reported: 2020-06-21 13:46 UTC by libre officer
Modified: 2021-02-26 20:51 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Arabic formula test (5.56 KB, application/vnd.oasis.opendocument.formula)
2020-06-21 13:46 UTC, libre officer
Details
RTL problem (24.09 KB, image/png)
2020-06-21 13:47 UTC, libre officer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description libre officer 2020-06-21 13:46:24 UTC
Description:
When I type a formula using Arabic, the command and the output is displayed as if it is a left-to-right writing system.

Steps to Reproduce:
1. Open attached file
2. Check out the formula (d = v × t)

Actual Results:
Command window:

المدة times السرعة = المسافة

Output window:

المدة × السرعة = المسافة


Expected Results:
Command window:

المسافة = السرعة times المدة

Output window:

المسافة = السرعة × المدة



Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.0.0.0.beta1 (x64)
Build ID: 94f789cbb33335b4a511c319542c7bdc31ff3b3c
CPU threads: 4; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: fr-CH (fr_FR); UI: en-GB
Calc: threaded


Note: left-to-right and right-to-left toolbar buttons are both disabled (see picture attachment)
Comment 1 libre officer 2020-06-21 13:46:49 UTC
Created attachment 162253 [details]
Arabic formula test
Comment 2 libre officer 2020-06-21 13:47:20 UTC
Created attachment 162254 [details]
RTL problem
Comment 3 V Stuart Foote 2020-06-21 17:15:45 UTC
Our native StarMath, and MathML in general, provide limited support for Presentation Markup of Arabic mathematical notation. Only the Content Markup needed for standard mathematical notation.

ICU libs Unicode bidi is functional for literal strings, but literal formulas as in OP simply need to be entered in line with text in the module in use.

Would require dev effort to refactor the sm Formula editor to provide logic needed to handle localized literal formula input and localized Presentation martup of formulas.

=-ref-=

https://www.w3.org/TR/2006/NOTE-arabic-math-20060131/
Comment 4 libre officer 2020-06-22 13:38:48 UTC
(In reply to V Stuart Foote from comment #3)
> Our native StarMath, and MathML in general, provide limited support for
> Presentation Markup of Arabic mathematical notation. Only the Content Markup
> needed for standard mathematical notation.
> 
> ICU libs Unicode bidi is functional for literal strings, but literal
> formulas as in OP simply need to be entered in line with text in the module
> in use.
> 
> Would require dev effort to refactor the sm Formula editor to provide logic
> needed to handle localized literal formula input and localized Presentation
> martup of formulas.
> 
> =-ref-=
> 
> https://www.w3.org/TR/2006/NOTE-arabic-math-20060131/

I see that the complex formula are difficult to reimplement, but at least for primary and secondary schools, you mostly need the ability to be able to render the unicode bidirectional characters (specially: LRE, RLE, PDF, RLM, LRM, etc.) in the output window.

At this moment, this is ignored in the output window, but supported in the command window (however, it should have the right/left alignment).
Comment 5 V Stuart Foote 2020-06-22 14:04:20 UTC
Yes, probably a valid enhancement that the Formula pane, and inline OLE provide more than simple bidi response to entered strings--and support minimal Presentation markup needs.

But IIUC that is not supported in any fashion by current sm command logic and node generators which were implemented to produce normalized mathematical formula content.
Comment 6 V Stuart Foote 2020-06-22 17:37:58 UTC
Due to poor direction handling of formula parsers, RTL formulas were specifically suppressed for OpenOffice.org i62413 in 2006.

https://opengrok.libreoffice.org/xref/core/starmath/source/edit.cxx?a=true&r=be53f326#87
Comment 7 libre officer 2020-06-24 10:57:43 UTC
(In reply to V Stuart Foote from comment #6)
> Due to poor direction handling of formula parsers, RTL formulas were
> specifically suppressed for OpenOffice.org i62413 in 2006.
> 
> https://opengrok.libreoffice.org/xref/core/starmath/source/edit.
> cxx?a=true&r=be53f326#87

2006 is considered antiquity era in 2020 !

However, I strongly disagree with Rüdiger Timm's `Even RTL languages don't use RTL for math` !! That's completely wrong, many countries still uses Arabic letters in math formula.

People forgot that Math formula could be written in other languages to teach kids in school basic geometry rules. For example, how can somebody type this 5th grade formula without inducing kids in error:


مساحة شبه المنحرف = (القاعدة الكبرى + القاعدة الصغرى) × الارتفاع ÷ 2

(  Trapezoid Area = (smaller side + bigger side) × height ÷ 2  )


Making exercises or lessons for kids in school would be impractical in LibreOffice :(


I hope in the future that at least the text direction control characters will be supported in math formula output..
Comment 8 V Stuart Foote 2020-06-24 13:51:30 UTC
(In reply to libre officer from comment #7)

> ... 
> 2006 is considered antiquity era in 2020 !
> 
> However, I strongly disagree with Rüdiger Timm's `Even RTL languages don't
> use RTL for math` !! That's completely wrong, many countries still uses
> Arabic letters in math formula.

Actually believe the commit author was Alan Yaniger, working with Thomas Lang.

https://bz.apache.org/ooo/attachment.cgi?id=39273&action=diff 

> 
> People forgot that Math formula could be written in other languages to teach
> kids in school basic geometry rules. For example, how can somebody type this
> 5th grade formula without inducing kids in error:
> 
> 
> مساحة شبه المنحرف = (القاعدة الكبرى + القاعدة الصغرى) × الارتفاع ÷ 2
> 
> (  Trapezoid Area = (smaller side + bigger side) × height ÷ 2  )
> 
> 
> Making exercises or lessons for kids in school would be impractical in
> LibreOffice :(
> 
> 
> I hope in the future that at least the text direction control characters
> will be supported in math formula output..


+1, and it could be as simple as enabling RTL for the sm edit shell to allow Command windows input RTL in addition to the Bidi handling--but more likely the sm node creation logic is coded only for standard mathematical formulas.

Getting reasonable RTL Presentation syntax may require sm logic specific to handle:

U+200E LEFT-TO-RIGHT MARK (LRM)
U+200F RIGHT-TO-LEFT-MARK (RLM)

U+202A LEFT-TO-RIGHT EMBEDDING (LRE)
U+202B RIGHT-TO-LEFT EMBEDDING (RLE)
U+202C POP DIRECTIONAL FORMATTING (PDF)
U+202D LEFT-TO-RIGHT OVERRIDE (LRO)
U+202E RIGHT-TO-LEFT OVERRIDE (RLO)

U+2066 LEFT-TO-RIGHT ISOLATE (LRI)
U+2067 RIGHT-TO-LEFT ISOLATE (RLI)
Comment 9 Eyal Rozenberg 2021-02-26 20:51:06 UTC
The text rendering here on bugzilla may be confusing us regarding the actual and expected results. Can you explain, in words, what order should the parts of the equation appear in? e.g. "From left to write, the words you should see are FOO, then BAR, then BAZ"

Also, are you complaining about what's in the output window, the edit window or both?