Bug 114434 - Font metrics in sm Formula editor erratic with Liberation 1.07 (Fedora 27)
Summary: Font metrics in sm Formula editor erratic with Liberation 1.07 (Fedora 27)
Status: RESOLVED MOVED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
6.1.0.0.alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:6.1.0
Keywords:
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2017-12-13 05:24 UTC by V Stuart Foote
Modified: 2018-05-07 06:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
sm fromula editor showing clipping of formula and bad scaling of nodes (76.64 KB, image/png)
2017-12-13 05:32 UTC, V Stuart Foote
Details
same system GTK3 Wayland, but FreeSerif font substitution--nodes composed better (78.15 KB, image/png)
2017-12-13 05:37 UTC, V Stuart Foote
Details
LO 5.4.4.1 on REL 7.2 so GTK2, smath preview nodes with LiberationSerif 1.07.2 matches 2.00.1 and no clipping of text in the Formula Editor frame (132.21 KB, image/png)
2017-12-13 23:34 UTC, V Stuart Foote
Details
Liberation Serif 1.07.2 (61.35 KB, image/png)
2017-12-15 13:53 UTC, Caolán McNamara
Details
Liberation Serif 1.07.4 (61.58 KB, image/png)
2017-12-15 13:54 UTC, Caolán McNamara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description V Stuart Foote 2017-12-13 05:24:33 UTC
On Fedora 27 64-bit en-US with
Version: 5.4.4.1
Build ID: 5.4.4.1-1.fc27
CPU threads: 4; OS: Linux 4.14; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); Calc: group

and on current 6.1.0alpha0+

The text of formulas being entered in the "Formula editor" box is pushed up against the edge with the "Preview Window" and is being clipped.

Also, there is some weird font metrics in play such that formula nodes composed using the default Liberation Serif are overlapping other nodes.

Using the bottom example formula: "f ( x ) = {1} over {%sigma sqrt{2%pi} }func e^-{{(x-%mu)^2} over {2%sigma^2}}"

A font replacement of Liberation Serif with FreeSerif gives clean composition of the nodes.

See attached.
Comment 1 V Stuart Foote 2017-12-13 05:32:25 UTC
Created attachment 138409 [details]
sm fromula editor showing clipping of formula and bad scaling of nodes

clipping in the sm Formula Editor on Fedora 27 GTK3 with Wayland (same using Xorg), note also the scaling issues with nodes in the preview window.  Substituting FreeSerif corrects the nodes.
Comment 2 V Stuart Foote 2017-12-13 05:37:54 UTC
Created attachment 138410 [details]
same system GTK3 Wayland, but FreeSerif font substitution--nodes composed better
Comment 3 Caolán McNamara 2017-12-13 13:15:01 UTC
In this distro build Liberation Serif 2.00.1 is not bundled and the Liberation Serif 1.07.4 from the system is picked up so can be reproduced in a master self-build on fedora with rm instdir/share/fonts/truetype/Liberation*
Comment 4 Caolán McNamara 2017-12-13 20:54:09 UTC
hmm, Liberation Serif 1.07 has kUseTypoMetricsMask set while Liberation Serif 2.X and Times New Roman do not
Comment 5 V Stuart Foote 2017-12-13 23:34:09 UTC
Created attachment 138432 [details]
LO 5.4.4.1 on REL 7.2 so GTK2, smath preview nodes with LiberationSerif 1.07.2 matches 2.00.1 and no clipping of text in the Formula Editor frame

Used FontCreator and compared the font metrics for the 1.07.2 and 2.00.1 builds of LiberationSerif-Regular. They seem identical on the metrics and the general tab, only difference I saw was 2.00.1 picking up a header field mark: "Apple specific field 9 -- This field should be set if the font contains any strong right-to-left glyphs."

I then installed TDF build of LO 5.4.4.1 on REL7.2 [3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec 4 23:52:40 UTC 2017 (Centos 7.2)]

Launching smath I see no issue with clipping of text in the sm Formula Editor frame with GTK2 here. And the formula nodes are well proportioned. 

And if I delete the 5.4.4.1 LiberationSerif*.ttf fronts from share/fonts/truetype, forcing fall back to the 1.07.2 ver of LiberationSerif (installed to /usr/share/fonts/liberation for LO 5.0.6.2) the 5.4.4 1 build does not have problems with the nodes in the preview using the fall back.

So, it doesn't seem to be from fall back font and is something in GTK+ for Wayland in the Fedora builds.
Comment 6 Commit Notification 2017-12-14 20:32:03 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f8399f442d7bf5abf3861e0285997d13f355eb6a

Related: tdf#114434 Enable ExtLeading by default for starmath edit window

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Caolán McNamara 2017-12-15 13:53:12 UTC
Created attachment 138461 [details]
Liberation Serif 1.07.2
Comment 8 Caolán McNamara 2017-12-15 13:54:10 UTC
Created attachment 138462 [details]
Liberation Serif 1.07.4
Comment 9 Caolán McNamara 2017-12-15 13:59:23 UTC
I think that it works on RHEL7 just helps us track down that this was ok in RHEL Liberation Serif 1.07.2 and has changed by Fedora Liberation Serif 1.07.4

I attach here the screenshots of fontforge and the OS/2 table of the RHEL vs Fedora versions of the font

(I rather suspect the different is in whatever tooling generates the ttf from the sfd source)
Comment 10 Caolán McNamara 2017-12-15 16:28:42 UTC
Yeah, if I build the fedora package on rhel-7 the bit is not set, while when built on fedora it is set
Comment 11 Caolán McNamara 2017-12-15 17:08:48 UTC
So I think the problem arises outside LibreOffice in the font itself so moving it to https://bugzilla.redhat.com/show_bug.cgi?id=1526510 and https://pagure.io/liberation-fonts
Comment 12 V Stuart Foote 2017-12-15 21:43:27 UTC
(In reply to Commit Notification from comment #6)
> Caolán McNamara committed a patch related to this issue.
> It has been pushed to "master":
> 
> http://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=f8399f442d7bf5abf3861e0285997d13f355eb6a
> 

On Fedora 27 64-bit with
Version: 6.1.0.0.alpha0+
Build ID: acc24edf21b99822b6e6d8119eba3ab843458401
CPU threads: 4; OS: Linux 4.14; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-12-15_01:59:17
Locale: en-US (en_US.UTF-8); Calc: group threaded

Made sure I was in Wayland, but I was unable to force this TDF build to show GTK3 (I thought I just needed to set SAL_USE_VCLPLUGIN=gtk3)...

Anyhow text entered into the sm "Formula Editor" now has room, and is not being clipped with addition of extra leading from the above commit. So think that is fixed.

Also checked the TDF LO distributed LiberationSerif-Regular.ttf. It is ver 2.00.1, and in FontCreator it is showing the OpenType OS/2 version 3 is set.  While the 1.07.04 build from Fedora 27 shows version 4 with "Use typo metrics for line spacing" set.

Replace 1.07.04 with the 2.00.1--and with the 5.4.4.1-fc27 build nodes in the sm Preview Window are again correctly spaced.

So there is a font metric gotcha with Liberation fonts and the OS/2 table metrics.
Comment 13 Caolán McNamara 2017-12-16 16:21:20 UTC
Wayland and/or version of gtk should have nothing to do with this, the TDF build IIRC don't have gtk3 support built in. The linked bugs have some more details as to what I think went wrong with the Fedora Liberation fonts and how Fedora can get that fixed
Comment 14 V Stuart Foote 2017-12-16 17:01:48 UTC
Stuart -> Caolán -- no objection. What caught my eye on opening in Fedora (first time in a while) was the clipping of sm formula input in the Formula Editor. The extra leading has cleared that--but was that a GTK3 issue?  Anyhow, agree bad formula nodes were caused by Fedora changes to Liberation font's OS/2 tables 1.07.2 -> 1.07.4 (OTF version 3 -> version 4 and "Really use Typo metrics").
Comment 15 Caolán McNamara 2017-12-16 18:53:53 UTC
Its all the same problem, and unrelated to gtk3, its just that asking the edit window to actually use external leading makes it look right, and is probably the right thing to do anyway.