sammycage / lunasvg

lunasvg is a standalone SVG rendering library in C++
MIT License
818 stars 115 forks source link

Local transformation and internal SVG element access - Text object attributes #165

Open rossanoparis opened 3 months ago

rossanoparis commented 3 months ago

Data

This issue refers to: issue 98 Library version: v2.3.9 (master) Testing SVG file: groups.svg.zip (InkScape)

Document Details
image IDs text2, text3
image

Scope

For a "text object" I'd like to get the following attributes: text value (array of strings), text position (array of float) and text angle Because they are useful to draw texts using other functions from other libraries ( for instance, wxWidgets ) It is up to the user select an appropriate font to draw them.

Testing code

// Load document
auto document = Document::loadFromFile(filesvg);
Box dbox(0, 0, document->width(), document->height());

// Retrieve the SVG element - text2
auto text2 = document->getElementById("text2");

Results

The pointer returned by the function auto text2 = document->getElementById("text2"); returns a NULL pointer.

Remarks

It is known that LunaSVG doesn't handle texts; they can't be rendered. Any way, it could handle them as internal objects with the scope of being useful for a user who needs to get their attributes. Perhaps LunaSVG should own functions able to operate on text objects only, in order to get something like below

ID text2 Text value[0] = TEXT2 Text position X[0] = 12.732866 Text position Y[0] = 141.75731 Text angle = -40.234662

ID text3 Text value[0] = TEXT3.1 Text value[1] = TEXT3.2 Text position X[0] = 73.865891 Text position Y[0] = 103.12551 Text position X[1] = 73.865891 Text position Y[2] = 108.12551 Text angle = 0