fix text node pad and font height bounds

This commit is contained in:
2019-11-29 12:16:20 +01:00
parent 26257e5a37
commit 2aadf9e92c
4 changed files with 13 additions and 9 deletions

View File

@@ -140,7 +140,7 @@ void TextMesh::update(kFont id, const std::string& text)
{
font_id = id;
auto& f = FontManager::get(id);
float spacing = f.bounds.w - f.bounds.y;
float spacing = (f.bounds.w - f.bounds.y);
float avg_width = f.bounds.z - f.bounds.x;
cur_box = glm::vec4(0, f.bounds.y, 5, spacing);
@@ -200,8 +200,8 @@ void TextMesh::update(kFont id, const std::string& text)
idx.push_back(n + 0);
idx.push_back(n + 2);
idx.push_back(n + 3);
bbmin = glm::min(bbmin, xy(f.bounds));
bbmax = glm::max(bbmax, { q.x1 / f.scale, y + f.bounds.w });
bbmin = glm::min(bbmin, glm::floor(xy(f.bounds)));
bbmax = glm::max(bbmax, glm::ceil(glm::vec2(q.x1 / f.scale, y / f.scale + f.bounds.w)));
if (max_width > 0 && q.x1 / f.scale + 5 > max_width * f.scale)
cur_box = glm::vec4(0, (y + spacing * f.scale) / f.scale + f.bounds.y, 5, spacing);
else