Fixed more font stuff, works really really good now.
This commit is contained in:
@ -37,12 +37,17 @@ float_t TrueTypeFont::getScale(float_t scale) {
|
||||
|
||||
float_t TrueTypeFont::getSpaceSize(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return mathRound<float_t>(this->fontSize * 0.3f);
|
||||
return mathRound<float_t>(this->getScale(fontSize) * 18);
|
||||
}
|
||||
|
||||
float_t TrueTypeFont::getInitialLineHeight(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return 8.0f;
|
||||
return mathRound<float_t>(42.0f * this->getScale(fontSize));
|
||||
}
|
||||
|
||||
float_t TrueTypeFont::getLineHeight(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return mathRound<float_t>(58.0f * this->getScale(fontSize));
|
||||
}
|
||||
|
||||
void TrueTypeFont::buffer(
|
||||
@ -100,7 +105,7 @@ void TrueTypeFont::buffer(
|
||||
// Setup the initial loop state, and X/Y coords for the quad.
|
||||
int32_t i = 0;
|
||||
float_t x = 0;
|
||||
float_t y = this->getInitialLineHeight(fontSize);
|
||||
float_t y = this->getInitialLineHeight(fontSize) / scale;
|
||||
float_t wordX = 0;
|
||||
char c;
|
||||
while(c = text[i++]) {
|
||||
@ -108,12 +113,12 @@ void TrueTypeFont::buffer(
|
||||
|
||||
// When space, start of new word about to begin
|
||||
if(c == FONT_SPACE) {
|
||||
x += this->getSpaceSize(fontSize);
|
||||
x += this->getSpaceSize(fontSize) / scale;
|
||||
|
||||
// Did this space cause a newline?
|
||||
if(x > maxWidth) {
|
||||
info->addLine(info->realLength, 0);
|
||||
y += this->getLineHeight(fontSize);
|
||||
y += this->getLineHeight(fontSize) / scale;
|
||||
x = 0;
|
||||
}
|
||||
wordX = x;
|
||||
@ -125,7 +130,7 @@ void TrueTypeFont::buffer(
|
||||
if(c == FONT_NEWLINE) {
|
||||
info->addLine(info->realLength, 0);
|
||||
wordStart = info->realLength;
|
||||
y += this->getLineHeight(fontSize);
|
||||
y += this->getLineHeight(fontSize) / scale;
|
||||
x = 0;
|
||||
continue;
|
||||
}
|
||||
@ -142,15 +147,15 @@ void TrueTypeFont::buffer(
|
||||
quad = quads + j;
|
||||
quad->x0 -= wordX;
|
||||
quad->x1 -= wordX;
|
||||
quad->y0 += this->getLineHeight(fontSize);
|
||||
quad->y1 += this->getLineHeight(fontSize);
|
||||
quad->y0 += this->getLineHeight(fontSize) / scale;
|
||||
quad->y1 += this->getLineHeight(fontSize) / scale;
|
||||
}
|
||||
|
||||
// Go back to the previous (still current) line and remove the chars
|
||||
info->lines[info->lines.size() - 1].length -= info->realLength - wordStart;
|
||||
|
||||
// Next line begins with this word
|
||||
y += this->getLineHeight(fontSize);
|
||||
y += this->getLineHeight(fontSize) / scale;
|
||||
info->addLine(wordStart, info->realLength-wordStart);
|
||||
wordX = 0;
|
||||
}
|
||||
@ -208,11 +213,6 @@ void TrueTypeFont::draw(Mesh *mesh, int32_t startchar, int32_t length) {
|
||||
);
|
||||
}
|
||||
|
||||
float_t TrueTypeFont::getLineHeight(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return 13.0f;
|
||||
}
|
||||
|
||||
float_t TrueTypeFont::getDefaultFontSize() {
|
||||
return (float_t)this->fontSize;
|
||||
}
|
Reference in New Issue
Block a user