Removed the link between the font textures resolution and the size of the characters displayed. That allows to use very high resolution fonts similarly to card pictures...
This commit is contained in:
@@ -172,6 +172,7 @@ private:
|
|||||||
|
|
||||||
float mHeight;
|
float mHeight;
|
||||||
float mScale;
|
float mScale;
|
||||||
|
float mTextureScale;
|
||||||
float mRotation;
|
float mRotation;
|
||||||
float mTracking;
|
float mTracking;
|
||||||
float mSpacing;
|
float mSpacing;
|
||||||
|
|||||||
@@ -49,12 +49,13 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
|||||||
|
|
||||||
sprintf(filename, "%s.png", fontname);
|
sprintf(filename, "%s.png", fontname);
|
||||||
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
||||||
|
mTextureScale = (float) lineheight/ (mTexture->mHeight/16);
|
||||||
|
|
||||||
if (mTexture == NULL) return;
|
if (mTexture == NULL) return;
|
||||||
|
|
||||||
mHeight = (float) lineheight;
|
mHeight = (float) lineheight;
|
||||||
|
|
||||||
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f, mHeight);
|
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f/mTextureScale, mHeight/mTextureScale);
|
||||||
|
|
||||||
float a, b, c;
|
float a, b, c;
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ void JLBFont::DrawString(const char *string, float x, float y, int align, float
|
|||||||
|
|
||||||
index = (*p - 32)+mBase;
|
index = (*p - 32)+mBase;
|
||||||
|
|
||||||
float charWidth = mCharWidth[index];
|
float charWidth = mCharWidth[index]*mTextureScale;
|
||||||
float delta = (charWidth + mTracking) * mScale;
|
float delta = (charWidth + mTracking) * mScale;
|
||||||
float xPos = mXPos[index];
|
float xPos = mXPos[index];
|
||||||
if (leftOffset)
|
if (leftOffset)
|
||||||
@@ -194,8 +195,8 @@ void JLBFont::DrawString(const char *string, float x, float y, int align, float
|
|||||||
charWidth = (delta/mScale) - mTracking;
|
charWidth = (delta/mScale) - mTracking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mQuad->SetTextureRect(xPos, mYPos[index], charWidth , mHeight);
|
mQuad->SetTextureRect(xPos, mYPos[index], charWidth/mTextureScale, mHeight/mTextureScale);
|
||||||
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale, mScale);
|
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale*mTextureScale, mScale*mTextureScale);
|
||||||
dx += delta;
|
dx += delta;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@@ -235,7 +236,7 @@ float JLBFont::GetStringWidth(const char *string) const
|
|||||||
ch = *p - 32;
|
ch = *p - 32;
|
||||||
p++;
|
p++;
|
||||||
if (ch < 0) continue;
|
if (ch < 0) continue;
|
||||||
len += mCharWidth[ch+mBase] + mTracking;
|
len += (mCharWidth[ch+mBase]*mTextureScale) + mTracking;
|
||||||
}
|
}
|
||||||
len -= mTracking;
|
len -= mTracking;
|
||||||
return len*mScale;
|
return len*mScale;
|
||||||
|
|||||||
Reference in New Issue
Block a user