A right-to-left document renders against the left edge, and `start`/`end` alignment resolves to the wrong side
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in the odrcore submodule: HtmlWriter::write_begin (html_writer.cpp:134) is where dir/lang would go on <html>. read_text_align (odf_style.cpp:108) maps start/end to left/right — first decide with the maintainer whether to keep start/end in TextAlign and emit text-align:start/end, or resolve at translation time. Then parse style:writing-mode into ParagraphStyle (style.hpp:166) and emit it in translate_paragraph_style (document_style.cpp:237). Done when an Arabic document renders flush right and mixed-direction paragraphs are ordered correctly.
由索引模型根據 Issue 內容生成。
描述
A user asked for right-to-left support in a Play Store review of 4.18.0, in Arabic, rating the app 5 ★ anyway. #468 is the same request from a support email, and #108 asked for it in 2019 and was closed without it. This is what is actually missing, because it is three separate things and only one of them is a feature.
The fix is in odrcore in all three cases; nothing on the Android side is involved. odrcore has #326 for the spreadsheet half of this.
The view has no base direction
HtmlWriter::write_begin writes a bare <html> (html_writer.cpp:134). No dir, no lang, anywhere in the output. So the WebView takes the default base direction, which is left-to-right.
That is not "Arabic does not render". The Unicode bidi algorithm still orders an Arabic run right-to-left inside a line, so a paragraph of pure Arabic reads correctly. What breaks is everything that depends on the paragraph's own direction: the sentence lands against the left edge, trailing punctuation goes to the wrong end, and a paragraph mixing Arabic with Latin words or digits is ordered by the wrong base.
style:writing-mode is never read
ODF states paragraph and page direction as style:writing-mode, rl-tb being right-to-left. Nothing parses it — there is no writing_mode anywhere in internal/odf/, and ParagraphStyle (style.hpp:166) has no field to put it in. The only writing-mode the translator ever emits is vertical-lr for a rotated table cell (document_style.cpp:415), which is unrelated.
So even with a base direction on <html>, a right-to-left paragraph inside an otherwise left-to-right document would still come out wrong, and vice versa.
start and end alignment resolve to the wrong edge
This one is a bug rather than a gap, and it is the visible one.
read_text_align (odf_style.cpp:108) maps fo:text-align values start → TextAlign::left and end → TextAlign::right, unconditionally. But start and end are relative to the writing direction: in a right-to-left paragraph start is the right edge. translate_paragraph_style (document_style.cpp:237) then writes that out as a literal text-align:left.
start is what writers emit for ordinary body text rather than left, so this hits the common case: a right-to-left document whose paragraphs are simply default-aligned renders flush left, and it stays flush left even if the base direction is fixed, because the wrong edge was baked in at parse time.
What we could do
TextAlign has the shape of the problem in it — left/right/center/justify, with no start/end. Two ways out:
- Keep
start/endall the way to the CSS. Add them toTextAlignand emittext-align:start/text-align:end, which browsers resolve against the element's direction. Then parsestyle:writing-modeinto a direction onParagraphStyle, emit it asdirection:rtl, and the alignment follows for free. The public enum gains two values, so this is a breaking change for the bindings. - Resolve at translation time, once direction is known, and leave the enum alone. Cheaper, and it puts the writing direction into the style model either way — so it is most of the same work with a worse result.
Either way <html dir> (or a direction on the document root element) still has to be set from the document's page style, or a document that states nothing per paragraph gets no direction at all.
Worth deciding whether the same pass carries lang, which is in the ODF too and which nothing currently emits — it is what a screen reader and hyphenation need, and it is the same attribute pair.
- 主要語言
- Kotlin
- 星號
- 473
- 分支
- 44
- 平均合併
- 4 小時 2 分鐘
- 30 天內合併 PR
- 45
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
opendocument-app/OpenDocument.droid 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 64/100
opendocument-app/OpenDocument.droid#484 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 52/100
opendocument-app/OpenDocument.droid#741 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 48/100
opendocument-app/OpenDocument.droid#690 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 50/100
opendocument-app/OpenDocument.droid#658 · 2 則留言 ·
維護者通常 1 天內回覆
-
low
難度 4/5 3-5 天 新手友好度 62/100
opendocument-app/OpenDocument.droid#644 ·
維護者通常 1 天內回覆
查看 opendocument-app/OpenDocument.droid 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
liberation-data/drivine4j#547 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
ccch1mneyyy/dsh-Go#381 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
wangzan101/Mika#227 ·
維護者通常 1 天內回覆
-
documentation
難度 1/5 1 小時以內 新手友好度 72/100
theopenconversationkit/tock#2136 ·
維護者通常 1 天內回覆
-
App asks for diameter for emergency=hydrant + water_source=groundwater. But should probably not.未關閉feedback required
難度 2/5 1-3 小時 新手友好度 62/100
streetcomplete/StreetComplete#7354 · 1 則留言 ·
維護者通常 1 天內回覆