diff --git a/include/llmr/text/types.hpp b/include/llmr/text/types.hpp index 91c4bbe28..46a130d0e 100644 --- a/include/llmr/text/types.hpp +++ b/include/llmr/text/types.hpp @@ -61,21 +61,17 @@ typedef std::vector GlyphBoxes; struct PlacedGlyph { explicit PlacedGlyph(const vec2 &tl, const vec2 &tr, const vec2 &bl, const vec2 &br, - const Rect &tex, uint32_t width, - uint32_t height, float angle, const GlyphBox &glyphBox) + const Rect &tex, float angle, const GlyphBox &glyphBox) : tl(tl), tr(tr), bl(bl), br(br), tex(tex), - width(width), - height(height), angle(angle), glyphBox(glyphBox) {} vec2 tl, tr, bl, br; Rect tex; - uint32_t width, height; float angle; GlyphBox glyphBox; }; diff --git a/src/renderer/text_bucket.cpp b/src/renderer/text_bucket.cpp index d9aa76d89..0fd351343 100644 --- a/src/renderer/text_bucket.cpp +++ b/src/renderer/text_bucket.cpp @@ -38,8 +38,6 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, const auto &bl = glyph.bl; const auto &br = glyph.br; const auto &tex = glyph.tex; - const auto &width = glyph.width; - const auto &height = glyph.height; const auto &angle = glyph.angle; float minZoom = util::max( @@ -78,13 +76,13 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, tex.y, angle, minZoom, placementRange, maxZoom, placementZoom); vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, tr.x, tr.y, - tex.x + width, tex.y, angle, minZoom, placementRange, + tex.x + tex.w, tex.y, angle, minZoom, placementRange, maxZoom, placementZoom); vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, bl.x, bl.y, tex.x, - tex.y + height, angle, minZoom, placementRange, + tex.y + tex.h, angle, minZoom, placementRange, maxZoom, placementZoom); vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, br.x, br.y, - tex.x + width, tex.y + height, angle, minZoom, + tex.x + tex.w, tex.y + tex.h, angle, minZoom, placementRange, maxZoom, placementZoom); // add the two triangles, referencing the four coordinates we just diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 7969df628..237fd05d7 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -174,20 +174,8 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, continue; } - uint32_t width = glyph.metrics.width; - uint32_t height = glyph.metrics.height; - - width += buffer * 2; - height += buffer * 2; - - // Increase to next number divisible by 4, but at least 1. - // This is so we can scale down the texture coordinates and pack them - // into 2 bytes rather than 4 bytes. - width += (4 - width % 4); - height += (4 - height % 4); - float x = - (origin.x + placed.x + glyph.metrics.left - buffer + width / 2) * + (origin.x + placed.x + glyph.metrics.left - buffer + glyph.rect.w / 2) * fontScale; GlyphInstances glyphInstances; @@ -204,8 +192,8 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, const float x1 = origin.x + placed.x + glyph.metrics.left - buffer; const float y1 = origin.y + placed.y - glyph.metrics.top - buffer; - const float x2 = x1 + width; - const float y2 = y1 + height; + const float x2 = x1 + glyph.rect.w; + const float y2 = y1 + glyph.rect.h; const vec2 otl{x1, y1}; const vec2 otr{x2, y1}; @@ -249,7 +237,7 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, // Remember the glyph for later insertion. glyphs.emplace_back(PlacedGlyph{ - tl, tr, bl, br, glyph.rect, width, height, + tl, tr, bl, br, glyph.rect, static_cast( std::fmod((anchor.angle + rotate + instance.offset + 2 * M_PI), (2 * M_PI))),