I’ve put some example of using FreeType 2 (+Harbuzz in some of them) with SDL2 into my githup repo (https://github.com/wutipong/drawtext-sdl2-freetype2-harfbuzz). The code might not be neat, and even far from perfect, but I think it might give some idea on how they could be used together. All of them are tested on Visual C++ 2013 express.
I started writing those a while ago, after I found that SDL_TTF does not match my requirement in some case.
Hopefully you find it interesting. Please let me know if you have any comments.
PS. All of the testing text in the code are in Thai, because I’m Thai. This is not about being proud of my language, nor being racist, but I’m just most familiar with the the language so I know what to expect from the rendering output.
I just tested sdl-ft-1 and sdl-ft-harfbuzz on Linux. While sdl-ft-1
worked fine as far as I can see, I had to change sdl-ft-harfbuzz to use
utf8 and std::string instead of utf16 and std::wstring. I’m not quite
sure why, I might look into it again later. By the way, the font I used
Probably because in Linux, wchar_t is 32-bit wide while on Windows it’s 16-bit. I’m not really sure, been away from Linux for quite a while.
Thanks for let me know :).
Probably because in Linux, wchar_t is 32-bit wide while on Windows
it’s 16-bit. I’m not really sure, been away from Linux for quite a
Exactly right, I didn’t know that wchar_t is actually UTF32 on Linux.
Using std::wstring and hb_buffer_add_utf32 works on my system. Consider
using char16_t/u16string or char32_t/u32string instead of wchar_t,
which would be awkward on Linux (but not nearly as bad as wchar_t)
or use UTF8 and char, which would be awkward on Windows.
C++13 defines 2 new character type, char16_t and char32_t. These 2 could come handy when we need a specific size of character. The downside is the older compiler does not support them, nor the older library.