Bug 114087 - Unicode BiDi characters break font rendering
Summary: Unicode BiDi characters break font rendering
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.4.0.0.beta1
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2017-11-27 09:39 UTC by Volga
Modified: 2024-05-28 14:36 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test file (10.17 KB, application/vnd.oasis.opendocument.text)
2017-11-27 09:40 UTC, Volga
Details
Snapshot (74.98 KB, image/png)
2017-11-27 09:40 UTC, Volga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Volga 2017-11-27 09:39:24 UTC
Description:
If text inserted Unicode BiDi characters, they could be rendering with fallback fonts.

Steps to Reproduce:
1. Copying some texts from https://en.wikipedia.org/wiki/Bi-directional_text#Chinese_characters_and_other_CJK_scripts
2. Paste into Writer
3. Set CJK font face

Actual Results:  
When CJK texts surrounding by BiDi characters, they aren’t rendered with specified font, using fallback fonts instead.

Expected Results:
Text surrounding with Bidi characters should be rendering with specified font even if the font does not has corresponding grapheme.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.0.0.0.beta1 (x64)
Build ID:97471ab4eb4db4c487195658631696bb3238656c
CPU 线程:4; 操作系统:Windows 10.0; UI 渲染:默认; 
Locale: zh-CN (zh_CN); Calc: group threaded


User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
Comment 1 Volga 2017-11-27 09:40:04 UTC
Created attachment 138012 [details]
Test file
Comment 2 Volga 2017-11-27 09:40:28 UTC
Created attachment 138013 [details]
Snapshot
Comment 3 Kevin Suo 2017-11-27 09:59:37 UTC
Do you mean setting same CJK font face to the two "海南航空"?
I tried to set both of them to "思源宋体 CN Medium", they are displaying correctly as this font. 
I also tried "仿宋", it works.

Am I doing right? If I am doing right, this may be tested by someone else on Windows.
Comment 4 Volga 2017-11-29 16:48:18 UTC
(In reply to Kevin Suo from comment #3)
> Do you mean setting same CJK font face to the two "海南航空"?
> I tried to set both of them to "思源宋体 CN Medium", they are displaying
> correctly as this font. 
> I also tried "仿宋", it works.
> 
> Am I doing right? If I am doing right, this may be tested by someone else on
> Windows.

I tested again, if I selest the who text, then set the font to "仿宋", it works, but if I set different font face for Western Text Font and Asian Text Font, the problem appearing to me.
Comment 5 Hiunn-hué 2017-11-30 11:01:42 UTC
Hi,

If I understand it correctly, that's because the RTL text "空航南海" here is identified as CTL Text, rather than East Asian Text. (Move the cursor to the text, and check the status bar.)

Therefore, it's using the font set for CTL Text (Format -> Character -> CTL font).


---

Tested on:

Version: 6.1.0.0.alpha0+
Build ID: 42dafb5c7bd218f4d368fbd1113fa4a0fcd7f0cb
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-11-30_00:36:09
Locale: zh-TW (zh_TW.UTF-8); Calc: group threaded

---
Comment 6 Volga 2017-11-30 14:52:27 UTC
(In reply to Hiunn-hué from comment #5)
> Hi,
> 
> If I understand it correctly, that's because the RTL text "空航南海" here is
> identified as CTL Text, rather than East Asian Text. (Move the cursor to the
> text, and check the status bar.)
> 
> Therefore, it's using the font set for CTL Text (Format -> Character -> CTL
> font).
Yes, the usage of BiDi characters should be used for controlling text direction, and just set costomized direction within text, not affect font rendering for surrounding text.
Comment 7 ⁨خالد حسني⁩ 2017-12-01 22:32:00 UTC
I don’t this is a font fallback issue since our HarfBuzz-based font fallback code certainly handles this (i.e. does not require control characters to be present in the font). I suspect the issue is happening at a higher level when we decide if a character should use Western/CTL/CJK font.
Comment 8 Volga 2017-12-02 05:55:14 UTC Comment hidden (obsolete)
Comment 9 ⁨خالد حسني⁩ 2017-12-03 15:22:20 UTC
(In reply to Volga from comment #8)
> So is it possible to add exceptions to make BiDi characters independent of
> Western/CTL/CJK font settings?

Possibly, I’m not 100% sure this is what is going on.
Comment 10 QA Administrators 2018-12-04 03:47:51 UTC Comment hidden (obsolete)
Comment 11 QA Administrators 2020-12-04 04:16:38 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2022-12-05 03:32:49 UTC Comment hidden (obsolete)
Comment 13 Volga 2024-05-28 14:32:46 UTC Comment hidden (no-value)
Comment 14 Volga 2024-05-28 14:34:43 UTC Comment hidden (no-value)
Comment 15 Volga 2024-05-28 14:36:09 UTC
(In reply to ⁨خالد حسني⁩ from comment #7)
> I don’t this is a font fallback issue since our HarfBuzz-based font fallback
> code certainly handles this (i.e. does not require control characters to be
> present in the font). I suspect the issue is happening at a higher level
> when we decide if a character should use Western/CTL/CJK font.
Yes, I think so. Because in certain cases there's some needs to make use of BiDi characters to alter text direction (for example, Runes), ideally such things should just affect the order of characters on screen, not font face.

https://commons.wikimedia.org/wiki/File:%E5%8D%B3%E4%BD%8D%E8%AF%8F%E4%B9%A6.png
https://commons.wikimedia.org/wiki/File:%E4%BC%AA%E6%BB%A1%E7%9A%87%E5%B8%9D%E6%BA%A5%E4%BB%AA%E9%A2%81%E5%8F%91%E7%9A%84%E5%8D%B3%E4%BD%8D%E8%AF%8F%E4%B9%A6%E3%80%82%E4%BC%AA%E6%BB%A1%E7%9A%87%E5%AE%AB%E5%8D%9A%E7%89%A9%E9%99%A2.jpg