Closed OriBibi closed 3 years ago
Rendering text requires font so you have to call loadFontFromFile(<path to font file>)
first before rendering. If i get your question correctly!? :-)
Please clarify your question with an example!
I will use your example with a little change:
#include <lunasvg/svgdocument.h>
using namespace lunasvg;
int main()
{
SVGDocument document;
document.loadFontFromFile("ARLRDBD.TTF");
document.loadFromData("<svg><text x="0" y="15" fill="red">I love SVG!</text></svg>");
Bitmap bitmap = document.renderToBitmap();
// do something useful with the bitmap.
return 0;
}
Everything works great for me except the text. Maybe I need a particular font or all types of font should work? I took the font from the fnots that windows provide (C:\Windows\Fonts).Maybe the string in loadFromData function invalid?. it doesn't work for me. Am I doing something wrong? BTW thank you for amazing library!
Please test whether this will fail.
#include <lunasvg/svgdocument.h>
#include <iostream>
using namespace lunasvg;
int main()
{
SVGDocument document;
if(!document.loadFontFromFile("ARLRDBD.TTF"))
std::cout << "loadFontFromFile : Failed" << std::endl;
if(!document.loadFromData("<svg><text x='0' y='15' fill='red'>I love SVG Too!</text></svg>"))
std::cout << "loadFromData : Failed" << std::endl;
Bitmap bitmap = document.renderToBitmap();
// do something useful with the bitmap.
return 0;
}
It works! thanks.
You're welcome :-)
I have seen the previous issues about reading text from svg file. Can I get more detailed about it? Or another example of the improvement you made? If I use the loadfromdata() function, what kind of string can be inserted into the function for reading text from svg?I tried to use the text tag but it was not so successful.