X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=48e15a8a23bb77d33b5d34e964b4f81d58f220dc;hp=3f00e64e5fed549a6cad39f8cfa36b9c2fc5813b;hb=398e6b2732decd57cdb57deb3f91d3ff08669e8b;hpb=0ce8df17fae3ec986bd9570e5552aed92c080088 diff --git a/src/document.cpp b/src/document.cpp index 3f00e64..48e15a8 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -545,6 +545,24 @@ void Document::ParseSVGNode(pugi::xml_node & root, SVGMatrix & parent_transform) } } +/** + * Parse an SVG string into a rectangle + */ +void Document::ParseSVG(const string & input, const Rect & bounds) +{ + using namespace pugi; + + xml_document doc_xml; + xml_parse_result result = doc_xml.load(input.c_str()); + + if (!result) + Error("Couldn't parse SVG input - %s", result.description()); + + Debug("Loaded XML - %s", result.description()); + SVGMatrix transform = {bounds.w, 0,bounds.x, 0,bounds.h,bounds.y}; + ParseSVGNode(doc_xml, transform); +} + /** * Load an SVG into a rectangle */ @@ -557,7 +575,7 @@ void Document::LoadSVG(const string & filename, const Rect & bounds) xml_parse_result result = doc_xml.load(input); if (!result) - Fatal("Couldn't load \"%s\" - %s", filename.c_str(), result.description()); + Error("Couldn't load \"%s\" - %s", filename.c_str(), result.description()); Debug("Loaded XML - %s", result.description()); @@ -758,7 +776,7 @@ void Document::SetFont(const string & font_filename) free(m_font_data); } - FILE *font_file = fopen("DejaVuSansMono.ttf", "rb"); + FILE *font_file = fopen(font_filename.c_str(), "rb"); fseek(font_file, 0, SEEK_END); size_t font_file_size = ftell(font_file); fseek(font_file, 0, SEEK_SET); @@ -863,6 +881,7 @@ void Document::AddFontGlyphAtPoint(stbtt_fontinfo *font, int character, Real sca { AddGroup(start_index, end_index); } + Debug("Added Glyph \"%c\" at %f %f, scale %f", (char)character, Float(x), Float(y), Float(scale)); stbtt_FreeShape(font, instructions); }