Bug 161820 - OpenType "lnum" (lining numbers) feature does not work properly for numerical cells inside a table
Summary: OpenType "lnum" (lining numbers) feature does not work properly for numerical...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: implementationError
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2024-06-27 17:45 UTC by Linus Drumbler
Modified: 2024-10-06 19:41 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
A document containing a table of numbers with the lining number feature enabled (25.52 MB, application/vnd.oasis.opendocument.text)
2024-06-27 17:45 UTC, Linus Drumbler
Details
Document with the font corrected to Zilla Slab:lnum (6.02 MB, application/vnd.oasis.opendocument.text)
2024-10-05 21:57 UTC, Linus Drumbler
Details
Screenshot of the problem (8.30 KB, image/png)
2024-10-05 21:58 UTC, Linus Drumbler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Linus Drumbler 2024-06-27 17:45:27 UTC
Created attachment 195023 [details]
A document containing a table of numbers with the lining number feature enabled

Steps to reproduce:

1. Install the free and open-source font "Zilla Slab", available at https://fonts.google.com/specimen/Zilla+Slab (or any other font that includes a lining numerals OpenType feature)
2. Create a table in which some of the entries are only a number or comma-separated numbers
3. Activate Zilla Slab's lining numerals (lnum) feature through Format → Character → Features or set the document's font to "Zilla Slab:lnum"

Expected behaviour: in the table entries that contain only a number or a number followed by a comma, the number displays in the lining number form, as it does for the table entries that contain letters.

Actual behaviour: in the table entries that contain only a number or a comma-separated number followed by a comma, the numbers display as their default non-lining forms. Even stranger, if any alphabetic character is typed in the cell, all digits in the cell switch to their lining form.

Attached is a file that reproduces the bug.
Comment 1 Buovjaga 2024-08-26 12:45:52 UTC
The document uses Linux Libertine G instead of Zilla Slab. Is this intentional?

Can you give exact cells where we will see the unexpected behaviour? I used Find & Replace with regex and could not find any piece of text ending in a comma, which seems to be in conflict with what you said: "in the table entries that contain only a number or a number followed by a comma"

Maybe you attached the wrong document?

To explain what lining numbers mean, I found this: https://typenetwork.com/articles/opentype-at-work-figure-styles

Set to NEEDINFO.
Change back to UNCONFIRMED after you have provided the information.
Comment 2 Linus Drumbler 2024-10-05 21:57:10 UTC
Created attachment 196918 [details]
Document with the font corrected to Zilla Slab:lnum

Here is the same document with the font corrected to Zilla Slab:lnum. That was my mistake.

You can clearly see the problem on the centre diagonal with entries like 10,10 and 3,3. The figures there are the old-style variants, with 1234579 going below the baseline and 6/8 going above it. Whereas if you type an alphabetical character in the cell, the numbers realize that they should be their lining variants and snap back to full height.

If you type just a number in a cell, it's the oldstyle variant. But I've specified via the OpenType font features that it should use the lining variant.
Comment 3 Linus Drumbler 2024-10-05 21:58:40 UTC
Created attachment 196919 [details]
Screenshot of the problem

Here is a further screenshot of the problem. In the top cell consisting of only numbers and commas, the 10 is much shorter than the full-height lining numerals in the bottom cell. I want the 10s in both cells to be the same.
Comment 4 Buovjaga 2024-10-06 06:27:19 UTC
Thanks, now I see it.

Checking with bibisect repositories, looks like the implementation happened in 5.3 with the move to HarfBuzz: https://wiki.documentfoundation.org/ReleaseNotes/5.3#Text_Layout

Arch Linux 64-bit
Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3370e122d7f9edf40895f90706047ceb8ee7229d
CPU threads: 8; OS: Linux 6.10; UI render: default; VCL: kf6 (cairo+wayland)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: CL threaded
Built on 4 October 2024
Comment 5 ⁨خالد حسني⁩ 2024-10-06 19:22:05 UTC Comment hidden (obsolete)
Comment 6 ⁨خالد حسني⁩ 2024-10-06 19:30:15 UTC Comment hidden (obsolete)
Comment 7 ⁨خالد حسني⁩ 2024-10-06 19:41:18 UTC
I think it is partly a font problem, and partly a LibreOffice problem. When the string is composed entirely from Common characters (i.e. characters that do not belong to a specific script, numbers here), LibreOffice can not detect what script these characters belong to and what OpenType script to enable, so uses “DFLT” script. However, the font registers the lnum feature only for “latn” script, so the feature does not get applied. When there is a Latin letter, LibreOffice will correctly use “latn” script for the whole string.

This can be reproduced with hb-shape command line tool. If I don’t specifically set a script (it will guess “DFLT”), the feature has no effect:

$ hb-shape ZillaSlab-Regular.ttf 10 --features=+lnum
[uni0031=0+385|uni0030=1+576]

When I explicitly set “latn” script, the feature gets applied:

$ hb-shape ZillaSlab-Regular.ttf 10 --features=+lnum --script=latn
[uni0031.pnum_lnum=0+374|uni0030.pnum_lnum=1+573]

I’d consider this a font bug, and it probably affects other applications.

LibreOffice can possibly be improved here, by consulting the language if no script can be detected.