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);
const std::string & glGetFont()
returns the name of the currently active font
#define THROW_EXCEPTION(msg)
std::pair< double, double > glGetExtends(const std::string &text, double spacing, double kerning)
returns the size of the bounding box of a text to be rendered, similar to glDrawText but without any ...
void fill(const char c, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, const mrpt::math::TPoint2Df &cursor) const
void outline(const char c, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, const mrpt::math::TPoint2Df &cursor) const
void glDrawTextTransformed(const std::string &text, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, std::vector< mrpt::img::TColor > &line_colors, const mrpt::poses::CPose3D &text_pose, float text_scale, const mrpt::img::TColor &text_color, TEXT_STYLE style, double spacing, double kerning)
Appends to {tris,lines} the entities representing a given text including a pose and scale transformat...
renders glyphs as outlines with GL_LINES
mrpt::math::TVector3D rotateVector(const mrpt::math::TVector3D &local) const
Rotates a vector (i.e.
map< string, Font * > FontMap
TOpenGLFontStyle
Different style for vectorized font rendering.
Base template for TPoint2D and TPoint2Df.
std::pair< double, double > glDrawText(const std::string &text, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &render_lines, TEXT_STYLE style, double spacing, double kerning)
renders a string in GL using the current settings.
float getAdvance(const char c) const
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
This was "renders glyphs filled with antialiased outlines", but since antialiased is not properly imp...
const Char * findChar(const char c) const
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
TPoint3D_< float > TPoint3Df
void draw(const char c, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, const mrpt::math::TPoint2Df &cursor) const
renders glyphs as filled polygons
static struct FontData data