Browse Source

Engine: Do not use offset for character advance

master
Riyyi 5 months ago
parent
commit
c607ebcc72
  1. 11
      src/inferno/system/textareasystem.cpp

11
src/inferno/system/textareasystem.cpp

@ -83,8 +83,8 @@ void TextAreaSystem::createLines(std::shared_ptr<Font> font, const TextAreaCompo
kerning = c->kernings.at(previous); kerning = c->kernings.at(previous);
} }
lineWidth += (c->advance + c->offset.x + kerning) * fontScale; lineWidth += (c->advance + kerning) * fontScale;
lineWidthSinceLastSpace += (c->advance + c->offset.x + kerning) * fontScale; lineWidthSinceLastSpace += (c->advance + kerning) * fontScale;
if (character == ' ') { if (character == ' ') {
spaceIndex = m_characters.size() - 1; spaceIndex = m_characters.size() - 1;
@ -147,11 +147,12 @@ std::optional<CharacterQuad> TextAreaSystem::calculateCharacterQuad(std::shared_
// ------------------------------------- // -------------------------------------
// Kerning // Kerning
char kerning = 0;
if (c->kernings.find(previous) != c->kernings.end()) { if (c->kernings.find(previous) != c->kernings.end()) {
advanceX += c->kernings.at(previous) * fontScale; kerning = c->kernings.at(previous);
} }
glm::vec2 cursor = { advanceX + (c->offset.x * fontScale), glm::vec2 cursor = { advanceX + (c->offset.x * fontScale) + (kerning * fontScale),
advanceY - (c->offset.y * fontScale) }; advanceY - (c->offset.y * fontScale) };
glm::vec2 cursorMax = { cursor.x + (c->size.x * fontScale), glm::vec2 cursorMax = { cursor.x + (c->size.x * fontScale),
cursor.y - (c->size.y * fontScale) }; cursor.y - (c->size.y * fontScale) };
@ -172,7 +173,7 @@ std::optional<CharacterQuad> TextAreaSystem::calculateCharacterQuad(std::shared_
characterQuad.at(3).quad.position = { cursorScreen.x, cursorScreen.y, 0.0f }; // top left characterQuad.at(3).quad.position = { cursorScreen.x, cursorScreen.y, 0.0f }; // top left
// Jump to the next glyph // Jump to the next glyph
advanceX += c->advance * fontScale; advanceX += (c->advance + kerning) * fontScale;
// Texture coordinates // Texture coordinates
// ------------------------------------- // -------------------------------------

Loading…
Cancel
Save