Bug 126754 - FONT FEATURES DIALOG: Wrong OpenType tag for fractions in "font features" dialog
Summary: FONT FEATURES DIALOG: Wrong OpenType tag for fractions in "font features" dialog
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: All All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:7.5.0 target:7.4.1
Keywords:
Depends on:
Blocks: Character-Dialog
  Show dependency treegraph
 
Reported: 2019-08-07 21:09 UTC by RGB
Modified: 2022-07-29 15:08 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
Font features menu (74.08 KB, image/png)
2019-08-07 21:09 UTC, RGB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description RGB 2019-08-07 21:09:24 UTC
Created attachment 153209 [details]
Font features menu

OpenType defines two kinds of fractions, the "diagonal" fraction with the +frac tag and the "nut" fraction with the tag +afrc

Character → Font tab → Features, LibreOffice offers "frac=1" for diagonal fractions and "frac=2" for nut fractions, which is wrong: those are Graphite tags, not OpenType tags, and they are valid only for Linux Libertine G and Linux Biolinum G fonts (Graphite tags are not standardized). 

Because of their similarity, LibreOffice understand both, "frac=1" and "frac=2" as just "frac" which apply the diagonal OpenType fraction.

This wrong preset also generates problems with font preview when using some fonts, because on 6.3 the "frac=1" is applied even if not explicitly selected by the user, as you can see in the attached screenshot. 

For the screenshot I'm using a font called Sukhumala that offer both, diagonal and (some) nut fractions: 

http://www.softerviews.org/Fonts.html#Sukhumala

Clearly, "frac=2" does not work to get nut fractions with Sukhumala, but "afrc" does.
Comment 1 BobBau 2019-08-14 16:00:19 UTC
If want you chose a styleset or something like "onum" or "pnum" from font feature menu automatically adds "frac=1" no matter if you have selected a feature or not.

So if you call up the menu item, this feature "frac=1" will be added.

I have testet it with font Fira Sans (original from Mozilla Foundation).
Comment 2 Heiko Tietze 2019-08-30 07:40:39 UTC
Don't see need for UX input (besides the UI, which is a different topic). Please add the keyword again if input is needed. 

Khaled, what do you think about the issue?
Comment 3 Tobias Hemm 2019-12-05 18:44:09 UTC
What RGB stated is absolutely correct.

I am about to file a bug/enhancement report regarding OpenType features, and have, in that course, found out that a newer version already contains a GUI implementation of them. So I have updated LO and tested the features.

And it is true: The fractions feature uses a wrong code (frac=1).
Furthermore, the default value is "diagonal", which doesn’t make sense.
This is a feature that should not be turned on by default.
Instead, there should be three values: "none", "diagonal" and "stacked".
(Please see my other report to see how I would implement it graphically.)
The code for "diagonal" would be "frac"; the code for "stacked" would be "afrc".
And I wouldn’t call the latter "nut" – that’s nuts.

At the moment, if I select the "nut fractions", what is created are diagonal fractions. As stated above, the default value is "diagonal", which creates no fractions at all.

But, guys, you are awesome to implement this, at all.
We will certainly get it to work properly.
Comment 4 Dieter 2019-12-06 07:26:50 UTC
(In reply to Tobias Hemm from comment #3)
> What RGB stated is absolutely correct.

=> Status NEW
Comment 5 Julien Nabet 2022-07-28 08:21:57 UTC
Just for information, there's frac=0 (so with None) since 7.0.0 (see tdf#132242).
Comment 6 Julien Nabet 2022-07-28 08:51:15 UTC
About "afrc", LO displays "Alternative (Vertical) Fractions" at top left of the screenshot. (I suppose the name comes from https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae).

https://en.wikipedia.org/wiki/List_of_typographic_features indicates:

Fractions 	frac 	S4 	Converts figures separated by slash with diagonal fraction

Alternative Fractions 	afrc 	S4 	Converts figures separated by slash with alternative stacked fraction form 

In addition to be able to distinguish Opentype tags and Graphite tags, another pb will be to not break config on existing files, what a mess...

Caolán: perhaps you may have some thoughts since it concerns vcl part (vcl/source/font/FeatureCollector.cxx + vcl/source/font/OpenTypeFeatureDefinitionList.cxx).
Comment 7 Caolán McNamara 2022-07-28 13:36:08 UTC
I don't really know the dialog and feature. Would it work to just offer two different views of this depending on IsGraphiteFont(), the current view when that's true and another when its false to address this.

I see that using literal

Sukhumala:afrc&frac
Sukhumala:afrc
Sukhumala:frac

give me three different things, so maybe for !IsGraphite() the Fraction and Alternative Fraction should just be checkboxes. I don't think we have to too concerned about backwards compat here(?)
Comment 8 Julien Nabet 2022-07-28 14:46:21 UTC
Thank you for the feedback.

Here's a bt:
#0  vcl::font::FeatureCollector::collectForLanguage(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
    (this=0x7fff08fa5690, aTableTag=1196643650, nScript=0, aScriptTag=1145457748, nLanguage=65535, aLanguageTag=1684434036) at vcl/source/font/FeatureCollector.cxx:105
#1  0x00007f1808285efa in vcl::font::FeatureCollector::collectForScript(unsigned int, unsigned int, unsigned int) (this=0x7fff08fa5690, aTableTag=1196643650, nScript=0, aScriptTag=1145457748)
    at vcl/source/font/FeatureCollector.cxx:115
#2  0x00007f18082861c3 in vcl::font::FeatureCollector::collectForTable(unsigned int) (this=0x7fff08fa5690, aTableTag=1196643650) at vcl/source/font/FeatureCollector.cxx:137
#3  0x00007f180828629c in vcl::font::FeatureCollector::collect() (this=0x7fff08fa5690) at vcl/source/font/FeatureCollector.cxx:150
#4  0x00007f1807ae11aa in OutputDevice::GetFontFeatures(std::__debug::vector<vcl::font::Feature, std::allocator<vcl::font::Feature> >&) const
     (this=0xab9ae30, rFontFeatures=std::__debug::vector of length 1, capacity 1 = {...}) at vcl/source/outdev/font.cxx:174
#5  0x00007f17b5893835 in getFontFeatureList(rtl::OUString const&, VirtualDevice&) (rFontName="Liberation Serif", rVDev=...) at cui/source/util/FontFeatures.cxx:23
#6  0x00007f17b544f50c in cui::FontFeaturesDialog::initialize() (this=0x7fff08fa5b78) at cui/source/dialogs/FontFeaturesDialog.cxx:54
#7  0x00007f17b544f2c0 in cui::FontFeaturesDialog::FontFeaturesDialog(weld::Window*, rtl::OUString) (this=0x7fff08fa5b78, pParent=0xa055768, aFontName="") at cui/source/dialogs/FontFeaturesDialog.cxx:29

I also noticed:
     20 OpenTypeFeatureDefinitionListPrivate& OpenTypeFeatureDefinitionList()
     21 {
     22     static OpenTypeFeatureDefinitionListPrivate SINGLETON;
     23     return SINGLETON;
     24 };
(see https://opengrok.libreoffice.org/xref/core/vcl/source/font/OpenTypeFeatureDefinitionList.cxx?r=85d15cfa#23)

Let's keep digging...
Comment 9 Julien Nabet 2022-07-28 16:06:49 UTC
It seems we're already distinguish both cases here:
    140 bool FeatureCollector::collect()
    141 {
    142     gr_face* grFace = hb_graphite2_face_get_gr_face(m_pHbFace);
    143 
    144     if (grFace)
    145     {
    146         return collectGraphite();
    147     }
    148     else
    149     {
    150         collectForTable(HB_OT_TAG_GSUB); // substitution
    151         collectForTable(HB_OT_TAG_GPOS); // positioning
    152         return true;
    153     }
    154 }

the test is exactly the same as here:
    146 bool LogicalFontInstance::IsGraphiteFont()
    147 {
    148     if (!m_xbIsGraphiteFont)
    149     {
    150         m_xbIsGraphiteFont = hb_graphite2_face_get_gr_face(hb_font_get_face(GetHbFont())) != nullptr;
    151     }
    152     return *m_xbIsGraphiteFont;
    153 }
in vcl/source/font/fontinstance.cxx
Comment 10 Julien Nabet 2022-07-28 16:17:13 UTC
I gave a try with https://gerrit.libreoffice.org/c/core/+/137574

Heiko/Xisco: perhaps you'd be interested in this one since it's related to UI part.
Comment 11 Commit Notification 2022-07-29 05:56:49 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d07f18e0c3f8d50deea643c0ecab171795bd1231

tdf#126754: Wrong OpenType tag for fractions in "font features" dialog

It will be available in 7.5.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 12 Julien Nabet 2022-07-29 06:02:34 UTC
Since I've not only removed translated strings but also modified one in the patch, I can't backport it on 7.4 branch.
Comment 13 Commit Notification 2022-07-29 15:08:07 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/de159e1ea264dae35cae90af24700bf971f065be

tdf#126754: Wrong OpenType tag for fractions in "font features" dialog

It will be available in 7.4.1.

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

Affected users are encouraged to test the fix and report feedback.