scimesh 0.3.4
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
text.cpp File Reference

Implementation of the text layer (see text.h). More...

#include <scimesh/text.h>
#include <scimesh/math_utils.h>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <limits>
#include <stdexcept>
#include <vector>
Include dependency graph for text.cpp:

Go to the source code of this file.

Namespaces

namespace  scimesh
 
namespace  scimesh::detail
 Internal helpers of the text renderer.
 

Functions

void scimesh::draw_text (Image &image, const std::string &text, const Font &font, float x, float baseline_y, const TextDrawStyle &style=TextDrawStyle())
 Draw text into an image at a given position and baseline.
 
TextExtent scimesh::measure_text (const std::string &text, float size, const std::string &font_file="", float line_spacing=1.2f)
 Measure a (possibly multi-line) string in a given font and size.
 
void scimesh::detail::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.
 

Detailed Description

Implementation of the text layer (see text.h).

Rendering works in "screen" coordinates with the origin at the top left and y growing downwards, which is both what ndc_to_screen() returns and the row order of Image (row 0 is the top row of the written file). Glyph bitmaps from stb_truetype are top-down as well, so no flipping is involved anywhere.

Definition in file text.cpp.

Variable Documentation

◆ bitmap

const GlyphBitmap* bitmap = nullptr

Definition at line 222 of file text.cpp.

◆ x

int x = 0

Left edge of the bitmap, in image pixels.

Definition at line 223 of file text.cpp.

◆ y

int y = 0

Top edge of the bitmap, in image pixels.

Definition at line 224 of file text.cpp.