
Modern text rendering with Linux: Part 1 - daww
https://mrandri19.github.io/2019/07/18/modern-text-rendering-linux-ep1.html
======
jack12
Nice, I've subscribed to the RSS feed. A little weird to see such old software
versions being used in an article with 'modern' in its title, but I suppose
you have to pick a point that's 'modern enough' to have something the majority
of people can follow along with when they're all running old software too.

I wish it covered error handling a bit more than just 'exit(EXIT_FAILURE)'.
FreeType must have some sort of error code or error message function.

But that's all just minor nitpicking. I like the simple and direct walkthrough
of the FreeType API (and promising to include friends from the ecosystem in
the future). I hope the blog series will continue!

~~~
daww
Thanks :) I've used what was available on the latest ubuntu lts. FreeType
functions return 0 (FT_Err_Ok) on success or a specific value for each
function, but yes I agree that error handling could be better, maybe at the
expense of terseness.

------
okasaki
It seems that with high resolution displays, font rendering techniques are
becoming less important. I remember spending days tweaking font rendering. Now
with a 300 dpi display, everything looks great.

~~~
ComputerGuru
No, this is wrong. Microsoft tried it with Windows 8, getting rid of subpixel
antialiasing for hardware accelerated rendering and the results were so bad
that a recent update to Windows 10 began switching back. Unfortunately, Google
did the same thing in Chrome and they still don’t get it and continue to
insist that “it’s too hard to do it right” every time I file a bug about UI
régressions that came about as a result.

macOS gets around this be aliasing the hell out of all fonts regardless of
manual type hinting (or lack thereof).

~~~
mmmrk
OP specifically mentions his 300 dpi displays, where you indeed don't need
subpixel rendering. Low-DPI displays do need to continue to use tricks to make
text halfway pleasant though. Windows with its hinting philosophy and off-by-
default vertical smoothing is a bit of a special case though... like every
other system out there. Oh well.

> they still don’t get it and continue to insist that “it’s too hard to do it
> right”

What is wrong with that reply? It _is_ hard to do it correct _and_ quick.

~~~
ComputerGuru
> What is wrong with that reply? It _is_ hard to do it correct _and_ quick.

If it were anyone other than Google/Microsoft/Apple, I might accept that.
Closing the bug (rather than assigning it to a future unknown release) because
it’s “too hard” is ridiculous. It’s a valid concern, the results are
noticeable even on hi-dpi displays, and it _should_ be fixed (if not now,
later).

------
cbzehner
What makes this approach "modern"? What is this approach the alternative to?

As someone broadly unfamiliar with text rendering it's not clear to me. An
introduction to these points would be very helpful

~~~
kevingadd
It's part 1, so I would hope the author plans to move on from the basics here
into more modern techniques (things like subpixel anti-aliasing, ligatures,
etc).

~~~
daww
Absolutely, Subpixel AA, Kerning, Ligatures, Gamma Blending, and Emojis will
be treated

------
new_realist
Can’t wait to hear about Linux’s gamma corrected antialiasing in future posts
(or lack thereof).

~~~
daww
I agree that it's an interesting topic. On reddit one of the authors of dear
imgui has some interesting thought on it:
[https://www.reddit.com/r/programming/comments/cfxltf/modern_...](https://www.reddit.com/r/programming/comments/cfxltf/modern_text_rendering_with_linux_part_1/eudnxab/)

------
Const-me
I recently needed that, too: [https://github.com/Const-
me/nanovg/](https://github.com/Const-me/nanovg/)

Also using FreeType, but unlike that article rendering on GPU, with ClearType.

No advanced typography features are supported, though.

------
angara
If you are following along with gcc on Linux and continuing to get linker
errors even after adding -lfreetype, try passing it as the very last argument,
e.g.

    
    
      gcc `pkg-config --cflags freetype2` -Wall -Werror -o main main.c -lfreetype

------
z3t4
While we have almost photo realistic live 3d, some text based app's are very
laggy. To their defence, even though it's probably not the reason for the lag,
rendering fonts are very slow and complicated.

------
bjourne
Small nitpick: Freetype works on Windows too. So the same code can be used to
render fonts there. Though it is perhaps easier to use the native DirectWrite
api.

~~~
kevingadd
DirectWrite isn't necessarily much easier, but it has many perks you don't get
from freetype - kerning, combining characters, etc - and supports hardware
acceleration, which is pretty cool.

Because integrating pango/harfbuzz is so difficult I'm tempted to replace my
freetype usages with DirectWrite...

~~~
mmmrk
What makes integration of HarfBuzz difficult?

------
drakmail
Awesome, please continue!

