Skip to content

Commit

Permalink
Let the Glyph return the XML from the path
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Feb 1, 2024
1 parent 52b4b18 commit ba296f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/vrv/glyph.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class Glyph {
*/
const Point *GetAnchor(SMuFLGlyphAnchor anchor) const;

/**
* Return the XML (content) of the glyph
*/
std::string GetXML() const;

private:
//
public:
Expand Down
11 changes: 11 additions & 0 deletions src/glyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include <cassert>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <sstream>

//----------------------------------------------------------------------------

Expand Down Expand Up @@ -144,4 +147,12 @@ const Point *Glyph::GetAnchor(SMuFLGlyphAnchor anchor) const
return &m_anchors.at(anchor);
}

std::string Glyph::GetXML() const
{
std::ifstream fstream(m_path);
std::stringstream sstream;
sstream << fstream.rdbuf();
return sstream.str();
}

} // namespace vrv
5 changes: 2 additions & 3 deletions src/svgdevicecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ void SvgDeviceContext::Commit(bool xml_declaration)

// for each needed glyph
for (const std::pair<const Glyph *, const SvgDeviceContext::GlyphRef &> entry : m_smuflGlyphs) {
// load the XML file that contains it as a pugi::xml_document
std::ifstream source(entry.first->GetPath());
sourceDoc.load(source);
// load the XML as a pugi::xml_document
sourceDoc.load_string(entry.first->GetXML().c_str());

// copy all the nodes inside into the master document
for (pugi::xml_node child = sourceDoc.first_child(); child; child = child.next_sibling()) {
Expand Down

0 comments on commit ba296f2

Please sign in to comment.