diff --git a/source/FreeTypeGX.cpp b/source/FreeTypeGX.cpp index 9b412f6a..1ad81855 100644 --- a/source/FreeTypeGX.cpp +++ b/source/FreeTypeGX.cpp @@ -308,13 +308,14 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) { textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat); this->fontData[charCode] = (ftgxCharData){ + this->ftSlot->bitmap_left, this->ftSlot->advance.x >> 6, gIndex, textureWidth, textureHeight, this->ftSlot->bitmap_top, this->ftSlot->bitmap_top, - textureHeight - this->ftSlot->bitmap_top, + glyphBitmap->rows - this->ftSlot->bitmap_top, NULL }; this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); @@ -487,7 +488,7 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color } GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE); - this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos - x_offset, y - glyphData->renderOffsetY - y_offset, color); + this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX - x_offset, y - glyphData->renderOffsetY - y_offset, color); x_pos += glyphData->glyphAdvanceX; printed++; diff --git a/source/FreeTypeGX.h b/source/FreeTypeGX.h index 9eddcdcd..fb6998e5 100644 --- a/source/FreeTypeGX.h +++ b/source/FreeTypeGX.h @@ -166,13 +166,14 @@ * Font face character glyph relevant data structure. */ typedef struct ftgxCharData_ { - uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */ - uint16_t glyphIndex; /**< Charachter glyph index in the font face. */ + int16_t renderOffsetX; /**< Texture X axis bearing offset. */ + uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */ + uint16_t glyphIndex; /**< Charachter glyph index in the font face. */ - uint16_t textureWidth; /**< Texture width in pixels/bytes. */ - uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */ + uint16_t textureWidth; /**< Texture width in pixels/bytes. */ + uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */ - uint16_t renderOffsetY; /**< Texture Y axis bearing offset. */ + int16_t renderOffsetY; /**< Texture Y axis bearing offset. */ int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */ int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */