Skip to content

Commit

Permalink
BitmapFont|Client: Fixed inverted glyph geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 15, 2013
1 parent aa65856 commit 0f552c3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions doomsday/client/src/resource/bitmapfont.cpp
Expand Up @@ -52,10 +52,10 @@ struct Glyph

DENG2_PIMPL(BitmapFont)
{
String filePath; ///< The "archived" version of this font (if any).
GLuint texGLName; ///< GL-texture name.
de::Vector2ui texMargin; ///< Margin in pixels.
Vector2i texDimensions; ///< Texture dimensions in pixels.
String filePath; ///< The "archived" version of this font (if any).
GLuint texGLName; ///< GL-texture name.
Vector2ui texMargin; ///< Margin in pixels.
Vector2i texDimensions; ///< Texture dimensions in pixels.
bool needGLInit;

/// Font metrics.
Expand Down Expand Up @@ -108,7 +108,7 @@ DENG2_PIMPL(BitmapFont)
ushort w = inByte(file);
ushort h = inByte(file);

ch->posCoords = Rectanglei::fromSize(Vector2i(0, 0), Vector2ui(w, h) - texMargin * 2);
ch->posCoords = Rectanglei::fromSize(Vector2i(0, 0), Vector2ui(w, h));
ch->texCoords = Rectanglei::fromSize(Vector2i(x, y), Vector2ui(w, h));

avgSize += ch->posCoords.size();
Expand Down Expand Up @@ -172,13 +172,15 @@ DENG2_PIMPL(BitmapFont)
for(int i = 0; i < glyphCount; ++i)
{
ushort code = inShort(file);
ushort x = inShort(file);
ushort y = inShort(file);
ushort w = inShort(file);
ushort h = inShort(file);
DENG2_ASSERT(code < MAX_CHARS);
Glyph *ch = &glyphs[code];

ch->posCoords = Rectanglei::fromSize(Vector2i(0, 0), texMargin * 2 - Vector2ui(w, h));
ushort x = inShort(file);
ushort y = inShort(file);
ushort w = inShort(file);
ushort h = inShort(file);

ch->posCoords = Rectanglei::fromSize(Vector2i(0, 0), Vector2ui(w, h) - texMargin * 2);
ch->texCoords = Rectanglei::fromSize(Vector2i(x, y), Vector2ui(w, h));

avgSize += ch->posCoords.size();
Expand Down Expand Up @@ -265,6 +267,8 @@ Rectanglei const &BitmapFont::glyphTexCoords(uchar ch)

void BitmapFont::glInit()
{
LOG_AS("BitmapFont");

if(!d->needGLInit) return;
if(novideo || isDedicated || BusyMode_Active()) return;

Expand Down Expand Up @@ -315,6 +319,8 @@ void BitmapFont::glInit()

void BitmapFont::glDeinit()
{
LOG_AS("BitmapFont");

if(novideo || isDedicated) return;

d->needGLInit = true;
Expand Down

0 comments on commit 0f552c3

Please sign in to comment.