Commit 40e26d0b authored by Declara Denis's avatar Declara Denis Committed by Christian Schulte zu Berge

FontAtlas: Added code for handling newlines

parent e0ae041b
......@@ -44,6 +44,7 @@ namespace campvis {
, _ftFace(nullptr)
, _texture(nullptr)
, _shader(nullptr)
, _height(height)
{
// Initialize the FreeType2 library
if (FT_Init_FreeType(&_ftLibrary)) {
......@@ -154,6 +155,12 @@ namespace campvis {
// Loop through all characters
for (size_t i = 0; i < text.length(); ++i) {
unsigned char p = text[i];
// Hanlde "\n"
if (p == 10) {
pos = cgt::vec2(position.x, pos.y - _height * 1.2f);
}
if (p >= 32 && p < 256) {
cgt::vec2 pos2(pos.x + _glyphs[p].bitmapOffset.x, -pos.y - _glyphs[p].bitmapOffset.y);
cgt::vec2 size = _glyphs[p].bitmapSize;
......
......@@ -107,6 +107,7 @@ namespace fontrendering {
FT_Face _ftFace; ///< Pointer to the font face
cgt::Texture* _texture; ///< OpenGL texture storing the texture atlas
cgt::Shader* _shader; ///< Shader used for font rendering
int _height;
static const int MAX_TEXTURE_WIDTH;
static const std::string loggerCat_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment