font rendering: reimplement tab-as-spaces support.

This commit is contained in:
Sasha Szpakowski
2022-12-28 19:46:48 -04:00
parent 7a0f6621e7
commit 9502942b7b
7 changed files with 136 additions and 78 deletions
+8
View File
@@ -81,11 +81,15 @@ public:
int height;
};
// This will be used if the Rasterizer doesn't have a tab character itself.
static const int SPACES_PER_TAB = 4;
static love::Type type;
virtual ~TextShaper();
const std::vector<StrongRef<Rasterizer>> &getRasterizers() const { return rasterizers; }
bool isUsingSpacesForTab() const { return useSpacesForTab; }
float getHeight() const;
@@ -128,6 +132,8 @@ protected:
TextShaper(Rasterizer *rasterizer);
static inline bool isWhitespace(uint32 codepoint) { return codepoint == ' ' || codepoint == '\t'; }
std::vector<StrongRef<Rasterizer>> rasterizers;
std::vector<float> dpiScales;
@@ -136,6 +142,8 @@ private:
int height;
float lineHeight;
bool useSpacesForTab;
// maps glyphs to advance and glyph+rasterizer index.
std::unordered_map<uint32, std::pair<int, GlyphIndex>> glyphAdvances;