diff options
Diffstat (limited to 'dviware/dvisvgm/src/SVGCharHandler.cpp')
-rw-r--r-- | dviware/dvisvgm/src/SVGCharHandler.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/dviware/dvisvgm/src/SVGCharHandler.cpp b/dviware/dvisvgm/src/SVGCharHandler.cpp index f8d75a28d3..3b3f4d3f31 100644 --- a/dviware/dvisvgm/src/SVGCharHandler.cpp +++ b/dviware/dvisvgm/src/SVGCharHandler.cpp @@ -2,7 +2,7 @@ ** SVGCharHandler.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -20,12 +20,12 @@ #include "SVGCharHandler.hpp" #include "utility.hpp" -#include "XMLNode.hpp" +#include "SVGElement.hpp" using namespace std; -void SVGCharHandler::setInitialContextNode (XMLElement *node) { +void SVGCharHandler::setInitialContextNode (SVGElement *node) { resetContextNode(); _initialContextNode = node; } @@ -34,9 +34,9 @@ void SVGCharHandler::setInitialContextNode (XMLElement *node) { /** Changes the context element. All following nodes will be appended to this node. * @param[in] node the new context node * @return bare pointer to the new context node or 0 if context hasn't changed */ -XMLElement* SVGCharHandler::pushContextNode (unique_ptr<XMLElement> node) { +SVGElement* SVGCharHandler::pushContextNode (unique_ptr<SVGElement> node) { if (node && (_contextNodeStack.empty() || node.get() != _contextNodeStack.top())) { - XMLElement *nodeptr = node.get(); + SVGElement *nodeptr = node.get(); contextNode()->append(std::move(node)); _contextNodeStack.push(nodeptr); return nodeptr; @@ -61,23 +61,22 @@ void SVGCharHandler::resetContextNode () { /** Creates and returns a new SVG text element. * @param[in] x current x coordinate * @param[in] y current y coordinate */ -unique_ptr<XMLElement> SVGCharTextHandler::createTextNode (double x, double y) const { +unique_ptr<SVGElement> SVGCharTextHandler::createTextNode (double x, double y) const { const Font *font = _font.get(); if (!font) return nullptr; - auto textNode = util::make_unique<XMLElement>("text"); + auto textNode = util::make_unique<SVGElement>("text"); if (_selectFontByClass) textNode->addAttribute("class", string("f")+XMLString(_fontnum)); else { textNode->addAttribute("font-family", font->name()); - textNode->addAttribute("font-size", XMLString(font->scaledSize())); - if (font->color() != Color::BLACK) - textNode->addAttribute("fill", font->color().svgColorString()); + textNode->addAttribute("font-size", font->scaledSize()); + textNode->setFillColor(font->color()); } if (_vertical) { textNode->addAttribute("writing-mode", "tb"); // align glyphs designed for horizontal layout properly - if (auto pf = dynamic_cast<const PhysicalFont*>(font)) { + if (auto pf = font_cast<const PhysicalFont*>(font)) { if (!pf->getMetrics()->verticalLayout()) { // alphabetic text designed for horizontal layout? x += pf->scaledAscent()/2.5; // move vertical baseline to the right by strikethrough offset textNode->addAttribute("glyph-orientation-vertical", 90); // ensure rotation @@ -86,7 +85,7 @@ unique_ptr<XMLElement> SVGCharTextHandler::createTextNode (double x, double y) c } textNode->addAttribute("x", x); textNode->addAttribute("y", y); - if (!_matrix.get().isIdentity()) - textNode->addAttribute("transform", _matrix.get().toSVG()); + if (!_matrix->isIdentity()) + textNode->addAttribute("transform", _matrix->toSVG()); return textNode; } |