diff --git a/src/gpufont/font.hpp b/src/gpufont/font.hpp index 538651d..d036427 100644 --- a/src/gpufont/font.hpp +++ b/src/gpufont/font.hpp @@ -700,7 +700,7 @@ class Font { } - void draw(float x, float y, float z, const std::string & text, bool vFlip = false){ + void draw(float x, float y, float z, const std::string & text, bool vFlip = false, float fontSize_px = 42){ float originalX = x; glBindVertexArray(vao); @@ -710,6 +710,7 @@ class Font { FT_UInt previous = 0; for(const char * textIt = text.c_str(); *textIt != '\0';){ + float letterFontSize_px = fontSize_px; // can be individual uint32_t charcode = decodeCharcode(&textIt); if(charcode == '\r'){ @@ -746,18 +747,18 @@ class Font { float v1 = (float)(glyph.bearingY + d) / emSize; - float x0 = x + u0 * worldSize; - float y0 = y + v0 * worldSize; - float x1 = x + u1 * worldSize; - float y1 = y + v1 * worldSize; + float x0 = x + u0 * worldSize * letterFontSize_px; + float y0 = y + v0 * worldSize * letterFontSize_px; + float x1 = x + u1 * worldSize * letterFontSize_px; + float y1 = y + v1 * worldSize * letterFontSize_px; if(vFlip){ float _v = v0; v0 = v1; v1 = _v; - y0 = y - v0 * worldSize; - y1 = y - v1 * worldSize; + y0 = y - v0 * worldSize * letterFontSize_px; + y1 = y - v1 * worldSize * letterFontSize_px; } int32_t base = static_cast (vertices.size()); @@ -769,7 +770,7 @@ class Font { indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base}); } - x += (float)glyph.advance / emSize * worldSize; + x += ((float)glyph.advance * letterFontSize_px) / emSize * worldSize; previous = glyph.index; } @@ -919,7 +920,7 @@ static void tryUpdateMainFont(FT_Library & library, Font::BoundingBox & bb){ { cout << "tryUpdateMainFont" << endl; - auto font = loadFont(library, filename, 0.05f); + auto font = loadFont(library, filename, 1.0f); if(!font){ return; }