146 const std::string &font_file =
"",
147 float line_spacing = 1.2f);
311 static const std::string
kEmpty;
354 const std::vector<float> &z_buffer,
355 const Color &default_color);
A TrueType font, loaded at a fixed pixel size, with a glyph cache.
TrueType font loading, glyph rasterization and text measurement.
The Image — an RGBA pixel buffer with compositing and I/O operations.
void render_text_layers(const std::vector< TextNodeRef > &layers, Image &output, const Mat4 &view_projection, float pixel_scale, const std::vector< float > &z_buffer, const Color &default_color)
Draw all text layers into an already rendered image.
void draw_text(Image &image, const std::string &text, const Font &font, float x, float baseline_y, const TextDrawStyle &style)
Draw text into an image at a given position and baseline.
TextExtent measure_text(const std::string &text, float size, const std::string &font_file, float line_spacing)
Measure a (possibly multi-line) string in a given font and size.
glm::vec2 Vec2
2-component floating-point vector (xy).
TextSpace
The coordinate space of a TextLayer's positions.
@ WORLD
3D world coordinates, projected with the scene camera.
@ SCREEN
Output image pixels, origin at the top left, y growing down.
glm::mat4 Mat4
4×4 floating-point matrix.
glm::vec3 Vec3
3-component floating-point vector (xyz).
An RGBA color with floating-point components.
How to draw text onto an image with draw_text().
Color color
Text color; alpha values below 1 blend with the background.
float rotation
Rotation of the text in degrees, counter-clockwise, about the point (x, baseline_y) passed to draw_te...
float line_spacing
Distance between two lines of a multi-line string, as a multiple of the height of the font's glyph bo...
Color halo_color
Color of the halo (outline) drawn behind the glyphs.
float halo_width
Halo thickness in pixels (default: 1.0).
Size of a (possibly multi-line) piece of text.
float height
Height of the whole text block, in pixels.
float ascent
Distance from the first baseline to the top of the block, in pixels.
float descent
Distance from the last baseline to the bottom of the block, in pixels.
float width
Width of the widest line, in pixels.
size_t line_count
Number of lines (a trailing newline does not add one).
A batch of text labels drawn together, in one coordinate space.
std::vector< Vec3 > positions
Anchor positions, in world space or in screen pixels.
bool empty() const
Whether this layer holds no label with a position and a string.
Vec3 position_or(size_t i) const
Position of label i (origin when out of range).
size_t count() const
Number of labels in this layer.
TextSpace space
Coordinate space of positions (default: TextSpace::WORLD).
std::vector< Color > colors
One color per label; may be empty (then the renderer uses RenderOptions::default_color) or shorter th...
float halo_width
Halo thickness in output pixels (default: 1).
Color color_or(size_t i, const Color &fallback) const
Color of label i, falling back to fallback when the layer holds no colors at all.
Vec2 offset
Extra offset applied after anchoring, in output pixels (positive x = right, positive y = down).
bool depth_test
Whether the label is hidden by geometry in front of its anchor (default: true).
Vec2 adj
Where the position sits relative to the text box, in [0, 1].
const std::string & string_or(size_t i) const
String of label i (empty when out of range).
float size
Text height ("em" size) in output pixels (default: 16).
std::string font_file
Path to the .ttf file to use, or an empty string for the bundled default font (see default_font_path(...
Color halo_color
Color of the halo (outline) drawn behind the glyphs.
float rotation
Rotation of the label in degrees, counter-clockwise, about the anchor position (default: 0).
std::vector< std::string > strings
One string per entry in positions (UTF-8; \n for line breaks).
float line_spacing
Distance between two lines of a multi-line string, as a multiple of the height of the font's glyph bo...
A non-owning reference to one text layer in a scene, together with its placement transform (and optio...
const TextLayer * layer
Pointer to the owned layer (never null for a valid node).
Mat4 transform
Model matrix applied to the anchor positions.
std::string name
Optional node name (used by exporters / debugging).
int x
Left edge of the bitmap, in image pixels.
Fundamental types used throughout the scimesh rendering engine.