Bug 165562 - Number format '?' does not maintain decimal alignment
Summary: Number format '?' does not maintain decimal alignment
Status: RESOLVED DUPLICATE of bug 157612
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.4.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-04 05:44 UTC by studog
Modified: 2025-03-10 08:10 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description studog 2025-03-04 05:44:17 UTC
A reproducible test case:
1. In A1 enter "18.672903"
2. In A2 enter "47"
3. In A3 enter "1.6052"
4. Apply the custom number format ".???" to all three cells
5. Observe that the "47." is badly misaligned with the other two cells

Expected behaviour: the decimal points in all three cells align in a vertical column. This is what Excel does.

I tried quite a number of fonts in my Excel instance, only a very small number of fonts ended up with misalignment: "Berlin Sans" and "Georgia" were two. The rest align the decimals as expected.

https://help.libreoffice.org/latest/en-US/text/shared/01/05020301.html specifically says "The ? works as the # but adds a space character to keep decimal alignment if there is a hidden non-significant zero."

I'm not sure how Excel manages to keep decimal alignment in most cases/fonts, but, LibreOffice needs to do the same.

Requiring a user to change from their chosen font to a mono-spaced font (which does work around the bug, I admit that) is not an acceptable solution long term.

This comment https://bugs.documentfoundation.org/show_bug.cgi?id=118337#c2 indicates that decimal alignment used to work, and then broke. Perhaps that could be bisected to determine the breaking change?

I originally left this as a comment on this bug ( https://bugs.documentfoundation.org/show_bug.cgi?id=158890#c11 ). That bug is resolved according to its original description but that does not solve this bug.

Reproduced just now on: 

Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: 480(Build:2)
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-US (C.UTF-8); UI: en-US
Ubuntu package version: 4:24.8.4~rc2-0ubuntu0.24.04.1~lo1
Calc: threaded
Comment 1 Mike Kaganski 2025-03-04 05:51:25 UTC
This is not a bug. The number format does no alignment - it just puts spaces in place of missing digits. But the size of spaces depends on the font; and if it's narrower than digits, than the resulting number strings will naturally be misaligned.

However, there is bug 157612, which aims to choose a better placeholder.

*** This bug has been marked as a duplicate of bug 157612 ***
Comment 2 studog 2025-03-09 04:35:15 UTC
(In reply to Mike Kaganski from comment #1)
> This is not a bug. The number format does no alignment

Can the documentation be updated to not claim alignment then? See https://help.libreoffice.org/latest/en-US/text/shared/01/05020301.html#:~:text=The%20?%20works%20as%20the%20#%20but%20adds%20a%20space%20character%20to%20keep%20decimal%20alignment

(I posted this in my original comment, but the link above has the text highlighting added to make clear the text I am talking about.)
Comment 3 Mike Kaganski 2025-03-09 08:53:55 UTC
(In reply to studog from comment #2)
> Can the documentation be updated to not claim alignment then? See
> https://help.libreoffice.org/latest/en-US/text/shared/01/05020301.html#:~:
> text=The%20?%20works%20as%20the%20#%20but%20adds%20a%20space%20character%20to
> %20keep%20decimal%20alignment

The documentation needs clarification, not removal. The alignment is the goal of the format, but it's reached not simply by use of the format code, but *also* by use of monospace fonts.
Comment 4 studog 2025-03-10 07:54:29 UTC
(In reply to Mike Kaganski from comment #3)
> The documentation needs clarification, not removal. The alignment is the
> goal of the format, but it's reached not simply by use of the format code,
> but *also* by use of monospace fonts.

Excel can do it in most fonts, including a number of non-monospace fonts. If alignment is claimed, it cannot rely on monospace fonts.
Comment 5 Mike Kaganski 2025-03-10 08:10:26 UTC
(In reply to studog from comment #4)

Did you look at 157612 at all? If yes, then what are we trying to discuss here?