5 ms·
Modern text rendering with Linux: Part 1
- new_realist 7y agoCan’t wait to hear about Linux’s gamma corrected antialiasing in future posts (or lack thereof).
- daww 7y agoI 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_text_rendering_with_linux_part_1/eudnxab/ https://www.reddit.com/r/programming/comments/cfxltf/modern_...
- mmmrk 7y agoIf you use Qt 5.9+ and set the UI font to a .otf font, you get alpha-blended and gamma corrected text.
- jack12 7y agoNice, 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 7y agoThanks :) 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.
- bjourne 7y agoSmall 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.
- aquabeagle 7y agoAnd every other Unix. There's nothing Linux-specific about this post.
- kevingadd 7y agoDirectWrite 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 7y agoWhat makes integration of HarfBuzz difficult?
- vetinari 7y agoI guess it is part 1, building up the stage to Harfbuzz/Pango.
- cbzehner 7y agoWhat 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
- drakmail 7y agoAwesome, please continue!
- Const-me 7y agoI 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.
- okasaki 7y agoIt 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 7y agoNo, 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).
- bluedino 7y agoYou can turn antialiasing off in Mac
- seanmcdirmid 7y agoI thought anti aliasing for most Macs these days was turned off since they don’t sell 1X resolutions anymore as of the MacBook Air refresh, anyways)? Windows land doesn’t have an equivalent movement, they don’t control the hardware and so there is still a lot of 1080p in use.
- ComputerGuru 7y agoThey turned off subpixel antialiasing, not all antialiasing. And I’m saying on Windows the results were atrocious on hi-dpi displays, not just legacy ones.
- mmmrk 7y agoOP 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.
- z3t4 7y agoWhile 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.
- angara 7y agoIf 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