mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
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:
@@ -39,15 +39,18 @@ namespace font
|
||||
class ImageRasterizer : public Rasterizer
|
||||
{
|
||||
public:
|
||||
ImageRasterizer(love::image::ImageData *imageData, uint32 *glyphs, int numglyphs, int extraspacing, float dpiscale);
|
||||
ImageRasterizer(love::image::ImageData *imageData, const uint32 *glyphs, int numglyphs, int extraspacing, float dpiscale);
|
||||
virtual ~ImageRasterizer();
|
||||
|
||||
// Implement Rasterizer
|
||||
int getLineHeight() const override;
|
||||
GlyphData *getGlyphData(uint32 glyph) const override;
|
||||
int getGlyphSpacing(uint32 glyph) const override;
|
||||
int getGlyphIndex(uint32 glyph) const override;
|
||||
GlyphData *getGlyphDataForIndex(int index) const override;
|
||||
int getGlyphCount() const override;
|
||||
bool hasGlyph(uint32 glyph) const override;
|
||||
DataType getDataType() const override;
|
||||
TextShaper *newTextShaper() override;
|
||||
|
||||
|
||||
private:
|
||||
@@ -57,23 +60,23 @@ private:
|
||||
{
|
||||
int x;
|
||||
int width;
|
||||
uint32 glyph;
|
||||
};
|
||||
|
||||
// Load all the glyph positions into memory
|
||||
void load();
|
||||
void load(const uint32 *glyphs, int glyphcount);
|
||||
|
||||
// The image data
|
||||
StrongRef<love::image::ImageData> imageData;
|
||||
|
||||
// The glyphs in the font
|
||||
uint32 *glyphs;
|
||||
|
||||
// Number of glyphs in the font
|
||||
int numglyphs;
|
||||
|
||||
int extraSpacing;
|
||||
|
||||
std::map<uint32, ImageGlyphData> imageGlyphs;
|
||||
|
||||
std::vector<ImageGlyphData> imageGlyphs;
|
||||
std::map<uint32, int> glyphIndices;
|
||||
|
||||
// Color used to identify glyph separation in the source ImageData
|
||||
Color32 spacer;
|
||||
|
||||
Reference in New Issue
Block a user