Added basic kerning support for TrueType and BMFont fonts (resolves issue #1055.)

This commit is contained in:
Alex Szpakowski
2015-07-02 21:07:34 -03:00
parent 4550409ffa
commit bf432aff7c
8 changed files with 80 additions and 7 deletions
+7 -3
View File
@@ -27,7 +27,7 @@
#include "image/ImageData.h"
// C++
#include <map>
#include <unordered_map>
#include <vector>
namespace love
@@ -50,6 +50,7 @@ public:
GlyphData *getGlyphData(uint32 glyph) const override;
int getGlyphCount() const override;
bool hasGlyph(uint32 glyph) const override;
float getKerning(uint32 leftglyph, uint32 rightglyph) const;
static bool accepts(love::filesystem::FileData *fontdef);
@@ -68,10 +69,13 @@ private:
std::string fontFolder;
// Image pages, indexed by their page id.
std::map<int, StrongRef<image::ImageData>> images;
std::unordered_map<int, StrongRef<image::ImageData>> images;
// Glyph characters, indexed by their glyph id.
std::map<uint32, BMFontCharacter> characters;
std::unordered_map<uint32, BMFontCharacter> characters;
// Kerning information, indexed by two (packed) characters.
std::unordered_map<uint64, int> kerning;
int fontSize;
bool unicode;