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
+23 -2
View File
@@ -31,6 +31,8 @@ namespace love
namespace font
{
class TextShaper;
/**
* Holds the specific font metrics.
**/
@@ -84,17 +86,32 @@ public:
**/
virtual int getLineHeight() const = 0;
/**
* Gets the spacing of the given unicode glyph.
**/
virtual int getGlyphSpacing(uint32 glyph) const = 0;
/**
* Gets a rasterizer-specific index associated with the given glyph.
**/
virtual int getGlyphIndex(uint32 glyph) const = 0;
/**
* Gets a specific glyph.
* @param glyph The (UNICODE) glyph codepoint to get data for.
**/
virtual GlyphData *getGlyphData(uint32 glyph) const = 0;
GlyphData *getGlyphData(uint32 glyph) const;
/**
* Gets a specific glyph.
* @param text The (UNICODE) glyph character to get the data for.
**/
virtual GlyphData *getGlyphData(const std::string &text) const;
GlyphData *getGlyphData(const std::string &text) const;
/**
* Gets a specific glyph for the given rasterizer glyph index.
**/
virtual GlyphData *getGlyphDataForIndex(int index) const = 0;
/**
* Gets the number of glyphs the rasterizer has data for.
@@ -120,6 +137,10 @@ public:
virtual DataType getDataType() const = 0;
virtual ptrdiff_t getHandle() const { return 0; }
virtual TextShaper *newTextShaper() = 0;
float getDPIScale() const;
protected: