Bug 164467 - Redundant spacing between characters of some fonts in italic in LibreOffice Math
Summary: Redundant spacing between characters of some fonts in italic in LibreOffice Math
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bisected, regression
Depends on:
Blocks:
 
Reported: 2024-12-26 18:11 UTC by Joshua Ali
Modified: 2025-05-05 13:02 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Demonstration of the bug (11.35 KB, application/vnd.oasis.opendocument.text)
2024-12-26 18:12 UTC, Joshua Ali
Details
Screenshot from the attached document (7.46 KB, image/png)
2024-12-26 18:13 UTC, Joshua Ali
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Ali 2024-12-26 18:11:35 UTC
Description:
I have mainly tried this with Math fonts. In this case, Tex Gyre Termes fonts.
For example, I can write A_x on LibreOffice Writer and it looks perfectly fine.
However, if I type the same thing on LibreOffice Math, there is an unreasonably large gap between A and x. For most other standard fonts, it looks just fine. However, every other Math font that I tested (Tex Gyre Bonum/DeJaVu/Pagella/Schola/Termes Math, Noto Sans Math, Libertinus Math, Latin Modern Math) suffers from this issue. This happens when the fonts in question are italic.

I am attaching an .odt file demonstrating this issue, as well as its screenshot.

Steps to Reproduce:
1. Go to LibreOffice Math or any other module and insert a formula
2. Type something with regular characters adjacent to characters in subscript/superscript


Actual Results:
The resulting characters are unusually separated despite there being no space between them.

Expected Results:
It shouldn't add unnecessary space between character


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.8.4.2 (X86_64)
Build ID: 480(Build:2)
CPU threads: 16; OS: Linux 6.12; UI render: default; VCL: kf6 (cairo+wayland)
Locale: de-DE (en_GB.UTF-8); UI: en-US
Calc: CL threaded
Comment 1 Joshua Ali 2024-12-26 18:12:52 UTC
Created attachment 198268 [details]
Demonstration of the bug
Comment 2 Joshua Ali 2024-12-26 18:13:14 UTC
Created attachment 198269 [details]
Screenshot from the attached document
Comment 3 Saburo 2025-03-05 09:46:12 UTC
In the case of "DejaVu Math Tex Gyre, Italic", an extra space seems to occur only after "A".
(Personally, I feel like there is a little extra space after "b" and "k".)

Bibisected with linux-64-24.2
commit dfe42e756b37642355356a6035081f4473609832
author	Khaled Hosny <khaled@libreoffice.org>

vcl: Use HarfBuzz to get glyph bounding rectangle

For consistent cross-platform results that also matches our glyph
advances since platform functions might be using hints which we don’t
use.
Comment 4 Khaled Hosny 2025-04-08 20:44:28 UTC
TeX Gyre Termes Math and DejaVu Math Tex Gyre do not have an italic variant, so what you are getting is synthetic slanting of the upright glyph, and there appears to be a bug in calculating the bounding box of synthetically slanted glyphs.

Synthetic italic is not really a good idea, and LibreOffice Math does no make use of the math italic glyphs in Unicode math fonts like these, so I suggest using the regular text font (e,g. TeX Gyre Termes) for all math font settings except Math font, or at least use the text font where you need italic or bold.
Comment 5 Khaled Hosny 2025-04-09 16:40:50 UTC
This is a HarfBuzz bug, reported upstream https://github.com/harfbuzz/harfbuzz/issues/5273.
Comment 6 Khaled Hosny 2025-04-28 14:00:23 UTC
This is now fixed in HarfBuzz 11.2.0 https://github.com/harfbuzz/harfbuzz/releases/tag/11.2.0
Comment 7 Khaled Hosny 2025-05-05 13:02:41 UTC
HarfBuzz have been updated and I confirmed that this issue is fixed using latest daily build. Note that when testing the attached document, one needs to double click on the formula to update the preview.