Exposed the internal Rasterizer and GlyphData object methods to Lua. Also added Font:hasGlyph.

This commit is contained in:
Alex Szpakowski
2013-06-16 07:36:18 -03:00
parent dd9cca1a55
commit d48d1fd441
21 changed files with 449 additions and 24 deletions
+38
View File
@@ -21,6 +21,9 @@
// LOVE
#include "Rasterizer.h"
// UTF-8
#include "libraries/utf8/utf8.h"
namespace love
{
namespace font
@@ -50,5 +53,40 @@ int Rasterizer::getDescent() const
return metrics.descent;
}
GlyphData *Rasterizer::getGlyphData(const std::string &text) const
{
unsigned int codepoint = 0;
try
{
codepoint = utf8::peek_next(text.begin(), text.end());
}
catch (utf8::exception &e)
{
throw love::Exception("Decoding error: %s", e.what());
}
return getGlyphData(codepoint);
}
bool Rasterizer::hasGlyph(const std::string &text) const
{
if (text.size() == 0)
return false;
unsigned int codepoint = 0;
try
{
codepoint = utf8::peek_next(text.begin(), text.end());
}
catch (utf8::exception &e)
{
throw love::Exception("Decoding error: %s", e.what());
}
return hasGlyph(codepoint);
}
} // font
} // love