Bug 157922 - Writer fails to attach Arabic letters in some fonts (due to buggy font)
Summary: Writer fails to attach Arabic letters in some fonts (due to buggy font)
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
7.3.0.1 rc
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2023-10-25 16:23 UTC by medmedin2014
Modified: 2024-02-24 07:52 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer fails to attach Arabic letters in some fonts (521.01 KB, application/zip)
2023-10-25 16:23 UTC, medmedin2014
Details
Fixed version of the font (85.48 KB, application/zip)
2023-10-26 00:47 UTC, ⁨خالد حسني⁩
Details
Screenshot after fixing the font (2.09 MB, image/png)
2023-10-26 00:49 UTC, ⁨خالد حسني⁩
Details

Note You need to log in before you can comment on or make changes to this bug.
Description medmedin2014 2023-10-25 16:23:37 UTC
Created attachment 190417 [details]
Writer fails to attach Arabic letters in some fonts

I downloaded a Maghrebi font used a lot in Morocco and other countries in North West Africa in many official documents.

In Microsoft Office 2019, the letters appear attached, but in LibreOffice they appear separated (in the form of "one letter").

See attached file, it contains the font + odt file + screenshots.

----------------------------
LibreOffice information:
Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 2; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+wayland)
Locale: en-US (en_US.UTF-8); UI: en-US
7.6.2-3
Calc: threaded

----------------------------
System information:
Operating System: Manjaro Linux 
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.5.8-4-MANJARO (64-bit)
Graphics Platform: Wayland
Comment 1 BogdanB 2023-10-25 18:01:57 UTC
Confirm with
Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 2 BogdanB 2023-10-25 18:03:49 UTC
Maybe it's a harfbuzz bug, not a LibreOffice bug, but it started since this.


author	Julien Nabet <serval2412@yahoo.fr>	2021-07-19 20:40:14 +0200
committer	Julien Nabet <serval2412@yahoo.fr>	2021-07-20 18:05:43 +0200
commit ed29da546754d0d11aa0cffd4dfe649cc95df722 (patch)
tree 1d3db9d36c8ae4c9a4298462de49827fa6caa475
parent 6128e2d55f0d0c68d3c7f6fb69539ec800637947 (diff)
tdf#143429: update harfbuzz to 2.8.2 version
Change-Id: I263dc6da5be3ea55205076a1f4e263fe5bba31fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119232
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
 12fc2bc2862de298773c67df178e8f399e3f5ad9 is the first bad commit
commit 12fc2bc2862de298773c67df178e8f399e3f5ad9
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Tue Jul 20 19:02:11 2021 +0200

    source ed29da546754d0d11aa0cffd4dfe649cc95df722
    
    source ed29da546754d0d11aa0cffd4dfe649cc95df722

 instdir/program/libvcllo.so         | Bin 16425504 -> 16515592 bytes
 instdir/program/libvclplug_kf5lo.so | Bin 1263456 -> 1349328 bytes
 instdir/program/libvclplug_qt5lo.so | Bin 2043792 -> 2129472 bytes
 instdir/program/setuprc             |   2 +-
 instdir/program/versionrc           |   2 +-
 5 files changed, 2 insertions(+), 2 deletions(-)
Comment 3 Julien Nabet 2023-10-25 18:09:32 UTC
Bogdan: the patch is just an upgrade of Harfbuzz version and nothing else.
So either the bug is still in last Harfbuzz version or is still in the LO code which in its way to use Harfbuzz.
I don't think removed local Harfbuzz patches are concerned.

Khaled: any thoughts here?
Comment 4 ⁨خالد حسني⁩ 2023-10-26 00:36:30 UTC
This is a font bug. The font contains non-functional AAT (Apple Advanced Typography) font support which is ignored by MS Office and older versions of HarfBuzz. Newer versions of HarfBuzz as well as Apple software support AAT and the font is broken there.

Currently, HarfBuzz does not give us a way to prefer OpenType over AAT, see https://github.com/harfbuzz/harfbuzz/issues/4108 for upstream discussion.

This is not a first time I see a bug report about this particular font, but I can’t find where I saw it before.
Comment 5 ⁨خالد حسني⁩ 2023-10-26 00:45:25 UTC
A workaround is to strip the AAT table from the font, using something like (ttx comes from FontTools Python package):

$ ttx -x morx -x feat -x prop -x lcar AALMAGHRIBI.ttf
$ ttx AALMAGHRIBI.ttx

This should result in a AALMAGHRIBI#1.ttf file, installing it instead of the original AALMAGHRIBI.ttf file should fix the issue.
Comment 6 ⁨خالد حسني⁩ 2023-10-26 00:47:50 UTC
Created attachment 190423 [details]
Fixed version of the font
Comment 7 ⁨خالد حسني⁩ 2023-10-26 00:49:59 UTC
Created attachment 190424 [details]
Screenshot after fixing the font
Comment 8 medmedin2014 2023-10-26 10:02:06 UTC
(In reply to ⁨خالد حسني⁩ from comment #5)
> A workaround is to strip the AAT table from the font, using something like
> (ttx comes from FontTools Python package):
> 
> $ ttx -x morx -x feat -x prop -x lcar AALMAGHRIBI.ttf
> $ ttx AALMAGHRIBI.ttx
> 
> This should result in a AALMAGHRIBI#1.ttf file, installing it instead of the
> original AALMAGHRIBI.ttf file should fix the issue.

I'm not an expert in fonts, but the effect of removing such part from the font wouldn't disable some advanced font capabilities ?

Some extreme and complex usage of that Maghrebi font is the writing of whole Muhammadi Qur’an, with the narration of Warsh on the authority of Nafi’, and I think (not sure) it was primarily done on Apple software to benefit from those complex font features.

https://play.google.com/store/apps/details?id=info.vacof.quranma

I tested the modified font, and it seems to work fine both on LibreOffice and Microsoft Office on Windows10 and Linux(Manjaro KDE), but I have no way to test if that removed part has any effect on availability of font features on Mac.
Comment 9 ⁨خالد حسني⁩ 2023-10-26 11:00:11 UTC
(In reply to medmedin2014 from comment #8)
> (In reply to ⁨خالد حسني⁩ from comment #5)
> > A workaround is to strip the AAT table from the font, using something like
> > (ttx comes from FontTools Python package):
> > 
> > $ ttx -x morx -x feat -x prop -x lcar AALMAGHRIBI.ttf
> > $ ttx AALMAGHRIBI.ttx
> > 
> > This should result in a AALMAGHRIBI#1.ttf file, installing it instead of the
> > original AALMAGHRIBI.ttf file should fix the issue.
> 
> I'm not an expert in fonts, but the effect of removing such part from the
> font wouldn't disable some advanced font capabilities ?

These tables are unused by MS text layout engine, so stripping them makes the font behave like it does in MS applications, which seems to be the only platform it was tested against (the font is broken also om macOS unless the tables I mentioned are removed).

> Some extreme and complex usage of that Maghrebi font is the writing of whole
> Muhammadi Qur’an, with the narration of Warsh on the authority of Nafi’, and
> I think (not sure) it was primarily done on Apple software to benefit from
> those complex font features.
> 
> https://play.google.com/store/apps/details?id=info.vacof.quranma

The screenshots of this app show handwritten calligraphy nit a computer font (look at the same letter, e.g. isolated alef, at different places and you will see variations that result from handwriting).
Comment 10 medmedin2014 2023-10-26 11:13:05 UTC
(In reply to ⁨خالد حسني⁩ from comment #9)

> These tables are unused by MS text layout engine, so stripping them makes
> the font behave like it does in MS applications, which seems to be the only
> platform it was tested against (the font is broken also om macOS unless the
> tables I mentioned are removed).

This is a brief description of some features of the font.

http://sama-tube.com/quran/FontAlmaghribi/Definition-font-almaghribi.pdf

I will test some of them tonight, and see if they are still working.