FIX: text spaces is not work

the mesh of space is null, so the width of space is 0.
we use 'i' instead of space to calculate width.

Change-Id: I95d92d96e19416406d644ca35f0f14ade870f315
This commit is contained in:
zhimin.zeng 2023-02-24 14:49:47 +08:00 committed by Lane.Wei
parent a2f88ac9d5
commit 93ad247eff
1 changed files with 7 additions and 1 deletions

View File

@ -931,8 +931,14 @@ bool GLGizmoText::update_text_positions(const std::vector<std::string>& texts)
{
std::vector<double> text_lengths;
for (int i = 0; i < texts.size(); ++i) {
std::string alpha;
if (texts[i] == " ") {
alpha = "i";
} else {
alpha = texts[i];
}
TriangleMesh mesh;
load_text_shape(texts[i].c_str(), m_font_name.c_str(), m_font_size, m_thickness + m_embeded_depth, m_bold, m_italic, mesh);
load_text_shape(alpha.c_str(), m_font_name.c_str(), m_font_size, m_thickness + m_embeded_depth, m_bold, m_italic, mesh);
auto center = mesh.bounding_box().center();
double half_x_length = center.x();
text_lengths.emplace_back(half_x_length);