Skip to content

Commit

Permalink
Overlay: Font - simplify GlyphInfo calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Nov 19, 2024
1 parent a1ee84b commit 8a5f41f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Components/Overlay/src/OgreFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,6 @@ namespace Ogre
}
finalWidth = roundUpSize;

Real textureAspect = (Real)finalWidth / (Real)finalHeight;

Image img(PF_BYTE_LA, finalWidth, finalHeight);
// Reset content (transparent)
img.setTo(ColourValue::ZERO);
Expand Down Expand Up @@ -518,12 +516,13 @@ namespace Ogre
}
}

UVRect uvs((Real)l / (Real)finalWidth, // u1
(Real)m / (Real)finalHeight, // v1
(Real)(l + width) / (Real)finalWidth, // u2
(m + max_height) / (Real)finalHeight); // v2
this->setGlyphInfo({cp, uvs, float(textureAspect * uvs.width() / uvs.height()),
float(x_bearing) / max_height, float(advance) / max_height});
UVRect uvs((Real)l / (Real)img.getWidth(), // u1
(Real)m / (Real)img.getHeight(), // v1
(Real)(l + width) / (Real)img.getWidth(), // u2
(m + max_height) / (Real)img.getHeight()); // v2

float font_height = max_height;
setGlyphInfo({cp, uvs, width / font_height, x_bearing / font_height, advance / font_height});

// Advance a column
if(width)
Expand Down

0 comments on commit 8a5f41f

Please sign in to comment.