Skip to content
This repository has been archived by the owner on Nov 10, 2018. It is now read-only.

Don’t override fonts.conf #29

Closed
frederik-elwert opened this issue Apr 5, 2016 · 10 comments
Closed

Don’t override fonts.conf #29

frederik-elwert opened this issue Apr 5, 2016 · 10 comments
Assignees
Milestone

Comments

@frederik-elwert
Copy link

Currently, the install script overrides the file $HOME/.config/fontconfig/fonts.conf (after creating a backup). This might break other customisations of font configuration that a user did before. But fontconfig also supports a more modern approach of independent configuration files. So instead of overriding fonts.conf, I would suggest adding a file 10-emojione.conf to $HOME/.config/fontconfig/conf.d/.

@13rac1 13rac1 added this to the v1.0 milestone Apr 5, 2016
@13rac1 13rac1 self-assigned this Apr 5, 2016
@13rac1
Copy link
Owner

13rac1 commented Apr 5, 2016

Ah, this will be better. I've got so much time in figuring out this fontconfig in the first place, I didn't think about the conf.d. Reference from 50-user.conf:

        <!--
            Load per-user customization files where stored on XDG Base Directory
            specification compliant places. it should be usually:
              $HOME/.config/fontconfig/conf.d
              $HOME/.config/fontconfig/fonts.conf
        -->
        <include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include>
        <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include>

Looking at /etc/fonts/conf.d/README:

 Files begining with:   Contain:

 00 through 09      Font directories
 10 through 19      system rendering defaults (AA, etc)
 20 through 29      font rendering options
 30 through 39      family substitution
 40 through 49      generic identification, map family->generic
 50 through 59      alternate config file loading
 60 through 69      generic aliases, map generic->family
 70 through 79      select font (adjust which fonts are available)
 80 through 89      match target="scan" (modify scanned patterns)
 90 through 99      font synthesis

Starting the filename with 10 isn't correct. The Arch packages use a fontconfig starting with 35. I'd like to make the provided fontconfig file usable for both user-only and system-wide installs.

This blocks #9

@13rac1
Copy link
Owner

13rac1 commented Apr 5, 2016

DejaVu uses 57 and 58:

57-dejavu-sans.conf
57-dejavu-sans-mono.conf
57-dejavu-serif.conf
58-dejavu-lgc-sans.conf
58-dejavu-lgc-sans-mono.conf
58-dejavu-lgc-serif.conf

Perhaps it should be 56? 59? 71? Since I created an "emoji" generic family, perhaps it makes sense to separate it into two files at 35 and 59?

@edgemaster: Any thoughts? Why did you select 35 for the fontconfig filename? I'm doing some tests now and 35 works with fc-match -s for "sans" and "emoji", but not correctly for "Bitstream Vera Sans". Well, I've figured a place to implement unit tests and/or travis.ci! Hmm... The current file works correctly at 56.

@IgnoredAmbience
Copy link

I picked 35 as a bit of a guess, and roughly following the hints given in the fontconfig system readme.
Arch ships the default font config files with the patches at https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/fontconfig
I'm not sure if other fonts diverge from other standard configs.

It is the priority of the config file I was referring to previously when I said that I needed to test the arch system install further. I didn't have the time you track down/run through test cases for each of the relevant configuration bugs though.
I seem to remember that there's some oddity with other font priorities relative to the user configuration priority also.
Need to compare with Debian/Ubuntu to see how the distributions differ.

@13rac1
Copy link
Owner

13rac1 commented Apr 7, 2016

Ah ha! I will figure out a good way to do automated testing to make it easier to confirm.

@13rac1
Copy link
Owner

13rac1 commented Apr 13, 2016

This looks good enough for confirming correct installation:

$ fc-match -s sans | head -n2
Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
$ fc-match -s serif | head -n2
VeraSe.ttf: "Bitstream Vera Serif" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
$ fc-match -s "Emoji One Color" | head -n2
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
Vera.ttf: "Bitstream Vera Sans" "Roman"
$ fc-match -s "Bitstream Vera Sans" | head -n2
Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
$ fc-match -s mono | head -n2
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
$ fc-match -s monospace | head -n2
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

I'm going to automate it into a tests.sh

13rac1 added a commit that referenced this issue Apr 14, 2016
13rac1 added a commit that referenced this issue Apr 14, 2016
@13rac1
Copy link
Owner

13rac1 commented Apr 14, 2016

@edgemaster I've made a tests.sh to do some "unit tests". It compares a diff of current fc-match -s "$FONT" | head -n2 results to expected results. The output on my machine:

diff current-results.test expected-results.test
Font: sans                                                         Font: sans
Vera.ttf: "Bitstream Vera Sans" "Roman"                            Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: sans-serif                                                   Font: sans-serif
Vera.ttf: "Bitstream Vera Sans" "Roman"                            Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: serif                                                        Font: serif
VeraSe.ttf: "Bitstream Vera Serif" "Roman"                         VeraSe.ttf: "Bitstream Vera Serif" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: mono                                                         Font: mono
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"                   VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: monospace                                                    Font: monospace
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"                   VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Sans                                          Font: Bitstream Vera Sans
Vera.ttf: "Bitstream Vera Sans" "Roman"                            Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Serif                                         Font: Bitstream Vera Serif
VeraSe.ttf: "Bitstream Vera Serif" "Roman"                         VeraSe.ttf: "Bitstream Vera Serif" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Sans Mono                                     Font: Bitstream Vera Sans Mono
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"                   VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Emoji One Color                                              Font: Emoji One Color
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"             EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
Vera.ttf: "Bitstream Vera Sans" "Roman"                            Vera.ttf: "Bitstream Vera Sans" "Roman"

Fontconfig tests: PASS

@IgnoredAmbience
Copy link

Awesome. I'll give it a whirl and see how tweaking the priority of the configuration file impacts things.

@13rac1
Copy link
Owner

13rac1 commented Apr 15, 2016

I've changed the file to 56-emojione-color.conf since it passes all of the tests in test.sh correctly.

The user installer has been updated to put the file in $HOME/.config/fontconfig/conf.d/. This also works for system-wide install.

@frederik-elwert I still need to backup the user's existing font.conf for backwards compatibility. Let me know if you can think of any better way to handle the upgrade process. Maybe I could get crazy and hash the file? Seems overkill.

@13rac1 13rac1 closed this as completed in e215f27 Apr 15, 2016
13rac1 added a commit that referenced this issue Apr 15, 2016
The provided font config was being installed at:
~/.config/fontconfig/fonts.conf
it is better to install at:
~/.config/fontconfig/conf.d/56-emojione-color.conf

Adds uninstall.sh

Fixes #29
13rac1 added a commit that referenced this issue Apr 15, 2016
The provided font config was being installed at:
~/.config/fontconfig/fonts.conf
it is better to install at:
~/.config/fontconfig/conf.d/56-emojione-color.conf

Adds uninstall.sh

Fixes #29
@IgnoredAmbience
Copy link

Installing at 56 causes many fonts in Firefox to become Bitstream, even when specified to be otherwise.

For example, the UI flow of the GitHub webpages is broken with Bitstream.

Trying to work out how CSS font selectors interact with the system fallbacks...

@IgnoredAmbience
Copy link

Apologies for the noise, I'm describing #31.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants