Context :
I'm using Luke Smith's version of st (suckless-terminal) with Monoid font for most Unicode symbols,
and I noticed it usually crash when it sees some emojis, like U1F970, st tries to load a color emoji font (currently, it's Apple Color Emoji, but for other users the default is with Noto Color Emoji, I tried both and it had the same issue) and crashes :
X Error of failed request: BadLength (poly request too large or internal Xlib length error)
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 20 (RenderAddGlyphs)
Serial number of failed request: 850
Current serial number in output stream: 883
If I want to avoid this crashes, I have several "unsatisfying" solutions :
- Don't use
stat all. And don't use any other softwares that has the same issue. - I installed
ttf-ancient-fonts-symbola. I can use it and have colorless emojis everywhere.
With this solution, I need to remove colored emojis, because every time I haveNotoorApplewith colored emojis, it's taken by default instead ofSymbola. - Disable the font when I launch
st(a.before the file name is enough to hide it), and enable it again after that. Looks like cheat and may cause problems when another software is launched. - Store emojis on personal
userfolder, create another useruser_2, launchstwithuser_2and becomeuseragain.
Is there a way to do this ? If so, is it the simplest way to avoid crashes ? - Use the solution from Luke Smith's St on Github :
If st crashes when viewing emojis, install libxft-bgra from the AUR.
will probably not work for me because I'm not using an Arch-based distro
(I'm currently using Ubuntu 20.04LTS. If someone knows a way to safely use AUR on it, why not, but it seems very unlikely).
What I want to do :
Tell to my computer to allow Apple Color Emoji to every software except those I chose
(currently, it's only st and pango-view (I use the second one only for a few tests), or other softwares using xft),
and tell st to use any "allowed for st" thing it wants for emojis, preferably Symbola.
Or tell to my computer at least to take Symbola by default for the emoji family.
If possible, "by default only for st".
I think there could be a solution with font-config.
Things I tried (non exhaustive) :
With font-config, there are tags like <match><test><string>st</string></test>…</match> to target st only
(I was able to tell it to "Make a font bold, only for st, only for some sizes". It worked on my computer).
And there are other tags like <selectfont><rejectfont><glob>/path/to/emoji/font</glob></rejectfont></selectfont> to disallow globally exactly one (or several, with a glob pattern) font.
I tried to combine them but it looks impossible. Here is a code that does not work :
(the font is removed everywhere, not "only for st").
<match>
<test qual="all" name="prgname" target="pattern" compare="eq"><string>St</string></test>
<selectfont>
<rejectfont>
<glob>/home/user/.local/share/fonts/Apple*</glob>
</rejectfont>
</selectfont>
</match>
I think a <selectfont> tag isn't supposed to be inside a <match> tag.
This issue is actually known, and not only related to st. I tried almost every solution here but still have crashes.
Example of what I tried, similar to a suggestion someone made about this issue :
<match target="pattern">
<test name="family"><string>emoji</string></test>
<edit name="family" mode="append"><string>Symbola</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>Apple Color Emoji</string></test>
<edit name="family" mode="assign" binding="same"><string>Symbola</string></edit>
</match>
but with or without it, the output of fc-match --verbose :family=emoji | grep '^.family:
remains family: "Apple Color Emoji"(s).
It still does not works for me when I write monospace instead of emoji and the default monospace font instead of Apple Color Emoji. Am I doing something wrong here ?
I found a solution to set a default font (in the following example ),
<alias>
<family>monospace</family>
<prefer><family>Cantarell</family></prefer>
</alias>
I set monospace to a random font called Cantarell and it worked.
It also worked for other fonts, including
But if I write emoji instead of monospace, here, it works !
So, there is a way to change default font. That's a good start, but it does not target a software, and emoji doesn't seems to be treated the same way sans-serif or serif or monospace are.
If I enable both Noto Color Emoji and Apple Color Emoji, the default for emojis is Noto Color Emoji and this solution didn't let me set Apple Color Emoji to default again.
I also noticed this config works with sans-serif (instead of monospace), but not with sans, even if :family=sans and :family=sans-serif has similar results every time I tried it on fc-match. Same remark for mono instead of monospace. Maybe, it means the wordssans, mono, and emoji have something in common.
But what is this "something in common" ?
Is there a way to make emoji works like monospace does?