Freetype2 + Harfbuzz for font rendering
Posted: 06 Sep 2016, 01:46
I implemented font rendering using freetype 2 and harfbuzz directly instead of using a third party lib as quesoglc.
Quesoglc is rather old, it still relies on fixed function pipeline which means it can't be used with an OpenGL Core context (which is mandatory to use GL 3.1+ on Linux Mesa and OSX). The current implementation is also using glScale to scale font, I don't know if it's a limitation of QuesoGLC or not, but it makes text blurry.
There are others libs like Freetype-gl but it's tied to OpenGL atm. There is no support for Vulkan or Metal afaik. Currently Warzone 2100 is OpenGL only but I think it would be good not to make usage of another API impossible because of a third party.
Using harfbuzz and Freetype 2 is not that hard so far, it takes around 100-200 lines of code to implement a basic font rendering infrastructure in Warzone 2100 ; this means code that can shape text (ie transform utf8 or utf16 string to a list of glyph (the "visual characters") and position that supports langage dépendent ligature and kerning) and rasterize glyph into a texture atlas on the fly, for different texture font. What's missing is the usage of bold characters and handling font file loading for different platform.
It adds 2 dependencies : freetype2, which is already a dependency of quesoglc, and harfbuzz (which does the shaping btw).
For reference I did a capture of the main menu on Windows with quesoglc and harfbuzz + FT2.
The donate link is quite blurry in the glc screen while it's not in the harfbuzz case.
I would like to know if I can continue working on this ; as far as I know it was planned to switch to freetype-gl however it is in discussion since 2013 so I don't know what the current status is.
Quesoglc is rather old, it still relies on fixed function pipeline which means it can't be used with an OpenGL Core context (which is mandatory to use GL 3.1+ on Linux Mesa and OSX). The current implementation is also using glScale to scale font, I don't know if it's a limitation of QuesoGLC or not, but it makes text blurry.
There are others libs like Freetype-gl but it's tied to OpenGL atm. There is no support for Vulkan or Metal afaik. Currently Warzone 2100 is OpenGL only but I think it would be good not to make usage of another API impossible because of a third party.
Using harfbuzz and Freetype 2 is not that hard so far, it takes around 100-200 lines of code to implement a basic font rendering infrastructure in Warzone 2100 ; this means code that can shape text (ie transform utf8 or utf16 string to a list of glyph (the "visual characters") and position that supports langage dépendent ligature and kerning) and rasterize glyph into a texture atlas on the fly, for different texture font. What's missing is the usage of bold characters and handling font file loading for different platform.
It adds 2 dependencies : freetype2, which is already a dependency of quesoglc, and harfbuzz (which does the shaping btw).
For reference I did a capture of the main menu on Windows with quesoglc and harfbuzz + FT2.
The donate link is quite blurry in the glc screen while it's not in the harfbuzz case.
I would like to know if I can continue working on this ; as far as I know it was planned to switch to freetype-gl however it is in discussion since 2013 so I don't know what the current status is.