VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Static Public Member Functions
makVrv::DtSvgRasterizer Class Reference

Converts an SVG string into a pixel buffer suitable for uploading as an OpenGL texture.

Rasterization is performed by LunaSVG (MIT-licensed). The SVG is scaled uniformly to fit the requested DtBitmapData dimensions; the caller controls the output resolution by constructing DtBitmapData with the desired width and height before calling rasterize().

Output pixel format is straight RGBA (GL_RGBA / GL_UNSIGNED_BYTE), top-down row order. The class has no instance state; all methods are static.

Static Public Member Functions

static bool rasterize (const std::string &svgString, DtBitmapData &bitmapData)
 
static bool rasterize (const std::vector< std::string > &svgLayers, DtBitmapData &bitmapData)
 
static void precacheFonts (const std::string &fontsDir=std::string())
 

Member Function Documentation

static bool makVrv::DtSvgRasterizer::rasterize ( const std::string &  svgString,
DtBitmapData &  bitmapData 
)
static

Rasterize an SVG string into a pre-allocated RGBA pixel buffer.

Parameters
svgStringSVG XML content to rasterize.
bitmapDataOutput bitmap; must be constructed with the desired width and height so that pixels is pre-allocated to width * height * 4 bytes before this call. On success the pixels are filled with straight RGBA data, top-down row order.
Returns
true on success; false if svgString is empty, if bitmapData dimensions are zero, or if LunaSVG fails to parse the SVG.
static bool makVrv::DtSvgRasterizer::rasterize ( const std::vector< std::string > &  svgLayers,
DtBitmapData &  bitmapData 
)
static

Rasterize a stack of SVG documents into one pre-allocated RGBA pixel buffer.

Layer 0 is the base document; each subsequent document is composited over it in order using source-over alpha blending in premultiplied space. Each layer is scaled independently with a uniform fit-to-bitmap scale (the minimum of the width and height ratios) and rendered from the bitmap's top-left corner. The premultiplied-to-straight-RGBA conversion happens exactly once, after the final layer.

All documents are parsed before any pixel is written: on any failure (empty list, zero bitmap dimensions, or a layer that fails to parse) the method returns false and the bitmap content is untouched.

Parameters
svgLayersSVG XML documents to rasterize, base (bottom) layer first.
bitmapDataOutput bitmap; must be constructed with the desired width and height so that pixels is pre-allocated to width * height * 4 bytes before this call. On success the pixels are filled with straight RGBA data, top-down row order.
Returns
true on success; false if svgLayers is empty, if bitmapData dimensions are zero, or if LunaSVG fails to parse any layer.
static void makVrv::DtSvgRasterizer::precacheFonts ( const std::string &  fontsDir = std::string())
static

Pre-load the LunaSVG font face cache with all .ttf files in the given directory.

Iterates all .ttf files in fontsDir and registers each with lunasvg_add_font_face_from_file. Font registration is guarded by std::call_once: the actual file I/O runs exactly once per process, regardless of how many times this function is called.

Parameters
fontsDirDirectory containing .ttf font files. Pass the resolved path of /Fonts/; if left empty the load is skipped.

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)