-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text support under TODO #37
Comments
With limited time and resources, I don't think it will be available anytime soon.
The following text attributes will be added :
|
60% to completion |
Is there way to loop all the elements of the svg file, and get all the text components. I mean, currently, I can use the lunasvg to generate a background image(this image dose not have text information shown), than I will use some native API to draw text on the image. More details, in my wxWidgets application, I'd like to first draw the svg image without any text labels on the canvas, than use wxWidgets' native DrawText API to draw text on the canvas? I would like to do this because some of my text labels need to be changed from time to time, so maybe this is the correct way to do this? Any ideas? Thanks. |
My major drawback is font handling... Oddly enough, I don't even know what happened to the code. |
...You need coordinates, this is where the problem is. |
All you need is an XML library to manipulation the document tree. Example : XMLDocument xmldocument; // create XML document
xmldocument.load("<Your SVG Data here>");
auto textElement = xmldocument.getElementById("<The id of text element you want to change>");
textElement->setInnerText("<Your constantly changing text here>");
auto svgdocument = lunasvg::Document::loadFromFile(xmldocument.toString());
auto bitmap = svgdocument->renderToBitmap();
// Do something useful with the bitmap here
|
Hi, @sammycage thanks for the quick response. What I would like to do is something slightly different. For example, I have such image shown in a dialog Then under this dialog, I have three text field (under wxWidgets, it could be three wxTextCtrl), when user click on the control, it can enter some text. The method you mentioned above:
has some issue. I mean if the user changes the Text filed "Up Chirp" with some text like "50ms", I would like it take effect immediately. So, what I'd expect to do is: 1, draw an SVG image with three Text components Normally, I don't need to call In you suggested method, you first changed the SVG xml file, and later render to bitmap, that means if I changes the text values of the svg, I have to re-render to bitmap again. My question is, is there any way to loop the components of the svgdocument? such as:
|
Is the SVG file complex? If the answer is NO.. You can |
It is quite simple. I create those a simple SVG file by inkscape, such a circuit or similar things, and leave the "resistor" value as user input. Are there any reference on how to draw/show them by the |
Lemme add makeshift Text support first and I will tell you what to do next. TGIF |
What do you mean by "makeshift"? BTW: if lunasvg can natively parse the |
It looks like the text rendering is partially working? I mean I see this ticket: And I see you have example code there in that issue. The first thing is loading the font file. Also, it looks like someone has similar feature request like me: |
Oh, it looks like some code feature of render TEXT element is removed from the EDIT: |
Hi, I did some trick on another svg library called See the discussion here: Adds basic text parsing by jamislike · Pull Request #94 · memononen/nanosvg And the result is shown below. I hope lunasvg can also have a way to do like this. Thanks. |
Nice one....
Things are different and complex here, I'm glad you found a solution to your problem. |
Compared with lunasvg and nanosvg, I noticed that lunasvg support more features than nanosvg, such as the Thanks. |
I don't want to expose lunasvg internal structure.
I wanted to make one that perfectly matches what you are trying to do. It is makeshift because I will drop the zipped source code here.
I'm currently implementing things like this in plutosvg but much better... Stay tight |
I looked at this file: https://github.com/sammycage/plutosvg/blob/master/source/plutosvg.h It looks like it also does not expose the internal structure. So, maybe, it is not implemented yet. Thanks. |
Hi, is there anything new? Did you manage to progress a little further? |
Engineering is choking... I will drop updates during easter holiday. |
@asmwarrior @OriBibi Hello! I'm happy to share that text and tspan are now fully supported, along with very convenient font loading. Thank you for your patience! |
Good news, thanks, I will try this as soon as I can. |
Hi, I did a simple test about the lunasvg, and a svg file with some text, and the result is good! This is what I did for my test(I know nothing about meson build system) 1, I'm using Code::Blocks, and I simply create a console C++ project. Here is my testing svg file. Here is the result png file generated from the project. So, it works fine! Great! BTW: It looks like the "U" character in the right bottom image has slightly different position between the svg file and the generated png file. |
Hello. I saw that you entered the text support under TODO and also downloaded the "loadFontFromFile" function for loading text. Do you know when the text support is expected to return. And will the support include the "font-family" attribute?
The text was updated successfully, but these errors were encountered: