54 size_t ind = glyphs.find(c);
55 if (ind == string::npos)
return nullptr;
56 return characters + ind;
61 const Char* ch = findChar(c);
67 const char c, std::vector<mrpt::opengl::TTriangle>& tris,
68 std::vector<mrpt::math::TPoint3Df>& lines,
71 const Char* ch = findChar(c);
84 P3f(cursor.
x + vs[idx0].
x, cursor.
y + vs[idx0].
y, .0f),
85 P3f(cursor.
x + vs[idx1].
x, cursor.
y + vs[idx1].
y, .0f),
86 P3f(cursor.
x + vs[idx2].
x, cursor.
y + vs[idx2].
y, .0f));
91 const char c, std::vector<mrpt::opengl::TTriangle>& tris,
92 std::vector<mrpt::math::TPoint3Df>& lines,
95 const Char* ch = findChar(c);
105 cursor.
x + vs[idx0].
x, cursor.
y + vs[idx0].
y, .0f);
107 cursor.
x + vs[idx1].
x, cursor.
y + vs[idx1].
y, .0f);
112 const char c, std::vector<mrpt::opengl::TTriangle>& tris,
113 std::vector<mrpt::math::TPoint3Df>& lines,
116 outline(c, tris, lines, cursor);
117 fill(c, tris, lines, cursor);
154 const std::string& text, std::vector<mrpt::opengl::TTriangle>& tris,
155 std::vector<mrpt::math::TPoint3Df>& render_lines,
TEXT_STYLE style,
156 double spacing,
double kerning)
163 void (
Font::*operation)(
164 const char c, std::vector<mrpt::opengl::TTriangle>& tris,
165 std::vector<mrpt::math::TPoint3Df>& lines,
170 operation = &Font::fill;
173 operation = &Font::outline;
177 operation = &Font::fill;
185 double max_total = 0;
189 const double tab_width = 8 * ((space) ? (space->
advance) : 1);
190 for (
size_t i = 0; i < text.length(); ++i)
198 max_total = std::max(max_total, total);
205 const float advance = tab_width - std::fmod(total, tab_width);
222 (font->*operation)(c, tris, render_lines, cursor);
224 double w = ch->
advance + kerning;
229 max_total = std::max(total, max_total);
230 return std::make_pair(max_total, (lines + 1) * spacing);
234 const std::string& text,
double spacing,
double kerning)
237 double max_total = 0;
240 for (
size_t i = 0; i < text.length(); ++i)
245 max_total = std::max(max_total, total);
262 total += ch->
advance + kerning;
264 max_total = std::max(total, max_total);
265 return std::make_pair(max_total, (lines + 1) * spacing);
269 const std::string& text, std::vector<mrpt::opengl::TTriangle>& tris,
270 std::vector<mrpt::math::TPoint3Df>& lines,
271 std::vector<mrpt::img::TColor>& line_colors,
277 std::vector<mrpt::opengl::TTriangle> new_tris;
278 std::vector<mrpt::math::TPoint3Df> new_lines;
279 glDrawText(text, new_tris, new_lines, style, spacing, kerning);
282 for (
auto& t : new_tris)
284 t.setColor(text_color);
286 for (
int i = 0; i < 3; i++)
289 t.vertices[i].xyzrgba.pt =
290 text_pose.
composePoint(t.vertices[i].xyzrgba.pt * text_scale);
293 tris.emplace_back(t);
297 for (
auto& v : new_lines)
299 lines.emplace_back(text_pose.
composePoint(v * text_scale));
300 line_colors.emplace_back(text_color);