J :
* Fix some errors in the string width computation.
This commit is contained in:
+14
-14
@@ -113,7 +113,7 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
|
|||||||
else if (align == JGETEXT_CENTER)
|
else if (align == JGETEXT_CENTER)
|
||||||
dx -= width/2;
|
dx -= width/2;
|
||||||
|
|
||||||
dx = floorf(dx) + 0.1;
|
dx = floorf(dx);
|
||||||
dy = floorf(dy);
|
dy = floorf(dy);
|
||||||
int index;
|
int index;
|
||||||
while (*p)
|
while (*p)
|
||||||
@@ -145,27 +145,27 @@ void JLBFont::printf(float x, float y, const char *format, ...)
|
|||||||
void JLBFont::SetColor(PIXEL_TYPE color)
|
void JLBFont::SetColor(PIXEL_TYPE color)
|
||||||
{
|
{
|
||||||
mColor = color;
|
mColor = color;
|
||||||
mQuad->SetColor(mColor);
|
mQuad->SetColor(mColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float JLBFont::GetStringWidth(const char *string) const
|
float JLBFont::GetStringWidth(const char *string) const
|
||||||
{
|
{
|
||||||
float len = 0.0f;
|
float len = 0.0f;
|
||||||
|
|
||||||
const char *p = string;
|
const char *p = string;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
ch = *p - 32;
|
ch = *p - 32;
|
||||||
p++;
|
p++;
|
||||||
if (ch < 0) continue;
|
if (ch < 0) continue;
|
||||||
len += mCharWidth[ch+mBase];
|
len += mCharWidth[ch+mBase] + mTracking;
|
||||||
}
|
}
|
||||||
|
len -= mTracking;
|
||||||
return len*mScale;
|
return len*mScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JLBFont::SetScale(float scale) { mScale = scale; }
|
void JLBFont::SetScale(float scale) { mScale = scale; }
|
||||||
|
|||||||
Reference in New Issue
Block a user