Hacker News new | ask | show | jobs
by blux 1098 days ago
For the text rendering part, is there no off-the-shelf library that provides that functionality?
2 comments

There might be a few, but the complexity of the task reduces the number of options (the most popular choice is probably FreeType+HarfBuzz). But even then there's the problem that FreeType's text rendering might look slightly different than the underlying system's text renderer (so your application stands out like a sore thumb), and text rendering also affects UI layout (just take right-to-left languages for instance) - so it's often not an isolated drop-in solution.

Ideally the underlying system would offer a low level text rendering API that's independent from the system's UI framework and can be combined with your own rendering efficiently (haven't used it, so don't know how good it actually is, but for instance on Windows there's DirectWrite). The problem with this approach is that not all platforms provide such a modular text renderer (for instance web browsers), and you need different code paths on different platforms (maybe even still have to integrate FreeType because one of the target platforms doesn't expose a text rendering API).

I believe Harfbuzz is used almost universally by every major application from Chrome to Firefox.
Harfbuzz only provides 'text shaping' (very important for UNICODE support, especially for languages like Arabic), but the actual text rendering needs to be done elsewhere.
Their rendering engines choose the OS native one. They have abstractions over that. For example they'll use DirectWrite on Windows. Implementing a partial GUI toolkit is just another thing in the list of extremely hard problems in browser engine development.