Closed Bug 1744765 Opened 2 years ago Closed 2 years ago

Support fontconfig fontfeature field to support user‘s OpenType feature setting in fontconfig global

Categories

(Core :: Layout: Text and Fonts, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
99 Branch
Tracking Status
firefox99 --- fixed

People

(Reporter: coelacanthushex, Assigned: coelacanthushex)

Details

(Keywords: fonts)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

  1. First you should have a font with OpenType, in this, we use Iosevka
  2. Enable some OpenType feature, like:
    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
    <match target="font">
    <test name="family" compare="eq" ignore-blanks="true">
    <string>Iosevka</string>
    </test>
    <edit name="fontfeatures" mode="append">
    <string>ss10 on</string>
    </edit>
    </match>
    </fontconfig>
  3. Open Firefox, look at some text using this font.

Actual results:

You will found it using default but not ss10 (The special point is that the default glyph y is two straight strokes, and ss10 is curved)

Expected results:

It uses ss10 variant rather than default, in other words, glyph y is two straight strokes.

pango has implemented it, so all pango-based applications works well with it.
Qt has the same problem with us, link is here, you can find another test case there.
https://bugreports.qt.io/browse/QTBUG-78645

In general, the way to choose font features in the browser would be to use the CSS font-variant-* or font-feature-settings properties (or the corresponding descriptor in an @font-face rule). But maybe for the Linux environment it would make sense to also consider features configured via fontconfig.... do you know if other browsers such as chromium support this?

As far as I know, Chromium does not support this feature.
I put forward this requirement based on two reasons:
First of all, this kind of demand exists objectively for users, that is, users (This refers to the end user of the browser, not the website developer) have the need to modify the configuration of a certain font globally without modifying the content of the webpage.
Second, the browser, as the party that obtains the information (from fontconfig), should respect the configuration obtained. In other words, since we got the existence of this configuration from fontconfig, we should follow this configuration

Keywords: fonts

(In reply to Jonathan Kew (:jfkthame) from comment #2)

In general, the way to choose font features in the browser would be to use the CSS font-variant-* or font-feature-settings properties (or the corresponding descriptor in an @font-face rule). But maybe for the Linux environment it would make sense to also consider features configured via fontconfig....

Such controls do exist here, but the main problem is that they are designed for websites and website authors, and its controls are embedded in the web page and its CSS; whereas for the browser user, we need a global solution that does not require intrusive changes to the content of the web page. So here are two solutions, the first one is that Firefox can provide a settings interface that allows us to configure the font characteristics enabled and disabled for each font, the advantage of this solution is that it is generic, the disadvantage is that there are more things to implement and the format of the configuration is an issue. The second solution is that fontconfig provides the ability to get the font features configured by the user in the fontconfig settings, we can simply get these settings and apply them to the font along with the features specified in the settings selection, e.g., font-features-settings. The advantage of this option is that it is less work and can be consistent with the behavior of applications that use Pango/GTK. The disadvantage is that it may not work on Windows (but there is no better solution for controlling font order and features on Windows).
My personal recommendation is to first implement the second option (the one mentioned in this bug), which is less work and is already used by many applications. There should be a switch for this feature, and then after this feature is rolled out, telemetry data will determine if a more complex implementation should be implemented on Windows.

Pango adds enabling features in fontconfig support in this commit. https://gitlab.gnome.org/GNOME/pango/-/commit/db410d8ebdbc5b697430617e761da6b5ce4940dd
They add disabling features in fontconfig support in this commit. https://gitlab.gnome.org/GNOME/pango/-/commit/2ae57392de417554b7d6e37adea1b99396ef578a
It is done 9 years ago. And you can see, the change is not big.

As Pango do, we get font feature settings for specfied from user's
fontconfig. This will not affect users that don't use this feature,
because they will not add fontfeatures setting in their fontconfig.

There is an example config I use to test:
<match target="pattern">
<test name="family" compare="eq" ignore-blanks="true">
<string>Iosevka</string>
</test>
<edit name="fontfeatures" mode="append">
<string>ss10 on</string> <!-- using SS10 variant shape -->
<string>cv49 1</string> <!-- straight y -->
<string>cv83 2</string> <!-- underline, not too high, not too low -->
</edit>
</match>

Signed-off-by: Coelacanthus <coelacanthus@outlook.com>

Assignee: nobody → coelacanthus
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/182c89c77191
Add font features config from user's fontconfig r=jfkthame,layout-reviewers
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: