12Me21/12term

[advisory] libXft vs. harfbuzz

Opened this issue · 3 comments

y-ack commented

emacs 28.1 has this to say about libXft:

** 'configure' now warns about building with libXft support.
libXft is unmaintained, and causes a number of problems with modern
fonts including but not limited to crashes; support for it may be
removed in a future version of Emacs. Please consider using
Cairo + HarfBuzz instead.

on june 11, 2021, 12 had these observations about harfbuzz (for ligature support):

st code inspection

looking at maybe ligatures, and
#include <hb.h>
"what the heck is hb?"
oh my gosh harfbuzz is REAL?
230 + ATTR_LIGA = 1 << 11,

wow fuck they really just used a cast to bypass const
declare function as
hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
then ,
((Glyph *)glyphs)[i].mode |= ATTR_LIGA;
why the fuck did they declare it as const if they're just going to modify it

mm it's starting to get pretty slow now

slow slow slow

ok so the speed issues uh
at least the new ones, seem to be entirely caused by harfbuzz,
ok I'll deal with this later i think,
not worth wasting time on a gimmick right now

library capability

also the need for both harfbuzz and freetype seems like
ugh so like
I don't think any of these libraries handle fallback at ALL
so if you can't find the glyph in your main font then you have to do like 15 billion different things and it's just stupidly inefficient
I might just umm
use one specific font for fallback just to keep this reasonable
rather than dynamically searching and
god this is so stupid
I thought libraries were supposed to actually DO things
so like,
freetype does font rasterization, but also does glyph lookup, so like
converting unicode codepoints into glyph indexes
but harfbuzz also does that,
except, harfbuzz can handle ligatures while freetype can't
but i still need freetype because harfbuzz doesn't do rasterization
and neither of these handle LOADING fonts, that's the job of fontconfig
but even fontconfig can't do fallback, or at least
not very well, anyway

leaving a ?TODO: look at harfbuzz again later re: performance?

latest release of xft was like a month ago so idk what they're talking about lol
I mean xft is definitely obsolete to some extent (as the world slowly moves away from X11), but it's just a wrapper around fontconfig (font loading), freetype (font rasterizing), and xrender (graphics drawing), which are libraries that Cairo also uses (on certain platforms)
I haven't encountered any fonts that crash xft so I have no idea what that's about...

harfbuzz itself isn't a exactly a replacement for any of these components, it just handles things like ligatures iirc as an extra step
I think the way I was using it wasn't optimal, but it also might just be overkill for this

y-ack commented

it seems like the recent libxft updates are mostly just build fixes
6 weeks, 2 years, 7 years, 9 years

It does seem like they are having trouble adding color font (i.e. emoji) support to xft:
https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1
not sure how far along the alternative libraries are though...