Bug 48965 - FORMATTING: Incorrect alignment of characters from Catalog
Summary: FORMATTING: Incorrect alignment of characters from Catalog
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
: 81684 (view as bug list)
Depends on:
Blocks: Formula-Editor
  Show dependency treegraph
 
Reported: 2012-04-20 05:20 UTC by Aleksandr
Modified: 2024-08-22 16:37 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Incorrect alignment of characters from Catalog (4.04 KB, image/png)
2012-04-20 05:20 UTC, Aleksandr
Details
rendering with OpenSymbol (bad) and Liberation Sans (good) (27.16 KB, image/png)
2013-07-14 08:28 UTC, john
Details
clip of Math module showing nodes with OVER elements with and without spacers (56.17 KB, image/png)
2017-03-01 19:22 UTC, V Stuart Foote
Details
1/alpha + 1/(alpha+1) alignment problem (29.58 KB, image/png)
2017-05-26 00:52 UTC, john
Details
unmatched nDenomDist and nNumDist in formula LO master/7.2.0 (38.89 KB, image/png)
2020-11-24 15:08 UTC, V Stuart Foote
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksandr 2012-04-20 05:20:45 UTC
Created attachment 60383 [details]
Incorrect alignment of characters from Catalog

When the numerator or the denominator of the fraction contains only characters from the Catalog, then the alignment is incorrect, for example:
%pi over {%xi %xi}
If you add a character is not from the Catalog, then the alignment is correct:
{2 %pi} over {4 %xi %xi}
or so:
{{}%pi} over {{}%xi %xi}

See the attached picture of how it looks to me.

MS Windows 7 Home Premium 32bit Russian
Comment 1 Christina Rossmanith 2012-08-06 19:13:07 UTC
confirmed on linux LibO 3.5.4.2
Comment 2 john 2013-07-14 08:28:40 UTC
Created attachment 82403 [details]
rendering with OpenSymbol (bad) and Liberation Sans (good)

I think this is a bug with the OpenSymbol font, rather than a but iwth LibreOffice. When I change the symbol catalog to use Liberation Sans to render my %alpha instead of OpenSymbol, the problem goes away.

Attached image illustrates the point.
Comment 3 john 2013-11-05 06:52:32 UTC
note, this bug is still present in LibreOffice 4.0.4.2 on Ubuntu 12.04 (from LibreOffice PPA).
Comment 4 QA Administrators 2015-04-19 03:20:58 UTC Comment hidden (obsolete)
Comment 5 robert.funnell 2016-05-08 15:58:08 UTC
This bug is still present in LO 5.0.1.2 (under MS Windows 7).
Comment 6 robert.funnell 2016-05-08 16:54:07 UTC
Tested in LO 3.3.0.4, it's the same there so I set as inherited from OOo
Comment 7 V Stuart Foote 2016-07-28 15:33:50 UTC
IIUC the "catalog" of Greek characters gets calculated based on the font assigned to FONTNAME_MATH.  

Any substitute font (e.g. Asana Math, STIX, Cambria Math-- or a general Unicode font Symbola, Nota, Code2000) used would be similarly affected in populating the catalog of objects.

Actions in comment 2 are not really changing the glyph metric of the default calculation--rather they are substituting a glyph --with new metrics-- for a value in the catalog.

Believe correcting this requires attention to rules of how the nodes are assembled into formulas.
Comment 8 V Stuart Foote 2017-03-01 19:22:45 UTC
Created attachment 131566 [details]
clip of Math module showing nodes with OVER elements with and without spacers

@Takeshi, Khaled, *

Notice that positioning of nodes composed with Greek symbols and the "over" element get odd spacing to the constructed over bar.

Inserting a "`" spacer and braces with the greek symbol corrects the base line for the symbol--but seems like it is always needed, both for above and below the "over" bar.  Adding the spacer corrects the construction of the node--so wouldn't we be able to adjust the logic for the nodes to apply the spacer without having to insert it and enclosing in braces?

To me this seems to have nothing to do with the font metrics as folks suggest, rather it is just the source controlling construction of the nodes.

Use this nonsense formula to see the effect of using spacers (regardless of font substitution, OpenSymbol default or Styx or Asana etc.):

{`%pi} over {`%xi %xi} + 1 over {`%pi} + {`%xi} over a + 1 over {`%chi} newline
{%pi} over {%xi %xi} + 1 over {%pi} + {%xi} over a + 1 over {%chi}
Comment 9 john 2017-05-26 00:47:11 UTC
I don't understand why others are concluding here that the problem is with the rendering engine... as my earlier-attached example image ('rendering with OpenSymbol and Liberation Sans') shows, everything works fine if the OpenSymbol font is replaced with Liberation Sans in the Symbol Catalog (this must be done manually, one symbol at a time, using the GUI).

If that is not a problem with the OpenSymbol font itself, then where else could the problem be?
Comment 10 john 2017-05-26 00:52:45 UTC
Created attachment 133592 [details]
1/alpha + 1/(alpha+1) alignment problem

Additional image added for further clarify the way that the problem disappears when choosing Liberation Serif font.
Comment 11 V Stuart Foote 2017-05-26 06:23:05 UTC
(In reply to john from comment #9)
> I don't understand why others are concluding here that the problem is with
> the rendering engine... as my earlier-attached example image ('rendering
> with OpenSymbol and Liberation Sans') shows, everything works fine if the
> OpenSymbol font is replaced with Liberation Sans in the Symbol Catalog (this
> must be done manually, one symbol at a time, using the GUI).
> 
> If that is not a problem with the OpenSymbol font itself, then where else
> could the problem be?

Well you are sort of right. Adjusting OpenSymbol typo/hhea metrics may be needed.

Issue here is the way the fonts are sized/scaled for the SmBinVerNode [1][2], as the nodes are being calculated, and when the OpenSymbol glyphs are _mixed_ with Liberation Serif in a subnode the Denominator spacing (nDenomDist) picks up the spacing for Liberation Serif--the OpenSymbol only subnode gets a different spacing.

That OpenSymbol only nodes are assigned an unhelpful Height metric can be demonstrated by modifying the Format -> Fonts: Numbers font to use the OpenSymbol glyphs. 

The "1 over %alpha + 1 over {%alpha + 1}" sample formula will then be calculated with OpenSymbol only Numerator spacing (nNumDist) and Denomenator spacing (nDenomDist) and collapses the spacing to the over bar.

Alternatively, modify the iGreek %ialpha "α" and assign it Liberation Serif (so to match default Numbers format) and the formula gets matching spacing for all the nodes.

@Takeshi, Khaled, Mike -- is the answer to chase the font metrics for errant fonts (notably OpenSymbol that we control, but others like Asana and STIX get assigned ugly spacing) or can we improve the logic for the node spacing to set minimum distances and handle mixed font composition of a node?

=-ref-=

[1] http://opengrok.libreoffice.org/xref/core/starmath/inc/node.hxx?#739
[2] http://opengrok.libreoffice.org/xref/core/starmath/source/node.cxx?#818
Comment 12 QA Administrators 2018-06-20 02:49:08 UTC Comment hidden (obsolete)
Comment 13 robert.funnell 2018-06-20 13:04:32 UTC
I still see the bug (using the formula in Comment 8) with the latest release:
Version: 6.0.4.2 (x64)
Build ID: 9b0d9b32d5dcda91d2f1a96dc04c645c450872bf
CPU threads: 8; OS: Windows 6.1; UI render: default; 
Locale: en-CA (en_CA); Calc: group
Comment 14 QA Administrators 2019-06-21 02:51:52 UTC Comment hidden (obsolete)
Comment 15 robert.funnell 2019-06-21 14:55:57 UTC
I still see the bug in version 6.2.4.2 (x64).
Comment 16 dante19031999 2020-07-19 12:02:59 UTC
This is a bug and not a bug. 
The % conserves the box size of the char, witch can of course be minor than other chars.
In 7.1 sould be corrected using the char command (stills in devellopment).
Comment 17 V Stuart Foote 2020-11-24 14:29:03 UTC
*** Bug 81684 has been marked as a duplicate of this bug. ***
Comment 18 V Stuart Foote 2020-11-24 15:08:07 UTC
Created attachment 167539 [details]
unmatched nDenomDist and nNumDist in formula LO master/7.2.0

glitch continues, from using font metric alone in composing node distance for over, and root controls
Comment 19 QA Administrators 2024-08-22 03:15:59 UTC Comment hidden (obsolete)
Comment 20 robert.funnell 2024-08-22 14:56:11 UTC
The formula in Comment 8 is displayed properly for me.

Under Formula Fonts, Math = OpenSymbol and the rest are Liberation.

Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 12; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: en-CA (en_CA); UI: en-US
Calc: CL threaded
Comment 21 V Stuart Foote 2024-08-22 16:37:22 UTC
Yep, confirmed node spacing is correct in a 24.2.5 build

This nonsensical formula (from comment 8 and comment 18) was wrong in a 7.6.6 build, but is now correctly spaced. I think it was some of Khaled's work on the sm Symbols... dialog for 24.2.0 release.

{`%pi} over {`%xi %xi} + 1 over {`%pi} + {`%xi} over a + 1 over {`%chi} newline
{%pi} over {%xi %xi} + 1 over {%pi} + {%xi} over a + 1 over {%chi} newline
1 over %alpha + 1 over { %alpha + 1 }