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

Override/blacklist DejaVu emoji glyphs without making Emoji One Color the default font #17

Closed
13rac1 opened this issue Mar 13, 2016 · 8 comments
Assignees
Milestone

Comments

@13rac1
Copy link
Owner

13rac1 commented Mar 13, 2016

The Problem

The current readme recommends creating/modifying the user's fontconfig fonts.conf to make Emoji One Color the primary fallback font for sans-serif, serif and, monospace font families. This causes a number of issues including #1, #5, and #16. Ideally the DejaVu font family would stay the default and Emoji One Color would override/replace the emoji included in DejaVu Sans.

According to my tests in #16 (comment), only DejaVu Sans has the actual emoji characters which cause this problem:
ohnoitsdejavu which is what happens when the recommended fonts.conf is not installed.

A nice solution would be to blacklist the DejaVu Sans glyphs...

Blacklisting glyphs

There has been a number of requests for an option to "blacklist glyphs" or "create virtual fonts" in fontconfig over the years, but there is no current implementation AFAIK. (Too much detail follows, but this is a good place to keep the research.) 😉

Mixing arbitrary unicode ranges into a virtual font
might be needed when some fonts have just a few bad
characters [eg numbers], but normally mixing would be
by language.

Ideas on how to approach it [if not done already]?

src: https://lists.freedesktop.org/archives/fontconfig/2004-October/001045.html

Blacklisting glyphs in fonts has been a long standing wish for lots of
people, and the patch for fontconfig was even written once I think, but
it was never applied. Fontconfig people are just blaming the fonts with
all the different scripts. But as said before, it'll have to be
fontconfig which needs to be patched, since fonts won't do anything as
long as font substitution isn't available everywhere (and even then it
remains to be seen).

src: https://sourceforge.net/p/dejavu/mailman/message/9671050/

I remember that once upon a time the whole issue of making it possible
for FontConfig to blacklist glyphs from
fonts was discussed.

The idea was that it is easy and fast to write a few lines of XML into
a FontConfig .conf file while it is slow and
laborious to remove glyphs from a font.

Perhaps now is the time to actually implement this functionality in FontConfig?

src: https://lists.freedesktop.org/archives/fontconfig/2008-January/002847.html
Followed up by:

Sure, Pango totally uses fontconfig to determine if a font supports a
character. So this can completely be fixed in fontconfig. Someone
needs to go finish the patch and pass it through Keith I think.

src: https://lists.freedesktop.org/archives/fontconfig/2008-January/002850.html

  • Finish patch for fontconfig to allow configuration to disable
    certain Unicode codepoints per font. The write such configuration for
    the crappy glyphs.

Pick whichever you prefer and just do it.

src: https://mail.gnome.org/archives/gtk-i18n-list/2007-December/msg00007.html

Solutions

As much fun as it would be to go down another rabbit hole, I don't have the time to patch fontconfig right now. Plus, backwards compatibility would still be an issue. The recommended solution is to remove the offending glyphs.

Actually IMO if the Latin glyph are crappy, removing them is the single
most correct solution.

src: https://lists.freedesktop.org/archives/fontconfig/2008-January/002846.html

This means a fork of DejaVu Sans is probably the answer. Any other ideas?! 😎

@13rac1
Copy link
Owner Author

13rac1 commented Mar 13, 2016

Yes, still looks like the best solution. Microsoft and Apple probably ship emoji characters in a separate font for this reason.

Short term goal: DejaVu Sans without emoji to ship with this font.
Long term goal: a DejaVu Emoji font in a pull request.

Follow along here: https://github.com/eosrei/dejavu-fonts/tree/emoji

@13rac1
Copy link
Owner Author

13rac1 commented Mar 13, 2016

Just found some emoji in DejaVu Serif and DejaVu Sans Mono. I need to fork the whole family! Yay.
DejaVu Serif too

@13rac1
Copy link
Owner Author

13rac1 commented Mar 13, 2016

This font: https://github.com/eosrei/dejavu-fonts/commit/46ba8581cd599b4e4e247c5d3d19e02aa99f73fa with the following fonts.conf seems to work:

<fontconfig>
  <match>
    <test name="family"><string>sans-serif</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>DejaVu Sans No Emoji</string>
      <string>Emoji One Color</string>
    </edit>
  </match>
  <match>
    <test name="family"><string>Apple Color Emoji</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Emoji One Color</string>
    </edit>
  </match>
  <match>
    <test name="family"><string>Segoe UI Emoji</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Emoji One Color</string>
    </edit>
  </match>
</fontconfig>

@13rac1 13rac1 added this to the v1.0 milestone Mar 16, 2016
13rac1 added a commit that referenced this issue Mar 17, 2016
The DejaVu font family is based on the Bitstream Vera font family to provide
greater unicode coverage. The only way to override the emoji it includes is
to make the emoji font the primary system font. This shouldn't be a problem,
but a number of programs do not correctly use font fallback resulting in font
rendering errors everywhere: #1, #5, #16, #18, #19.

This font.conf makes Bitstream Vera the default font for Serif, Sans-Serif,
and Monospace font requests since it does not contain any Unicode Emoji
characters. Emoji One Color font is the first fallback, followed by DejaVu
to provide everything else.

Test with:
fc-match -s serif
fc-match -s sans-serif
fc-match -s monospace

May be the solution for #17
@13rac1
Copy link
Owner Author

13rac1 commented Mar 17, 2016

I've found a much better solution to this issue: Bitstream Vera! It's the basis for DejaVu and doesn't include all of these characters needing to be overridden. Bitstream Vera is going to be the default install recommendation going forward. Noto can work if modified to remove a few emoji from the regular fonts which IMO should be moved to Noto Emoji I'll open on that project about it.

13rac1 added a commit to 13rac1/scfbuild that referenced this issue Mar 18, 2016
Specifically add notdef, null, CR and space. Space is hardcoded to
a width of 1024. Todo: Space width should be a config yaml option.

The font rendering systems are supposed to fallback to the space width
in the next available fallback font, but it doesn't work reliably.

Workaround for: 13rac1/emojione-color-font#2
Caused by: https://bugzilla.gnome.org/show_bug.cgi?id=757785
Related: 13rac1/emojione-color-font#17
13rac1 added a commit that referenced this issue Mar 21, 2016
Requires Bitstream Vera as the default serif, sans-serif, and
monospace font family since it contains no emoji characters.
Any other emoji-less font can be used, but most systems include
Bitstream Vera so it is used here as the example default. Noto
works well except primarily for 0x2639 and 0x263a.

See fonts.conf example:
fontconfig/user-bitstream-vera-fonts.conf

Workaround fix for #2
Related to #17
13rac1 added a commit that referenced this issue Mar 21, 2016
@13rac1 13rac1 closed this as completed in f93c509 Mar 21, 2016
evanpurkhiser added a commit to evanpurkhiser/dots-personal that referenced this issue May 14, 2016
@qnub
Copy link

qnub commented Jun 9, 2016

Have same view

@13rac1
Copy link
Owner Author

13rac1 commented Jun 9, 2016

DejaVu is the default font family for Linux. My provided fontconfig is the solution for this.

@qnub
Copy link

qnub commented Jun 9, 2016

fonts.config installed with this tdistributio give result from this screenshot.

@13rac1
Copy link
Owner Author

13rac1 commented Jun 9, 2016

Please open a new issue with the following details:

Repository owner locked and limited conversation to collaborators Jun 9, 2016
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

2 participants