Initial (WIP) Harfbuzz text shaping integration.

This a significant refactor / rewrite of much of the love.graphics Font code.
Text positioning is now split into TextShaper classes in the love.font module. This isn't exposed to users yet.
BMFonts and ImageFonts use the same text shaping as before (in the new TextShaper API). Fonts loaded via FreeType now use Harfbuzz for text shaping.

The new code isn't at feature-parity with the old code yet. Harfbuzz-based text shaping enables kerning support in more fonts, character combining into ligature glyphs, and directions other than left-to-right (this isn't supported in love yet).
This commit is contained in:
Sasha Szpakowski
2022-12-26 19:06:08 -04:00
parent 9086afb718
commit 7a0f6621e7
27 changed files with 1490 additions and 626 deletions
+5 -5
View File
@@ -439,7 +439,7 @@ Mesh *Graphics::newMesh(const std::vector<Mesh::BufferAttribute> &attributes, Pr
return new Mesh(attributes, drawmode);
}
love::graphics::TextBatch *Graphics::newTextBatch(graphics::Font *font, const std::vector<Font::ColoredString> &text)
love::graphics::TextBatch *Graphics::newTextBatch(graphics::Font *font, const std::vector<love::font::ColoredString> &text)
{
return new TextBatch(font, text);
}
@@ -1893,7 +1893,7 @@ void Graphics::drawShaderVertices(Buffer *indexbuffer, int indexcount, int insta
draw(cmd);
}
void Graphics::print(const std::vector<Font::ColoredString> &str, const Matrix4 &m)
void Graphics::print(const std::vector<love::font::ColoredString> &str, const Matrix4 &m)
{
checkSetDefaultFont();
@@ -1901,12 +1901,12 @@ void Graphics::print(const std::vector<Font::ColoredString> &str, const Matrix4
print(str, states.back().font.get(), m);
}
void Graphics::print(const std::vector<Font::ColoredString> &str, Font *font, const Matrix4 &m)
void Graphics::print(const std::vector<love::font::ColoredString> &str, Font *font, const Matrix4 &m)
{
font->print(this, str, m, states.back().color);
}
void Graphics::printf(const std::vector<Font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m)
void Graphics::printf(const std::vector<love::font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m)
{
checkSetDefaultFont();
@@ -1914,7 +1914,7 @@ void Graphics::printf(const std::vector<Font::ColoredString> &str, float wrap, F
printf(str, states.back().font.get(), wrap, align, m);
}
void Graphics::printf(const std::vector<Font::ColoredString> &str, Font *font, float wrap, Font::AlignMode align, const Matrix4 &m)
void Graphics::printf(const std::vector<love::font::ColoredString> &str, Font *font, float wrap, Font::AlignMode align, const Matrix4 &m)
{
font->printf(this, str, wrap, align, m, states.back().color);
}