summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src
diff options
context:
space:
mode:
Diffstat (limited to 'dviware/dvisvgm/src')
-rw-r--r--dviware/dvisvgm/src/AGLTable.hpp2
-rw-r--r--dviware/dvisvgm/src/BasicDVIReader.cpp2
-rw-r--r--dviware/dvisvgm/src/BasicDVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Bezier.cpp2
-rw-r--r--dviware/dvisvgm/src/Bezier.hpp2
-rw-r--r--dviware/dvisvgm/src/BgColorSpecialHandler.cpp4
-rw-r--r--dviware/dvisvgm/src/BgColorSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/Bitmap.cpp2
-rw-r--r--dviware/dvisvgm/src/Bitmap.hpp2
-rw-r--r--dviware/dvisvgm/src/BoundingBox.cpp4
-rw-r--r--dviware/dvisvgm/src/BoundingBox.hpp2
-rw-r--r--dviware/dvisvgm/src/CLCommandLine.cpp2
-rw-r--r--dviware/dvisvgm/src/CLCommandLine.hpp2
-rw-r--r--dviware/dvisvgm/src/CLOption.hpp2
-rw-r--r--dviware/dvisvgm/src/CMap.cpp2
-rw-r--r--dviware/dvisvgm/src/CMap.hpp2
-rw-r--r--dviware/dvisvgm/src/CMapManager.cpp4
-rw-r--r--dviware/dvisvgm/src/CMapManager.hpp2
-rw-r--r--dviware/dvisvgm/src/CMapReader.cpp2
-rw-r--r--dviware/dvisvgm/src/CMapReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Calculator.cpp228
-rw-r--r--dviware/dvisvgm/src/Calculator.hpp22
-rw-r--r--dviware/dvisvgm/src/CharMapID.cpp2
-rw-r--r--dviware/dvisvgm/src/CharMapID.hpp2
-rw-r--r--dviware/dvisvgm/src/Character.hpp2
-rw-r--r--dviware/dvisvgm/src/Color.cpp2
-rw-r--r--dviware/dvisvgm/src/Color.hpp2
-rw-r--r--dviware/dvisvgm/src/ColorSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/ColorSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/CommandLine.hpp4
-rw-r--r--dviware/dvisvgm/src/DLLoader.cpp2
-rw-r--r--dviware/dvisvgm/src/DLLoader.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIActions.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIReader.cpp11
-rw-r--r--dviware/dvisvgm/src/DVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIToSVG.cpp15
-rw-r--r--dviware/dvisvgm/src/DVIToSVG.hpp16
-rw-r--r--dviware/dvisvgm/src/DVIToSVGActions.cpp16
-rw-r--r--dviware/dvisvgm/src/DVIToSVGActions.hpp4
-rw-r--r--dviware/dvisvgm/src/Directory.cpp2
-rw-r--r--dviware/dvisvgm/src/Directory.hpp2
-rw-r--r--dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp18
-rw-r--r--dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp5
-rw-r--r--dviware/dvisvgm/src/EPSFile.cpp2
-rw-r--r--dviware/dvisvgm/src/EPSFile.hpp2
-rw-r--r--dviware/dvisvgm/src/EPSToSVG.hpp2
-rw-r--r--dviware/dvisvgm/src/EllipticalArc.cpp8
-rw-r--r--dviware/dvisvgm/src/EllipticalArc.hpp2
-rw-r--r--dviware/dvisvgm/src/EmSpecialHandler.cpp47
-rw-r--r--dviware/dvisvgm/src/EmSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/EncFile.cpp2
-rw-r--r--dviware/dvisvgm/src/EncFile.hpp2
-rw-r--r--dviware/dvisvgm/src/FileFinder.cpp2
-rw-r--r--dviware/dvisvgm/src/FileFinder.hpp2
-rw-r--r--dviware/dvisvgm/src/FilePath.cpp123
-rw-r--r--dviware/dvisvgm/src/FilePath.hpp2
-rw-r--r--dviware/dvisvgm/src/FileSystem.cpp26
-rw-r--r--dviware/dvisvgm/src/FileSystem.hpp5
-rw-r--r--dviware/dvisvgm/src/FixWord.hpp2
-rw-r--r--dviware/dvisvgm/src/Font.cpp12
-rw-r--r--dviware/dvisvgm/src/Font.hpp56
-rw-r--r--dviware/dvisvgm/src/FontCache.cpp6
-rw-r--r--dviware/dvisvgm/src/FontCache.hpp2
-rw-r--r--dviware/dvisvgm/src/FontEncoding.cpp2
-rw-r--r--dviware/dvisvgm/src/FontEncoding.hpp2
-rw-r--r--dviware/dvisvgm/src/FontEngine.cpp39
-rw-r--r--dviware/dvisvgm/src/FontEngine.hpp4
-rw-r--r--dviware/dvisvgm/src/FontManager.cpp16
-rw-r--r--dviware/dvisvgm/src/FontManager.hpp2
-rw-r--r--dviware/dvisvgm/src/FontMap.cpp2
-rw-r--r--dviware/dvisvgm/src/FontMap.hpp2
-rw-r--r--dviware/dvisvgm/src/FontMetrics.cpp2
-rw-r--r--dviware/dvisvgm/src/FontMetrics.hpp3
-rw-r--r--dviware/dvisvgm/src/FontStyle.hpp2
-rw-r--r--dviware/dvisvgm/src/FontWriter.cpp4
-rw-r--r--dviware/dvisvgm/src/FontWriter.hpp2
-rw-r--r--dviware/dvisvgm/src/GFGlyphTracer.cpp6
-rw-r--r--dviware/dvisvgm/src/GFGlyphTracer.hpp6
-rw-r--r--dviware/dvisvgm/src/GFReader.cpp4
-rw-r--r--dviware/dvisvgm/src/GFReader.hpp2
-rw-r--r--dviware/dvisvgm/src/GFTracer.cpp2
-rw-r--r--dviware/dvisvgm/src/GFTracer.hpp2
-rw-r--r--dviware/dvisvgm/src/Ghostscript.cpp6
-rw-r--r--dviware/dvisvgm/src/Ghostscript.hpp6
-rw-r--r--dviware/dvisvgm/src/Glyph.hpp2
-rw-r--r--dviware/dvisvgm/src/GlyphTracerMessages.hpp2
-rw-r--r--dviware/dvisvgm/src/GraphicsPath.hpp17
-rw-r--r--dviware/dvisvgm/src/HashFunction.cpp2
-rw-r--r--dviware/dvisvgm/src/HashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/HtmlSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/HtmlSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/HyperlinkManager.cpp26
-rw-r--r--dviware/dvisvgm/src/HyperlinkManager.hpp4
-rw-r--r--dviware/dvisvgm/src/ImageToSVG.cpp2
-rw-r--r--dviware/dvisvgm/src/ImageToSVG.hpp4
-rw-r--r--dviware/dvisvgm/src/InputBuffer.cpp2
-rw-r--r--dviware/dvisvgm/src/InputBuffer.hpp7
-rw-r--r--dviware/dvisvgm/src/InputReader.cpp2
-rw-r--r--dviware/dvisvgm/src/InputReader.hpp2
-rw-r--r--dviware/dvisvgm/src/JFM.cpp2
-rw-r--r--dviware/dvisvgm/src/JFM.hpp3
-rw-r--r--dviware/dvisvgm/src/Length.cpp2
-rw-r--r--dviware/dvisvgm/src/Length.hpp2
-rw-r--r--dviware/dvisvgm/src/MD5HashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/Makefile.am4
-rw-r--r--dviware/dvisvgm/src/Makefile.in105
-rw-r--r--dviware/dvisvgm/src/MapLine.cpp2
-rw-r--r--dviware/dvisvgm/src/MapLine.hpp2
-rw-r--r--dviware/dvisvgm/src/Matrix.cpp4
-rw-r--r--dviware/dvisvgm/src/Matrix.hpp7
-rw-r--r--dviware/dvisvgm/src/Message.cpp4
-rw-r--r--dviware/dvisvgm/src/Message.hpp2
-rw-r--r--dviware/dvisvgm/src/MessageException.hpp2
-rw-r--r--dviware/dvisvgm/src/MetafontWrapper.cpp2
-rw-r--r--dviware/dvisvgm/src/MetafontWrapper.hpp2
-rw-r--r--dviware/dvisvgm/src/MiKTeXCom.cpp2
-rw-r--r--dviware/dvisvgm/src/MiKTeXCom.hpp2
-rw-r--r--dviware/dvisvgm/src/NoPsSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/NoPsSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/NumericRanges.hpp2
-rw-r--r--dviware/dvisvgm/src/Opacity.cpp59
-rw-r--r--dviware/dvisvgm/src/Opacity.hpp75
-rw-r--r--dviware/dvisvgm/src/PDFParser.cpp2
-rw-r--r--dviware/dvisvgm/src/PDFParser.hpp2
-rw-r--r--dviware/dvisvgm/src/PDFToSVG.hpp2
-rw-r--r--dviware/dvisvgm/src/PSFilter.hpp2
-rw-r--r--dviware/dvisvgm/src/PSInterpreter.cpp18
-rw-r--r--dviware/dvisvgm/src/PSInterpreter.hpp5
-rw-r--r--dviware/dvisvgm/src/PSPattern.cpp6
-rw-r--r--dviware/dvisvgm/src/PSPattern.hpp8
-rw-r--r--dviware/dvisvgm/src/PSPreviewFilter.cpp2
-rw-r--r--dviware/dvisvgm/src/PSPreviewFilter.hpp2
-rw-r--r--dviware/dvisvgm/src/PageRanges.cpp2
-rw-r--r--dviware/dvisvgm/src/PageRanges.hpp2
-rw-r--r--dviware/dvisvgm/src/PageSize.cpp2
-rw-r--r--dviware/dvisvgm/src/PageSize.hpp2
-rw-r--r--dviware/dvisvgm/src/Pair.hpp2
-rw-r--r--dviware/dvisvgm/src/PapersizeSpecialHandler.cpp4
-rw-r--r--dviware/dvisvgm/src/PapersizeSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/PathClipper.cpp2
-rw-r--r--dviware/dvisvgm/src/PathClipper.hpp2
-rw-r--r--dviware/dvisvgm/src/PdfSpecialHandler.cpp4
-rw-r--r--dviware/dvisvgm/src/PdfSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/PreScanDVIReader.cpp2
-rw-r--r--dviware/dvisvgm/src/PreScanDVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Process.cpp2
-rw-r--r--dviware/dvisvgm/src/Process.hpp2
-rw-r--r--dviware/dvisvgm/src/PsSpecialHandler.cpp176
-rw-r--r--dviware/dvisvgm/src/PsSpecialHandler.hpp24
-rw-r--r--dviware/dvisvgm/src/RangeMap.cpp6
-rw-r--r--dviware/dvisvgm/src/RangeMap.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandler.cpp25
-rw-r--r--dviware/dvisvgm/src/SVGCharHandler.hpp45
-rw-r--r--dviware/dvisvgm/src/SVGCharHandlerFactory.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandlerFactory.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharPathHandler.cpp44
-rw-r--r--dviware/dvisvgm/src/SVGCharPathHandler.hpp4
-rw-r--r--dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp22
-rw-r--r--dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp8
-rw-r--r--dviware/dvisvgm/src/SVGElement.cpp153
-rw-r--r--dviware/dvisvgm/src/SVGElement.hpp60
-rw-r--r--dviware/dvisvgm/src/SVGOutput.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGOutput.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp14
-rw-r--r--dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGTree.cpp42
-rw-r--r--dviware/dvisvgm/src/SVGTree.hpp35
-rw-r--r--dviware/dvisvgm/src/ShadingPatch.cpp2
-rw-r--r--dviware/dvisvgm/src/ShadingPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/SignalHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SignalHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SourceInput.cpp2
-rw-r--r--dviware/dvisvgm/src/SourceInput.hpp2
-rw-r--r--dviware/dvisvgm/src/SpecialActions.hpp7
-rw-r--r--dviware/dvisvgm/src/SpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SpecialManager.cpp2
-rw-r--r--dviware/dvisvgm/src/SpecialManager.hpp2
-rw-r--r--dviware/dvisvgm/src/StreamReader.cpp2
-rw-r--r--dviware/dvisvgm/src/StreamReader.hpp2
-rw-r--r--dviware/dvisvgm/src/StreamWriter.cpp2
-rw-r--r--dviware/dvisvgm/src/StreamWriter.hpp2
-rw-r--r--dviware/dvisvgm/src/Subfont.cpp4
-rw-r--r--dviware/dvisvgm/src/Subfont.hpp2
-rw-r--r--dviware/dvisvgm/src/System.cpp2
-rw-r--r--dviware/dvisvgm/src/System.hpp2
-rw-r--r--dviware/dvisvgm/src/TFM.cpp2
-rw-r--r--dviware/dvisvgm/src/TFM.hpp2
-rw-r--r--dviware/dvisvgm/src/TTFAutohint.cpp2
-rw-r--r--dviware/dvisvgm/src/TTFAutohint.hpp2
-rw-r--r--dviware/dvisvgm/src/TensorProductPatch.cpp18
-rw-r--r--dviware/dvisvgm/src/TensorProductPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/Terminal.cpp2
-rw-r--r--dviware/dvisvgm/src/Terminal.hpp2
-rw-r--r--dviware/dvisvgm/src/ToUnicodeMap.cpp2
-rw-r--r--dviware/dvisvgm/src/ToUnicodeMap.hpp2
-rw-r--r--dviware/dvisvgm/src/TpicSpecialHandler.cpp83
-rw-r--r--dviware/dvisvgm/src/TpicSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/TriangularPatch.cpp10
-rw-r--r--dviware/dvisvgm/src/TriangularPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/TrueTypeFont.cpp6
-rw-r--r--dviware/dvisvgm/src/TrueTypeFont.hpp2
-rw-r--r--dviware/dvisvgm/src/Unicode.cpp2
-rw-r--r--dviware/dvisvgm/src/Unicode.hpp2
-rw-r--r--dviware/dvisvgm/src/VFActions.hpp2
-rw-r--r--dviware/dvisvgm/src/VFReader.cpp2
-rw-r--r--dviware/dvisvgm/src/VFReader.hpp2
-rw-r--r--dviware/dvisvgm/src/VectorIterator.hpp4
-rw-r--r--dviware/dvisvgm/src/VectorStream.hpp2
-rw-r--r--dviware/dvisvgm/src/XMLDocument.cpp4
-rw-r--r--dviware/dvisvgm/src/XMLDocument.hpp2
-rw-r--r--dviware/dvisvgm/src/XMLNode.cpp8
-rw-r--r--dviware/dvisvgm/src/XMLNode.hpp4
-rw-r--r--dviware/dvisvgm/src/XMLString.cpp2
-rw-r--r--dviware/dvisvgm/src/XMLString.hpp2
-rw-r--r--dviware/dvisvgm/src/XXHashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/ZLibOutputStream.hpp2
-rw-r--r--dviware/dvisvgm/src/dvisvgm.cpp7
-rw-r--r--dviware/dvisvgm/src/ffwrapper.c2
-rw-r--r--dviware/dvisvgm/src/ffwrapper.h2
-rw-r--r--dviware/dvisvgm/src/macros.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/DependencyGraph.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/GroupCollapser.cpp4
-rw-r--r--dviware/dvisvgm/src/optimizer/GroupCollapser.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/Makefile.in1
-rw-r--r--dviware/dvisvgm/src/optimizer/OptimizerModule.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TextSimplifier.cpp8
-rw-r--r--dviware/dvisvgm/src/optimizer/TextSimplifier.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp2
-rw-r--r--dviware/dvisvgm/src/options.dtd2
-rw-r--r--dviware/dvisvgm/src/options.xml4
-rw-r--r--dviware/dvisvgm/src/psdefs.cpp92
-rw-r--r--dviware/dvisvgm/src/utility.cpp8
-rw-r--r--dviware/dvisvgm/src/utility.hpp14
-rw-r--r--dviware/dvisvgm/src/version.hpp.in2
-rw-r--r--dviware/dvisvgm/src/windows.hpp2
244 files changed, 1427 insertions, 933 deletions
diff --git a/dviware/dvisvgm/src/AGLTable.hpp b/dviware/dvisvgm/src/AGLTable.hpp
index c1d460273a..67c6dbcea1 100644
--- a/dviware/dvisvgm/src/AGLTable.hpp
+++ b/dviware/dvisvgm/src/AGLTable.hpp
@@ -2,7 +2,7 @@
** AGLTable.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/BasicDVIReader.cpp b/dviware/dvisvgm/src/BasicDVIReader.cpp
index 29ca84999f..d37a89c20c 100644
--- a/dviware/dvisvgm/src/BasicDVIReader.cpp
+++ b/dviware/dvisvgm/src/BasicDVIReader.cpp
@@ -2,7 +2,7 @@
** BasicDVIReader.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 **
diff --git a/dviware/dvisvgm/src/BasicDVIReader.hpp b/dviware/dvisvgm/src/BasicDVIReader.hpp
index a5b18b0420..a71c547fa5 100644
--- a/dviware/dvisvgm/src/BasicDVIReader.hpp
+++ b/dviware/dvisvgm/src/BasicDVIReader.hpp
@@ -2,7 +2,7 @@
** BasicDVIReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Bezier.cpp b/dviware/dvisvgm/src/Bezier.cpp
index 87a0070621..b26ed71149 100644
--- a/dviware/dvisvgm/src/Bezier.cpp
+++ b/dviware/dvisvgm/src/Bezier.cpp
@@ -2,7 +2,7 @@
** Bezier.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 **
diff --git a/dviware/dvisvgm/src/Bezier.hpp b/dviware/dvisvgm/src/Bezier.hpp
index 322dd4e72d..18050ca857 100644
--- a/dviware/dvisvgm/src/Bezier.hpp
+++ b/dviware/dvisvgm/src/Bezier.hpp
@@ -2,7 +2,7 @@
** Bezier.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/BgColorSpecialHandler.cpp b/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
index 3b315b50a3..3ae90b13a5 100644
--- a/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
@@ -2,7 +2,7 @@
** BgColorSpecialHandler.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 **
@@ -36,7 +36,7 @@ void BgColorSpecialHandler::preprocess (const string&, std::istream &is, Special
if (!_pageColors.empty() && _pageColors.back().first == pageno)
_pageColors.back().second = color;
else
- _pageColors.emplace_back(PageColor(pageno, color));
+ _pageColors.emplace_back(pageno, color);
}
}
diff --git a/dviware/dvisvgm/src/BgColorSpecialHandler.hpp b/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
index 9334a5c541..07c13437e5 100644
--- a/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
@@ -2,7 +2,7 @@
** BgColorSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Bitmap.cpp b/dviware/dvisvgm/src/Bitmap.cpp
index 64ebd6195e..c59e444608 100644
--- a/dviware/dvisvgm/src/Bitmap.cpp
+++ b/dviware/dvisvgm/src/Bitmap.cpp
@@ -2,7 +2,7 @@
** Bitmap.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 **
diff --git a/dviware/dvisvgm/src/Bitmap.hpp b/dviware/dvisvgm/src/Bitmap.hpp
index 0d04aa2a69..f0bba3b41e 100644
--- a/dviware/dvisvgm/src/Bitmap.hpp
+++ b/dviware/dvisvgm/src/Bitmap.hpp
@@ -2,7 +2,7 @@
** Bitmap.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/BoundingBox.cpp b/dviware/dvisvgm/src/BoundingBox.cpp
index 2dbcc2ebcd..0fb6fde883 100644
--- a/dviware/dvisvgm/src/BoundingBox.cpp
+++ b/dviware/dvisvgm/src/BoundingBox.cpp
@@ -2,7 +2,7 @@
** BoundingBox.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 **
@@ -76,7 +76,7 @@ vector<Length> BoundingBox::extractLengths (string boxstr) {
vector<string> lengthStrings = util::split(boxstr, " ");
for (const string &lenstr : lengthStrings) {
if (!lenstr.empty())
- lengths.emplace_back(Length(lenstr));
+ lengths.emplace_back(lenstr);
}
return lengths;
}
diff --git a/dviware/dvisvgm/src/BoundingBox.hpp b/dviware/dvisvgm/src/BoundingBox.hpp
index c52312a24a..e3b59ebf5d 100644
--- a/dviware/dvisvgm/src/BoundingBox.hpp
+++ b/dviware/dvisvgm/src/BoundingBox.hpp
@@ -2,7 +2,7 @@
** BoundingBox.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CLCommandLine.cpp b/dviware/dvisvgm/src/CLCommandLine.cpp
index 1f6bb4475e..ae245699c5 100644
--- a/dviware/dvisvgm/src/CLCommandLine.cpp
+++ b/dviware/dvisvgm/src/CLCommandLine.cpp
@@ -2,7 +2,7 @@
** CLCommandLine.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 **
diff --git a/dviware/dvisvgm/src/CLCommandLine.hpp b/dviware/dvisvgm/src/CLCommandLine.hpp
index 257ff4160f..9f9814368b 100644
--- a/dviware/dvisvgm/src/CLCommandLine.hpp
+++ b/dviware/dvisvgm/src/CLCommandLine.hpp
@@ -2,7 +2,7 @@
** CLCommandLine.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CLOption.hpp b/dviware/dvisvgm/src/CLOption.hpp
index d9da7ae008..594610b896 100644
--- a/dviware/dvisvgm/src/CLOption.hpp
+++ b/dviware/dvisvgm/src/CLOption.hpp
@@ -2,7 +2,7 @@
** CLOption.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CMap.cpp b/dviware/dvisvgm/src/CMap.cpp
index 193def52fd..6c9b10ed10 100644
--- a/dviware/dvisvgm/src/CMap.cpp
+++ b/dviware/dvisvgm/src/CMap.cpp
@@ -2,7 +2,7 @@
** CMap.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 **
diff --git a/dviware/dvisvgm/src/CMap.hpp b/dviware/dvisvgm/src/CMap.hpp
index 37a54ba0f8..606a401ff7 100644
--- a/dviware/dvisvgm/src/CMap.hpp
+++ b/dviware/dvisvgm/src/CMap.hpp
@@ -2,7 +2,7 @@
** CMap.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CMapManager.cpp b/dviware/dvisvgm/src/CMapManager.cpp
index 52b323ebc6..3a4c1a4e80 100644
--- a/dviware/dvisvgm/src/CMapManager.cpp
+++ b/dviware/dvisvgm/src/CMapManager.cpp
@@ -2,7 +2,7 @@
** CMapManager.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 **
@@ -119,7 +119,7 @@ const CMap* CMapManager::findCompatibleBaseFontMap (const PhysicalFont *font, co
// try to find a compatible encoding CMap
- const bool is_unicode_map = bool(dynamic_cast<const UnicodeCMap*>(cmap));
+ const bool is_unicode_map = cmap->mapsToUnicode();
const string ro = cmap->getROString();
for (const CharMapIDToEncName &enc : encodings) {
for (const CharMapID &id : charmapIDs) {
diff --git a/dviware/dvisvgm/src/CMapManager.hpp b/dviware/dvisvgm/src/CMapManager.hpp
index aeb9156e84..eab32e7646 100644
--- a/dviware/dvisvgm/src/CMapManager.hpp
+++ b/dviware/dvisvgm/src/CMapManager.hpp
@@ -2,7 +2,7 @@
** CMapManager.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CMapReader.cpp b/dviware/dvisvgm/src/CMapReader.cpp
index 8ab22c22e3..c56d3bd463 100644
--- a/dviware/dvisvgm/src/CMapReader.cpp
+++ b/dviware/dvisvgm/src/CMapReader.cpp
@@ -2,7 +2,7 @@
** CMapReader.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 **
diff --git a/dviware/dvisvgm/src/CMapReader.hpp b/dviware/dvisvgm/src/CMapReader.hpp
index 04ce5740c0..6e9a03ce98 100644
--- a/dviware/dvisvgm/src/CMapReader.hpp
+++ b/dviware/dvisvgm/src/CMapReader.hpp
@@ -2,7 +2,7 @@
** CMapReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Calculator.cpp b/dviware/dvisvgm/src/Calculator.cpp
index 0fdcf0f2fa..00490efa04 100644
--- a/dviware/dvisvgm/src/Calculator.cpp
+++ b/dviware/dvisvgm/src/Calculator.cpp
@@ -2,7 +2,7 @@
** Calculator.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 **
@@ -25,20 +25,19 @@
using namespace std;
-// token types
-const char END = 0;
-const char NUMBER = 1;
-const char NAME = 2;
-
-
/** Evaluates a given arithmetic expression and returns its value.
* The evaluator is implemented as a recursive descent parser.
* @param[in] is reads expression from this stream
* @return expression value */
-double Calculator::eval (istream &is) {
+double Calculator::eval (istream &is) const {
double ret = expr(is, false);
- if (lookAhead(is) > 0)
+ try {
+ // check if expression has been fully evaluated (next token is of type bool)
+ mpark::get<bool>(lookAhead(is));
+ }
+ catch (mpark::bad_variant_access &e) {
throw CalculatorException("expression syntax error");
+ }
return ret;
}
@@ -46,7 +45,7 @@ double Calculator::eval (istream &is) {
/** Evaluates a given arithmetic expression and returns its value.
* @param[in] expr expression to evaluate
* @return expression value */
-double Calculator::eval (const string &expr) {
+double Calculator::eval (const string &expr) const {
istringstream iss;
iss.str(expr);
return eval(iss);
@@ -54,133 +53,150 @@ double Calculator::eval (const string &expr) {
/** Evaluates the root rule of the expression grammar. */
-double Calculator::expr (istream &is, bool skip) { // expr:
+double Calculator::expr (istream &is, bool skip) const { // expr:
double left = term(is, skip);
- for (;;) {
- switch (lookAhead(is)) {
- case '+': left += term(is, true); break; // term '+' term => $1 + $3
- case '-': left -= term(is, true); break; // term '-' term => $1 - $3
- default : return left; // term => $1
+ bool ready=false;
+ while (!ready) {
+ Token token = lookAhead(is);
+ char *op = mpark::get_if<char>(&token);
+ if (!op)
+ ready = true;
+ else {
+ switch (*op) {
+ case '+': left += term(is, true); break; // term '+' term => $1 + $3
+ case '-': left -= term(is, true); break; // term '-' term => $1 - $3
+ default : ready = true;
+ }
}
}
+ return left; // term => $1
}
-double Calculator::term (istream &is, bool skip) { // term:
+double Calculator::term (istream &is, bool skip) const { // term:
double left = prim(is, skip);
- for (;;)
- switch (lookAhead(is)) {
- case '*': left *= prim(is, true); break; // prim '*' prim => $1 * $3
- case '(': left *= prim(is, false); break; // prim '*' prim => $1 * $3
- case '/': { // prim '/' prim => $1 / $3
- double denom = prim(is, true);
- if (denom == 0)
- throw CalculatorException("division by zero");
- left /= denom;
- break;
+ bool ready=false;
+ while (!ready) {
+ Token token = lookAhead(is);
+ char *op = mpark::get_if<char>(&token);
+ if (!op)
+ ready = true;
+ else {
+ switch (*op) {
+ case '*': left *= prim(is, true); break; // prim '*' prim => $1 * $3
+ case '(': left *= prim(is, false); break; // prim '(' prim => $1 * $3
+ case '/': { // prim '/' prim => $1 / $3
+ double denom = prim(is, true);
+ if (denom == 0)
+ throw CalculatorException("division by zero");
+ left /= denom;
+ break;
+ }
+ case '%': { // prim '%' prim => $1 mod $3
+ double denom = prim(is, true);
+ if (denom == 0)
+ throw CalculatorException("division by zero");
+ left -= denom * floor(left / denom);
+ break;
+ }
+ default:
+ ready = true;
}
- case '%': { // prim '%' prim => $1 mod $3
- double denom = prim(is, true);
- if (denom == 0)
- throw CalculatorException("division by zero");
- left -= denom*floor(left/denom);
- break;
- }
- default: // prim => $1
- return left;
}
+ }
+ return left;
}
-double Calculator::prim (istream &is, bool skip) { // prim:
+/** Evaluates a primary expression of the grammar which doesn't contain any binary operators. */
+double Calculator::prim (istream &is, bool skip) const { // prim:
if (skip)
lex(is);
- switch (lookAhead(is)) {
- case NUMBER: { // NUMBER => $1
- lex(is);
- double ret = _numValue;
- if (lookAhead(is) == NAME) { // NUMBER NAME => $1 * $2
- lex(is);
- ret *= getVariable(_strValue);
+ Token token = lookAhead(is);
+ if (mpark::get_if<double>(&token)) { // NUMBER => $1
+ double ret = mpark::get<double>(lex(is));
+ token = lookAhead(is);
+ if (mpark::get_if<string>(&token)) // NUMBER STRING => $1 * $2
+ ret *= getVariable(mpark::get<string>(lex(is)));
+ return ret;
+ }
+ if (mpark::get_if<string>(&token)) // STRING => getVariable($1)
+ return getVariable(mpark::get<string>(lex(is)));
+ if (char *op = mpark::get_if<char>(&token)) {
+ switch (*op) {
+ case '-': // '-' prim => -$2
+ return -prim(is, true);
+ case '(': { // '(' expr ')' => $2
+ double e = expr(is, true);
+ try {
+ if (mpark::get<char>(lookAhead(is)) != ')')
+ throw CalculatorException("')' expected");
+ }
+ catch (mpark::bad_variant_access &e) {
+ throw CalculatorException("')' expected");
+ }
+ is.get(); // skip processed char
+ return e;
}
- return ret;
- }
- case NAME: { // NAME => getVariable($1)
- lex(is);
- return getVariable(_strValue);
- }
- case '-': // '-' prim => -$2
- return -prim(is, true);
- case '(': { // '(' expr ')' => $2
- double e = expr(is, true);
- if (lookAhead(is) != ')')
- throw CalculatorException("')' expected");
- lex(is);
- return e;
}
- default:
- throw CalculatorException("primary expression expected");
}
+ throw CalculatorException("primary expression expected");
+}
+
+
+/** Returns the value of a previously defined variable. If there
+ * is no variable of the given name, a CalculatorException is thrown.
+ * @param[in] name name of variable
+ * @return assigned value */
+double Calculator::getVariable (const string &name) const {
+ auto it = _variables.find(name);
+ if (it == _variables.end())
+ throw CalculatorException("undefined variable '" + name + "'");
+ return it->second;
}
-/** Determines type of next token without swallowing it. That means
- * the same token will be read again next time. */
-char Calculator::lookAhead (istream &is) {
+/** Determines the type of the next token without swallowing it. That means
+ * the same token will be read again next time. The value of the returned token
+ * object is only set for character tokens and should be considered undefined
+ * for the other types. */
+Calculator::Token Calculator::lookAhead (istream &is) {
is >> ws;
int c = is.peek();
if (is.eof())
- return END;
+ return false;
if (isdigit(c) || c == '.')
- return NUMBER;
+ return double(0);
if (isalpha(c))
- return NAME;
+ return string();
return char(c);
}
-/** Reads next token and returns its type. The token value is either assigned
- * to the object members numValue or strValue depending on the type. The token
- * type is represented by a unique integer. In contrast to method 'lookAhead'
- * lex consumes the read token.
+/** Reads and swallows the next token. The returned Token object is represented by
+ * a variant and thus contains both its type and value.
* @param[in] is next token is read from this stream
- * @return token type */
-char Calculator::lex (istream &is) {
- int tokenType = lookAhead(is);
- switch (tokenType) {
- case NUMBER: {
- string str;
- while (isdigit(is.peek()) || is.peek() == '.')
- str += char(is.get());
- try {
- _numValue = stod(str);
- }
- catch (const exception&) {
- throw CalculatorException("invalid number: "+str);
- }
- break;
+ * @return the read token */
+Calculator::Token Calculator::lex (istream &is) {
+ Token token = lookAhead(is);
+ if (mpark::get_if<char>(&token))
+ is.get(); // token already contains the value from look ahead
+ else if (mpark::get_if<double>(&token)) {
+ string str;
+ while (isdigit(is.peek()) || is.peek() == '.')
+ str += char(is.get());
+ try {
+ token.emplace<double>(stod(str));
}
- case NAME: {
- _strValue.clear();
- while (isalpha(is.peek()))
- _strValue += char(is.get());
- break;
+ catch (const exception&) {
+ throw CalculatorException("invalid number: "+str);
}
- default:
- tokenType = is.get();
}
- return char(tokenType);
-}
-
-
-/** Returns the value of a previously defined variable. If there
- * is no variable of the given name, a CalculatorException is thrown.
- * @param[in] name name of variable
- * @return assigned value */
-double Calculator::getVariable (const string &name) const {
- auto it = _variables.find(name);
- if (it == _variables.end())
- throw CalculatorException("undefined variable '" + name + "'");
- return it->second;
+ else if (mpark::get_if<string>(&token)) {
+ string name;
+ while (isalpha(is.peek()))
+ name += char(is.get());
+ token.emplace<string>(name);
+ }
+ return token;
}
-
diff --git a/dviware/dvisvgm/src/Calculator.hpp b/dviware/dvisvgm/src/Calculator.hpp
index 92ec4e40b1..50f8fb959c 100644
--- a/dviware/dvisvgm/src/Calculator.hpp
+++ b/dviware/dvisvgm/src/Calculator.hpp
@@ -2,7 +2,7 @@
** Calculator.hpp **
** **
** 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 **
@@ -24,31 +24,31 @@
#include <istream>
#include <map>
#include <string>
+#include <mpark/variant.hpp>
#include "MessageException.hpp"
-
struct CalculatorException : public MessageException {
explicit CalculatorException (const std::string &msg) : MessageException(msg) {}
};
class Calculator {
public:
- double eval (std::istream &is);
- double eval (const std::string &expr);
+ double eval (std::istream &is) const;
+ double eval (const std::string &expr) const;
void setVariable (const std::string &name, double value) {_variables[name] = value;}
double getVariable (const std::string &name) const;
protected:
- double expr (std::istream &is, bool skip);
- double term (std::istream &is, bool skip);
- double prim (std::istream &is, bool skip);
- char lex (std::istream &is);
- char lookAhead (std::istream &is);
+ double expr (std::istream &is, bool skip) const;
+ double term (std::istream &is, bool skip) const;
+ double prim (std::istream &is, bool skip) const;
+
+ using Token = mpark::variant<bool, char, double, std::string>;
+ static Token lex (std::istream &is);
+ static Token lookAhead (std::istream &is);
private:
std::map<std::string,double> _variables;
- double _numValue=0;
- std::string _strValue;
};
#endif
diff --git a/dviware/dvisvgm/src/CharMapID.cpp b/dviware/dvisvgm/src/CharMapID.cpp
index 9c56afc73a..0020b38d04 100644
--- a/dviware/dvisvgm/src/CharMapID.cpp
+++ b/dviware/dvisvgm/src/CharMapID.cpp
@@ -2,7 +2,7 @@
** CharMapID.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 **
diff --git a/dviware/dvisvgm/src/CharMapID.hpp b/dviware/dvisvgm/src/CharMapID.hpp
index ed044a9cf3..8b8890bc3a 100644
--- a/dviware/dvisvgm/src/CharMapID.hpp
+++ b/dviware/dvisvgm/src/CharMapID.hpp
@@ -2,7 +2,7 @@
** CharMapID.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Character.hpp b/dviware/dvisvgm/src/Character.hpp
index 667a583100..1e381f9311 100644
--- a/dviware/dvisvgm/src/Character.hpp
+++ b/dviware/dvisvgm/src/Character.hpp
@@ -2,7 +2,7 @@
** Character.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Color.cpp b/dviware/dvisvgm/src/Color.cpp
index bf9a05d7a3..60107be9de 100644
--- a/dviware/dvisvgm/src/Color.cpp
+++ b/dviware/dvisvgm/src/Color.cpp
@@ -2,7 +2,7 @@
** Color.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 **
diff --git a/dviware/dvisvgm/src/Color.hpp b/dviware/dvisvgm/src/Color.hpp
index 6f6f812207..061e3e1236 100644
--- a/dviware/dvisvgm/src/Color.hpp
+++ b/dviware/dvisvgm/src/Color.hpp
@@ -2,7 +2,7 @@
** Color.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/ColorSpecialHandler.cpp b/dviware/dvisvgm/src/ColorSpecialHandler.cpp
index 2cacf82992..fed3a985f4 100644
--- a/dviware/dvisvgm/src/ColorSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/ColorSpecialHandler.cpp
@@ -2,7 +2,7 @@
** ColorSpecialHandler.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 **
diff --git a/dviware/dvisvgm/src/ColorSpecialHandler.hpp b/dviware/dvisvgm/src/ColorSpecialHandler.hpp
index eeab300f47..0d90283503 100644
--- a/dviware/dvisvgm/src/ColorSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/ColorSpecialHandler.hpp
@@ -2,7 +2,7 @@
** ColorSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/CommandLine.hpp b/dviware/dvisvgm/src/CommandLine.hpp
index 7ea6ddd76e..c4a215b301 100644
--- a/dviware/dvisvgm/src/CommandLine.hpp
+++ b/dviware/dvisvgm/src/CommandLine.hpp
@@ -2,7 +2,7 @@
// It is part of the dvisvgm package and published under the terms
// of the GNU General Public License version 3, or (at your option) any later version.
// See file COPYING for further details.
-// Copyright (C) 2016-2020 Martin Gieseking <martin.gieseking@uos.de>
+// Copyright (C) 2016-2021 Martin Gieseking <martin.gieseking@uos.de>
#ifndef COMMANDLINE_HPP
#define COMMANDLINE_HPP
@@ -20,7 +20,7 @@ class CommandLine : public CL::CommandLine {
CommandLine () : CL::CommandLine(
"This program converts DVI files, as created by TeX/LaTeX, as well as\nEPS and PDF files to the XML-based scalable vector graphics format SVG.",
"[options] dvifile\n--eps [options] epsfile\n--pdf [options] pdffile",
- "Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>"
+ "Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de>"
) {}
CommandLine (int argc, char **argv) : CommandLine() {
diff --git a/dviware/dvisvgm/src/DLLoader.cpp b/dviware/dvisvgm/src/DLLoader.cpp
index 9a974e89d9..064368c24a 100644
--- a/dviware/dvisvgm/src/DLLoader.cpp
+++ b/dviware/dvisvgm/src/DLLoader.cpp
@@ -2,7 +2,7 @@
** DLLoader.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 **
diff --git a/dviware/dvisvgm/src/DLLoader.hpp b/dviware/dvisvgm/src/DLLoader.hpp
index 469fd1c4aa..558c27d0c3 100644
--- a/dviware/dvisvgm/src/DLLoader.hpp
+++ b/dviware/dvisvgm/src/DLLoader.hpp
@@ -2,7 +2,7 @@
** DLLoader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/DVIActions.hpp b/dviware/dvisvgm/src/DVIActions.hpp
index 31ea693477..f51120ab77 100644
--- a/dviware/dvisvgm/src/DVIActions.hpp
+++ b/dviware/dvisvgm/src/DVIActions.hpp
@@ -2,7 +2,7 @@
** DVIActions.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/DVIReader.cpp b/dviware/dvisvgm/src/DVIReader.cpp
index 893e6a818b..c524ff60db 100644
--- a/dviware/dvisvgm/src/DVIReader.cpp
+++ b/dviware/dvisvgm/src/DVIReader.cpp
@@ -2,7 +2,7 @@
** DVIReader.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 **
@@ -26,7 +26,6 @@
#include "Font.hpp"
#include "FontManager.hpp"
#include "HashFunction.hpp"
-#include "JFM.hpp"
#include "utility.hpp"
#include "VectorStream.hpp"
@@ -203,11 +202,11 @@ void DVIReader::cmdPop (int) {
* @param[in] font current font (corresponding to _currFontNum)
* @param[in] c character to typeset */
void DVIReader::putVFChar (Font *font, uint32_t c) {
- if (auto vf = dynamic_cast<VirtualFont*>(font)) { // is current font a virtual font?
+ if (auto vf = font_cast<VirtualFont*>(font)) { // is current font a virtual font?
FontManager &fm = FontManager::instance();
const vector<uint8_t> *dvi = vf->getDVI(c); // try to get DVI snippet that represents character c
Font *firstFont = fm.vfFirstFont(vf);
- if (!dvi && (!firstFont || !dynamic_cast<const JFM*>(firstFont->getMetrics())))
+ if (!dvi && (!firstFont || !firstFont->getMetrics()->isJFM()))
return;
fm.enterVF(vf); // enter VF font number context
int savedFontNum = _currFontNum; // save current font number
@@ -485,7 +484,7 @@ const Font* DVIReader::defineFont (uint32_t fontnum, const string &name, uint32_
else { // TFM-based font specified by name
int id = fm.registerFont(fontnum, name, cs, dsize, ssize);
font = fm.getFontById(id);
- if (auto vf = dynamic_cast<VirtualFont*>(font)) {
+ if (auto vf = font_cast<VirtualFont*>(font)) {
// read vf file, register its font and character definitions
fm.enterVF(vf);
ifstream ifs(vf->path(), ios::binary);
@@ -592,7 +591,7 @@ void DVIReader::cmdXFontDef (int) {
FontManager::instance().registerFont(fontnum, fontname, fontIndex, ptsize, style, color);
font = FontManager::instance().getFont(fontnum);
}
- dviXFontDef(fontnum, dynamic_cast<const NativeFont*>(font));
+ dviXFontDef(fontnum, font_cast<const NativeFont*>(font));
}
diff --git a/dviware/dvisvgm/src/DVIReader.hpp b/dviware/dvisvgm/src/DVIReader.hpp
index 0e227ba8f6..ff8390f515 100644
--- a/dviware/dvisvgm/src/DVIReader.hpp
+++ b/dviware/dvisvgm/src/DVIReader.hpp
@@ -2,7 +2,7 @@
** DVIReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/DVIToSVG.cpp b/dviware/dvisvgm/src/DVIToSVG.cpp
index df3d3e39e6..22c41415bf 100644
--- a/dviware/dvisvgm/src/DVIToSVG.cpp
+++ b/dviware/dvisvgm/src/DVIToSVG.cpp
@@ -2,7 +2,7 @@
** DVIToSVG.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 **
@@ -74,13 +74,10 @@ bool DVIToSVG::COMPUTE_PROGRESS = false;
DVIToSVG::HashSettings DVIToSVG::PAGE_HASH_SETTINGS;
-DVIToSVG::DVIToSVG (istream &is, SVGOutputBase &out) : DVIReader(is), _out(out)
+DVIToSVG::DVIToSVG (istream &is, SVGOutputBase &out)
+ : DVIReader(is), _out(out), _prevWritingMode(WritingMode::LR)
{
- _pageHeight = _pageWidth = 0;
- _tx = _ty = 0; // no cursor translation
- _pageByte = 0;
_prevXPos = _prevYPos = numeric_limits<double>::min();
- _prevWritingMode = WritingMode::LR;
_actions = util::make_unique<DVIToSVGActions>(*this, _svg);
}
@@ -362,7 +359,7 @@ void DVIToSVG::embedFonts (XMLElement *svgElement) {
unordered_set<const Font*> tracedFonts; // collect unique fonts already traced
for (const auto &fontchar : usedCharsMap) {
const Font *font = fontchar.first;
- if (auto ph_font = dynamic_cast<const PhysicalFont*>(font)) {
+ if (auto ph_font = font_cast<const PhysicalFont*>(font)) {
// Check if glyphs should be traced. Only trace the glyphs of unique fonts, i.e.
// avoid retracing the same glyphs again if they are referenced in various sizes.
if (TRACE_MODE != 0 && tracedFonts.find(ph_font->uniqueFont()) == tracedFonts.end()) {
@@ -481,7 +478,7 @@ void DVIToSVG::dviEop () {
void DVIToSVG::dviSetChar0 (uint32_t c, const Font *font) {
- if (_actions && !dynamic_cast<const VirtualFont*>(font))
+ if (_actions && !font_cast<const VirtualFont*>(font))
_actions->setChar(dviState().h+_tx, dviState().v+_ty, c, dviState().d != WritingMode::LR, *font);
}
@@ -520,7 +517,7 @@ void DVIToSVG::dviPop () {
void DVIToSVG::dviFontNum (uint32_t fontnum, SetFontMode, const Font *font) {
- if (_actions && font && !dynamic_cast<const VirtualFont*>(font))
+ if (_actions && font && !font_cast<const VirtualFont*>(font))
_actions->setFont(FontManager::instance().fontID(fontnum), *font); // all fonts get a recomputed ID
}
diff --git a/dviware/dvisvgm/src/DVIToSVG.hpp b/dviware/dvisvgm/src/DVIToSVG.hpp
index 1bafa7cb3d..150f611fd0 100644
--- a/dviware/dvisvgm/src/DVIToSVG.hpp
+++ b/dviware/dvisvgm/src/DVIToSVG.hpp
@@ -2,7 +2,7 @@
** DVIToSVG.hpp **
** **
** 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 **
@@ -101,13 +101,13 @@ class DVIToSVG : public DVIReader {
SVGTree _svg;
SVGOutputBase &_out;
std::unique_ptr<DVIActions> _actions;
- std::string _bboxFormatString; ///< bounding box size/format set by the user
- std::string _transCmds; ///< page transformation commands set by the user
- double _pageHeight, _pageWidth; ///< global page height and width stored in the postamble
- double _tx, _ty; ///< translation of cursor position
- double _prevXPos, _prevYPos; ///< previous cursor position
- WritingMode _prevWritingMode; ///< previous writing mode
- std::streampos _pageByte; ///< position of the stream pointer relative to the preceding bop (in bytes)
+ std::string _bboxFormatString; ///< bounding box size/format set by the user
+ std::string _transCmds; ///< page transformation commands set by the user
+ double _pageHeight=0, _pageWidth=0; ///< global page height and width stored in the postamble
+ double _tx=0, _ty=0; ///< translation of cursor position
+ double _prevXPos, _prevYPos; ///< previous cursor position
+ WritingMode _prevWritingMode; ///< previous writing mode
+ std::streampos _pageByte=0; ///< position of the stream pointer relative to the preceding bop (in bytes)
};
#endif
diff --git a/dviware/dvisvgm/src/DVIToSVGActions.cpp b/dviware/dvisvgm/src/DVIToSVGActions.cpp
index 2464aec517..6de95de7b8 100644
--- a/dviware/dvisvgm/src/DVIToSVGActions.cpp
+++ b/dviware/dvisvgm/src/DVIToSVGActions.cpp
@@ -2,7 +2,7 @@
** DVIToSVGActions.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 **
@@ -105,7 +105,7 @@ void DVIToSVGActions::setChar (double x, double y, unsigned c, bool vertical, co
GlyphMetrics metrics;
font.getGlyphMetrics(c, vertical, metrics);
- auto pf = dynamic_cast<const PhysicalFont*>(&font);
+ auto pf = font_cast<const PhysicalFont*>(&font);
if (PhysicalFont::EXACT_BBOX && pf) {
GlyphMetrics exact_metrics;
pf->getExactGlyphBox(c, exact_metrics, vertical, &callback);
@@ -166,15 +166,13 @@ void DVIToSVGActions::setRule (double x, double y, double height, double width)
return;
// (x,y) is the lower left corner of the rectangle
- auto rect = util::make_unique<XMLElement>("rect");
+ auto rect = util::make_unique<SVGElement>("rect");
rect->addAttribute("x", x);
rect->addAttribute("y", y-height);
rect->addAttribute("height", height);
rect->addAttribute("width", width);
- if (!getMatrix().isIdentity())
- rect->addAttribute("transform", getMatrix().toSVG());
- if (getColor() != Color::BLACK)
- rect->addAttribute("fill", _svg.getColor().svgColorString());
+ rect->setTransform(getMatrix());
+ rect->setFillColor(_svg.getColor());
_svg.appendToPage(std::move(rect));
// update bounding box
@@ -237,12 +235,12 @@ void DVIToSVGActions::endPage (unsigned pageno) {
_svg.transformPage(matrix);
if (_bgcolor != Color::TRANSPARENT) {
// create a rectangle filled with the background color
- auto rect = util::make_unique<XMLElement>("rect");
+ auto rect = util::make_unique<SVGElement>("rect");
rect->addAttribute("x", _bbox.minX());
rect->addAttribute("y", _bbox.minY());
rect->addAttribute("width", _bbox.width());
rect->addAttribute("height", _bbox.height());
- rect->addAttribute("fill", _bgcolor.svgColorString());
+ rect->setFillColor(_bgcolor);
_svg.prependToPage(std::move(rect));
}
}
diff --git a/dviware/dvisvgm/src/DVIToSVGActions.hpp b/dviware/dvisvgm/src/DVIToSVGActions.hpp
index 2ae3fb9a2e..23706f987d 100644
--- a/dviware/dvisvgm/src/DVIToSVGActions.hpp
+++ b/dviware/dvisvgm/src/DVIToSVGActions.hpp
@@ -2,7 +2,7 @@
** DVIToSVGActions.hpp **
** **
** 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 **
@@ -49,6 +49,8 @@ class DVIToSVGActions : public DVIActions, public SpecialActions {
void setBgColor (const Color &color) override;
void setColor (const Color &color) override {_svg.setColor(color);}
void setMatrix (const Matrix &m) override {_svg.setMatrix(m);}
+ void setOpacity (const Opacity &opacity) override {_svg.setOpacity(opacity);}
+ const Opacity& getOpacity () const override {return _svg.getOpacity();}
const Matrix& getMatrix () const override {return _svg.getMatrix();}
Matrix getPageTransformation () const override {return _dvireader->getPageTransformation();}
Color getColor () const override {return _svg.getColor();}
diff --git a/dviware/dvisvgm/src/Directory.cpp b/dviware/dvisvgm/src/Directory.cpp
index e7200a0dc3..224165e255 100644
--- a/dviware/dvisvgm/src/Directory.cpp
+++ b/dviware/dvisvgm/src/Directory.cpp
@@ -2,7 +2,7 @@
** Directory.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 **
diff --git a/dviware/dvisvgm/src/Directory.hpp b/dviware/dvisvgm/src/Directory.hpp
index d617b4fcbd..14360a9f67 100644
--- a/dviware/dvisvgm/src/Directory.hpp
+++ b/dviware/dvisvgm/src/Directory.hpp
@@ -2,7 +2,7 @@
** Directory.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
index 97285db1a9..e6f444fa84 100644
--- a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
@@ -2,7 +2,7 @@
** DvisvgmSpecialHandler.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 **
@@ -81,8 +81,7 @@ void DvisvgmSpecialHandler::preprocessRawSet (InputReader &ir) {
_currentMacro = _macros.end();
throw SpecialException("redefinition of SVG fragment '" + id + "'");
}
- pair<string, StringVector> entry(id, StringVector());
- pair<MacroMap::iterator, bool> state = _macros.emplace(move(entry));
+ pair<MacroMap::iterator, bool> state = _macros.emplace(id, StringVector());
_currentMacro = state.first;
}
@@ -194,7 +193,7 @@ static void expand_constants (string &str, SpecialActions &actions) {
/** Evaluates substrings of the form {?(expr)} where 'expr' is a math expression,
* and replaces the substring by the computed value.
* @param[in,out] str string to scan for expressions */
-static void evaluate_expressions (string &str, SpecialActions &actions) {
+static void evaluate_expressions (string &str, const SpecialActions &actions) {
size_t left = str.find("{?("); // start position of expression macro
while (left != string::npos) {
size_t right = str.find(")}", left+2); // end position of expression macro
@@ -386,14 +385,13 @@ void DvisvgmSpecialHandler::processImg (InputReader &ir, SpecialActions &actions
Length h = read_length(ir);
string f = ir.getString();
update_bbox(w, h, Length(0), false, actions);
- auto img = util::make_unique<XMLElement>("image");
+ auto img = util::make_unique<SVGElement>("image");
img->addAttribute("x", actions.getX());
img->addAttribute("y", actions.getY());
img->addAttribute("width", w.bp());
img->addAttribute("height", h.bp());
img->addAttribute("xlink:href", f);
- if (!actions.getMatrix().isIdentity())
- img->addAttribute("transform", actions.getMatrix().toSVG());
+ img->setTransform(actions.getMatrix());
actions.svgTree().appendToPage(std::move(img));
}
catch (const UnitException &e) {
@@ -448,10 +446,10 @@ void DvisvgmSpecialHandler::XMLParser::parse (const string &xml, SpecialActions
// collect/extract an XML fragment that only contains complete tags
// incomplete tags are held back
_xmlbuf += xml;
- size_t left=0, right;
+ size_t left=0;
try {
while (left != string::npos) {
- right = _xmlbuf.find('<', left);
+ size_t right = _xmlbuf.find('<', left);
if (left < right && left < _xmlbuf.length()) // plain text found?
(actions.svgTree().*_append)(util::make_unique<XMLText>(_xmlbuf.substr(left, right-left)));
if (right != string::npos) {
@@ -523,7 +521,7 @@ void DvisvgmSpecialHandler::XMLParser::openElement (const string &tag, SpecialAc
BufferInputReader ir(ib);
string name = ir.getString("/ \t\n\r");
ir.skipSpace();
- auto elemNode = util::make_unique<XMLElement>(name);
+ auto elemNode = util::make_unique<SVGElement>(name);
map<string, string> attribs;
if (ir.parseAttributes(attribs, true, "\"'")) {
for (const auto &attrpair : attribs)
diff --git a/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp b/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
index d6aa32c9ee..5bd8d66874 100644
--- a/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
@@ -2,7 +2,7 @@
** DvisvgmSpecialHandler.hpp **
** **
** 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 **
@@ -29,6 +29,7 @@
class InputReader;
class SpecialActions;
+class SVGElement;
class SVGTree;
class XMLElement;
class XMLNode;
@@ -44,7 +45,7 @@ class XMLNode;
class DvisvgmSpecialHandler : public SpecialHandler {
class XMLParser {
using AppendFunc = void (SVGTree::*)(std::unique_ptr<XMLNode>);
- using PushFunc = void (SVGTree::*)(std::unique_ptr<XMLElement>);
+ using PushFunc = void (SVGTree::*)(std::unique_ptr<SVGElement>);
using PopFunc = void (SVGTree::*)();
using NameStack = std::vector<std::string>;
diff --git a/dviware/dvisvgm/src/EPSFile.cpp b/dviware/dvisvgm/src/EPSFile.cpp
index 1a19c07cc7..2f61f9f07d 100644
--- a/dviware/dvisvgm/src/EPSFile.cpp
+++ b/dviware/dvisvgm/src/EPSFile.cpp
@@ -2,7 +2,7 @@
** EPSFile.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 **
diff --git a/dviware/dvisvgm/src/EPSFile.hpp b/dviware/dvisvgm/src/EPSFile.hpp
index 7b02db95b1..384af7225e 100644
--- a/dviware/dvisvgm/src/EPSFile.hpp
+++ b/dviware/dvisvgm/src/EPSFile.hpp
@@ -2,7 +2,7 @@
** EPSFile.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/EPSToSVG.hpp b/dviware/dvisvgm/src/EPSToSVG.hpp
index 64f5ac604d..75a574cf38 100644
--- a/dviware/dvisvgm/src/EPSToSVG.hpp
+++ b/dviware/dvisvgm/src/EPSToSVG.hpp
@@ -2,7 +2,7 @@
** EPSToSVG.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/EllipticalArc.cpp b/dviware/dvisvgm/src/EllipticalArc.cpp
index a151c51307..e7353458e3 100644
--- a/dviware/dvisvgm/src/EllipticalArc.cpp
+++ b/dviware/dvisvgm/src/EllipticalArc.cpp
@@ -2,7 +2,7 @@
** EllipticalArc.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 **
@@ -177,7 +177,7 @@ vector<Bezier> EllipticalArc::approximate () const {
if (isStraightLine()) {
DPair dir = (_endPoint - _startPoint);
dir /= dir.length()/3.0;
- beziers.emplace_back(Bezier(_startPoint, _startPoint+dir, _endPoint-dir, _endPoint));
+ beziers.emplace_back(_startPoint, _startPoint+dir, _endPoint-dir, _endPoint);
}
else {
CenterParams cparams = getCenterParams();
@@ -190,11 +190,11 @@ vector<Bezier> EllipticalArc::approximate () const {
if (numCurves > 0) {
double c = cos(_rotationAngle);
double s = sin(_rotationAngle);
- Matrix ellipse = {_rx*c, -_ry*s, cparams.center.x(), _rx*s, _ry*c, cparams.center.y()};
+ Matrix ellipse{_rx*c, -_ry*s, cparams.center.x(), _rx*s, _ry*c, cparams.center.y()};
double angle = cparams.startAngle;
double diff = cparams.deltaAngle/numCurves;
while (numCurves-- > 0) {
- beziers.emplace_back(approx_unit_arc(angle, diff).transform(ellipse));
+ beziers.push_back(approx_unit_arc(angle, diff).transform(ellipse));
angle += diff;
}
}
diff --git a/dviware/dvisvgm/src/EllipticalArc.hpp b/dviware/dvisvgm/src/EllipticalArc.hpp
index 422a40b207..78785c4ff1 100644
--- a/dviware/dvisvgm/src/EllipticalArc.hpp
+++ b/dviware/dvisvgm/src/EllipticalArc.hpp
@@ -2,7 +2,7 @@
** EllipticalArc.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/EmSpecialHandler.cpp b/dviware/dvisvgm/src/EmSpecialHandler.cpp
index efbd7abef3..ac1d4fc6bc 100644
--- a/dviware/dvisvgm/src/EmSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/EmSpecialHandler.cpp
@@ -2,7 +2,7 @@
** EmSpecialHandler.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 **
@@ -24,9 +24,8 @@
#include "InputReader.hpp"
#include "Length.hpp"
#include "SpecialActions.hpp"
+#include "SVGElement.hpp"
#include "SVGTree.hpp"
-#include "XMLNode.hpp"
-#include "XMLString.hpp"
using namespace std;
@@ -77,17 +76,19 @@ static DPair cut_vector (char cuttype, const DPair &linedir, double linewidth) {
static void create_line (const DPair &p1, const DPair &p2, char c1, char c2, double lw, SpecialActions &actions) {
if (actions.outputLocked())
return;
- unique_ptr<XMLElement> node;
+ unique_ptr<SVGElement> node;
DPair dir = p2-p1;
if (dir.x() == 0 || dir.y() == 0 || (c1 == 'p' && c2 == 'p')) {
// draw regular line
- node = util::make_unique<XMLElement>("line");
+ node = util::make_unique<SVGElement>("line");
node->addAttribute("x1", p1.x());
node->addAttribute("y1", p1.y());
node->addAttribute("x2", p2.x());
node->addAttribute("y2", p2.y());
- node->addAttribute("stroke-width", lw);
- node->addAttribute("stroke", actions.getColor().svgColorString());
+ node->setStrokeWidth(lw);
+ node->setStrokeColor(actions.getColor());
+ node->setStrokeOpacity(actions.getOpacity());
+
// update bounding box
DPair cv = cut_vector('p', dir, lw);
actions.embed(p1+cv);
@@ -97,24 +98,24 @@ static void create_line (const DPair &p1, const DPair &p2, char c1, char c2, dou
}
else {
// draw polygon
+ vector<DPair> points;
DPair cv1 = cut_vector(c1, dir, lw);
DPair cv2 = cut_vector(c2, dir, lw);
- DPair q11 = p1+cv1, q12 = p1-cv1;
- DPair q21 = p2+cv2, q22 = p2-cv2;
- ostringstream oss;
- oss << XMLString(q11.x()) << ',' << XMLString(q11.y()) << ' '
- << XMLString(q12.x()) << ',' << XMLString(q12.y()) << ' '
- << XMLString(q22.x()) << ',' << XMLString(q22.y()) << ' '
- << XMLString(q21.x()) << ',' << XMLString(q21.y());
- node = util::make_unique<XMLElement>("polygon");
- node->addAttribute("points", oss.str());
- if (actions.getColor() != Color::BLACK)
- node->addAttribute("fill", actions.getColor().svgColorString());
+ points.push_back(p1+cv1);
+ points.push_back(p1-cv1);
+ points.push_back(p2-cv2);
+ points.push_back(p2+cv2);
+
+ node = util::make_unique<SVGElement>("polygon");
+ node->setPoints(points);
+ node->setFillColor(actions.getColor());
+ node->setFillOpacity(actions.getOpacity());
+
// update bounding box
- actions.embed(q11);
- actions.embed(q12);
- actions.embed(q21);
- actions.embed(q22);
+ actions.embed(points[0]);
+ actions.embed(points[1]);
+ actions.embed(points[2]);
+ actions.embed(points[3]);
}
actions.svgTree().appendToPage(std::move(node));
}
@@ -236,7 +237,7 @@ void EmSpecialHandler::line (InputReader &ir, SpecialActions& actions) {
// Line endpoints don't necessarily have to be defined before
// a line definition. If a point isn't defined yet, we put the line
// in a wait list and process the lines at the end of the page.
- _lines.emplace_back(Line(pointnum1, pointnum2, char(cut1), char(cut2), linewidth));
+ _lines.emplace_back(pointnum1, pointnum2, char(cut1), char(cut2), linewidth);
}
}
diff --git a/dviware/dvisvgm/src/EmSpecialHandler.hpp b/dviware/dvisvgm/src/EmSpecialHandler.hpp
index e20339e548..fc9f14a468 100644
--- a/dviware/dvisvgm/src/EmSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/EmSpecialHandler.hpp
@@ -2,7 +2,7 @@
** EmSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/EncFile.cpp b/dviware/dvisvgm/src/EncFile.cpp
index ce0f18d81e..d08791c03e 100644
--- a/dviware/dvisvgm/src/EncFile.cpp
+++ b/dviware/dvisvgm/src/EncFile.cpp
@@ -2,7 +2,7 @@
** EncFile.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 **
diff --git a/dviware/dvisvgm/src/EncFile.hpp b/dviware/dvisvgm/src/EncFile.hpp
index 8f2b14c430..0e5f90bcb3 100644
--- a/dviware/dvisvgm/src/EncFile.hpp
+++ b/dviware/dvisvgm/src/EncFile.hpp
@@ -2,7 +2,7 @@
** EncFile.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FileFinder.cpp b/dviware/dvisvgm/src/FileFinder.cpp
index a52ccd37d3..3358d5c273 100644
--- a/dviware/dvisvgm/src/FileFinder.cpp
+++ b/dviware/dvisvgm/src/FileFinder.cpp
@@ -2,7 +2,7 @@
** FileFinder.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 **
diff --git a/dviware/dvisvgm/src/FileFinder.hpp b/dviware/dvisvgm/src/FileFinder.hpp
index 7218bf6c0b..5774f8165c 100644
--- a/dviware/dvisvgm/src/FileFinder.hpp
+++ b/dviware/dvisvgm/src/FileFinder.hpp
@@ -2,7 +2,7 @@
** FileFinder.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FilePath.cpp b/dviware/dvisvgm/src/FilePath.cpp
index 2150cf31f7..fd81c0221b 100644
--- a/dviware/dvisvgm/src/FilePath.cpp
+++ b/dviware/dvisvgm/src/FilePath.cpp
@@ -2,7 +2,7 @@
** FilePath.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 **
@@ -37,34 +37,24 @@ static string& single_slashes (string &str) {
#ifdef _WIN32
+/** Returns the drive letter of a given path string or 0 if there's none. */
+static char drive_letter (const string &path) {
+ if (path.length() >= 2 && path[1] == ':' && isalpha(path[0]))
+ return tolower(path[0]);
+ return '\0';
+}
+
+/** Removes the drive letter and following colon from a given path string if present.
+ * @param[in] path path to strip drive letter from
+ * @return drive letter or 0 if there was none */
static char strip_drive_letter (string &path) {
- char letter = 0;
+ char letter = '\0';
if (path.length() >= 2 && path[1] == ':' && isalpha(path[0])) {
letter = path[0];
path.erase(0, 2);
}
- return letter;
-}
-
-
-static char adapt_current_path (string &path, char target_drive) {
- if (char current_drive = strip_drive_letter(path)) {
- if (target_drive != current_drive) {
- if (target_drive == 0)
- target_drive = current_drive;
- if (path.empty() || path[0] != '/') {
- if (FileSystem::chdir(string(1, target_drive) + ":")) {
- path.insert(0, FileSystem::getcwd()+"/");
- strip_drive_letter(path);
- }
- else
- throw MessageException("drive " + string(1, target_drive) + ": not accessible");
- }
- }
- }
- return target_drive;
+ return tolower(letter);
}
-
#endif
@@ -99,7 +89,7 @@ void FilePath::set (const string &path) {
* @param[in] path absolute or relative path to a file or directory
* @param[in] isfile true if 'path' references a file, false if a directory is referenced */
void FilePath::set (const string &path, bool isfile) {
- init(path, isfile, FileSystem::getcwd());
+ init(path, isfile, "");
}
@@ -121,47 +111,42 @@ void FilePath::init (string path, bool isfile, string current_dir) {
_fname.clear();
single_slashes(path);
single_slashes(current_dir);
-#ifdef _WIN32
- path = FileSystem::ensureForwardSlashes(path);
+#ifndef _WIN32
+ if (current_dir.empty())
+ current_dir = FileSystem::getcwd();
+#else
_drive = strip_drive_letter(path);
+ if (current_dir.empty() || drive_letter(current_dir) != _drive)
+ current_dir = FileSystem::getcwd(_drive);
+ if (!_drive)
+ _drive = drive_letter(current_dir);
+ strip_drive_letter(current_dir);
+ path = FileSystem::ensureForwardSlashes(path);
#endif
if (isfile) {
size_t pos = path.rfind('/');
_fname = path.substr((pos == string::npos) ? 0 : pos+1);
- if (pos != string::npos)
+ // remove filename from path
+ if (pos == 0 && _fname.length() > 1) // file in root directory?
+ path.erase(1);
+ else if (pos != string::npos)
path.erase(pos);
else
path.clear();
}
- if (current_dir.empty())
- current_dir = FileSystem::getcwd();
-#ifdef _WIN32
- _drive = adapt_current_path(current_dir, _drive);
-#endif
- if (!path.empty()) {
- if (path[0] == '/')
- current_dir.clear();
- else if (current_dir[0] != '/')
- current_dir = "/";
- else {
- FilePath curr(current_dir, false, "/");
- current_dir = curr.absolute();
-#ifdef _WIN32
- adapt_current_path(current_dir, _drive);
-#endif
- }
- }
- path.insert(0, current_dir + "/");
+ if ((path.empty() || path[0] != '/') && !current_dir.empty())
+ path.insert(0, current_dir + "/");
string elem;
for (char c : path) {
if (c != '/')
elem += c;
- else {
+ else if (!elem.empty()){
add(elem);
elem.clear();
}
}
- add(elem);
+ if (!elem.empty())
+ add(elem);
}
@@ -169,7 +154,7 @@ void FilePath::init (string path, bool isfile, string current_dir) {
void FilePath::add (const string &dir) {
if (dir == ".." && !_dirs.empty())
_dirs.pop_back();
- else if (dir.length() > 0 && dir != ".")
+ else if (!dir.empty() && dir != ".")
_dirs.emplace_back(dir);
}
@@ -223,16 +208,16 @@ string FilePath::basename () const {
* @return the absolute path string */
string FilePath::absolute (bool with_filename) const {
string path;
+#ifdef _WIN32
+ if (_drive)
+ path = string(1, _drive) + ":";
+#endif
for (const Directory &dir : _dirs)
path += "/" + string(dir);
if (path.empty())
path = "/";
if (with_filename && !_fname.empty())
path += "/"+_fname;
-#ifdef _WIN32
- if (_drive)
- path.insert(0, string(1, _drive) + ":");
-#endif
return single_slashes(path);
}
@@ -245,28 +230,32 @@ string FilePath::absolute (bool with_filename) const {
* @param[in] with_filename if false, the filename is omitted
* @return the relative path string */
string FilePath::relative (string reldir, bool with_filename) const {
+#ifdef _WIN32
+ char reldrive = drive_letter(reldir);
+ if (reldir.empty()) {
+ reldir = FileSystem::getcwd(_drive);
+ reldrive = drive_letter(FileSystem::getcwd());
+ }
+ bool isAbsolute = (reldir[0] == '/')
+ || (reldir.length() >= 3 && isalpha(reldir[0]) && reldir[1] == ':' && reldir[2] == '/');
+#else
if (reldir.empty())
reldir = FileSystem::getcwd();
-#ifdef _WIN32
- adapt_current_path(reldir, _drive);
+ bool isAbsolute = (reldir[0] == '/');
#endif
- if (reldir[0] != '/')
+ if (!isAbsolute)
return absolute();
- FilePath rel(reldir, false);
+ FilePath relpath(reldir, false);
string path;
-#ifdef _WIN32
- if (rel._drive && _drive && tolower(rel._drive) != tolower(_drive))
- path += string(1, _drive) + ":";
-#endif
auto it1 = _dirs.begin();
- auto it2 = rel._dirs.begin();
- while (it1 != _dirs.end() && it2 != rel._dirs.end() && *it1 == *it2)
+ auto it2 = relpath._dirs.begin();
+ while (it1 != _dirs.end() && it2 != relpath._dirs.end() && *it1 == *it2)
++it1, ++it2;
- for (; it2 != rel._dirs.end(); ++it2)
+ for (; it2 != relpath._dirs.end(); ++it2)
path += "../";
for (; it1 != _dirs.end(); ++it1)
path += string(*it1) + "/";
- if (!path.empty())
+ if (!path.empty() && path.back() == '/')
path.erase(path.length()-1, 1); // remove trailing slash
if (with_filename && !_fname.empty()) {
if (!path.empty() && path != "/")
@@ -275,6 +264,10 @@ string FilePath::relative (string reldir, bool with_filename) const {
}
if (path.empty())
path = ".";
+#ifdef _WIN32
+ if (relpath._drive && _drive && _drive != reldrive)
+ path.insert(0, string(1, _drive) + ":");
+#endif
return single_slashes(path);
}
diff --git a/dviware/dvisvgm/src/FilePath.hpp b/dviware/dvisvgm/src/FilePath.hpp
index e9d55562c5..af81db66f4 100644
--- a/dviware/dvisvgm/src/FilePath.hpp
+++ b/dviware/dvisvgm/src/FilePath.hpp
@@ -2,7 +2,7 @@
** FilePath.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FileSystem.cpp b/dviware/dvisvgm/src/FileSystem.cpp
index e1db59fa03..ada3f8e47c 100644
--- a/dviware/dvisvgm/src/FileSystem.cpp
+++ b/dviware/dvisvgm/src/FileSystem.cpp
@@ -2,7 +2,7 @@
** FileSystem.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 **
@@ -135,16 +135,38 @@ string FileSystem::ensureForwardSlashes (string path) {
}
+/** Returns the absolute path of the current working directory. */
string FileSystem::getcwd () {
char buf[1024];
#ifdef _WIN32
- return ensureForwardSlashes(_getcwd(buf, 1024));
+ GetCurrentDirectoryA(1024, buf);
+ return ensureForwardSlashes(buf);
#else
return ::getcwd(buf, 1024);
#endif
}
+#ifdef _WIN32
+/** Returns the absolute path of the current directory of a given drive.
+ * Windows keeps a current directory for every drive, i.e. when accessing a drive
+ * without specifying a path (e.g. with "cd z:"), the current directory of that
+ * drive is used.
+ * @param[in] drive letter of drive to get the current directory from
+ * @return absolute path of the directory */
+string FileSystem::getcwd (char drive) {
+ string cwd = getcwd();
+ if (cwd.length() > 1 && cwd[1] == ':' && tolower(cwd[0]) != tolower(drive)) {
+ chdir(string(1, drive)+":");
+ string cwd2 = cwd;
+ cwd = getcwd();
+ chdir(string(1, cwd2[0])+":");
+ }
+ return cwd;
+}
+#endif
+
+
/** Changes the work directory.
* @param[in] dir path to new work directory
* @return true on success */
diff --git a/dviware/dvisvgm/src/FileSystem.hpp b/dviware/dvisvgm/src/FileSystem.hpp
index 9a45c4ac19..0c13f178e9 100644
--- a/dviware/dvisvgm/src/FileSystem.hpp
+++ b/dviware/dvisvgm/src/FileSystem.hpp
@@ -2,7 +2,7 @@
** FileSystem.hpp **
** **
** 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 **
@@ -48,6 +48,9 @@ class FileSystem {
static uint64_t filesize (const std::string &fname);
static std::string ensureForwardSlashes (std::string path);
static std::string getcwd ();
+#ifdef _WIN32
+ static std::string getcwd (char drive);
+#endif
static std::string tmpdir ();
static bool chdir (const std::string &dir);
static bool exists (const std::string &fname);
diff --git a/dviware/dvisvgm/src/FixWord.hpp b/dviware/dvisvgm/src/FixWord.hpp
index 3414e1ead4..b6166b15dc 100644
--- a/dviware/dvisvgm/src/FixWord.hpp
+++ b/dviware/dvisvgm/src/FixWord.hpp
@@ -2,7 +2,7 @@
** FixWord.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Font.cpp b/dviware/dvisvgm/src/Font.cpp
index 5aee699422..052d6c038f 100644
--- a/dviware/dvisvgm/src/Font.cpp
+++ b/dviware/dvisvgm/src/Font.cpp
@@ -2,7 +2,7 @@
** Font.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 **
@@ -636,7 +636,7 @@ bool NativeFontImpl::findAndAssignBaseFontMap () {
FontEngine &fe = FontEngine::instance();
fe.setFont(*this);
fe.setUnicodeCharMap();
- fe.buildCharMap(_toUnicodeMap);
+ fe.buildGidToCharCodeMap(_toUnicodeMap);
if (!_toUnicodeMap.addMissingMappings(fe.getNumGlyphs()))
Message::wstream(true) << "incomplete Unicode mapping for native font " << name() << " (" << filename() << ")\n";
return true;
@@ -679,3 +679,11 @@ const vector<uint8_t>* VirtualFontImpl::getDVI (int c) const {
return (it == _charDefs.end() ? nullptr : &it->second);
}
+//////////////////////////////////////////////////////////////////////////////
+
+void PhysicalFont::visit (FontVisitor &visitor) {visitor.visited(this);}
+void VirtualFont::visit (FontVisitor &visitor) {visitor.visited(this);}
+void NativeFont::visit (FontVisitor &visitor) {visitor.visited(this);}
+void PhysicalFont::visit (FontVisitor &visitor) const {visitor.visited(this);}
+void VirtualFont::visit (FontVisitor &visitor) const {visitor.visited(this);}
+void NativeFont::visit (FontVisitor &visitor) const {visitor.visited(this);}
diff --git a/dviware/dvisvgm/src/Font.hpp b/dviware/dvisvgm/src/Font.hpp
index 0a92cbeff5..f4bb58a9c6 100644
--- a/dviware/dvisvgm/src/Font.hpp
+++ b/dviware/dvisvgm/src/Font.hpp
@@ -2,7 +2,7 @@
** Font.hpp **
** **
** 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 **
@@ -50,6 +50,7 @@ struct GlyphMetrics {
double wl, wr, h, d;
};
+class FontVisitor;
/** Abstract base for all font classes. */
class Font {
@@ -69,17 +70,19 @@ class Font {
virtual const char* path () const =0;
virtual const char* filename () const;
virtual const FontEncoding* encoding () const;
- virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *callback=nullptr) const =0;
+ virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *callback) const =0;
virtual void getGlyphMetrics (int c, bool vertical, GlyphMetrics &metrics) const;
virtual uint32_t unicode (uint32_t c) const;
virtual void tidy () const {}
virtual bool findAndAssignBaseFontMap () {return true;}
- virtual bool verticalLayout () const {return getMetrics() ? getMetrics()->verticalLayout() : false;}
+ virtual bool verticalLayout () const {return getMetrics() != nullptr && getMetrics()->verticalLayout();}
virtual bool verifyChecksums () const {return true;}
virtual int fontIndex () const {return 0;}
virtual const FontStyle* style () const {return nullptr;}
virtual Color color () const {return Color::BLACK;}
virtual const FontMap::Entry* fontMapEntry () const;
+ virtual void visit (FontVisitor &visitor) =0;
+ virtual void visit (FontVisitor &visitor) const =0;
};
@@ -100,7 +103,9 @@ class EmptyFont : public Font {
double italicCorr (int c) const override {return 0;}
const FontMetrics* getMetrics () const override {return nullptr;}
const char* path () const override {return nullptr;}
- bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override {return false;}
+ bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback*) const override {return false;}
+ void visit (FontVisitor &visitor) override {}
+ void visit (FontVisitor &visitor) const override {}
private:
std::string _fontname;
@@ -115,9 +120,9 @@ class PhysicalFont : public virtual Font {
static std::unique_ptr<Font> create (const std::string &name, uint32_t checksum, double dsize, double ssize, PhysicalFont::Type type);
static std::unique_ptr<Font> create (const std::string &name, int fontindex, uint32_t checksum, double dsize, double ssize);
virtual Type type () const =0;
- bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override;
- virtual bool getExactGlyphBox (int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb=nullptr) const;
- virtual bool getExactGlyphBox (int c, GlyphMetrics &metrics, bool vertical, GFGlyphTracer::Callback *cb=nullptr) const;
+ bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb) const override;
+ virtual bool getExactGlyphBox (int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb) const;
+ virtual bool getExactGlyphBox (int c, GlyphMetrics &metrics, bool vertical, GFGlyphTracer::Callback *cb) const;
virtual bool isCIDFont () const;
virtual int hAdvance () const;
virtual std::string familyName () const;
@@ -129,12 +134,14 @@ class PhysicalFont : public virtual Font {
virtual double scaledAscent () const;
virtual int ascent () const;
virtual int descent () const;
- virtual int traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb=nullptr) const;
+ virtual int traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb) const;
virtual int collectCharMapIDs (std::vector<CharMapID> &charmapIDs) const;
virtual CharMapID getCharMapID () const =0;
virtual void setCharMapID (const CharMapID &id) {}
virtual Character decodeChar (uint32_t c) const;
const char* path () const override;
+ void visit (FontVisitor &visitor) override;
+ void visit (FontVisitor &visitor) const override;
protected:
bool createGF (std::string &gfname) const;
@@ -159,7 +166,9 @@ class VirtualFont : public virtual Font {
public:
static std::unique_ptr<Font> create (const std::string &name, uint32_t checksum, double dsize, double ssize);
virtual const DVIVector* getDVI (int c) const =0;
- bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=nullptr) const override {return false;}
+ bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback*) const override {return false;}
+ void visit (FontVisitor &visitor) override;
+ void visit (FontVisitor &visitor) const override;
protected:
virtual void assignChar (uint32_t c, DVIVector &&dvi) =0;
@@ -272,6 +281,8 @@ class NativeFont : public PhysicalFont {
Color color () const override {return _color;}
const FontMap::Entry* fontMapEntry () const override {return nullptr;}
static std::string uniqueName (const std::string &path, const FontStyle &style);
+ void visit (FontVisitor &visitor) override;
+ void visit (FontVisitor &visitor) const override;
protected:
NativeFont (double ptsize, const FontStyle &style, Color color) : _ptsize(ptsize), _style(style), _color(color) {}
@@ -390,6 +401,33 @@ class VirtualFontImpl : public VirtualFont, public TFMFont {
};
+struct FontVisitor {
+ virtual ~FontVisitor () =default;
+ virtual void visited (const PhysicalFont *font) {}
+ virtual void visited (const VirtualFont *font) {}
+ virtual void visited (const NativeFont *font) {visited(static_cast<const PhysicalFont*>(font));}
+ virtual void visited (PhysicalFont *font) {}
+ virtual void visited (VirtualFont *font) {}
+ virtual void visited (NativeFont *font) {visited(static_cast<PhysicalFont*>(font));}
+};
+
+
+/** This function works similar to dynamic_cast but only on pointers to Font classes.
+ * It uses double dispatch instead of RTTI and should therefore be faster.
+ * @param[in] font font pointer to be cast
+ * @return cast pointer on success, nullptr otherwise */
+template <typename C>
+C font_cast (typename util::set_const_of<Font>::by<typename std::remove_pointer<C>::type>::type *font) {
+ struct : FontVisitor {
+ void visited (C font) override {result = font;}
+ C result = nullptr;
+ } visitor;
+ if (font)
+ font->visit(visitor);
+ return visitor.result;
+}
+
+
struct FontException : public MessageException {
explicit FontException (const std::string &msg) : MessageException(msg) {}
};
diff --git a/dviware/dvisvgm/src/FontCache.cpp b/dviware/dvisvgm/src/FontCache.cpp
index 1fd13c9c11..2e741fb82c 100644
--- a/dviware/dvisvgm/src/FontCache.cpp
+++ b/dviware/dvisvgm/src/FontCache.cpp
@@ -2,7 +2,7 @@
** FontCache.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 **
@@ -281,9 +281,9 @@ bool FontCache::fontinfo (const string &dirname, vector<FontInfo> &infos, vector
string path = dirname+"/"+(fname.substr(1));
ifstream ifs(path, ios::binary);
if (fontinfo(ifs, info))
- infos.emplace_back(move(info));
+ infos.push_back(move(info));
else
- invalid.emplace_back(fname.substr(1));
+ invalid.push_back(fname.substr(1));
}
}
}
diff --git a/dviware/dvisvgm/src/FontCache.hpp b/dviware/dvisvgm/src/FontCache.hpp
index 8a6025a3d2..e7bbf36126 100644
--- a/dviware/dvisvgm/src/FontCache.hpp
+++ b/dviware/dvisvgm/src/FontCache.hpp
@@ -2,7 +2,7 @@
** FontCache.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FontEncoding.cpp b/dviware/dvisvgm/src/FontEncoding.cpp
index f1e1e38383..afc221063e 100644
--- a/dviware/dvisvgm/src/FontEncoding.cpp
+++ b/dviware/dvisvgm/src/FontEncoding.cpp
@@ -2,7 +2,7 @@
** FontEncoding.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 **
diff --git a/dviware/dvisvgm/src/FontEncoding.hpp b/dviware/dvisvgm/src/FontEncoding.hpp
index a50d97eabf..141f4486fe 100644
--- a/dviware/dvisvgm/src/FontEncoding.hpp
+++ b/dviware/dvisvgm/src/FontEncoding.hpp
@@ -2,7 +2,7 @@
** FontEncoding.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FontEngine.cpp b/dviware/dvisvgm/src/FontEngine.cpp
index bee1ca886d..4a9e9dd955 100644
--- a/dviware/dvisvgm/src/FontEngine.cpp
+++ b/dviware/dvisvgm/src/FontEngine.cpp
@@ -2,7 +2,7 @@
** FontEngine.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 **
@@ -103,7 +103,7 @@ bool FontEngine::setFont (const Font &font) {
return true;
if (const char *path=font.path()) {
- auto pf = dynamic_cast<const PhysicalFont*>(&font);
+ auto pf = font_cast<const PhysicalFont*>(&font);
if (setFont(path, font.fontIndex(), pf ? pf->getCharMapID() : CharMapID())) {
_currentFont = &font;
return true;
@@ -131,37 +131,38 @@ bool FontEngine::setCharMap (const CharMapID &charMapID) {
}
-/** Returns a character map that maps from character indexes to character codes
+/** Returns a character map that maps from glyph indexes to character codes
* of the current encoding.
* @param[out] charmap the resulting charmap */
-void FontEngine::buildCharMap (RangeMap &charmap) {
+void FontEngine::buildGidToCharCodeMap (RangeMap &charmap) {
charmap.clear();
- FT_UInt glyph_index;
- uint32_t charcode = FT_Get_First_Char(_currentFace, &glyph_index);
- while (glyph_index) {
- charmap.addRange(glyph_index, glyph_index, charcode);
- charcode = FT_Get_Next_Char(_currentFace, charcode, &glyph_index);
+ FT_UInt gid; // index of current glyph
+ uint32_t charcode = FT_Get_First_Char(_currentFace, &gid);
+ while (gid) {
+ if (!charmap.valueAt(gid))
+ charmap.addRange(gid, gid, charcode);
+ charcode = FT_Get_Next_Char(_currentFace, charcode, &gid);
}
}
-/** Creates a charmap that maps from the custom character encoding to unicode.
+/** Creates a charmap that maps from the custom character encoding to Unicode.
* @return pointer to charmap if it could be created, 0 otherwise */
unique_ptr<const RangeMap> FontEngine::createCustomToUnicodeMap () {
FT_CharMap ftcharmap = _currentFace->charmap;
if (FT_Select_Charmap(_currentFace, FT_ENCODING_ADOBE_CUSTOM) != 0)
return nullptr;
- RangeMap index_to_source_chrcode;
- buildCharMap(index_to_source_chrcode);
+ RangeMap gidToCharCodeMap;
+ buildGidToCharCodeMap(gidToCharCodeMap);
if (FT_Select_Charmap(_currentFace, FT_ENCODING_UNICODE) != 0)
return nullptr;
auto charmap = util::make_unique<RangeMap>();
- FT_UInt glyph_index;
- uint32_t unicode_point = FT_Get_First_Char(_currentFace, &glyph_index);
- while (glyph_index) {
- uint32_t custom_charcode = index_to_source_chrcode.valueAt(glyph_index);
- charmap->addRange(custom_charcode, custom_charcode, unicode_point);
- unicode_point = FT_Get_Next_Char(_currentFace, unicode_point, &glyph_index);
+ FT_UInt gid; // index of current glyph
+ uint32_t ucCharcode = FT_Get_First_Char(_currentFace, &gid); // Unicode code point
+ while (gid) {
+ uint32_t customCharcode = gidToCharCodeMap.valueAt(gid);
+ charmap->addRange(customCharcode, customCharcode, ucCharcode);
+ ucCharcode = FT_Get_Next_Char(_currentFace, ucCharcode, &gid);
}
FT_Set_Charmap(_currentFace, ftcharmap);
return std::move(charmap);
@@ -307,7 +308,7 @@ int FontEngine::getCharMapIDs (vector<CharMapID> &charmapIDs) const {
if (_currentFace) {
for (int i=0; i < _currentFace->num_charmaps; i++) {
FT_CharMap charmap = _currentFace->charmaps[i];
- charmapIDs.emplace_back(CharMapID(charmap->platform_id, charmap->encoding_id));
+ charmapIDs.emplace_back(charmap->platform_id, charmap->encoding_id);
}
}
return charmapIDs.size();
diff --git a/dviware/dvisvgm/src/FontEngine.hpp b/dviware/dvisvgm/src/FontEngine.hpp
index 5796c2b1b3..45d9c6d3b6 100644
--- a/dviware/dvisvgm/src/FontEngine.hpp
+++ b/dviware/dvisvgm/src/FontEngine.hpp
@@ -2,7 +2,7 @@
** FontEngine.hpp **
** **
** 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 **
@@ -64,7 +64,7 @@ class FontEngine {
std::string getGlyphName (const Character &c) const;
int getCharByGlyphName (const char *name) const;
bool setCharMap (const CharMapID &charMapID);
- void buildCharMap (RangeMap &charmap);
+ void buildGidToCharCodeMap (RangeMap &charmap);
std::unique_ptr<const RangeMap> createCustomToUnicodeMap ();
protected:
diff --git a/dviware/dvisvgm/src/FontManager.cpp b/dviware/dvisvgm/src/FontManager.cpp
index 929e9f823b..a41b8563b8 100644
--- a/dviware/dvisvgm/src/FontManager.cpp
+++ b/dviware/dvisvgm/src/FontManager.cpp
@@ -2,7 +2,7 @@
** FontManager.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 **
@@ -221,16 +221,14 @@ int FontManager::registerFont (uint32_t fontnum, const string &name, uint32_t ch
}
_name2id[name] = newid;
}
- _fonts.emplace_back(std::move(newfont));
+ _fonts.push_back(std::move(newfont));
if (_vfStack.empty()) // register font referenced in dvi file?
_num2id[fontnum] = newid;
else { // register font referenced in vf file
const VirtualFont *vf = _vfStack.top();
_vfnum2id[vf][fontnum] = newid;
- if (_vfFirstFontNumMap.find(vf) == _vfFirstFontNumMap.end()) { // first fontdef of VF?
- _vfFirstFontNumMap.emplace(vf, fontnum);
- _vfFirstFontMap.emplace(vf, _fonts.back().get());
- }
+ _vfFirstFontNumMap.emplace(vf, fontnum);
+ _vfFirstFontMap.emplace(vf, _fonts.back().get());
}
return newid;
}
@@ -269,7 +267,7 @@ int FontManager::registerFont (uint32_t fontnum, string filename, int fontIndex,
const int newid = _fonts.size(); // the new font gets this ID
auto it = _name2id.find(fontname);
if (it != _name2id.end()) { // font with same name already registered?
- if (auto font = dynamic_cast<NativeFont*>(_fonts[it->second].get()))
+ if (auto font = font_cast<NativeFont*>(_fonts[it->second].get()))
newfont = font->clone(ptsize, style, color);
}
else {
@@ -291,7 +289,7 @@ int FontManager::registerFont (uint32_t fontnum, string filename, int fontIndex,
}
_name2id[fontname] = newid;
}
- _fonts.emplace_back(std::move(newfont));
+ _fonts.push_back(std::move(newfont));
_num2id[fontnum] = newid;
return newid;
}
@@ -330,7 +328,7 @@ ostream& FontManager::write (ostream &os, Font *font, int level) {
if (_fonts[i] == font)
id = i;
- VirtualFont *vf = dynamic_cast<VirtualFont*>(font);
+ VirtualFont *vf = font_cast<VirtualFont*>(font);
for (int j=0; j < level+1; j++)
os << " ";
os << "id " << id
diff --git a/dviware/dvisvgm/src/FontManager.hpp b/dviware/dvisvgm/src/FontManager.hpp
index 321e167b11..413b649169 100644
--- a/dviware/dvisvgm/src/FontManager.hpp
+++ b/dviware/dvisvgm/src/FontManager.hpp
@@ -2,7 +2,7 @@
** FontManager.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FontMap.cpp b/dviware/dvisvgm/src/FontMap.cpp
index 6be5fe6690..a16d38aa2f 100644
--- a/dviware/dvisvgm/src/FontMap.cpp
+++ b/dviware/dvisvgm/src/FontMap.cpp
@@ -2,7 +2,7 @@
** FontMap.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 **
diff --git a/dviware/dvisvgm/src/FontMap.hpp b/dviware/dvisvgm/src/FontMap.hpp
index f4824aa7f1..8ed6519922 100644
--- a/dviware/dvisvgm/src/FontMap.hpp
+++ b/dviware/dvisvgm/src/FontMap.hpp
@@ -2,7 +2,7 @@
** FontMap.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FontMetrics.cpp b/dviware/dvisvgm/src/FontMetrics.cpp
index 7d858fea90..b2cba24818 100644
--- a/dviware/dvisvgm/src/FontMetrics.cpp
+++ b/dviware/dvisvgm/src/FontMetrics.cpp
@@ -2,7 +2,7 @@
** FontMetrics.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 **
diff --git a/dviware/dvisvgm/src/FontMetrics.hpp b/dviware/dvisvgm/src/FontMetrics.hpp
index 66637e3044..20a2d46be0 100644
--- a/dviware/dvisvgm/src/FontMetrics.hpp
+++ b/dviware/dvisvgm/src/FontMetrics.hpp
@@ -2,7 +2,7 @@
** FontMetrics.hpp **
** **
** 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 **
@@ -43,6 +43,7 @@ struct FontMetrics {
virtual uint32_t getChecksum () const =0;
virtual uint16_t firstChar () const =0;
virtual uint16_t lastChar () const =0;
+ virtual bool isJFM () const {return false;}
static std::unique_ptr<FontMetrics> read (const std::string &fontname);
};
diff --git a/dviware/dvisvgm/src/FontStyle.hpp b/dviware/dvisvgm/src/FontStyle.hpp
index 79a03dac36..094ba2da1f 100644
--- a/dviware/dvisvgm/src/FontStyle.hpp
+++ b/dviware/dvisvgm/src/FontStyle.hpp
@@ -2,7 +2,7 @@
** FontStyle.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/FontWriter.cpp b/dviware/dvisvgm/src/FontWriter.cpp
index 4dd4c5c0d8..ccd4d037f5 100644
--- a/dviware/dvisvgm/src/FontWriter.cpp
+++ b/dviware/dvisvgm/src/FontWriter.cpp
@@ -2,7 +2,7 @@
** FontWriter.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 **
@@ -59,7 +59,7 @@ const FontWriter::FontFormatInfo* FontWriter::fontFormatInfo (FontFormat format)
vector<string> FontWriter::supportedFormats () {
vector<string> formats;
for (const FontFormatInfo &info : _formatInfos)
- formats.emplace_back(info.formatstr_short);
+ formats.push_back(info.formatstr_short);
return formats;
}
diff --git a/dviware/dvisvgm/src/FontWriter.hpp b/dviware/dvisvgm/src/FontWriter.hpp
index e6cad37e88..1fa5dab4db 100644
--- a/dviware/dvisvgm/src/FontWriter.hpp
+++ b/dviware/dvisvgm/src/FontWriter.hpp
@@ -2,7 +2,7 @@
** FontWriter.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/GFGlyphTracer.cpp b/dviware/dvisvgm/src/GFGlyphTracer.cpp
index db77ae1dc8..8c346b0464 100644
--- a/dviware/dvisvgm/src/GFGlyphTracer.cpp
+++ b/dviware/dvisvgm/src/GFGlyphTracer.cpp
@@ -2,7 +2,7 @@
** GFGlyphTracer.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 **
@@ -25,7 +25,7 @@ using namespace std;
/** Constructs a new glyph tracer.
* @param[in] is GF input stream
* @param[in] upp target units per PS point */
-GFGlyphTracer::GFGlyphTracer (string &fname, double upp, Callback *cb)
+GFGlyphTracer::GFGlyphTracer (const string &fname, double upp, Callback *cb)
: GFTracer(_ifs, upp), _callback(cb)
{
if (_callback)
@@ -34,7 +34,7 @@ GFGlyphTracer::GFGlyphTracer (string &fname, double upp, Callback *cb)
}
-void GFGlyphTracer::reset (string &fname, double upp) {
+void GFGlyphTracer::reset (const string &fname, double upp) {
if (_callback)
_callback->setFont(fname);
if (_ifs.is_open())
diff --git a/dviware/dvisvgm/src/GFGlyphTracer.hpp b/dviware/dvisvgm/src/GFGlyphTracer.hpp
index d0d45ffd61..21ff3178fc 100644
--- a/dviware/dvisvgm/src/GFGlyphTracer.hpp
+++ b/dviware/dvisvgm/src/GFGlyphTracer.hpp
@@ -2,7 +2,7 @@
** GFGlyphTracer.hpp **
** **
** 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 **
@@ -38,8 +38,8 @@ class GFGlyphTracer : public GFTracer {
public:
GFGlyphTracer () : GFTracer(_ifs, 0) {}
- GFGlyphTracer (std::string &fname, double upp, Callback *cb=nullptr);
- void reset (std::string &fname, double upp);
+ GFGlyphTracer (const std::string &fname, double upp, Callback *cb=nullptr);
+ void reset (const std::string &fname, double upp);
void setCallback (Callback *cb) {_callback = cb;}
bool executeChar (uint8_t c) override;
void moveTo (double x, double y) override;
diff --git a/dviware/dvisvgm/src/GFReader.cpp b/dviware/dvisvgm/src/GFReader.cpp
index 4712de41d3..fba6e665de 100644
--- a/dviware/dvisvgm/src/GFReader.cpp
+++ b/dviware/dvisvgm/src/GFReader.cpp
@@ -2,7 +2,7 @@
** GFReader.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 **
@@ -92,7 +92,7 @@ int GFReader::executeCommand () {
if (opcode < 0) // at end of file?
throw GFException("unexpected end of file");
- if (opcode >= 0 && opcode <= 63)
+ if (opcode <= 63)
cmdPaint0(opcode);
else if (opcode >= 74 && opcode <= 238)
cmdNewRow(opcode-74);
diff --git a/dviware/dvisvgm/src/GFReader.hpp b/dviware/dvisvgm/src/GFReader.hpp
index e829bf8ffa..401f89babb 100644
--- a/dviware/dvisvgm/src/GFReader.hpp
+++ b/dviware/dvisvgm/src/GFReader.hpp
@@ -2,7 +2,7 @@
** GFReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/GFTracer.cpp b/dviware/dvisvgm/src/GFTracer.cpp
index 4a3fa5e776..408fb49d0b 100644
--- a/dviware/dvisvgm/src/GFTracer.cpp
+++ b/dviware/dvisvgm/src/GFTracer.cpp
@@ -2,7 +2,7 @@
** GFTracer.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 **
diff --git a/dviware/dvisvgm/src/GFTracer.hpp b/dviware/dvisvgm/src/GFTracer.hpp
index e72848896d..f52ffd6cc8 100644
--- a/dviware/dvisvgm/src/GFTracer.hpp
+++ b/dviware/dvisvgm/src/GFTracer.hpp
@@ -2,7 +2,7 @@
** GFTracer.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Ghostscript.cpp b/dviware/dvisvgm/src/Ghostscript.cpp
index 11ea79fc1a..96b06b1b68 100644
--- a/dviware/dvisvgm/src/Ghostscript.cpp
+++ b/dviware/dvisvgm/src/Ghostscript.cpp
@@ -2,7 +2,7 @@
** Ghostscript.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 **
@@ -215,7 +215,7 @@ bool Ghostscript::available () {
/** Retrieves version information about Ghostscript.
* @param[out] r takes the revision information (see GS API documentation for further details)
* @return true on success */
-bool Ghostscript::revision (gsapi_revision_t *r) {
+bool Ghostscript::revision (gsapi_revision_t *r) const {
#if defined(HAVE_LIBGS)
return (gsapi_revision(r, sizeof(gsapi_revision_t)) == 0);
#else
@@ -227,7 +227,7 @@ bool Ghostscript::revision (gsapi_revision_t *r) {
/** Returns the revision number of the GS library. */
-int Ghostscript::revision () {
+int Ghostscript::revision () const {
gsapi_revision_t r;
if (revision(&r))
return static_cast<int>(r.revision);
diff --git a/dviware/dvisvgm/src/Ghostscript.hpp b/dviware/dvisvgm/src/Ghostscript.hpp
index 8c9a429798..88bebf01ea 100644
--- a/dviware/dvisvgm/src/Ghostscript.hpp
+++ b/dviware/dvisvgm/src/Ghostscript.hpp
@@ -2,7 +2,7 @@
** Ghostscript.hpp **
** **
** 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 **
@@ -78,8 +78,8 @@ class Ghostscript
~Ghostscript ();
bool init (int argc, const char **argv, void *caller=nullptr);
bool available ();
- bool revision (gsapi_revision_t *r);
- int revision ();
+ bool revision (gsapi_revision_t *r) const;
+ int revision () const;
std::string revisionstr ();
int set_stdio (Stdin in, Stdout out, Stderr err);
int run_string_begin (int user_errors, int *pexit_code);
diff --git a/dviware/dvisvgm/src/Glyph.hpp b/dviware/dvisvgm/src/Glyph.hpp
index dfa8cb366a..37de9bd58c 100644
--- a/dviware/dvisvgm/src/Glyph.hpp
+++ b/dviware/dvisvgm/src/Glyph.hpp
@@ -2,7 +2,7 @@
** Glyph.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/GlyphTracerMessages.hpp b/dviware/dvisvgm/src/GlyphTracerMessages.hpp
index f291d05ccc..32f4f08955 100644
--- a/dviware/dvisvgm/src/GlyphTracerMessages.hpp
+++ b/dviware/dvisvgm/src/GlyphTracerMessages.hpp
@@ -2,7 +2,7 @@
** GlyphTracerMessages.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/GraphicsPath.hpp b/dviware/dvisvgm/src/GraphicsPath.hpp
index 64c112ad0b..a0c9f8ab8f 100644
--- a/dviware/dvisvgm/src/GraphicsPath.hpp
+++ b/dviware/dvisvgm/src/GraphicsPath.hpp
@@ -2,7 +2,7 @@
** GraphicsPath.hpp **
** **
** 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,6 +20,7 @@
#pragma once
+#include <algorithm>
#include <array>
#include <cctype>
#include <cmath>
@@ -662,24 +663,14 @@ class GraphicsPath {
bool operator == (const GraphicsPath &path) const {
if (size() != path.size())
return false;
- auto it = _commands.begin();
- for (const auto &cmd : path._commands) {
- if (*it++ != cmd)
- return false;
- }
- return true;
+ return std::equal(_commands.begin(), _commands.end(), path._commands.begin());
}
/** Returns true if this path differs from another one (command-wise). */
bool operator != (const GraphicsPath &path) const {
if (size() != path.size())
return true;
- auto it = _commands.begin();
- for (const auto &cmd : path._commands) {
- if (*it++ != cmd)
- return true;
- }
- return false;
+ return !std::equal(_commands.begin(), _commands.end(), path._commands.begin());
}
/** Iterates over all commands defining this path and calls the corresponding template methods.
diff --git a/dviware/dvisvgm/src/HashFunction.cpp b/dviware/dvisvgm/src/HashFunction.cpp
index 16661fb3d6..bada148b6c 100644
--- a/dviware/dvisvgm/src/HashFunction.cpp
+++ b/dviware/dvisvgm/src/HashFunction.cpp
@@ -2,7 +2,7 @@
** HashFunction.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 **
diff --git a/dviware/dvisvgm/src/HashFunction.hpp b/dviware/dvisvgm/src/HashFunction.hpp
index e31040075e..5efbdf8468 100644
--- a/dviware/dvisvgm/src/HashFunction.hpp
+++ b/dviware/dvisvgm/src/HashFunction.hpp
@@ -2,7 +2,7 @@
** HashFunction.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/HtmlSpecialHandler.cpp b/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
index 01051f9d64..dca8111405 100644
--- a/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
@@ -2,7 +2,7 @@
** HtmlSpecialHandler.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 **
diff --git a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
index e09a6d7b51..2122ed749d 100644
--- a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
@@ -2,7 +2,7 @@
** HtmlSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/HyperlinkManager.cpp b/dviware/dvisvgm/src/HyperlinkManager.cpp
index ef636c5aac..f991e13145 100644
--- a/dviware/dvisvgm/src/HyperlinkManager.cpp
+++ b/dviware/dvisvgm/src/HyperlinkManager.cpp
@@ -2,7 +2,7 @@
** HyperlinkManager.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 **
@@ -106,7 +106,7 @@ void HyperlinkManager::createLink (string uri, SpecialActions &actions) {
uri = "/" + uri;
uri = _base + uri;
}
- auto anchorNode = util::make_unique<XMLElement>("a");
+ auto anchorNode = util::make_unique<SVGElement>("a");
anchorNode->addAttribute("xlink:href", uri);
anchorNode->addAttribute("xlink:title", XMLString(name.empty() ? uri : name, false));
actions.svgTree().pushPageContext(std::move(anchorNode));
@@ -148,14 +148,14 @@ void HyperlinkManager::markLinkedBox (SpecialActions &actions) {
if (bbox.width() > 0 && bbox.height() > 0) { // does the bounding box extend in both dimensions?
if (MARKER_TYPE != MarkerType::NONE) {
const double linewidth = _linewidth >= 0 ? _linewidth : min(0.5, bbox.height()/15);
- auto rect = util::make_unique<XMLElement>("rect");
+ auto rect = util::make_unique<SVGElement>("rect");
double x = bbox.minX();
double y = bbox.maxY()+linewidth;
double w = bbox.width();
double h = linewidth;
const Color linecolor = COLORSOURCE == ColorSource::DEFAULT ? actions.getColor() : LINK_LINECOLOR;
if (MARKER_TYPE == MarkerType::LINE)
- rect->addAttribute("fill", linecolor.svgColorString());
+ rect->setFillColor(linecolor);
else {
const double offset = _linewidth < 0 ? linewidth : 0 ;
x -= offset;
@@ -163,16 +163,16 @@ void HyperlinkManager::markLinkedBox (SpecialActions &actions) {
w += 2*offset;
h += bbox.height()+offset;
if (MARKER_TYPE == MarkerType::BGCOLOR) {
- rect->addAttribute("fill", LINK_BGCOLOR.svgColorString());
+ rect->setFillColor(LINK_BGCOLOR);
if (COLORSOURCE != ColorSource::DEFAULT) {
- rect->addAttribute("stroke", linecolor.svgColorString());
- rect->addAttribute("stroke-width", linewidth);
+ rect->setStrokeColor(linecolor);
+ rect->setStrokeWidth(linewidth);
}
}
else { // LM_BOX
- rect->addAttribute("fill", "none");
- rect->addAttribute("stroke", linecolor.svgColorString());
- rect->addAttribute("stroke-width", linewidth);
+ rect->setNoFillColor();
+ rect->setStrokeColor(linecolor);
+ rect->setStrokeWidth(linewidth);
}
}
rect->addAttribute("x", x);
@@ -192,13 +192,13 @@ void HyperlinkManager::markLinkedBox (SpecialActions &actions) {
// Create an invisible rectangle around the linked area so that it's easier to access.
// This is only necessary when using paths rather than real text elements together with fonts.
if (!SVGTree::USE_FONTS) {
- auto rect = util::make_unique<XMLElement>("rect");
+ auto rect = util::make_unique<SVGElement>("rect");
rect->addAttribute("x", bbox.minX());
rect->addAttribute("y", bbox.minY());
rect->addAttribute("width", bbox.width());
rect->addAttribute("height", bbox.height());
- rect->addAttribute("fill", "white");
- rect->addAttribute("fill-opacity", 0);
+ rect->setFillColor(Color::WHITE);
+ rect->setFillOpacity(OpacityAlpha(0, 0));
actions.svgTree().appendToPage(std::move(rect));
}
}
diff --git a/dviware/dvisvgm/src/HyperlinkManager.hpp b/dviware/dvisvgm/src/HyperlinkManager.hpp
index ca8d4fd0ef..9dfbb02532 100644
--- a/dviware/dvisvgm/src/HyperlinkManager.hpp
+++ b/dviware/dvisvgm/src/HyperlinkManager.hpp
@@ -2,7 +2,7 @@
** HyperlinkManager.hpp **
** **
** 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 **
@@ -52,7 +52,7 @@ class HyperlinkManager {
void checkNewLine (SpecialActions &actions);
void createLink (std::string uri, SpecialActions &actions);
void createViews (unsigned pageno, SpecialActions &actions);
- void setBaseUrl (std::string &base) {_base = base;}
+ void setBaseUrl (const std::string &base) {_base = base;}
void setLineWidth (double w) {_linewidth = w;}
static HyperlinkManager& instance ();
static bool setLinkMarker (const std::string &marker);
diff --git a/dviware/dvisvgm/src/ImageToSVG.cpp b/dviware/dvisvgm/src/ImageToSVG.cpp
index dfb7943a06..6c52a0b826 100644
--- a/dviware/dvisvgm/src/ImageToSVG.cpp
+++ b/dviware/dvisvgm/src/ImageToSVG.cpp
@@ -2,7 +2,7 @@
** ImageToSVG.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 **
diff --git a/dviware/dvisvgm/src/ImageToSVG.hpp b/dviware/dvisvgm/src/ImageToSVG.hpp
index 92a860949c..04d86751eb 100644
--- a/dviware/dvisvgm/src/ImageToSVG.hpp
+++ b/dviware/dvisvgm/src/ImageToSVG.hpp
@@ -2,7 +2,7 @@
** ImageToSVG.hpp **
** **
** 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 **
@@ -57,9 +57,11 @@ class ImageToSVG : protected SpecialActions {
void setY (double y) override {_y = y; _svg.setY(y);}
void finishLine () override {}
void setColor (const Color &color) override {_svg.setColor(color);}
+ void setOpacity (const Opacity &opacity) override {_svg.setOpacity(opacity);}
Color getColor () const override {return _svg.getColor();}
void setMatrix (const Matrix &m) override {_svg.setMatrix(m);}
const Matrix& getMatrix () const override {return _svg.getMatrix();}
+ const Opacity& getOpacity () const override {return _svg.getOpacity();}
const SVGTree& svgTree () const override {return _svg;}
void setBgColor (const Color &color) override {}
void embed (const BoundingBox &bbox) override {_bbox.embed(bbox);}
diff --git a/dviware/dvisvgm/src/InputBuffer.cpp b/dviware/dvisvgm/src/InputBuffer.cpp
index b6e85f27e1..6ee562da7d 100644
--- a/dviware/dvisvgm/src/InputBuffer.cpp
+++ b/dviware/dvisvgm/src/InputBuffer.cpp
@@ -2,7 +2,7 @@
** InputBuffer.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 **
diff --git a/dviware/dvisvgm/src/InputBuffer.hpp b/dviware/dvisvgm/src/InputBuffer.hpp
index 1474ce0a52..a59cdc31c9 100644
--- a/dviware/dvisvgm/src/InputBuffer.hpp
+++ b/dviware/dvisvgm/src/InputBuffer.hpp
@@ -2,7 +2,7 @@
** InputBuffer.hpp **
** **
** 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 **
@@ -40,12 +40,14 @@ struct InputBuffer {
class StreamInputBuffer : public InputBuffer {
public:
explicit StreamInputBuffer (std::istream &is, size_t bufsize=1024);
+ StreamInputBuffer (const StreamInputBuffer &ib) =delete;
~StreamInputBuffer () override;
int get () override;
int peek () const override;
int peek (size_t n) const override;
bool eof () const override {return pos() == _size1 && _size2 == 0;}
void invalidate () override {_bufptr = _buf1+_size1; _size2 = 0;}
+ void operator = (const StreamInputBuffer &ib) =delete;
protected:
int fillBuffer (uint8_t *buf);
@@ -65,6 +67,7 @@ class StreamInputBuffer : public InputBuffer {
class StringInputBuffer : public InputBuffer {
public:
explicit StringInputBuffer (const std::string &str) : _str(&str) {}
+ StringInputBuffer (const StreamInputBuffer &ib) =delete;
void assign (const std::string &str) {_str = &str; _pos=0;}
int get () override {return _pos < _str->length() ? _str->at(_pos++) : -1;}
int peek () const override {return _pos < _str->length() ? _str->at(_pos) : -1;}
@@ -81,6 +84,7 @@ class StringInputBuffer : public InputBuffer {
class CharInputBuffer : public InputBuffer {
public:
CharInputBuffer (const char *buf, size_t size) : _pos(buf), _size(buf ? size : 0) {}
+ CharInputBuffer (const CharInputBuffer &ib) =delete;
int get () override {
if (_size == 0)
@@ -112,6 +116,7 @@ class CharInputBuffer : public InputBuffer {
class SplittedCharInputBuffer : public InputBuffer {
public:
SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2);
+ SplittedCharInputBuffer (const SplittedCharInputBuffer &ib) =delete;
int get () override;
int peek () const override;
int peek (size_t n) const override;
diff --git a/dviware/dvisvgm/src/InputReader.cpp b/dviware/dvisvgm/src/InputReader.cpp
index 074c184822..6b5a7b70f0 100644
--- a/dviware/dvisvgm/src/InputReader.cpp
+++ b/dviware/dvisvgm/src/InputReader.cpp
@@ -2,7 +2,7 @@
** InputReader.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 **
diff --git a/dviware/dvisvgm/src/InputReader.hpp b/dviware/dvisvgm/src/InputReader.hpp
index 9825156c09..d9b697963b 100644
--- a/dviware/dvisvgm/src/InputReader.hpp
+++ b/dviware/dvisvgm/src/InputReader.hpp
@@ -2,7 +2,7 @@
** InputReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/JFM.cpp b/dviware/dvisvgm/src/JFM.cpp
index 7c749fd34e..d0dd13c9b9 100644
--- a/dviware/dvisvgm/src/JFM.cpp
+++ b/dviware/dvisvgm/src/JFM.cpp
@@ -2,7 +2,7 @@
** JFM.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 **
diff --git a/dviware/dvisvgm/src/JFM.hpp b/dviware/dvisvgm/src/JFM.hpp
index 8d4a1daf21..29da9d53c3 100644
--- a/dviware/dvisvgm/src/JFM.hpp
+++ b/dviware/dvisvgm/src/JFM.hpp
@@ -2,7 +2,7 @@
** JFM.hpp **
** **
** 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 **
@@ -29,6 +29,7 @@ class JFM : public TFM {
public:
explicit JFM (std::istream &is);
bool verticalLayout () const override {return _vertical;}
+ bool isJFM () const override {return true;}
uint32_t minChar () const {return _minchar;}
uint32_t maxChar () const {return static_cast<uint32_t>(_minchar+_charTypeTable.size()-1);}
diff --git a/dviware/dvisvgm/src/Length.cpp b/dviware/dvisvgm/src/Length.cpp
index d20af5056c..d4992c77ef 100644
--- a/dviware/dvisvgm/src/Length.cpp
+++ b/dviware/dvisvgm/src/Length.cpp
@@ -2,7 +2,7 @@
** Length.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 **
diff --git a/dviware/dvisvgm/src/Length.hpp b/dviware/dvisvgm/src/Length.hpp
index 1b0d35d35f..f03711ecd2 100644
--- a/dviware/dvisvgm/src/Length.hpp
+++ b/dviware/dvisvgm/src/Length.hpp
@@ -2,7 +2,7 @@
** Length.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/MD5HashFunction.hpp b/dviware/dvisvgm/src/MD5HashFunction.hpp
index 27539576ed..e34db10602 100644
--- a/dviware/dvisvgm/src/MD5HashFunction.hpp
+++ b/dviware/dvisvgm/src/MD5HashFunction.hpp
@@ -2,7 +2,7 @@
** MD5HashFunction.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Makefile.am b/dviware/dvisvgm/src/Makefile.am
index e7c7c27522..3163e892a8 100644
--- a/dviware/dvisvgm/src/Makefile.am
+++ b/dviware/dvisvgm/src/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
@@ -104,6 +104,7 @@ libdvisvgm_la_SOURCES = \
MetafontWrapper.hpp MetafontWrapper.cpp \
NoPsSpecialHandler.hpp NoPsSpecialHandler.cpp \
NumericRanges.hpp \
+ Opacity.hpp Opacity.cpp \
PageRanges.hpp PageRanges.cpp \
PageSize.hpp PageSize.cpp \
Pair.hpp \
@@ -134,6 +135,7 @@ libdvisvgm_la_SOURCES = \
SVGCharHandlerFactory.hpp SVGCharHandlerFactory.cpp \
SVGCharPathHandler.hpp SVGCharPathHandler.cpp \
SVGCharTspanTextHandler.hpp SVGCharTspanTextHandler.cpp \
+ SVGElement.hpp SVGElement.cpp \
SVGOutput.hpp SVGOutput.cpp \
SVGSingleCharTextHandler.hpp SVGSingleCharTextHandler.cpp \
SVGTree.hpp SVGTree.cpp \
diff --git a/dviware/dvisvgm/src/Makefile.in b/dviware/dvisvgm/src/Makefile.in
index b327bda7ac..0ef19f52c2 100644
--- a/dviware/dvisvgm/src/Makefile.in
+++ b/dviware/dvisvgm/src/Makefile.in
@@ -163,29 +163,30 @@ am__libdvisvgm_la_SOURCES_DIST = AGLTable.hpp BasicDVIReader.hpp \
MD5HashFunction.hpp Message.hpp Message.cpp \
MessageException.hpp MetafontWrapper.hpp MetafontWrapper.cpp \
NoPsSpecialHandler.hpp NoPsSpecialHandler.cpp \
- NumericRanges.hpp PageRanges.hpp PageRanges.cpp PageSize.hpp \
- PageSize.cpp Pair.hpp PapersizeSpecialHandler.hpp \
- PapersizeSpecialHandler.cpp PathClipper.hpp PathClipper.cpp \
- PDFParser.hpp PDFParser.cpp PdfSpecialHandler.hpp \
- PdfSpecialHandler.cpp PDFToSVG.hpp PreScanDVIReader.hpp \
- PreScanDVIReader.cpp Process.hpp Process.cpp psdefs.cpp \
- PSFilter.hpp PSInterpreter.hpp PSInterpreter.cpp PSPattern.hpp \
- PSPattern.cpp PSPreviewFilter.hpp PSPreviewFilter.cpp \
- PsSpecialHandler.hpp PsSpecialHandler.cpp RangeMap.hpp \
- RangeMap.cpp ShadingPatch.hpp ShadingPatch.cpp \
- SignalHandler.hpp SignalHandler.cpp SourceInput.hpp \
- SourceInput.cpp SpecialActions.hpp SpecialHandler.hpp \
- SpecialManager.hpp SpecialManager.cpp StreamReader.hpp \
- StreamReader.cpp StreamWriter.hpp StreamWriter.cpp Subfont.hpp \
- Subfont.cpp SVGCharHandler.hpp SVGCharHandler.cpp \
+ NumericRanges.hpp Opacity.hpp Opacity.cpp PageRanges.hpp \
+ PageRanges.cpp PageSize.hpp PageSize.cpp Pair.hpp \
+ PapersizeSpecialHandler.hpp PapersizeSpecialHandler.cpp \
+ PathClipper.hpp PathClipper.cpp PDFParser.hpp PDFParser.cpp \
+ PdfSpecialHandler.hpp PdfSpecialHandler.cpp PDFToSVG.hpp \
+ PreScanDVIReader.hpp PreScanDVIReader.cpp Process.hpp \
+ Process.cpp psdefs.cpp PSFilter.hpp PSInterpreter.hpp \
+ PSInterpreter.cpp PSPattern.hpp PSPattern.cpp \
+ PSPreviewFilter.hpp PSPreviewFilter.cpp PsSpecialHandler.hpp \
+ PsSpecialHandler.cpp RangeMap.hpp RangeMap.cpp \
+ ShadingPatch.hpp ShadingPatch.cpp SignalHandler.hpp \
+ SignalHandler.cpp SourceInput.hpp SourceInput.cpp \
+ SpecialActions.hpp SpecialHandler.hpp SpecialManager.hpp \
+ SpecialManager.cpp StreamReader.hpp StreamReader.cpp \
+ StreamWriter.hpp StreamWriter.cpp Subfont.hpp Subfont.cpp \
+ SVGCharHandler.hpp SVGCharHandler.cpp \
SVGCharHandlerFactory.hpp SVGCharHandlerFactory.cpp \
SVGCharPathHandler.hpp SVGCharPathHandler.cpp \
SVGCharTspanTextHandler.hpp SVGCharTspanTextHandler.cpp \
- SVGOutput.hpp SVGOutput.cpp SVGSingleCharTextHandler.hpp \
- SVGSingleCharTextHandler.cpp SVGTree.hpp SVGTree.cpp \
- System.hpp System.cpp TensorProductPatch.hpp \
- TensorProductPatch.cpp Terminal.hpp Terminal.cpp TFM.hpp \
- TFM.cpp ToUnicodeMap.hpp ToUnicodeMap.cpp \
+ SVGElement.hpp SVGElement.cpp SVGOutput.hpp SVGOutput.cpp \
+ SVGSingleCharTextHandler.hpp SVGSingleCharTextHandler.cpp \
+ SVGTree.hpp SVGTree.cpp System.hpp System.cpp \
+ TensorProductPatch.hpp TensorProductPatch.cpp Terminal.hpp \
+ Terminal.cpp TFM.hpp TFM.cpp ToUnicodeMap.hpp ToUnicodeMap.cpp \
TpicSpecialHandler.hpp TpicSpecialHandler.cpp \
TriangularPatch.hpp TriangularPatch.cpp TrueTypeFont.hpp \
TrueTypeFont.cpp TTFAutohint.hpp TTFAutohint.cpp Unicode.hpp \
@@ -208,7 +209,7 @@ am_libdvisvgm_la_OBJECTS = BasicDVIReader.lo Bezier.lo \
Ghostscript.lo HashFunction.lo HtmlSpecialHandler.lo \
HyperlinkManager.lo ImageToSVG.lo InputBuffer.lo \
InputReader.lo JFM.lo Length.lo MapLine.lo Matrix.lo \
- Message.lo MetafontWrapper.lo NoPsSpecialHandler.lo \
+ Message.lo MetafontWrapper.lo NoPsSpecialHandler.lo Opacity.lo \
PageRanges.lo PageSize.lo PapersizeSpecialHandler.lo \
PathClipper.lo PDFParser.lo PdfSpecialHandler.lo \
PreScanDVIReader.lo Process.lo psdefs.lo PSInterpreter.lo \
@@ -216,8 +217,8 @@ am_libdvisvgm_la_OBJECTS = BasicDVIReader.lo Bezier.lo \
RangeMap.lo ShadingPatch.lo SignalHandler.lo SourceInput.lo \
SpecialManager.lo StreamReader.lo StreamWriter.lo Subfont.lo \
SVGCharHandler.lo SVGCharHandlerFactory.lo \
- SVGCharPathHandler.lo SVGCharTspanTextHandler.lo SVGOutput.lo \
- SVGSingleCharTextHandler.lo SVGTree.lo System.lo \
+ SVGCharPathHandler.lo SVGCharTspanTextHandler.lo SVGElement.lo \
+ SVGOutput.lo SVGSingleCharTextHandler.lo SVGTree.lo System.lo \
TensorProductPatch.lo Terminal.lo TFM.lo ToUnicodeMap.lo \
TpicSpecialHandler.lo TriangularPatch.lo TrueTypeFont.lo \
TTFAutohint.lo Unicode.lo utility.lo VFReader.lo \
@@ -277,10 +278,10 @@ am__depfiles_remade = ./$(DEPDIR)/BasicDVIReader.Plo \
./$(DEPDIR)/JFM.Plo ./$(DEPDIR)/Length.Plo \
./$(DEPDIR)/MapLine.Plo ./$(DEPDIR)/Matrix.Plo \
./$(DEPDIR)/Message.Plo ./$(DEPDIR)/MetafontWrapper.Plo \
- ./$(DEPDIR)/NoPsSpecialHandler.Plo ./$(DEPDIR)/PDFParser.Plo \
- ./$(DEPDIR)/PSInterpreter.Plo ./$(DEPDIR)/PSPattern.Plo \
- ./$(DEPDIR)/PSPreviewFilter.Plo ./$(DEPDIR)/PageRanges.Plo \
- ./$(DEPDIR)/PageSize.Plo \
+ ./$(DEPDIR)/NoPsSpecialHandler.Plo ./$(DEPDIR)/Opacity.Plo \
+ ./$(DEPDIR)/PDFParser.Plo ./$(DEPDIR)/PSInterpreter.Plo \
+ ./$(DEPDIR)/PSPattern.Plo ./$(DEPDIR)/PSPreviewFilter.Plo \
+ ./$(DEPDIR)/PageRanges.Plo ./$(DEPDIR)/PageSize.Plo \
./$(DEPDIR)/PapersizeSpecialHandler.Plo \
./$(DEPDIR)/PathClipper.Plo ./$(DEPDIR)/PdfSpecialHandler.Plo \
./$(DEPDIR)/PreScanDVIReader.Plo ./$(DEPDIR)/Process.Plo \
@@ -289,7 +290,7 @@ am__depfiles_remade = ./$(DEPDIR)/BasicDVIReader.Plo \
./$(DEPDIR)/SVGCharHandlerFactory.Plo \
./$(DEPDIR)/SVGCharPathHandler.Plo \
./$(DEPDIR)/SVGCharTspanTextHandler.Plo \
- ./$(DEPDIR)/SVGOutput.Plo \
+ ./$(DEPDIR)/SVGElement.Plo ./$(DEPDIR)/SVGOutput.Plo \
./$(DEPDIR)/SVGSingleCharTextHandler.Plo \
./$(DEPDIR)/SVGTree.Plo ./$(DEPDIR)/ShadingPatch.Plo \
./$(DEPDIR)/SignalHandler.Plo ./$(DEPDIR)/SourceInput.Plo \
@@ -559,6 +560,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -618,29 +620,30 @@ libdvisvgm_la_SOURCES = AGLTable.hpp BasicDVIReader.hpp \
MD5HashFunction.hpp Message.hpp Message.cpp \
MessageException.hpp MetafontWrapper.hpp MetafontWrapper.cpp \
NoPsSpecialHandler.hpp NoPsSpecialHandler.cpp \
- NumericRanges.hpp PageRanges.hpp PageRanges.cpp PageSize.hpp \
- PageSize.cpp Pair.hpp PapersizeSpecialHandler.hpp \
- PapersizeSpecialHandler.cpp PathClipper.hpp PathClipper.cpp \
- PDFParser.hpp PDFParser.cpp PdfSpecialHandler.hpp \
- PdfSpecialHandler.cpp PDFToSVG.hpp PreScanDVIReader.hpp \
- PreScanDVIReader.cpp Process.hpp Process.cpp psdefs.cpp \
- PSFilter.hpp PSInterpreter.hpp PSInterpreter.cpp PSPattern.hpp \
- PSPattern.cpp PSPreviewFilter.hpp PSPreviewFilter.cpp \
- PsSpecialHandler.hpp PsSpecialHandler.cpp RangeMap.hpp \
- RangeMap.cpp ShadingPatch.hpp ShadingPatch.cpp \
- SignalHandler.hpp SignalHandler.cpp SourceInput.hpp \
- SourceInput.cpp SpecialActions.hpp SpecialHandler.hpp \
- SpecialManager.hpp SpecialManager.cpp StreamReader.hpp \
- StreamReader.cpp StreamWriter.hpp StreamWriter.cpp Subfont.hpp \
- Subfont.cpp SVGCharHandler.hpp SVGCharHandler.cpp \
+ NumericRanges.hpp Opacity.hpp Opacity.cpp PageRanges.hpp \
+ PageRanges.cpp PageSize.hpp PageSize.cpp Pair.hpp \
+ PapersizeSpecialHandler.hpp PapersizeSpecialHandler.cpp \
+ PathClipper.hpp PathClipper.cpp PDFParser.hpp PDFParser.cpp \
+ PdfSpecialHandler.hpp PdfSpecialHandler.cpp PDFToSVG.hpp \
+ PreScanDVIReader.hpp PreScanDVIReader.cpp Process.hpp \
+ Process.cpp psdefs.cpp PSFilter.hpp PSInterpreter.hpp \
+ PSInterpreter.cpp PSPattern.hpp PSPattern.cpp \
+ PSPreviewFilter.hpp PSPreviewFilter.cpp PsSpecialHandler.hpp \
+ PsSpecialHandler.cpp RangeMap.hpp RangeMap.cpp \
+ ShadingPatch.hpp ShadingPatch.cpp SignalHandler.hpp \
+ SignalHandler.cpp SourceInput.hpp SourceInput.cpp \
+ SpecialActions.hpp SpecialHandler.hpp SpecialManager.hpp \
+ SpecialManager.cpp StreamReader.hpp StreamReader.cpp \
+ StreamWriter.hpp StreamWriter.cpp Subfont.hpp Subfont.cpp \
+ SVGCharHandler.hpp SVGCharHandler.cpp \
SVGCharHandlerFactory.hpp SVGCharHandlerFactory.cpp \
SVGCharPathHandler.hpp SVGCharPathHandler.cpp \
SVGCharTspanTextHandler.hpp SVGCharTspanTextHandler.cpp \
- SVGOutput.hpp SVGOutput.cpp SVGSingleCharTextHandler.hpp \
- SVGSingleCharTextHandler.cpp SVGTree.hpp SVGTree.cpp \
- System.hpp System.cpp TensorProductPatch.hpp \
- TensorProductPatch.cpp Terminal.hpp Terminal.cpp TFM.hpp \
- TFM.cpp ToUnicodeMap.hpp ToUnicodeMap.cpp \
+ SVGElement.hpp SVGElement.cpp SVGOutput.hpp SVGOutput.cpp \
+ SVGSingleCharTextHandler.hpp SVGSingleCharTextHandler.cpp \
+ SVGTree.hpp SVGTree.cpp System.hpp System.cpp \
+ TensorProductPatch.hpp TensorProductPatch.cpp Terminal.hpp \
+ Terminal.cpp TFM.hpp TFM.cpp ToUnicodeMap.hpp ToUnicodeMap.cpp \
TpicSpecialHandler.hpp TpicSpecialHandler.cpp \
TriangularPatch.hpp TriangularPatch.cpp TrueTypeFont.hpp \
TrueTypeFont.cpp TTFAutohint.hpp TTFAutohint.cpp Unicode.hpp \
@@ -821,6 +824,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Message.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetafontWrapper.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NoPsSpecialHandler.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Opacity.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PDFParser.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PSInterpreter.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PSPattern.Plo@am__quote@ # am--include-marker
@@ -838,6 +842,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGCharHandlerFactory.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGCharPathHandler.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGCharTspanTextHandler.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGElement.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGOutput.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGSingleCharTextHandler.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGTree.Plo@am__quote@ # am--include-marker
@@ -1180,6 +1185,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/Message.Plo
-rm -f ./$(DEPDIR)/MetafontWrapper.Plo
-rm -f ./$(DEPDIR)/NoPsSpecialHandler.Plo
+ -rm -f ./$(DEPDIR)/Opacity.Plo
-rm -f ./$(DEPDIR)/PDFParser.Plo
-rm -f ./$(DEPDIR)/PSInterpreter.Plo
-rm -f ./$(DEPDIR)/PSPattern.Plo
@@ -1197,6 +1203,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/SVGCharHandlerFactory.Plo
-rm -f ./$(DEPDIR)/SVGCharPathHandler.Plo
-rm -f ./$(DEPDIR)/SVGCharTspanTextHandler.Plo
+ -rm -f ./$(DEPDIR)/SVGElement.Plo
-rm -f ./$(DEPDIR)/SVGOutput.Plo
-rm -f ./$(DEPDIR)/SVGSingleCharTextHandler.Plo
-rm -f ./$(DEPDIR)/SVGTree.Plo
@@ -1321,6 +1328,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/Message.Plo
-rm -f ./$(DEPDIR)/MetafontWrapper.Plo
-rm -f ./$(DEPDIR)/NoPsSpecialHandler.Plo
+ -rm -f ./$(DEPDIR)/Opacity.Plo
-rm -f ./$(DEPDIR)/PDFParser.Plo
-rm -f ./$(DEPDIR)/PSInterpreter.Plo
-rm -f ./$(DEPDIR)/PSPattern.Plo
@@ -1338,6 +1346,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/SVGCharHandlerFactory.Plo
-rm -f ./$(DEPDIR)/SVGCharPathHandler.Plo
-rm -f ./$(DEPDIR)/SVGCharTspanTextHandler.Plo
+ -rm -f ./$(DEPDIR)/SVGElement.Plo
-rm -f ./$(DEPDIR)/SVGOutput.Plo
-rm -f ./$(DEPDIR)/SVGSingleCharTextHandler.Plo
-rm -f ./$(DEPDIR)/SVGTree.Plo
diff --git a/dviware/dvisvgm/src/MapLine.cpp b/dviware/dvisvgm/src/MapLine.cpp
index cd3d8ae7ea..5b43cd448a 100644
--- a/dviware/dvisvgm/src/MapLine.cpp
+++ b/dviware/dvisvgm/src/MapLine.cpp
@@ -2,7 +2,7 @@
** MapLine.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 **
diff --git a/dviware/dvisvgm/src/MapLine.hpp b/dviware/dvisvgm/src/MapLine.hpp
index 9a6fa17648..2d75665353 100644
--- a/dviware/dvisvgm/src/MapLine.hpp
+++ b/dviware/dvisvgm/src/MapLine.hpp
@@ -2,7 +2,7 @@
** MapLine.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Matrix.cpp b/dviware/dvisvgm/src/Matrix.cpp
index d0dcb2124d..d4c6e19629 100644
--- a/dviware/dvisvgm/src/Matrix.cpp
+++ b/dviware/dvisvgm/src/Matrix.cpp
@@ -2,7 +2,7 @@
** Matrix.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 **
@@ -520,7 +520,7 @@ Matrix Matrix::parseSVGTransform (const string &transform) {
vector<double> params;
if (parse_transform_cmd(iss, "matrix", 6, 6, params)) {
if (ne(params[0], 1) || ne(params[1], 0) || ne(params[2], 0) || ne(params[3], 1) || ne(params[4], 0) || ne(params[5], 0))
- matrix.rmultiply({params[0], params[2], params[4], params[1], params[3], params[5]});
+ matrix.rmultiply(Matrix{params[0], params[2], params[4], params[1], params[3], params[5]});
}
else if (parse_transform_cmd(iss, "rotate", 1, 3, params)) {
if (params.size() == 1) {
diff --git a/dviware/dvisvgm/src/Matrix.hpp b/dviware/dvisvgm/src/Matrix.hpp
index 154ac8a37b..cff7353055 100644
--- a/dviware/dvisvgm/src/Matrix.hpp
+++ b/dviware/dvisvgm/src/Matrix.hpp
@@ -2,7 +2,7 @@
** Matrix.hpp **
** **
** 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 **
@@ -40,11 +40,12 @@ class Matrix {
friend double det (const Matrix &m, int row, int col);
public:
+ Matrix () {set(0);}
+ Matrix (double d);
Matrix (const std::string &cmds, Calculator &calc);
- Matrix (double d=0);
explicit Matrix (const double *v, unsigned size=9);
explicit Matrix (const std::vector<double> &v, int start=0);
- Matrix (std::initializer_list<double> initlist);
+ explicit Matrix (std::initializer_list<double> initlist);
Matrix& set (double d);
Matrix& set (const double *v, unsigned size);
Matrix& set (const std::vector<double> &v, int start=0);
diff --git a/dviware/dvisvgm/src/Message.cpp b/dviware/dvisvgm/src/Message.cpp
index caf8051f88..e829f78e16 100644
--- a/dviware/dvisvgm/src/Message.cpp
+++ b/dviware/dvisvgm/src/Message.cpp
@@ -2,7 +2,7 @@
** Message.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 **
@@ -74,7 +74,7 @@ void MessageStream::putChar (char c, ostream &os) {
_col++;
}
_nl = false;
- if (!_nl || c != '\n')
+ if (c != '\n')
os << c;
}
}
diff --git a/dviware/dvisvgm/src/Message.hpp b/dviware/dvisvgm/src/Message.hpp
index fd6f048622..afb93d9432 100644
--- a/dviware/dvisvgm/src/Message.hpp
+++ b/dviware/dvisvgm/src/Message.hpp
@@ -2,7 +2,7 @@
** Message.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/MessageException.hpp b/dviware/dvisvgm/src/MessageException.hpp
index 325e83e403..1cfcb49e7d 100644
--- a/dviware/dvisvgm/src/MessageException.hpp
+++ b/dviware/dvisvgm/src/MessageException.hpp
@@ -2,7 +2,7 @@
** MessageException.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/MetafontWrapper.cpp b/dviware/dvisvgm/src/MetafontWrapper.cpp
index 11667fb5e7..7788bef3d9 100644
--- a/dviware/dvisvgm/src/MetafontWrapper.cpp
+++ b/dviware/dvisvgm/src/MetafontWrapper.cpp
@@ -2,7 +2,7 @@
** MetafontWrapper.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 **
diff --git a/dviware/dvisvgm/src/MetafontWrapper.hpp b/dviware/dvisvgm/src/MetafontWrapper.hpp
index 582a146aee..4ec5afd304 100644
--- a/dviware/dvisvgm/src/MetafontWrapper.hpp
+++ b/dviware/dvisvgm/src/MetafontWrapper.hpp
@@ -2,7 +2,7 @@
** MetafontWrapper.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/MiKTeXCom.cpp b/dviware/dvisvgm/src/MiKTeXCom.cpp
index 9cd02edf41..1bbd40cae6 100644
--- a/dviware/dvisvgm/src/MiKTeXCom.cpp
+++ b/dviware/dvisvgm/src/MiKTeXCom.cpp
@@ -2,7 +2,7 @@
** MiKTeXCom.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 **
diff --git a/dviware/dvisvgm/src/MiKTeXCom.hpp b/dviware/dvisvgm/src/MiKTeXCom.hpp
index 3da270cea1..b05b26a132 100644
--- a/dviware/dvisvgm/src/MiKTeXCom.hpp
+++ b/dviware/dvisvgm/src/MiKTeXCom.hpp
@@ -2,7 +2,7 @@
** MiKTeXCom.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/NoPsSpecialHandler.cpp b/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
index f5b3d7244e..77af3d9d0c 100644
--- a/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
@@ -2,7 +2,7 @@
** NoPsSpecialHandler.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 **
diff --git a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
index 9af3d47df5..b4af33ab6c 100644
--- a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
@@ -2,7 +2,7 @@
** NoPsSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/NumericRanges.hpp b/dviware/dvisvgm/src/NumericRanges.hpp
index 1669f7ddce..5102b715b0 100644
--- a/dviware/dvisvgm/src/NumericRanges.hpp
+++ b/dviware/dvisvgm/src/NumericRanges.hpp
@@ -2,7 +2,7 @@
** NumericRanges.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Opacity.cpp b/dviware/dvisvgm/src/Opacity.cpp
new file mode 100644
index 0000000000..efc8bed05e
--- /dev/null
+++ b/dviware/dvisvgm/src/Opacity.cpp
@@ -0,0 +1,59 @@
+/*************************************************************************
+** Opacity.cpp **
+** **
+** This file is part of dvisvgm -- a fast DVI to SVG converter **
+** 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 **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include "Opacity.hpp"
+
+using namespace std;
+
+string Opacity::cssBlendMode (BlendMode bm) {
+ switch (bm) {
+ case BM_NORMAL : return "normal";
+ case BM_MULTIPLY : return "multiply";
+ case BM_SCREEN : return "screen";
+ case BM_OVERLAY : return "overlay";
+ case BM_SOFTLIGHT : return "soft-light";
+ case BM_HARDLIGHT : return "hard-light";
+ case BM_COLORDODGE: return "color-dodge";
+ case BM_COLORBURN : return "color-burn";
+ case BM_DARKEN : return "darken";
+ case BM_LIGHTEN : return "lighten";
+ case BM_DIFFERENCE: return "difference";
+ case BM_EXCLUSION : return "exclusion";
+ case BM_HUE : return "hue";
+ case BM_SATURATION: return "saturation";
+ case BM_COLOR : return "color";
+ case BM_LUMINOSITY: return "luminosity";
+ }
+ return "";
+}
+
+
+bool Opacity::operator == (const Opacity &opacity) const {
+ return opacity._fillalpha == _fillalpha
+ && opacity._strokealpha == _strokealpha
+ && opacity._blendMode == _blendMode;
+}
+
+
+bool Opacity::operator != (const Opacity &opacity) const {
+ return opacity._fillalpha != _fillalpha
+ || opacity._strokealpha != _strokealpha
+ || opacity._blendMode != _blendMode;
+} \ No newline at end of file
diff --git a/dviware/dvisvgm/src/Opacity.hpp b/dviware/dvisvgm/src/Opacity.hpp
new file mode 100644
index 0000000000..8a4e1edac6
--- /dev/null
+++ b/dviware/dvisvgm/src/Opacity.hpp
@@ -0,0 +1,75 @@
+/*************************************************************************
+** Opacity.hpp **
+** **
+** This file is part of dvisvgm -- a fast DVI to SVG converter **
+** 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 **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#ifndef OPACITY_HPP
+#define OPACITY_HPP
+
+#include <string>
+
+class OpacityAlpha {
+ public:
+ OpacityAlpha () =default;
+ OpacityAlpha (double constalpha, double shapealpha) : _constalpha(constalpha), _shapealpha(shapealpha) {}
+ void setConstAlpha (double alpha) { _constalpha = alpha;}
+ void setShapeAlpha (double shapealpha) {_shapealpha = shapealpha;}
+ double value () const {return _constalpha * _shapealpha;}
+ bool operator == (const OpacityAlpha &alpha) const {return alpha._constalpha == _constalpha && alpha._shapealpha == _shapealpha;}
+ bool operator != (const OpacityAlpha &alpha) const {return alpha._constalpha != _constalpha || alpha._shapealpha != _shapealpha;}
+ bool isOpaque () const {return _constalpha == 1.0 && _shapealpha == 1.0;}
+
+ private:
+ double _constalpha=1.0;
+ double _shapealpha=1.0;
+};
+
+class Opacity {
+ public:
+ enum BlendMode {
+ BM_NORMAL, BM_MULTIPLY, BM_SCREEN, BM_OVERLAY,
+ BM_SOFTLIGHT, BM_HARDLIGHT, BM_COLORDODGE, BM_COLORBURN,
+ BM_DARKEN, BM_LIGHTEN, BM_DIFFERENCE, BM_EXCLUSION,
+ BM_HUE, BM_SATURATION, BM_COLOR, BM_LUMINOSITY
+ };
+
+ public:
+ Opacity () =default;
+ Opacity (OpacityAlpha fillalpha, OpacityAlpha strokealpha, BlendMode bm) : _fillalpha(fillalpha), _strokealpha(strokealpha), _blendMode(bm) {}
+ Opacity (OpacityAlpha fillalpha, OpacityAlpha strokealpha) : Opacity(fillalpha, strokealpha, BM_NORMAL) {}
+ explicit Opacity (BlendMode bm) : _blendMode(bm) {}
+ OpacityAlpha& fillalpha () {return _fillalpha;}
+ OpacityAlpha& strokealpha () {return _strokealpha;}
+ const OpacityAlpha& fillalpha () const {return _fillalpha;}
+ const OpacityAlpha& strokealpha () const {return _strokealpha;}
+ BlendMode blendMode () const {return _blendMode;}
+ void setBlendMode (BlendMode mode) {_blendMode = mode;}
+ std::string cssBlendMode () const {return cssBlendMode(_blendMode);}
+ static std::string cssBlendMode (BlendMode bm);
+ bool isFillDefault () const {return _fillalpha.isOpaque() && _blendMode == BM_NORMAL;}
+ bool isStrokeDefault () const {return _strokealpha.isOpaque() && _blendMode == BM_NORMAL;}
+ bool operator == (const Opacity &opacity) const;
+ bool operator != (const Opacity &opacity) const;
+
+ private:
+ OpacityAlpha _fillalpha;
+ OpacityAlpha _strokealpha;
+ BlendMode _blendMode=BM_NORMAL;
+};
+
+#endif
diff --git a/dviware/dvisvgm/src/PDFParser.cpp b/dviware/dvisvgm/src/PDFParser.cpp
index e511d4dc39..aaf50886ec 100644
--- a/dviware/dvisvgm/src/PDFParser.cpp
+++ b/dviware/dvisvgm/src/PDFParser.cpp
@@ -2,7 +2,7 @@
** PDFParser.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 **
diff --git a/dviware/dvisvgm/src/PDFParser.hpp b/dviware/dvisvgm/src/PDFParser.hpp
index b261ee9cf7..a342e740cd 100644
--- a/dviware/dvisvgm/src/PDFParser.hpp
+++ b/dviware/dvisvgm/src/PDFParser.hpp
@@ -2,7 +2,7 @@
** PDFParser.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PDFToSVG.hpp b/dviware/dvisvgm/src/PDFToSVG.hpp
index a6c71f964b..91792689a2 100644
--- a/dviware/dvisvgm/src/PDFToSVG.hpp
+++ b/dviware/dvisvgm/src/PDFToSVG.hpp
@@ -2,7 +2,7 @@
** PDFToSVG.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PSFilter.hpp b/dviware/dvisvgm/src/PSFilter.hpp
index 87aff89a7c..59a4565d1d 100644
--- a/dviware/dvisvgm/src/PSFilter.hpp
+++ b/dviware/dvisvgm/src/PSFilter.hpp
@@ -2,7 +2,7 @@
** PSFilter.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PSInterpreter.cpp b/dviware/dvisvgm/src/PSInterpreter.cpp
index 5e09642ef6..c296a18f04 100644
--- a/dviware/dvisvgm/src/PSInterpreter.cpp
+++ b/dviware/dvisvgm/src/PSInterpreter.cpp
@@ -2,7 +2,7 @@
** PSInterpreter.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 **
@@ -59,8 +59,10 @@ void PSInterpreter::init () {
// in conjunction with -dDELAYBIND and -dWRITESYSTEMDICT.
// Thus, -dDELAYSAFER (or -dNOSAFER) must be added.
// https://www.ghostscript.com/doc/9.50/Use.htm#Safer
- if (gsrev >= 950)
+ if (gsrev >= 950) {
gsargs.emplace_back("-dDELAYSAFER");
+ gsargs.emplace_back("-dALLOWPSTRANSPARENCY");
+ }
}
_gs.init(gsargs.size(), gsargs.data(), this);
_gs.set_stdio(input, output, error);
@@ -130,7 +132,7 @@ bool PSInterpreter::execute (const char *str, size_t len, bool flush) {
// feed Ghostscript with code chunks that are not larger than 64KB
// => see documentation of gsapi_run_string_foo()
const char *p=str;
- while (PS_RUNNING && len > 0) {
+ while (_mode == PS_RUNNING && len > 0) {
SignalHandler::instance().check();
size_t chunksize = min(len, (size_t)0xffff);
_gs.run_string_continue(p, chunksize, 0, &status);
@@ -279,6 +281,7 @@ void PSInterpreter::callActions (InputReader &in) {
{"rotate", { 1, &PSActions::rotate}},
{"save", { 1, &PSActions::save}},
{"scale", { 2, &PSActions::scale}},
+ {"setalphaisshape", { 1, &PSActions::setalphaisshape}},
{"setblendmode", { 1, &PSActions::setblendmode}},
{"setcolorspace", { 1, &PSActions::setcolorspace}},
{"setcmykcolor", { 4, &PSActions::setcmykcolor}},
@@ -286,7 +289,6 @@ void PSInterpreter::callActions (InputReader &in) {
{"setfillconstantalpha", { 1, &PSActions::setfillconstantalpha}},
{"setgray", { 1, &PSActions::setgray}},
{"sethsbcolor", { 3, &PSActions::sethsbcolor}},
- {"setisshapealpha", { 1, &PSActions::setisshapealpha}},
{"setlinecap", { 1, &PSActions::setlinecap}},
{"setlinejoin", { 1, &PSActions::setlinejoin}},
{"setlinewidth", { 1, &PSActions::setlinewidth}},
@@ -309,7 +311,7 @@ void PSInterpreter::callActions (InputReader &in) {
_rawData.clear();
in.skipSpace();
while (!in.eof()) {
- _rawData.emplace_back(in.getString());
+ _rawData.push_back(in.getString());
in.skipSpace();
}
}
@@ -320,14 +322,14 @@ void PSInterpreter::callActions (InputReader &in) {
if (pcount < 0) { // variable number of parameters?
in.skipSpace();
while (!in.eof()) { // read all available parameters
- params.emplace_back(in.getString());
+ params.push_back(in.getString());
in.skipSpace();
}
}
else { // fix number of parameters
for (int i=0; i < pcount; i++) {
in.skipSpace();
- params.emplace_back(in.getString());
+ params.push_back(in.getString());
}
}
// convert parameter strings to doubles
@@ -415,7 +417,7 @@ bool PSInterpreter::imageDeviceKnown (string deviceStr) {
return false;
deviceStr = deviceStr.substr(0, deviceStr.find(':')); // strip optional argument
auto infos = getImageDeviceInfos();
- auto it = find_if(infos.begin(), infos.end(), [&](PSDeviceInfo &info) {
+ auto it = find_if(infos.begin(), infos.end(), [&](const PSDeviceInfo &info) {
return info.name == deviceStr;
});
return it != infos.end();
diff --git a/dviware/dvisvgm/src/PSInterpreter.hpp b/dviware/dvisvgm/src/PSInterpreter.hpp
index 638e42dd8d..180b99e0ea 100644
--- a/dviware/dvisvgm/src/PSInterpreter.hpp
+++ b/dviware/dvisvgm/src/PSInterpreter.hpp
@@ -2,7 +2,7 @@
** PSInterpreter.hpp **
** **
** 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 **
@@ -62,6 +62,7 @@ struct PSActions {
virtual void rotate (std::vector<double> &p) =0;
virtual void save (std::vector<double> &p) =0;
virtual void scale (std::vector<double> &p) =0;
+ virtual void setalphaisshape (std::vector<double> &p) =0;
virtual void setblendmode (std::vector<double> &p) =0;
virtual void setcolorspace (std::vector<double> &p) =0;
virtual void setcmykcolor (std::vector<double> &cmyk) =0;
@@ -69,7 +70,6 @@ struct PSActions {
virtual void setfillconstantalpha (std::vector<double> &p) =0;
virtual void setgray (std::vector<double> &p) =0;
virtual void sethsbcolor (std::vector<double> &hsb) =0;
- virtual void setisshapealpha (std::vector<double> &p) =0;
virtual void setlinecap (std::vector<double> &p) =0;
virtual void setlinejoin (std::vector<double> &p) =0;
virtual void setlinewidth (std::vector<double> &p) =0;
@@ -114,6 +114,7 @@ class PSInterpreter {
BoundingBox pdfPageBox (const std::string &fname, int pageno);
const std::vector<std::string>& rawData () const {return _rawData;}
bool setImageDevice (const std::string &deviceStr);
+ bool hasFullOpacitySupport () const {return _gs.revision() >= 952;}
static std::vector<PSDeviceInfo> getImageDeviceInfos ();
static void listImageDeviceInfos (std::ostream &os);
static bool imageDeviceKnown (std::string deviceStr);
diff --git a/dviware/dvisvgm/src/PSPattern.cpp b/dviware/dvisvgm/src/PSPattern.cpp
index 4659dc7a84..2320e14cac 100644
--- a/dviware/dvisvgm/src/PSPattern.cpp
+++ b/dviware/dvisvgm/src/PSPattern.cpp
@@ -2,7 +2,7 @@
** PSPattern.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 **
@@ -106,8 +106,8 @@ unique_ptr<XMLElement> PSTilingPattern::createClipNode() const {
* define the pattern graphic. */
unique_ptr<XMLElement> PSTilingPattern::createGroupNode () const {
// add all succeeding path elements to this group
- auto group = util::make_unique<XMLElement>("g");
- group->addAttribute("clip-path", XMLString("url(#pc")+XMLString(psID())+")");
+ auto group = util::make_unique<SVGElement>("g");
+ group->setClipPathUrl("pc"+XMLString(psID()));
return group;
}
diff --git a/dviware/dvisvgm/src/PSPattern.hpp b/dviware/dvisvgm/src/PSPattern.hpp
index 2c53dd2b3e..5e3661fd35 100644
--- a/dviware/dvisvgm/src/PSPattern.hpp
+++ b/dviware/dvisvgm/src/PSPattern.hpp
@@ -2,7 +2,7 @@
** PSPattern.hpp **
** **
** 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 **
@@ -40,6 +40,8 @@ class PSPattern {
virtual int psID () const {return _id;}
virtual std::string svgID () const;
virtual void apply (SpecialActions &actions);
+ virtual void setColor (Color color) {}
+ virtual bool tiled () const =0;
protected:
explicit PSPattern (int id) : _id(id) {}
@@ -54,6 +56,8 @@ class PSTilingPattern : public PSPattern {
public:
virtual XMLElement* getContainerNode () {return _groupNode.get();}
void apply (SpecialActions &actions) override;
+ bool tiled () const override {return true;}
+
protected:
PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep);
@@ -82,7 +86,7 @@ class PSUncoloredTilingPattern final : public PSTilingPattern {
public:
PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep);
std::string svgID () const override;
- void setColor (Color color) {_currentColor = color;}
+ void setColor (Color color) override {_currentColor = color;}
void apply (SpecialActions &actions) override;
protected:
diff --git a/dviware/dvisvgm/src/PSPreviewFilter.cpp b/dviware/dvisvgm/src/PSPreviewFilter.cpp
index 20e8b53643..312b3eb6de 100644
--- a/dviware/dvisvgm/src/PSPreviewFilter.cpp
+++ b/dviware/dvisvgm/src/PSPreviewFilter.cpp
@@ -2,7 +2,7 @@
** PSPreviewFilter.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 **
diff --git a/dviware/dvisvgm/src/PSPreviewFilter.hpp b/dviware/dvisvgm/src/PSPreviewFilter.hpp
index acadf9f39e..62860b6932 100644
--- a/dviware/dvisvgm/src/PSPreviewFilter.hpp
+++ b/dviware/dvisvgm/src/PSPreviewFilter.hpp
@@ -2,7 +2,7 @@
** PSPreviewFilter.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PageRanges.cpp b/dviware/dvisvgm/src/PageRanges.cpp
index 2623d2ef46..46f2707821 100644
--- a/dviware/dvisvgm/src/PageRanges.cpp
+++ b/dviware/dvisvgm/src/PageRanges.cpp
@@ -2,7 +2,7 @@
** PageRanges.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 **
diff --git a/dviware/dvisvgm/src/PageRanges.hpp b/dviware/dvisvgm/src/PageRanges.hpp
index 555338449a..f03dfc5162 100644
--- a/dviware/dvisvgm/src/PageRanges.hpp
+++ b/dviware/dvisvgm/src/PageRanges.hpp
@@ -2,7 +2,7 @@
** PageRanges.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PageSize.cpp b/dviware/dvisvgm/src/PageSize.cpp
index ac8e1c5275..8b5c29445b 100644
--- a/dviware/dvisvgm/src/PageSize.cpp
+++ b/dviware/dvisvgm/src/PageSize.cpp
@@ -2,7 +2,7 @@
** PageSize.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 **
diff --git a/dviware/dvisvgm/src/PageSize.hpp b/dviware/dvisvgm/src/PageSize.hpp
index 43c555b9dd..4eb4e5e201 100644
--- a/dviware/dvisvgm/src/PageSize.hpp
+++ b/dviware/dvisvgm/src/PageSize.hpp
@@ -2,7 +2,7 @@
** PageSize.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Pair.hpp b/dviware/dvisvgm/src/Pair.hpp
index 63806c5b6a..466e6fd8f2 100644
--- a/dviware/dvisvgm/src/Pair.hpp
+++ b/dviware/dvisvgm/src/Pair.hpp
@@ -2,7 +2,7 @@
** Pair.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp b/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
index c2ab96a8a8..00a7a4191e 100644
--- a/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PapersizeSpecialHandler.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 **
@@ -58,7 +58,7 @@ void PapersizeSpecialHandler::storePaperSize (unsigned pageno, Length width, Len
if (!_pageSizes.empty() && _pageSizes.back().first == pageno)
_pageSizes.back().second = whpair;
else
- _pageSizes.emplace_back(PageSize(pageno, whpair));
+ _pageSizes.emplace_back(pageno, whpair);
}
}
diff --git a/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp b/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
index ed836f37d7..02599d8c32 100644
--- a/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PapersizeSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PathClipper.cpp b/dviware/dvisvgm/src/PathClipper.cpp
index f1cca09fd6..a36dc5d3df 100644
--- a/dviware/dvisvgm/src/PathClipper.cpp
+++ b/dviware/dvisvgm/src/PathClipper.cpp
@@ -2,7 +2,7 @@
** PathClipper.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 **
diff --git a/dviware/dvisvgm/src/PathClipper.hpp b/dviware/dvisvgm/src/PathClipper.hpp
index 7c42f5de6d..8ab9b48c4f 100644
--- a/dviware/dvisvgm/src/PathClipper.hpp
+++ b/dviware/dvisvgm/src/PathClipper.hpp
@@ -2,7 +2,7 @@
** PathClipper.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PdfSpecialHandler.cpp b/dviware/dvisvgm/src/PdfSpecialHandler.cpp
index 0d1b7177bd..9a12af7a64 100644
--- a/dviware/dvisvgm/src/PdfSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PdfSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PdfSpecialHandler.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 **
@@ -95,7 +95,7 @@ static char prepare_mode (InputReader &ir) {
void PdfSpecialHandler::preprocessPagesize (StreamInputReader &ir, SpecialActions &actions) {
// add page sizes to collection of paper sizes in order to handle them equally
SpecialHandler *handler = SpecialManager::instance().findHandlerByName("papersize");
- if (auto papersizeHandler = dynamic_cast<PapersizeSpecialHandler*>(handler)) {
+ if (auto papersizeHandler = static_cast<PapersizeSpecialHandler*>(handler)) {
try {
Length width, height;
// parse parameter sequence of the form (name length)+
diff --git a/dviware/dvisvgm/src/PdfSpecialHandler.hpp b/dviware/dvisvgm/src/PdfSpecialHandler.hpp
index 0e7d3382ad..e7a18bacce 100644
--- a/dviware/dvisvgm/src/PdfSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PdfSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PdfSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PreScanDVIReader.cpp b/dviware/dvisvgm/src/PreScanDVIReader.cpp
index 8e255ef088..ef862f02cc 100644
--- a/dviware/dvisvgm/src/PreScanDVIReader.cpp
+++ b/dviware/dvisvgm/src/PreScanDVIReader.cpp
@@ -2,7 +2,7 @@
** PreScanDVIReader.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 **
diff --git a/dviware/dvisvgm/src/PreScanDVIReader.hpp b/dviware/dvisvgm/src/PreScanDVIReader.hpp
index 900fd1fc01..a0e5a5fc64 100644
--- a/dviware/dvisvgm/src/PreScanDVIReader.hpp
+++ b/dviware/dvisvgm/src/PreScanDVIReader.hpp
@@ -2,7 +2,7 @@
** PreScanDVIReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Process.cpp b/dviware/dvisvgm/src/Process.cpp
index 2e15153b9e..2010b05db9 100644
--- a/dviware/dvisvgm/src/Process.cpp
+++ b/dviware/dvisvgm/src/Process.cpp
@@ -2,7 +2,7 @@
** Process.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 **
diff --git a/dviware/dvisvgm/src/Process.hpp b/dviware/dvisvgm/src/Process.hpp
index 53311921c9..3e9417d7bb 100644
--- a/dviware/dvisvgm/src/Process.hpp
+++ b/dviware/dvisvgm/src/Process.hpp
@@ -2,7 +2,7 @@
** Process.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/PsSpecialHandler.cpp b/dviware/dvisvgm/src/PsSpecialHandler.cpp
index f7b5508b65..0df21e8804 100644
--- a/dviware/dvisvgm/src/PsSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PsSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PsSpecialHandler.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 **
@@ -32,7 +32,7 @@
#include "PSPreviewFilter.hpp"
#include "PsSpecialHandler.hpp"
#include "SpecialActions.hpp"
-#include "SVGTree.hpp"
+#include "SVGElement.hpp"
#include "TensorProductPatch.hpp"
#include "TriangularPatch.hpp"
#include "utility.hpp"
@@ -81,11 +81,11 @@ void PsSpecialHandler::initgraphics () {
_linecap = _linejoin = 0; // butt end caps and miter joins
_miterlimit = 4;
_xmlnode = _savenode = nullptr;
- _isshapealpha = false; // opacity operators change constant component by default
- _fillalpha = _strokealpha = {1, 1}; // set constant and shape opacity to non-transparent
- _blendmode = 0; // "normal" mode (no blending)
+ _isshapealpha = false; // opacity operators change constant component by default
+ _opacity = Opacity();
_sx = _sy = _cos = 1.0;
_pattern = nullptr;
+ _makingPattern = false;
_patternEnabled = false;
_currentcolor = Color::BLACK;
_dashoffset = 0;
@@ -287,7 +287,6 @@ bool PsSpecialHandler::process (const string &prefix, istream &is, SpecialAction
return true;
}
-
/** Handles a psfile/pdffile special which places an external EPS/PDF graphic
* at the current DVI position. The lower left corner (llx,lly) of the
* given bounding box is placed at the DVI position.
@@ -366,16 +365,15 @@ void PsSpecialHandler::imgfile (FileType filetype, const string &fname, const ma
matrix.scale(sx, sy).rotate(-angle).scale(hscale/100, vscale/100); // apply transformation attributes
matrix.translate(x+hoffset, y-voffset); // move image to current DVI position
matrix.lmultiply(_actions->getMatrix());
-
// update bounding box
BoundingBox bbox(0, 0, urx-llx, ury-lly);
bbox.transform(matrix);
_actions->embed(bbox);
// insert element containing the image data
- matrix.rmultiply(TranslationMatrix(-llx, -lly)); // move lower left corner of image to origin
- if (!matrix.isIdentity())
- imgNode->addAttribute("transform", matrix.toSVG());
+ if (filetype != FileType::PDF)
+ matrix.rmultiply(TranslationMatrix(-llx, -lly)); // move lower left corner of image to origin
+ imgNode->setTransform(matrix);
_actions->svgTree().appendToPage(std::move(imgNode));
}
// restore DVI position
@@ -386,7 +384,7 @@ void PsSpecialHandler::imgfile (FileType filetype, const string &fname, const ma
/** Returns path + basename of temporary bitmap images. */
-static string image_base_path (SpecialActions &actions) {
+static string image_base_path (const SpecialActions &actions) {
FilePath imgpath = actions.getSVGFilePath(actions.getCurrentPageNumber());
return FileSystem::tmpdir() + "/" + imgpath.basename() + "-tmp-";
}
@@ -399,8 +397,8 @@ static string image_base_path (SpecialActions &actions) {
* @param[in] bbox bounding box of the image
* @param[in] clip if true, the image is clipped to its bounding box
* @return pointer to the element or nullptr if there's no image data */
-unique_ptr<XMLElement> PsSpecialHandler::createImageNode (FileType type, const string &fname, int pageno, BoundingBox bbox, bool clip) {
- unique_ptr<XMLElement> node;
+unique_ptr<SVGElement> PsSpecialHandler::createImageNode (FileType type, const string &fname, int pageno, BoundingBox bbox, bool clip) {
+ unique_ptr<SVGElement> node;
string pathstr;
if (const char *path = FileFinder::instance().lookup(fname, false))
pathstr = FileSystem::ensureForwardSlashes(path);
@@ -409,7 +407,7 @@ unique_ptr<XMLElement> PsSpecialHandler::createImageNode (FileType type, const s
if (pathstr.empty())
Message::wstream(true) << "file '" << fname << "' not found\n";
else if (type == FileType::BITMAP || type == FileType::SVG) {
- node = util::make_unique<XMLElement>("image");
+ node = util::make_unique<SVGElement>("image");
node->addAttribute("x", 0);
node->addAttribute("y", 0);
node->addAttribute("width", bbox.width());
@@ -429,7 +427,7 @@ unique_ptr<XMLElement> PsSpecialHandler::createImageNode (FileType type, const s
if (clip)
rectclip = to_string(bbox.minX())+" "+to_string(bbox.minY())+" "+to_string(bbox.width())+" "+to_string(bbox.height())+" rectclip";
- node = util::make_unique<XMLElement>("g"); // put SVG nodes created from the EPS/PDF file in this group
+ node = util::make_unique<SVGElement>("g"); // put SVG nodes created from the EPS/PDF file in this group
_xmlnode = node.get();
_psi.execute(
"\n@beginspecial @setspecial" // enter special environment
@@ -556,9 +554,8 @@ void PsSpecialHandler::setpagedevice (std::vector<double> &p) {
_linewidth = 1;
_linecap = _linejoin = 0; // butt end caps and miter joins
_miterlimit = 4;
- _isshapealpha = false; // opacity operators change constant component by default
- _fillalpha = _strokealpha = {1, 1}; // set constant and shape opacity to non-transparent
- _blendmode = 0; // "normal" mode (no blending)
+ _isshapealpha = false; // opacity operators change constant component by default
+ _opacity = Opacity();
_sx = _sy = _cos = 1.0;
_pattern = nullptr;
_currentcolor = Color::BLACK;
@@ -613,14 +610,37 @@ void PsSpecialHandler::closepath (vector<double>&) {
}
-static string css_blendmode_name (int mode) {
- static const array<const char*,16> modenames = {{
- "normal", "multiply", "screen", "overlay", "soft-light", "hard-light", "color-dodge", "color-burn",
- "darken", "lighten", "difference", "exclusion", "hue", "saturation", "color", "luminosity"
- }};
+void PsSpecialHandler::setblendmode (vector<double> &p) {
+ int mode = static_cast<int>(p[0]);
+ static const Opacity::BlendMode blendmodes[] = {
+ Opacity::BM_NORMAL, Opacity::BM_MULTIPLY, Opacity::BM_SCREEN, Opacity::BM_OVERLAY,
+ Opacity::BM_SOFTLIGHT, Opacity::BM_HARDLIGHT, Opacity::BM_COLORDODGE, Opacity::BM_COLORBURN,
+ Opacity::BM_DARKEN, Opacity::BM_LIGHTEN, Opacity::BM_DIFFERENCE, Opacity::BM_EXCLUSION,
+ Opacity::BM_HUE, Opacity::BM_SATURATION, Opacity::BM_COLOR, Opacity::BM_LUMINOSITY
+ };
if (mode < 0 || mode > 15)
- return "";
- return modenames[mode];
+ mode = Opacity::BM_NORMAL;
+ _opacity.setBlendMode(blendmodes[mode]);
+}
+
+
+void PsSpecialHandler::setfillconstantalpha (vector<double> &p) {
+ if (_isshapealpha)
+ _opacity.fillalpha().setShapeAlpha(p[0]);
+ else
+ _opacity.fillalpha().setConstAlpha(p[0]);
+ if (_actions)
+ _actions->setOpacity(_opacity);
+}
+
+
+void PsSpecialHandler::setstrokeconstantalpha (vector<double> &p) {
+ if (_isshapealpha)
+ _opacity.strokealpha().setShapeAlpha(p[0]);
+ else
+ _opacity.strokealpha().setConstAlpha(p[0]);
+ if (_actions)
+ _actions->setOpacity(_opacity);
}
@@ -639,18 +659,18 @@ void PsSpecialHandler::stroke (vector<double> &p) {
}
if (_clipStack.prependedPath())
_path.prepend(*_clipStack.prependedPath());
- unique_ptr<XMLElement> path;
+ unique_ptr<SVGElement> path;
Pair<double> point;
if (_path.isDot(point)) { // zero-length path?
if (_linecap == 1) { // round line ends? => draw dot
double x = point.x();
double y = point.y();
double r = _linewidth/2.0;
- path = util::make_unique<XMLElement>("circle");
+ path = util::make_unique<SVGElement>("circle");
path->addAttribute("cx", x);
path->addAttribute("cy", y);
path->addAttribute("r", r);
- path->addAttribute("fill", _actions->getColor().svgColorString());
+ path->setFillColor(_actions->getColor());
bbox = BoundingBox(x-r, y-r, x+r, y+r);
}
}
@@ -661,35 +681,20 @@ void PsSpecialHandler::stroke (vector<double> &p) {
ostringstream oss;
_path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
- path = util::make_unique<XMLElement>("path");
+ path = util::make_unique<SVGElement>("path");
path->addAttribute("d", oss.str());
- path->addAttribute("stroke", _actions->getColor().svgColorString());
- path->addAttribute("fill", "none");
- if (_linewidth != 1)
- path->addAttribute("stroke-width", _linewidth);
- if (_miterlimit != 4)
- path->addAttribute("stroke-miterlimit", _miterlimit);
- if (_linecap > 0) // default value is "butt", no need to set it explicitly
- path->addAttribute("stroke-linecap", _linecap == 1 ? "round" : "square");
- if (_linejoin > 0) // default value is "miter", no need to set it explicitly
- path->addAttribute("stroke-linejoin", _linecap == 1 ? "round" : "bevel");
- if (_strokealpha[0] < 1 || _strokealpha[1] < 1)
- path->addAttribute("stroke-opacity", _strokealpha[0] * _strokealpha[1]);
- if (_blendmode > 0 && _blendmode < 16)
- path->addAttribute("style", "mix-blend-mode:"+css_blendmode_name(_blendmode));
- if (!_dashpattern.empty()) {
- string patternStr;
- for (double dashValue : _dashpattern)
- patternStr += XMLString(dashValue)+",";
- patternStr.pop_back();
- path->addAttribute("stroke-dasharray", patternStr);
- if (_dashoffset != 0)
- path->addAttribute("stroke-dashoffset", _dashoffset);
- }
+ path->setStrokeColor(_actions->getColor());
+ path->setNoFillColor();
+ path->setStrokeWidth(_linewidth);
+ path->setStrokeMiterLimit(_miterlimit);
+ path->setStrokeLineCap(_linecap == 0 ? SVGElement::LC_BUTT : _linecap == 1 ? SVGElement::LC_ROUND : SVGElement::LC_SQUARE);
+ path->setStrokeLineJoin(_linejoin == 0 ? SVGElement::LJ_MITER : _linecap == 1 ? SVGElement::LJ_ROUND : SVGElement::LJ_BEVEL);
+ path->setStrokeOpacity(_opacity);
+ path->setStrokeDash(_dashpattern, _dashoffset);
}
- if (path && _clipStack.path() && !_savenode) {
+ if (path && _clipStack.path() && !_makingPattern) {
// assign clipping path and clip bounding box
- path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ path->setClipPathUrl("clip"+XMLString(_clipStack.topID()));
bbox.intersect(_clipStack.path()->computeBBox());
_clipStack.removePrependedPath();
}
@@ -708,7 +713,7 @@ void PsSpecialHandler::stroke (vector<double> &p) {
* @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */
void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
_path.removeRedundantCommands();
- if ((_path.empty() && !_clipStack.prependedPath()) || !_actions)
+ if ((_path.empty() && !_clipStack.prependedPath()) || (_patternEnabled && !_pattern) || !_actions)
return;
// compute bounding box
@@ -723,24 +728,20 @@ void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
ostringstream oss;
_path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
- unique_ptr<XMLElement> path = util::make_unique<XMLElement>("path");
+ auto path = util::make_unique<SVGElement>("path");
path->addAttribute("d", oss.str());
if (_pattern)
- path->addAttribute("fill", XMLString("url(#")+_pattern->svgID()+")");
- else if (_actions->getColor() != Color::BLACK || _savenode)
- path->addAttribute("fill", _actions->getColor().svgColorString());
- if (_clipStack.path() && !_savenode) { // clip path active and not inside pattern definition?
+ path->setFillPatternUrl(XMLString(_pattern->svgID()));
+ else if (_actions->getColor() != Color::BLACK || _makingPattern)
+ path->setFillColor(_actions->getColor(), false);
+ if (_clipStack.path() && !_makingPattern) { // clip path active and not inside pattern definition?
// assign clipping path and clip bounding box
- path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ path->setClipPathUrl("clip"+XMLString(_clipStack.topID()));
bbox.intersect(_clipStack.path()->computeBBox());
_clipStack.removePrependedPath();
}
- if (evenodd) // SVG default fill rule is "nonzero" algorithm
- path->addAttribute("fill-rule", "evenodd");
- if (_fillalpha[0] < 1 || _fillalpha[1] < 1)
- path->addAttribute("fill-opacity", _fillalpha[0] * _fillalpha[1]);
- if (_blendmode > 0 && _blendmode < 16)
- path->addAttribute("style", "mix-blend-mode:"+css_blendmode_name(_blendmode));
+ path->setFillRule(evenodd ? SVGElement::FR_EVENODD : SVGElement::FR_NONZERO);
+ path->setFillOpacity(_opacity);
if (_xmlnode)
_xmlnode->append(std::move(path));
else {
@@ -788,8 +789,8 @@ void PsSpecialHandler::image (std::vector<double> &p) {
// if set, assign clipping path to image
if (_clipStack.path()) {
- auto group = util::make_unique<XMLElement>("g");
- group->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ auto group = util::make_unique<SVGElement>("g");
+ group->setClipPathUrl("clip"+XMLString(_clipStack.topID()));
group->append(std::move(image));
image = std::move(group); // handle the entire group as image to add
}
@@ -846,10 +847,9 @@ void PsSpecialHandler::makepattern (vector<double> &p) {
switch (pattern_type) {
case 0:
// pattern definition completed
- if (_savenode) {
- _xmlnode = _savenode;
- _savenode = nullptr;
- }
+ _xmlnode = _savenode;
+ _savenode = nullptr;
+ _makingPattern = false;
break;
case 1: { // tiling pattern
int id = static_cast<int>(p[1]);
@@ -869,6 +869,7 @@ void PsSpecialHandler::makepattern (vector<double> &p) {
_savenode = _xmlnode;
_xmlnode = pattern->getContainerNode(); // insert the following SVG elements into this node
_patterns[id] = std::move(pattern);
+ _makingPattern = true;
break;
}
case 2: {
@@ -891,13 +892,9 @@ void PsSpecialHandler::setpattern (vector<double> &p) {
if (it == _patterns.end())
_pattern = nullptr;
else {
- if (auto pattern = dynamic_cast<PSUncoloredTilingPattern*>(it->second.get()))
- pattern->setColor(color);
+ it->second->setColor(color);
it->second->apply(*_actions);
- if (auto pattern = dynamic_cast<PSTilingPattern*>(it->second.get()))
- _pattern = pattern;
- else
- _pattern = nullptr;
+ _pattern = it->second->tiled() ? static_cast<PSTilingPattern*>(it->second.get()) : nullptr;
}
}
@@ -961,16 +958,15 @@ void PsSpecialHandler::clip (Path path, bool evenodd) {
intersectedPath.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
}
if (pathReplaced) {
- auto pathElem = util::make_unique<XMLElement>("path");
+ auto pathElem = util::make_unique<SVGElement>("path");
pathElem->addAttribute("d", oss.str());
- if (evenodd)
- pathElem->addAttribute("clip-rule", "evenodd");
+ pathElem->setClipRule(evenodd ? SVGElement::FR_EVENODD : SVGElement::FR_NONZERO);
int newID = _clipStack.topID();
- auto clipElem = util::make_unique<XMLElement>("clipPath");
+ auto clipElem = util::make_unique<SVGElement>("clipPath");
clipElem->addAttribute("id", XMLString("clip")+XMLString(newID));
if (!COMPUTE_CLIPPATHS_INTERSECTIONS && oldID)
- clipElem->addAttribute("clip-path", XMLString("url(#clip")+XMLString(oldID)+")");
+ clipElem->setClipPathUrl("clip"+XMLString(oldID));
clipElem->append(std::move(pathElem));
_actions->svgTree().appendToDefs(std::move(clipElem));
@@ -1046,7 +1042,7 @@ void PsSpecialHandler::shfill (vector<double> &params) {
* @param[in,out] it iterator used to sequentially access the patch data
* @param[out] points the points defining the geometry of the patch
* @param[out] colors the colors assigned to the vertices of the patch */
-static void read_patch_data (ShadingPatch &patch, int edgeflag,
+static void read_patch_data (const ShadingPatch &patch, int edgeflag,
VectorIterator<double> &it, vector<DPair> &points, vector<Color> &colors)
{
// number of control points and colors required to define a single patch
@@ -1087,14 +1083,14 @@ class ShadingCallback : public ShadingPatch::Callback {
ShadingCallback (SpecialActions &actions, XMLElement *parent, int clippathID)
: _actions(actions)
{
- auto group = util::make_unique<XMLElement>("g");
+ auto group = util::make_unique<SVGElement>("g");
_group = group.get();
if (parent)
parent->append(std::move(group));
else
actions.svgTree().appendToPage(std::move(group));
if (clippathID > 0)
- _group->addAttribute("clip-path", XMLString("url(#clip")+XMLString(clippathID)+")");
+ _group->setClipPathUrl("clip"+XMLString(clippathID));
}
void patchSegment (GraphicsPath<double> &path, const Color &color) override {
@@ -1104,15 +1100,15 @@ class ShadingCallback : public ShadingPatch::Callback {
// draw a single patch segment
ostringstream oss;
path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
- auto pathElem = util::make_unique<XMLElement>("path");
+ auto pathElem = util::make_unique<SVGElement>("path");
pathElem->addAttribute("d", oss.str());
- pathElem->addAttribute("fill", color.svgColorString());
+ pathElem->setFillColor(color);
_group->append(std::move(pathElem));
}
private:
SpecialActions &_actions;
- XMLElement *_group;
+ SVGElement *_group;
};
diff --git a/dviware/dvisvgm/src/PsSpecialHandler.hpp b/dviware/dvisvgm/src/PsSpecialHandler.hpp
index 8b66499041..72586ba659 100644
--- a/dviware/dvisvgm/src/PsSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PsSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PsSpecialHandler.hpp **
** **
** 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 **
@@ -28,12 +28,13 @@
#include <vector>
#include "GraphicsPath.hpp"
#include "PSInterpreter.hpp"
-#include "SpecialHandler.hpp"
+#include "Opacity.hpp"
#include "PSPattern.hpp"
#include "PSPreviewFilter.hpp"
-
+#include "SpecialHandler.hpp"
class PSPattern;
+class SVGElement;
class XMLElement;
class PsSpecialHandler : public SpecialHandler, protected PSActions {
@@ -104,7 +105,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void executeAndSync (std::istream &is, bool updatePos);
void processHeaderFile (const char *fname);
void imgfile (FileType type, const std::string &fname, const std::map<std::string,std::string> &attr);
- std::unique_ptr<XMLElement> createImageNode (FileType type, const std::string &fname, int pageno, BoundingBox bbox, bool clip);
+ std::unique_ptr<SVGElement> createImageNode (FileType type, const std::string &fname, int pageno, BoundingBox bbox, bool clip);
void dviBeginPage (unsigned int pageno, SpecialActions &actions) override;
void dviEndPage (unsigned pageno, SpecialActions &actions) override;
void clip (Path path, bool evenodd);
@@ -138,14 +139,14 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void rotate (std::vector<double> &p) override;
void save (std::vector<double> &p) override;
void scale (std::vector<double> &p) override;
- void setblendmode (std::vector<double> &p) override {_blendmode = int(p[0]);}
+ void setalphaisshape (std::vector<double> &p) override { _isshapealpha = bool(p[0]);}
+ void setblendmode (std::vector<double> &p) override;
void setcolorspace (std::vector<double> &p) override {_patternEnabled = bool(p[0]);}
void setcmykcolor (std::vector<double> &cmyk) override;
void setdash (std::vector<double> &p) override;
- void setfillconstantalpha (std::vector<double> &p) override {_fillalpha[_isshapealpha ? 1 : 0] = p[0];}
+ void setfillconstantalpha (std::vector<double> &p) override;
void setgray (std::vector<double> &p) override;
void sethsbcolor (std::vector<double> &hsb) override;
- void setisshapealpha (std::vector<double> &p) override {_isshapealpha = bool(p[0]);}
void setlinecap (std::vector<double> &p) override {_linecap = uint8_t(p[0]);}
void setlinejoin (std::vector<double> &p) override {_linejoin = uint8_t(p[0]);}
void setlinewidth (std::vector<double> &p) override {_linewidth = scale(p[0] ? p[0] : 0.5);}
@@ -155,7 +156,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void setpagedevice (std::vector<double> &p) override;
void setpattern (std::vector<double> &p) override;
void setrgbcolor (std::vector<double> &rgb) override;
- void setstrokeconstantalpha (std::vector<double> &p) override {_strokealpha[_isshapealpha ? 1 : 0] = p[0];}
+ void setstrokeconstantalpha (std::vector<double> &p) override;
void shfill (std::vector<double> &p) override;
void stroke (std::vector<double> &p) override;
void translate (std::vector<double> &p) override;
@@ -176,15 +177,14 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
double _cos; ///< cosine of angle between (1,0) and transform(1,0)
double _linewidth; ///< current line width in bp units
double _miterlimit; ///< current miter limit in bp units
- bool _isshapealpha; ///< if true, opacity operators act on index 1 (shape component), otherwise on index 0 (constant component)
- std::array<double,2> _fillalpha; ///< constant and shape opacity used for fill operations (0=fully transparent, ..., 1=opaque)
- std::array<double,2> _strokealpha; ///< constant and shape opacity used for stroke operations (0=fully transparent, ..., 1=opaque)
- int _blendmode; ///< blend mode used when overlaying colored areas
+ bool _isshapealpha; ///< if true, opacity operators act on shape component, otherwise on constant component
+ Opacity _opacity;
uint8_t _linecap : 2; ///< current line cap (0=butt, 1=round, 2=projecting square)
uint8_t _linejoin : 2; ///< current line join (0=miter, 1=round, 2=bevel)
double _dashoffset; ///< current dash offset
std::vector<double> _dashpattern;
ClippingStack _clipStack;
+ bool _makingPattern=false; ///< true if executing makepattern operator
std::map<int, std::unique_ptr<PSPattern>> _patterns;
PSTilingPattern *_pattern; ///< current pattern
bool _patternEnabled; ///< true if active color space is a pattern
diff --git a/dviware/dvisvgm/src/RangeMap.cpp b/dviware/dvisvgm/src/RangeMap.cpp
index 86190cacf9..27aa8bc427 100644
--- a/dviware/dvisvgm/src/RangeMap.cpp
+++ b/dviware/dvisvgm/src/RangeMap.cpp
@@ -2,7 +2,7 @@
** RangeMap.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 **
@@ -82,14 +82,14 @@ void RangeMap::addRange (uint32_t cmin, uint32_t cmax, uint32_t vmin) {
Range range(cmin, cmax, vmin);
if (_ranges.empty())
- _ranges.emplace_back(std::move(range));
+ _ranges.push_back(std::move(range));
else {
// check for simple cases that can be handled pretty fast
Range &lrange = *_ranges.begin();
Range &rrange = *_ranges.rbegin();
if (cmin > rrange.max()) { // non-overlapping range at end of vector?
if (!rrange.join(range))
- _ranges.emplace_back(std::move(range));
+ _ranges.push_back(std::move(range));
}
else if (cmax < lrange.min()) { // non-overlapping range at begin of vector?
if (!lrange.join(range))
diff --git a/dviware/dvisvgm/src/RangeMap.hpp b/dviware/dvisvgm/src/RangeMap.hpp
index 3e3bff9d4b..3f5cb7a6e5 100644
--- a/dviware/dvisvgm/src/RangeMap.hpp
+++ b/dviware/dvisvgm/src/RangeMap.hpp
@@ -2,7 +2,7 @@
** RangeMap.hpp **
** **
** 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 **
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;
}
diff --git a/dviware/dvisvgm/src/SVGCharHandler.hpp b/dviware/dvisvgm/src/SVGCharHandler.hpp
index f75df47215..99ac4af858 100644
--- a/dviware/dvisvgm/src/SVGCharHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharHandler.hpp **
** **
** 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 **
@@ -26,12 +26,15 @@
#include "Color.hpp"
#include "Font.hpp"
#include "Matrix.hpp"
+#include "Opacity.hpp"
template <typename T>
class CharProperty {
public:
+ CharProperty () =default;
CharProperty (const T &v) : _value(v) {}
+ CharProperty (T &&v) : _value(std::move(v)) {}
void set (const T &v) {
if (v != _value) {
@@ -40,10 +43,11 @@ class CharProperty {
}
}
- const T& get () const {return _value;}
- operator const T& () const {return _value;}
- bool changed () const {return _changed;}
- void changed (bool c) {_changed = c;}
+ const T& get () const {return _value;}
+ const T* operator -> () const {return &_value;}
+ operator const T& () const {return _value;}
+ bool changed () const {return _changed;}
+ void changed (bool c) {_changed = c;}
private:
T _value;
@@ -51,7 +55,7 @@ class CharProperty {
};
-class XMLElement;
+class SVGElement;
/** Base class for all character handlers. These handlers create SVG representations
@@ -60,36 +64,39 @@ class SVGCharHandler {
public:
SVGCharHandler () : _matrix(1) {}
virtual ~SVGCharHandler() =default;
- virtual void setInitialContextNode (XMLElement *node);
+ virtual void setInitialContextNode (SVGElement *node);
virtual void appendChar (uint32_t c, double x, double y) =0;
virtual void notifyXAdjusted () {}
virtual void notifyYAdjusted () {}
- void setColor (const Color &color) {_color.set(color);}
- void setFont (const Font &font, int id) {_font.set(&font); _fontnum = id;}
- void setMatrix (const Matrix &matrix) {_matrix.set(matrix);}
- void setVertical (bool vertical) {_vertical.set(vertical);}
- Color getColor () const {return _color.get();}
- const Font* getFont () const {return _font.get();}
- const Matrix& getMatrix () const {return _matrix.get();}
+ void setColor (const Color &color) {_color.set(color);}
+ void setOpacity (const Opacity &opacity) {_opacity.set(opacity);}
+ void setFont (const Font &font, int id) {_font.set(&font); _fontnum = id;}
+ void setMatrix (const Matrix &matrix) {_matrix.set(matrix);}
+ void setVertical (bool vertical) {_vertical.set(vertical);}
+ Color getColor () const {return _color.get();}
+ const Opacity& getOpacity () const {return _opacity.get();}
+ const Font* getFont () const {return _font.get();}
+ const Matrix& getMatrix () const {return _matrix.get();}
protected:
virtual void resetContextNode ();
- XMLElement* pushContextNode (std::unique_ptr<XMLElement> node);
+ SVGElement* pushContextNode (std::unique_ptr<SVGElement> node);
void popContextNode ();
- XMLElement* contextNode () const {
+ SVGElement* contextNode () const {
return _contextNodeStack.empty() ? _initialContextNode : _contextNodeStack.top();
}
CharProperty<Color> _color=Color::BLACK; ///< current color
+ CharProperty<Opacity> _opacity; ///< current opacity values
CharProperty<const Font*> _font=0; ///< current font
int _fontnum=0; ///< current font ID
CharProperty<Matrix> _matrix; ///< current transformation
CharProperty<bool> _vertical=false; ///< current writing mode
private:
- XMLElement *_initialContextNode= nullptr; ///< SVG element the generated character nodes are attached to
- std::stack<XMLElement*> _contextNodeStack;
+ SVGElement *_initialContextNode= nullptr; ///< SVG element the generated character nodes are attached to
+ std::stack<SVGElement*> _contextNodeStack;
};
@@ -99,7 +106,7 @@ class SVGCharTextHandler : public SVGCharHandler {
explicit SVGCharTextHandler (bool selectFontByClass) : _selectFontByClass(selectFontByClass) {}
protected:
- std::unique_ptr<XMLElement> createTextNode (double x, double y) const;
+ std::unique_ptr<SVGElement> createTextNode (double x, double y) const;
private:
bool _selectFontByClass;
diff --git a/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp b/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
index 397943ace0..0a4666f5ae 100644
--- a/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
+++ b/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
@@ -2,7 +2,7 @@
** SVGCharHandlerFactory.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 **
diff --git a/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp b/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
index f37b9977c2..a43257bc15 100644
--- a/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
+++ b/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
@@ -2,7 +2,7 @@
** SVGCharHandlerFactory.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SVGCharPathHandler.cpp b/dviware/dvisvgm/src/SVGCharPathHandler.cpp
index 7a766bae49..2aa9209dda 100644
--- a/dviware/dvisvgm/src/SVGCharPathHandler.cpp
+++ b/dviware/dvisvgm/src/SVGCharPathHandler.cpp
@@ -2,7 +2,7 @@
** SVGCharPathHandler.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 **
@@ -23,7 +23,7 @@
#include "FontManager.hpp"
#include "SVGCharPathHandler.hpp"
#include "utility.hpp"
-#include "XMLNode.hpp"
+#include "SVGElement.hpp"
using namespace std;
@@ -61,22 +61,23 @@ void SVGCharPathHandler::appendChar (uint32_t c, double x, double y) {
// Glyphs of non-black fonts (e.g. defined in a XeTeX document) can't change their color.
CharProperty<Color> &color = (_fontColor.get() != Color::BLACK) ? _fontColor : _color;
bool applyColor = color.get() != Color::BLACK;
- bool applyMatrix = !_matrix.get().isIdentity();
+ bool applyMatrix = !_matrix->isIdentity();
+ bool applyOpacity = !_opacity->isFillDefault();
if (!_groupNode) {
color.changed(applyColor);
_matrix.changed(applyMatrix);
}
- if (color.changed() || _matrix.changed()) {
+ if (color.changed() || _matrix.changed() || _opacity.changed()) {
resetContextNode();
- if (applyColor || applyMatrix) {
- _groupNode = pushContextNode(util::make_unique<XMLElement>("g"));
- if (applyColor)
- contextNode()->addAttribute("fill", color.get().svgColorString());
- if (applyMatrix)
- contextNode()->addAttribute("transform", _matrix.get().toSVG());
+ if (applyColor || applyMatrix || applyOpacity) {
+ _groupNode = pushContextNode(util::make_unique<SVGElement>("g"));
+ contextNode()->setFillColor(color);
+ contextNode()->setFillOpacity(_opacity->fillalpha());
+ contextNode()->setTransform(_matrix);
}
color.changed(false);
_matrix.changed(false);
+ _opacity.changed(false);
}
const Font *font = _font.get();
if (font->verticalLayout()) {
@@ -84,12 +85,12 @@ void SVGCharPathHandler::appendChar (uint32_t c, double x, double y) {
GlyphMetrics metrics;
font->getGlyphMetrics(c, _vertical, metrics);
x -= metrics.wl;
- if (auto pf = dynamic_cast<const PhysicalFont*>(font)) {
+ if (auto pf = font_cast<const PhysicalFont*>(font)) {
// Center glyph between top and bottom border of the TFM box.
// This is just an approximation used until I find a way to compute
// the exact location in vertical mode.
GlyphMetrics exact_metrics;
- pf->getExactGlyphBox(c, exact_metrics, false);
+ pf->getExactGlyphBox(c, exact_metrics, false, nullptr);
y += exact_metrics.h+(metrics.d-exact_metrics.h-exact_metrics.d)/2;
}
else
@@ -109,28 +110,27 @@ void SVGCharPathHandler::appendChar (uint32_t c, double x, double y) {
void SVGCharPathHandler::appendUseElement (uint32_t c, double x, double y, const Matrix &matrix) {
string id = "#g" + to_string(FontManager::instance().fontID(_font)) + "-" + to_string(c);
- auto useNode = util::make_unique<XMLElement>("use");
- useNode->addAttribute("x", XMLString(x));
- useNode->addAttribute("y", XMLString(y));
+ auto useNode = util::make_unique<SVGElement>("use");
+ useNode->addAttribute("x", x);
+ useNode->addAttribute("y", y);
useNode->addAttribute("xlink:href", id);
- if (!matrix.isIdentity())
- useNode->addAttribute("transform", matrix.toSVG());
+ useNode->setFillOpacity(_opacity->blendMode()); // add blend mode style here because it's not inheritable
+ useNode->setTransform(matrix);
contextNode()->append(std::move(useNode));
}
void SVGCharPathHandler::appendPathElement (uint32_t c, double x, double y, const Matrix &matrix) {
Glyph glyph;
- auto pf = dynamic_cast<const PhysicalFont*>(_font.get());
- if (pf && pf->getGlyph(c, glyph)) {
+ auto pf = font_cast<const PhysicalFont*>(_font.get());
+ if (pf && pf->getGlyph(c, glyph, nullptr)) {
double sx = pf->scaledSize()/pf->unitsPerEm();
double sy = -sx;
ostringstream oss;
glyph.writeSVG(oss, _relativePathCommands, sx, sy, x, y);
- auto glyphNode = util::make_unique<XMLElement>("path");
+ auto glyphNode = util::make_unique<SVGElement>("path");
glyphNode->addAttribute("d", oss.str());
- if (!matrix.isIdentity())
- glyphNode->addAttribute("transform", matrix.toSVG());
+ glyphNode->setTransform(matrix);
contextNode()->append(std::move(glyphNode));
}
}
diff --git a/dviware/dvisvgm/src/SVGCharPathHandler.hpp b/dviware/dvisvgm/src/SVGCharPathHandler.hpp
index c404cbcd5a..4ecdd5272e 100644
--- a/dviware/dvisvgm/src/SVGCharPathHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharPathHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharPathHandler.hpp **
** **
** 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 **
@@ -39,7 +39,7 @@ class SVGCharPathHandler : public SVGCharHandler {
private:
AppendMethod _appendChar; ///< method called to append a single character
bool _relativePathCommands; ///< if true, create relative rather than absolute SVG path commands
- XMLElement *_groupNode=nullptr; ///< current group node taking the path elements
+ SVGElement *_groupNode=nullptr; ///< current group node taking the path elements
CharProperty<Color> _fontColor=Color::BLACK; ///< color of current font
};
diff --git a/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp b/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
index 6b89348dc1..5c9d57f8a9 100644
--- a/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
+++ b/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
@@ -2,7 +2,7 @@
** SVGCharTspanTextHandler.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,7 +20,7 @@
#include "SVGCharTspanTextHandler.hpp"
#include "utility.hpp"
-#include "XMLNode.hpp"
+#include "SVGElement.hpp"
using namespace std;
@@ -36,9 +36,10 @@ void SVGCharTspanTextHandler::appendChar (uint32_t c, double x, double y) {
if (!_textNode || _font.changed() || _matrix.changed() || _vertical.changed()) {
resetContextNode();
_textNode = pushContextNode(createTextNode(x, y));
- _color.changed(true); // force creating tspan with color attribute if current color differs from font color
+ _color.changed(true); // force creating tspan with color attribute if current color differs from font color
+ _opacity.changed(true); // dito for opacity properties
}
- if (_tspanNode && (_xchanged || _ychanged || _color.changed())) {
+ if (_tspanNode && (_xchanged || _ychanged || _color.changed() || _opacity.changed())) {
// if drawing position or color was explicitly changed, finish current tspan element
popContextNode();
_tspanNode = nullptr;
@@ -46,15 +47,18 @@ void SVGCharTspanTextHandler::appendChar (uint32_t c, double x, double y) {
// Apply text color changes only if the color of the entire font is black.
// Glyphs of non-black fonts (e.g. defined in a XeTeX document) can't change their color.
bool applyColor = _color.get() != Color::BLACK && _font.get()->color() == Color::BLACK;
- if (_xchanged || _ychanged || (_color.changed() && applyColor)) {
- _tspanNode = pushContextNode(util::make_unique<XMLElement>("tspan"));
+ bool applyOpacity = !_opacity->isFillDefault();
+ if (_xchanged || _ychanged || (_color.changed() && applyColor) || (_opacity.changed() && applyOpacity)) {
+ _tspanNode = pushContextNode(util::make_unique<SVGElement>("tspan"));
if (applyColor)
- _tspanNode->addAttribute("fill", _color.get().svgColorString());
+ _tspanNode->setFillColor(_color);
_color.changed(false);
+ _tspanNode->setFillOpacity(_opacity);
+ _opacity.changed(false);
if (_xchanged) {
if (_vertical) {
// align glyphs designed for horizontal layout properly
- if (auto pf = dynamic_cast<const PhysicalFont*>(_font.get()))
+ if (auto pf = font_cast<const PhysicalFont*>(_font.get()))
if (!pf->getMetrics()->verticalLayout())
x += pf->scaledAscent()/2.5; // move vertical baseline to the right by strikethrough offset
}
@@ -70,7 +74,7 @@ void SVGCharTspanTextHandler::appendChar (uint32_t c, double x, double y) {
}
-void SVGCharTspanTextHandler::setInitialContextNode (XMLElement *node) {
+void SVGCharTspanTextHandler::setInitialContextNode (SVGElement *node) {
SVGCharHandler::setInitialContextNode(node);
_textNode = _tspanNode = nullptr;
_xchanged = _ychanged = false;
diff --git a/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp b/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
index b847965a1a..28ec792ece 100644
--- a/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharTspanTextHandler.hpp **
** **
** 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 **
@@ -29,15 +29,15 @@ class SVGCharTspanTextHandler : public SVGCharTextHandler {
void notifyXAdjusted () override {_xchanged = true;}
void notifyYAdjusted() override {_ychanged = true;}
void appendChar (uint32_t c, double x, double y) override;
- void setInitialContextNode (XMLElement *node) override;
+ void setInitialContextNode (SVGElement *node) override;
protected:
void resetContextNode () override;
private:
bool _xchanged, _ychanged;
- XMLElement *_textNode;
- XMLElement *_tspanNode;
+ SVGElement *_textNode;
+ SVGElement *_tspanNode;
};
#endif
diff --git a/dviware/dvisvgm/src/SVGElement.cpp b/dviware/dvisvgm/src/SVGElement.cpp
new file mode 100644
index 0000000000..129bb22c82
--- /dev/null
+++ b/dviware/dvisvgm/src/SVGElement.cpp
@@ -0,0 +1,153 @@
+/*************************************************************************
+** SVGElement.cpp **
+** **
+** This file is part of dvisvgm -- a fast DVI to SVG converter **
+** 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 **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include <sstream>
+#include "Color.hpp"
+#include "Matrix.hpp"
+#include "Opacity.hpp"
+#include "SVGElement.hpp"
+#include "XMLString.hpp"
+
+using namespace std;
+
+
+void SVGElement::setClipPathUrl (const string &url) {
+ if (!url.empty())
+ addAttribute("clip-path", "url(#"+url+")");
+}
+
+
+void SVGElement::setClipRule (FillRule rule) {
+ if (rule != FR_NONZERO)
+ addAttribute("clip-rule", "evenodd");
+}
+
+
+void SVGElement::setFillColor (Color color, bool skipBlack) {
+ if (color != Color::BLACK || !skipBlack)
+ addAttribute("fill", color.svgColorString());
+}
+
+
+void SVGElement::setFillOpacity (const Opacity &opacity) {
+ if (!opacity.isFillDefault()) {
+ setFillOpacity(opacity.fillalpha());
+ setFillOpacity(opacity.blendMode());
+ }
+}
+
+
+void SVGElement::setFillOpacity (const OpacityAlpha &alpha) {
+ if (!alpha.isOpaque())
+ addAttribute("fill-opacity", alpha.value());
+}
+
+
+void SVGElement::setFillOpacity (Opacity::BlendMode blendMode) {
+ if (blendMode != Opacity::BM_NORMAL)
+ addAttribute("style", "mix-blend-mode:"+Opacity::cssBlendMode(blendMode));
+}
+
+
+void SVGElement::setFillRule (FillRule rule) {
+ if (rule != FR_NONZERO)
+ addAttribute("fill-rule", "evenodd");
+}
+
+
+void SVGElement::setFillPatternUrl (const std::string &url) {
+ if (!url.empty())
+ addAttribute("fill", "url(#" + url + ")");
+}
+
+
+void SVGElement::setNoFillColor () {
+ addAttribute("fill", "none");
+}
+
+
+void SVGElement::setPoints (const vector<DPair> &points) {
+ if (!points.empty()) {
+ ostringstream oss;
+ for (const DPair &p : points)
+ oss << XMLString(p.x()) << ' ' << XMLString(p.y()) << ' ';
+ string str = oss.str();
+ str.pop_back();
+ addAttribute("points", str);
+ }
+}
+
+
+void SVGElement::setStrokeColor (Color color) {
+ addAttribute("stroke", color.svgColorString());
+}
+
+
+void SVGElement::setStrokeDash (const vector<double> &pattern, double offset) {
+ if (!pattern.empty()) {
+ string patternStr;
+ for (double dashValue : pattern)
+ patternStr += XMLString(dashValue)+" ";
+ patternStr.pop_back();
+ addAttribute("stroke-dasharray", patternStr);
+ if (offset != 0)
+ addAttribute("stroke-dashoffset", offset);
+ }
+}
+
+
+void SVGElement::setStrokeLineCap (LineCap cap) {
+ if (cap != LC_BUTT)
+ addAttribute("stroke-linecap", cap == LC_ROUND ? "round" : "square");
+}
+
+
+void SVGElement::setStrokeLineJoin (LineJoin join) {
+ if (join != LJ_MITER)
+ addAttribute("stroke-linejoin", join == LJ_BEVEL ? "bevel" : "round");
+}
+
+
+void SVGElement::setStrokeMiterLimit (double limit) {
+ if (limit != 4)
+ addAttribute("stroke-miterlimit", limit);
+}
+
+
+void SVGElement::setStrokeOpacity (const Opacity &opacity) {
+ if (!opacity.isStrokeDefault()) {
+ if (!opacity.strokealpha().isOpaque())
+ addAttribute("stroke-opacity", opacity.strokealpha().value());
+ if (opacity.blendMode() != Opacity::BM_NORMAL)
+ addAttribute("style", "mix-blend-mode:"+opacity.cssBlendMode());
+ }
+}
+
+
+void SVGElement::setStrokeWidth (double width) {
+ if (width != 1)
+ addAttribute("stroke-width", width);
+}
+
+
+void SVGElement::setTransform (const Matrix &matrix) {
+ if (!matrix.isIdentity())
+ addAttribute("transform", matrix.toSVG());
+}
diff --git a/dviware/dvisvgm/src/SVGElement.hpp b/dviware/dvisvgm/src/SVGElement.hpp
new file mode 100644
index 0000000000..c3d68bf593
--- /dev/null
+++ b/dviware/dvisvgm/src/SVGElement.hpp
@@ -0,0 +1,60 @@
+/*************************************************************************
+** SVGElement.hpp **
+** **
+** This file is part of dvisvgm -- a fast DVI to SVG converter **
+** 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 **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#ifndef SVGELEMENT_HPP
+#define SVGELEMENT_HPP
+
+#include "XMLNode.hpp"
+
+class Color;
+class Matrix;
+class Opacity;
+
+class SVGElement : public XMLElement {
+ public:
+ enum FillRule {FR_EVENODD, FR_NONZERO};
+ enum LineCap {LC_BUTT, LC_ROUND, LC_SQUARE};
+ enum LineJoin {LJ_BEVEL, LJ_MITER, LJ_ROUND};
+
+ public:
+ explicit SVGElement (std::string name) : XMLElement(std::move(name)) {}
+ explicit SVGElement (const XMLElement &node) : XMLElement(node) {}
+ explicit SVGElement (XMLElement &&node) noexcept : XMLElement(std::move(node)) {}
+ void setClipPathUrl (const std::string &url);
+ void setClipRule (FillRule rule);
+ void setFillColor (Color color, bool skipBlack=true);
+ void setFillOpacity (const Opacity &opacity);
+ void setFillOpacity (const OpacityAlpha &alpha);
+ void setFillOpacity (Opacity::BlendMode blendMode);
+ void setFillPatternUrl (const std::string &url);
+ void setFillRule (FillRule rule);
+ void setNoFillColor ();
+ void setPoints (const std::vector<DPair> &points);
+ void setStrokeColor (Color color);
+ void setStrokeDash (const std::vector<double> &pattern, double offset=0);
+ void setStrokeLineCap (LineCap cap);
+ void setStrokeLineJoin (LineJoin join);
+ void setStrokeOpacity (const Opacity &opacity);
+ void setStrokeWidth (double width);
+ void setStrokeMiterLimit (double limit);
+ void setTransform (const Matrix &matrix);
+};
+
+#endif
diff --git a/dviware/dvisvgm/src/SVGOutput.cpp b/dviware/dvisvgm/src/SVGOutput.cpp
index 18702be776..59a26764a7 100644
--- a/dviware/dvisvgm/src/SVGOutput.cpp
+++ b/dviware/dvisvgm/src/SVGOutput.cpp
@@ -2,7 +2,7 @@
** SVGOutput.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 **
diff --git a/dviware/dvisvgm/src/SVGOutput.hpp b/dviware/dvisvgm/src/SVGOutput.hpp
index f29a032674..96acf807e3 100644
--- a/dviware/dvisvgm/src/SVGOutput.hpp
+++ b/dviware/dvisvgm/src/SVGOutput.hpp
@@ -2,7 +2,7 @@
** SVGOutput.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp b/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
index 89d1c548b0..4cece0bdab 100644
--- a/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
+++ b/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
@@ -2,7 +2,7 @@
** SVGSingleCharTextHandler.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 **
@@ -19,7 +19,7 @@
*************************************************************************/
#include "SVGSingleCharTextHandler.hpp"
-#include "XMLNode.hpp"
+#include "SVGElement.hpp"
using namespace std;
@@ -29,9 +29,11 @@ void SVGSingleCharTextHandler::appendChar (uint32_t c, double x, double y) {
textNode->append(XMLString(font->unicode(c), false));
// Apply color changes only if the color differs from black and if the font color itself is black.
// Glyphs from non-black fonts (e.g. defined in a XeTeX document) can't change their color.
- if (_color.get() != Color::BLACK && font->color() == Color::BLACK) {
- textNode->addAttribute("fill", _color.get().svgColorString());
- _color.changed(false);
- }
+ if (_color.get() != Color::BLACK && font->color() == Color::BLACK)
+ textNode->setFillColor(_color);
+ _color.changed(false);
+ if (!_opacity->isFillDefault())
+ textNode->setFillOpacity(_opacity);
+ _opacity.changed(false);
contextNode()->append(std::move(textNode));
}
diff --git a/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp b/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
index 67fcabd44c..57f05a4b07 100644
--- a/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
+++ b/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
@@ -2,7 +2,7 @@
** SVGSingleCharTextHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SVGTree.cpp b/dviware/dvisvgm/src/SVGTree.cpp
index e35a14d9b3..f501a2c85b 100644
--- a/dviware/dvisvgm/src/SVGTree.cpp
+++ b/dviware/dvisvgm/src/SVGTree.cpp
@@ -2,7 +2,7 @@
** SVGTree.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 **
@@ -31,7 +31,6 @@
#include "SVGCharHandlerFactory.hpp"
#include "SVGTree.hpp"
#include "XMLDocument.hpp"
-#include "XMLNode.hpp"
#include "XMLString.hpp"
using namespace std;
@@ -55,7 +54,7 @@ SVGTree::SVGTree () : _charHandler(SVGCharHandlerFactory::createHandler()) {
/** Clears the SVG tree and initializes the root element. */
void SVGTree::reset () {
_doc.clear();
- auto rootNode = util::make_unique<XMLElement>("svg");
+ auto rootNode = util::make_unique<SVGElement>("svg");
rootNode->addAttribute("version", "1.1");
rootNode->addAttribute("xmlns", "http://www.w3.org/2000/svg");
rootNode->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
@@ -111,20 +110,20 @@ bool SVGTree::setFontFormat (string formatstr) {
/** Starts a new page.
* @param[in] pageno number of new page */
void SVGTree::newPage (int pageno) {
- auto pageNode = util::make_unique<XMLElement>("g");
+ auto pageNode = util::make_unique<SVGElement>("g");
if (pageno >= 0)
pageNode->addAttribute("id", string("page")+XMLString(pageno));
_charHandler->setInitialContextNode(pageNode.get());
_page = pageNode.get();
_root->append(std::move(pageNode));
- _defsContextStack = stack<XMLElement*>();
- _pageContextStack = stack<XMLElement*>();
+ _defsContextStack = stack<SVGElement*>();
+ _pageContextStack = stack<SVGElement*>();
}
void SVGTree::appendToDefs (unique_ptr<XMLNode> node) {
if (!_defs) {
- auto defsNode = util::make_unique<XMLElement>("defs");
+ auto defsNode = util::make_unique<SVGElement>("defs");
_defs = defsNode.get();
_root->prepend(std::move(defsNode));
}
@@ -134,7 +133,7 @@ void SVGTree::appendToDefs (unique_ptr<XMLNode> node) {
void SVGTree::appendToPage (unique_ptr<XMLNode> node) {
- XMLElement *parent = _pageContextStack.empty() ? _page : _pageContextStack.top();
+ SVGElement *parent = _pageContextStack.empty() ? _page : _pageContextStack.top();
parent->append(std::move(node));
_charHandler->setInitialContextNode(parent);
}
@@ -149,8 +148,7 @@ void SVGTree::prependToPage (unique_ptr<XMLNode> node) {
void SVGTree::transformPage (const Matrix &usermatrix) {
- if (!usermatrix.isIdentity())
- _page->addAttribute("transform", usermatrix.toSVG());
+ _page->setTransform(usermatrix);
}
@@ -171,8 +169,8 @@ static unique_ptr<XMLElement> createGlyphNode (int c, const PhysicalFont &font,
double extend = font.style() ? font.style()->extend : 1;
glyphNode = util::make_unique<XMLElement>("glyph");
glyphNode->addAttribute("unicode", XMLString(font.unicode(c), false));
- glyphNode->addAttribute("horiz-adv-x", XMLString(font.hAdvance(c)*extend));
- glyphNode->addAttribute("vert-adv-y", XMLString(font.vAdvance(c)));
+ glyphNode->addAttribute("horiz-adv-x", font.hAdvance(c)*extend);
+ glyphNode->addAttribute("vert-adv-y", font.vAdvance(c));
string name = font.glyphName(c);
if (!name.empty())
glyphNode->addAttribute("glyph-name", name);
@@ -192,7 +190,7 @@ static unique_ptr<XMLElement> createGlyphNode (int c, const PhysicalFont &font,
static string font_info (const Font &font) {
ostringstream oss;
- if (auto nf = dynamic_cast<const NativeFont*>(&font)) {
+ if (auto nf = font_cast<const NativeFont*>(&font)) {
oss << nf->familyName() << ' ' << nf->styleName() << "; " << nf->filename();
if (nf->style()) {
if (nf->style()->bold != 0)
@@ -211,7 +209,7 @@ void SVGTree::appendFontStyles (const unordered_set<const Font*> &fonts) {
if (CREATE_CSS && USE_FONTS && !fonts.empty() && _page) {
map<int, const Font*> sortmap;
for (const Font *font : fonts)
- if (!dynamic_cast<const VirtualFont*>(font)) // skip virtual fonts
+ if (!font_cast<const VirtualFont*>(font)) // skip virtual fonts
sortmap[FontManager::instance().fontID(font)] = font;
ostringstream style;
// add font style definitions in ascending order
@@ -260,14 +258,14 @@ void SVGTree::append (const PhysicalFont &font, const set<int> &chars, GFGlyphTr
auto fontNode = util::make_unique<XMLElement>("font");
string fontname = font.name();
fontNode->addAttribute("id", fontname);
- fontNode->addAttribute("horiz-adv-x", XMLString(font.hAdvance()));
+ fontNode->addAttribute("horiz-adv-x", font.hAdvance());
auto faceNode = util::make_unique<XMLElement>("font-face");
faceNode->addAttribute("font-family", fontname);
- faceNode->addAttribute("units-per-em", XMLString(font.unitsPerEm()));
+ faceNode->addAttribute("units-per-em", font.unitsPerEm());
if (!font.verticalLayout()) {
- faceNode->addAttribute("ascent", XMLString(font.ascent()));
- faceNode->addAttribute("descent", XMLString(font.descent()));
+ faceNode->addAttribute("ascent", font.ascent());
+ faceNode->addAttribute("descent", font.descent());
}
fontNode->append(std::move(faceNode));
for (int c : chars)
@@ -297,8 +295,8 @@ void SVGTree::append (const PhysicalFont &font, const set<int> &chars, GFGlyphTr
}
-void SVGTree::pushDefsContext (unique_ptr<XMLElement> node) {
- XMLElement *nodePtr = node.get();
+void SVGTree::pushDefsContext (unique_ptr<SVGElement> node) {
+ SVGElement *nodePtr = node.get();
if (_defsContextStack.empty())
appendToDefs(std::move(node));
else
@@ -314,8 +312,8 @@ void SVGTree::popDefsContext () {
/** Pushes a new context element that will take all following nodes added to the page. */
-void SVGTree::pushPageContext (unique_ptr<XMLElement> node) {
- XMLElement *nodePtr = node.get();
+void SVGTree::pushPageContext (unique_ptr<SVGElement> node) {
+ SVGElement *nodePtr = node.get();
if (_pageContextStack.empty())
_page->append(std::move(node));
else
diff --git a/dviware/dvisvgm/src/SVGTree.hpp b/dviware/dvisvgm/src/SVGTree.hpp
index a441a314a5..86d9411449 100644
--- a/dviware/dvisvgm/src/SVGTree.hpp
+++ b/dviware/dvisvgm/src/SVGTree.hpp
@@ -2,7 +2,7 @@
** SVGTree.hpp **
** **
** 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 **
@@ -31,13 +31,14 @@
#include "GFGlyphTracer.hpp"
#include "Matrix.hpp"
#include "SVGCharHandler.hpp"
+#include "SVGElement.hpp"
#include "XMLDocument.hpp"
-#include "XMLNode.hpp"
class BoundingBox;
class Color;
class Font;
class Matrix;
+class Opacity;
class PhysicalFont;
class SVGTree {
@@ -54,24 +55,26 @@ class SVGTree {
void appendChar (int c, double x, double y) {_charHandler->appendChar(c, x, y);}
void appendFontStyles (const std::unordered_set<const Font*> &fonts);
void append (const PhysicalFont &font, const std::set<int> &chars, GFGlyphTracer::Callback *callback=nullptr);
- void pushDefsContext (std::unique_ptr<XMLElement> node);
+ void pushDefsContext (std::unique_ptr<SVGElement> node);
void popDefsContext ();
- void pushPageContext (std::unique_ptr<XMLElement> node);
+ void pushPageContext (std::unique_ptr<SVGElement> node);
void popPageContext ();
void setBBox (const BoundingBox &bbox);
void setFont (int id, const Font &font);
static bool setFontFormat (std::string formatstr);
- void setX (double x) {_charHandler->notifyXAdjusted();}
- void setY (double y) {_charHandler->notifyYAdjusted();}
- void setMatrix (const Matrix &m) {_charHandler->setMatrix(m);}
+ void setX (double x) {_charHandler->notifyXAdjusted();}
+ void setY (double y) {_charHandler->notifyYAdjusted();}
+ void setMatrix (const Matrix &m) {_charHandler->setMatrix(m);}
void setColor (const Color &c);
- void setVertical (bool state) {_charHandler->setVertical(state);}
+ void setOpacity (const Opacity &op) {_charHandler->setOpacity(op);}
+ void setVertical (bool state) {_charHandler->setVertical(state);}
void transformPage (const Matrix &m);
- Color getColor () const {return _charHandler->getColor();}
- const Matrix& getMatrix () const {return _charHandler->getMatrix();}
- XMLElement* rootNode () const {return _root;}
- XMLElement* defsNode () const {return _defs;}
- XMLElement* pageNode () const {return _page;}
+ Color getColor () const {return _charHandler->getColor();}
+ const Opacity& getOpacity () const {return _charHandler->getOpacity();}
+ const Matrix& getMatrix () const {return _charHandler->getMatrix();}
+ XMLElement* rootNode () const {return _root;}
+ XMLElement* defsNode () const {return _defs;}
+ XMLElement* pageNode () const {return _page;}
protected:
XMLCData* styleCDataNode ();
@@ -88,11 +91,11 @@ class SVGTree {
private:
XMLDocument _doc;
- XMLElement *_root, *_page, *_defs;
+ SVGElement *_root, *_page, *_defs;
XMLCData *_styleCDataNode;
std::unique_ptr<SVGCharHandler> _charHandler;
- std::stack<XMLElement*> _defsContextStack;
- std::stack<XMLElement*> _pageContextStack;
+ std::stack<SVGElement*> _defsContextStack;
+ std::stack<SVGElement*> _pageContextStack;
};
#endif
diff --git a/dviware/dvisvgm/src/ShadingPatch.cpp b/dviware/dvisvgm/src/ShadingPatch.cpp
index 847dc3aa0c..a734c4c48b 100644
--- a/dviware/dvisvgm/src/ShadingPatch.cpp
+++ b/dviware/dvisvgm/src/ShadingPatch.cpp
@@ -2,7 +2,7 @@
** ShadingPatch.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 **
diff --git a/dviware/dvisvgm/src/ShadingPatch.hpp b/dviware/dvisvgm/src/ShadingPatch.hpp
index 573188b77b..2a8103d044 100644
--- a/dviware/dvisvgm/src/ShadingPatch.hpp
+++ b/dviware/dvisvgm/src/ShadingPatch.hpp
@@ -2,7 +2,7 @@
** ShadingPatch.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SignalHandler.cpp b/dviware/dvisvgm/src/SignalHandler.cpp
index 14badba085..129b010d72 100644
--- a/dviware/dvisvgm/src/SignalHandler.cpp
+++ b/dviware/dvisvgm/src/SignalHandler.cpp
@@ -2,7 +2,7 @@
** SignalHandler.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 **
diff --git a/dviware/dvisvgm/src/SignalHandler.hpp b/dviware/dvisvgm/src/SignalHandler.hpp
index 647a3650fc..ef6a0a4e55 100644
--- a/dviware/dvisvgm/src/SignalHandler.hpp
+++ b/dviware/dvisvgm/src/SignalHandler.hpp
@@ -2,7 +2,7 @@
** SignalHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SourceInput.cpp b/dviware/dvisvgm/src/SourceInput.cpp
index 5cd2e22749..55196c76ce 100644
--- a/dviware/dvisvgm/src/SourceInput.cpp
+++ b/dviware/dvisvgm/src/SourceInput.cpp
@@ -2,7 +2,7 @@
** SourceInput.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 **
diff --git a/dviware/dvisvgm/src/SourceInput.hpp b/dviware/dvisvgm/src/SourceInput.hpp
index 63f4af9b7a..7d7a08c88f 100644
--- a/dviware/dvisvgm/src/SourceInput.hpp
+++ b/dviware/dvisvgm/src/SourceInput.hpp
@@ -2,7 +2,7 @@
** SourceInput.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SpecialActions.hpp b/dviware/dvisvgm/src/SpecialActions.hpp
index f8eba3fd12..a7e4ac31f9 100644
--- a/dviware/dvisvgm/src/SpecialActions.hpp
+++ b/dviware/dvisvgm/src/SpecialActions.hpp
@@ -2,7 +2,7 @@
** SpecialActions.hpp **
** **
** 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 **
@@ -27,6 +27,7 @@
#include "Color.hpp"
#include "FilePath.hpp"
#include "Matrix.hpp"
+#include "Opacity.hpp"
#include "SVGTree.hpp"
class XMLElement;
@@ -46,6 +47,8 @@ class SpecialActions {
virtual const Matrix& getMatrix () const =0;
virtual Matrix getPageTransformation () const {return Matrix(1);}
virtual void setBgColor (const Color &color) =0;
+ virtual void setOpacity (const Opacity &opacity) =0;
+ virtual const Opacity& getOpacity () const =0;
virtual const SVGTree& svgTree () const =0;
SVGTree& svgTree () {return const_cast<SVGTree&>(const_cast<const SpecialActions*>(this)->svgTree());}
virtual BoundingBox& bbox () =0;
@@ -75,6 +78,8 @@ class EmptySpecialActions : public SpecialActions {
void finishLine () override {}
void setColor (const Color &color) override {}
void setBgColor (const Color &color) override {}
+ void setOpacity (const Opacity &opacity) override {}
+ const Opacity& getOpacity () const override {return _svg.getOpacity();}
Color getColor () const override {return Color::BLACK;}
void setMatrix (const Matrix &m) override {}
const Matrix& getMatrix () const override {return _matrix;}
diff --git a/dviware/dvisvgm/src/SpecialHandler.hpp b/dviware/dvisvgm/src/SpecialHandler.hpp
index 6c676a6ba0..382f0e53d1 100644
--- a/dviware/dvisvgm/src/SpecialHandler.hpp
+++ b/dviware/dvisvgm/src/SpecialHandler.hpp
@@ -2,7 +2,7 @@
** SpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/SpecialManager.cpp b/dviware/dvisvgm/src/SpecialManager.cpp
index f3b2f3aa50..68e1c68b51 100644
--- a/dviware/dvisvgm/src/SpecialManager.cpp
+++ b/dviware/dvisvgm/src/SpecialManager.cpp
@@ -2,7 +2,7 @@
** SpecialManager.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 **
diff --git a/dviware/dvisvgm/src/SpecialManager.hpp b/dviware/dvisvgm/src/SpecialManager.hpp
index 4c4ccae281..76cdb3e2e6 100644
--- a/dviware/dvisvgm/src/SpecialManager.hpp
+++ b/dviware/dvisvgm/src/SpecialManager.hpp
@@ -2,7 +2,7 @@
** SpecialManager.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/StreamReader.cpp b/dviware/dvisvgm/src/StreamReader.cpp
index 200b6592d9..8924d885b5 100644
--- a/dviware/dvisvgm/src/StreamReader.cpp
+++ b/dviware/dvisvgm/src/StreamReader.cpp
@@ -2,7 +2,7 @@
** StreamReader.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 **
diff --git a/dviware/dvisvgm/src/StreamReader.hpp b/dviware/dvisvgm/src/StreamReader.hpp
index 653b451b69..08a4fd3636 100644
--- a/dviware/dvisvgm/src/StreamReader.hpp
+++ b/dviware/dvisvgm/src/StreamReader.hpp
@@ -2,7 +2,7 @@
** StreamReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/StreamWriter.cpp b/dviware/dvisvgm/src/StreamWriter.cpp
index c0885c31b1..21eefd1b9e 100644
--- a/dviware/dvisvgm/src/StreamWriter.cpp
+++ b/dviware/dvisvgm/src/StreamWriter.cpp
@@ -2,7 +2,7 @@
** StreamWriter.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 **
diff --git a/dviware/dvisvgm/src/StreamWriter.hpp b/dviware/dvisvgm/src/StreamWriter.hpp
index 16a54b1050..5128bbf736 100644
--- a/dviware/dvisvgm/src/StreamWriter.hpp
+++ b/dviware/dvisvgm/src/StreamWriter.hpp
@@ -2,7 +2,7 @@
** StreamWriter.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Subfont.cpp b/dviware/dvisvgm/src/Subfont.cpp
index 540270f8a8..738ce24455 100644
--- a/dviware/dvisvgm/src/Subfont.cpp
+++ b/dviware/dvisvgm/src/Subfont.cpp
@@ -2,7 +2,7 @@
** Subfont.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 **
@@ -53,7 +53,7 @@ SubfontDefinition::SubfontDefinition (string name, const char *fpath) : _sfname(
while (is && !isspace(is.peek()))
id += char(is.get());
if (!id.empty()) {
- auto state = _subfonts.emplace(pair<string,unique_ptr<Subfont>>(id, unique_ptr<Subfont>()));
+ auto state = _subfonts.emplace(id, unique_ptr<Subfont>());
if (state.second) // id was not present in map already
state.first->second = unique_ptr<Subfont>(new Subfont(*this, state.first->first));
skip_mapping_data(is);
diff --git a/dviware/dvisvgm/src/Subfont.hpp b/dviware/dvisvgm/src/Subfont.hpp
index 5b921bdddb..961720a99c 100644
--- a/dviware/dvisvgm/src/Subfont.hpp
+++ b/dviware/dvisvgm/src/Subfont.hpp
@@ -2,7 +2,7 @@
** Subfont.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/System.cpp b/dviware/dvisvgm/src/System.cpp
index ed14df6821..4f8b0a139c 100644
--- a/dviware/dvisvgm/src/System.cpp
+++ b/dviware/dvisvgm/src/System.cpp
@@ -2,7 +2,7 @@
** System.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 **
diff --git a/dviware/dvisvgm/src/System.hpp b/dviware/dvisvgm/src/System.hpp
index 72a0cb3da8..fb698d303b 100644
--- a/dviware/dvisvgm/src/System.hpp
+++ b/dviware/dvisvgm/src/System.hpp
@@ -2,7 +2,7 @@
** System.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TFM.cpp b/dviware/dvisvgm/src/TFM.cpp
index ea6f2ecbe4..011e659dc9 100644
--- a/dviware/dvisvgm/src/TFM.cpp
+++ b/dviware/dvisvgm/src/TFM.cpp
@@ -2,7 +2,7 @@
** TFM.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 **
diff --git a/dviware/dvisvgm/src/TFM.hpp b/dviware/dvisvgm/src/TFM.hpp
index 261a5ce736..0bb881df8f 100644
--- a/dviware/dvisvgm/src/TFM.hpp
+++ b/dviware/dvisvgm/src/TFM.hpp
@@ -2,7 +2,7 @@
** TFM.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TTFAutohint.cpp b/dviware/dvisvgm/src/TTFAutohint.cpp
index ad1b03f21a..6e8fbefd48 100644
--- a/dviware/dvisvgm/src/TTFAutohint.cpp
+++ b/dviware/dvisvgm/src/TTFAutohint.cpp
@@ -2,7 +2,7 @@
** TTFAutohint.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 **
diff --git a/dviware/dvisvgm/src/TTFAutohint.hpp b/dviware/dvisvgm/src/TTFAutohint.hpp
index d23ceb2be0..3d774984c7 100644
--- a/dviware/dvisvgm/src/TTFAutohint.hpp
+++ b/dviware/dvisvgm/src/TTFAutohint.hpp
@@ -2,7 +2,7 @@
** TTFAutohint.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TensorProductPatch.cpp b/dviware/dvisvgm/src/TensorProductPatch.cpp
index dcd31e275d..261dbc28f5 100644
--- a/dviware/dvisvgm/src/TensorProductPatch.cpp
+++ b/dviware/dvisvgm/src/TensorProductPatch.cpp
@@ -2,7 +2,7 @@
** TensorProductPatch.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 **
@@ -63,7 +63,9 @@ void TensorProductPatch::setFirstMatrixColumn (DPair source[4][4], int col, bool
* @param[in] edgeflag defines how to connect this patch with another one
* @param[in] patch reference patch required if edgeflag > 0 */
void TensorProductPatch::setPoints (const PointVec &points, int edgeflag, ShadingPatch *patch) {
- auto tpPatch = dynamic_cast<TensorProductPatch*>(patch);
+ TensorProductPatch *tpPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ tpPatch = static_cast<TensorProductPatch*>(patch);
if (edgeflag > 0 && !tpPatch)
throw ShadingException("missing preceding data in definition of tensor-product patch");
if ((edgeflag == 0 && points.size() != 16) || (edgeflag > 0 && points.size() != 12))
@@ -107,7 +109,9 @@ void TensorProductPatch::setPoints (const PointVec &points, int edgeflag, Shadin
* @param[in] edgeflag defines how to connect this patch with another one
* @param[in] patch reference patch required if edgeflag > 0 */
void TensorProductPatch::setColors(const ColorVec &colors, int edgeflag, ShadingPatch* patch) {
- auto tpPatch = dynamic_cast<TensorProductPatch*>(patch);
+ TensorProductPatch *tpPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ tpPatch = static_cast<TensorProductPatch*>(patch);
if (edgeflag > 0 && !tpPatch)
throw ShadingException("missing preceding data in definition of tensor-product patch");
if ((edgeflag == 0 && colors.size() != 4) || (edgeflag > 0 && colors.size() != 2))
@@ -492,7 +496,9 @@ DPair CoonsPatch::valueAt (double u, double v) const {
* @param[in] edgeflag defines how to connect this patch to another one
* @param[in] patch reference patch required if edgeflag > 0 */
void CoonsPatch::setPoints (const PointVec &points, int edgeflag, ShadingPatch *patch) {
- auto coonsPatch = dynamic_cast<CoonsPatch*>(patch);
+ CoonsPatch *coonsPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ coonsPatch = static_cast<CoonsPatch*>(patch);
if (edgeflag > 0 && !coonsPatch)
throw ShadingException("missing preceding data in definition of relative Coons patch");
if ((edgeflag == 0 && points.size() != 12) || (edgeflag > 0 && points.size() != 8))
@@ -529,7 +535,9 @@ void CoonsPatch::setPoints (const PointVec &points, int edgeflag, ShadingPatch *
void CoonsPatch::setColors (const ColorVec &colors, int edgeflag, ShadingPatch *patch) {
- auto coonsPatch = dynamic_cast<CoonsPatch*>(patch);
+ CoonsPatch *coonsPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ coonsPatch = static_cast<CoonsPatch*>(patch);
if (edgeflag > 0 && !coonsPatch)
throw ShadingException("missing preceding data in definition of relative Coons patch");
if ((edgeflag == 0 && colors.size() != 4) || (edgeflag > 0 && colors.size() != 2))
diff --git a/dviware/dvisvgm/src/TensorProductPatch.hpp b/dviware/dvisvgm/src/TensorProductPatch.hpp
index e53604cf52..654271b90d 100644
--- a/dviware/dvisvgm/src/TensorProductPatch.hpp
+++ b/dviware/dvisvgm/src/TensorProductPatch.hpp
@@ -2,7 +2,7 @@
** TensorProductPatch.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Terminal.cpp b/dviware/dvisvgm/src/Terminal.cpp
index 3b2ff2b871..274426443a 100644
--- a/dviware/dvisvgm/src/Terminal.cpp
+++ b/dviware/dvisvgm/src/Terminal.cpp
@@ -2,7 +2,7 @@
** Terminal.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 **
diff --git a/dviware/dvisvgm/src/Terminal.hpp b/dviware/dvisvgm/src/Terminal.hpp
index fd7a920c16..f84d47b707 100644
--- a/dviware/dvisvgm/src/Terminal.hpp
+++ b/dviware/dvisvgm/src/Terminal.hpp
@@ -2,7 +2,7 @@
** Terminal.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/ToUnicodeMap.cpp b/dviware/dvisvgm/src/ToUnicodeMap.cpp
index 6ab99a248e..0a0b069e96 100644
--- a/dviware/dvisvgm/src/ToUnicodeMap.cpp
+++ b/dviware/dvisvgm/src/ToUnicodeMap.cpp
@@ -2,7 +2,7 @@
** ToUnicodeMap.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 **
diff --git a/dviware/dvisvgm/src/ToUnicodeMap.hpp b/dviware/dvisvgm/src/ToUnicodeMap.hpp
index 74d6dcb648..806233e12f 100644
--- a/dviware/dvisvgm/src/ToUnicodeMap.hpp
+++ b/dviware/dvisvgm/src/ToUnicodeMap.hpp
@@ -2,7 +2,7 @@
** ToUnicodeMap.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TpicSpecialHandler.cpp b/dviware/dvisvgm/src/TpicSpecialHandler.cpp
index 47d3e46988..b611117725 100644
--- a/dviware/dvisvgm/src/TpicSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/TpicSpecialHandler.cpp
@@ -2,7 +2,7 @@
** TpicSpecialHandler.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 **
@@ -28,6 +28,7 @@
#include "InputReader.hpp"
#include "GraphicsPath.hpp"
#include "SpecialActions.hpp"
+#include "SVGElement.hpp"
#include "SVGTree.hpp"
#include "TpicSpecialHandler.hpp"
#include "utility.hpp"
@@ -70,28 +71,32 @@ Color TpicSpecialHandler::fillColor (bool grayOnly) const {
* @param[in] penwidth pen with used to compute the stroke parameters
* @param[in] pencolor the drawing color
* @param[in] ddist dash/dot distance of line in PS point units (0:solid line, >0:dashed line, <0:dotted line) */
-static void add_stroke_attribs (XMLElement *elem, double penwidth, Color pencolor, double ddist) {
+static void add_stroke_attribs (SVGElement *elem, double penwidth, Color pencolor, double ddist) {
if (penwidth > 0) { // attributes actually required?
- elem->addAttribute("stroke", pencolor.svgColorString());
- elem->addAttribute("stroke-width", XMLString(penwidth));
+ elem->setStrokeColor(pencolor);
+ elem->setStrokeWidth(penwidth);
+ vector<double> dasharray;
if (ddist > 0)
- elem->addAttribute("stroke-dasharray", XMLString(ddist));
- else if (ddist < 0)
- elem->addAttribute("stroke-dasharray", XMLString(penwidth) + ' ' + XMLString(-ddist));
+ dasharray.push_back(ddist);
+ else if (ddist < 0) {
+ dasharray.push_back(penwidth);
+ dasharray.push_back(-ddist);
+ }
+ elem->setStrokeDash(dasharray);
}
}
-static unique_ptr<XMLElement> create_ellipse_element (double cx, double cy, double rx, double ry) {
+static unique_ptr<SVGElement> create_ellipse_element (double cx, double cy, double rx, double ry) {
bool is_circle = (rx == ry);
- auto elem = util::make_unique<XMLElement>(is_circle ? "circle" : "ellipse");
- elem->addAttribute("cx", XMLString(cx));
- elem->addAttribute("cy", XMLString(cy));
+ auto elem = util::make_unique<SVGElement>(is_circle ? "circle" : "ellipse");
+ elem->addAttribute("cx", cx);
+ elem->addAttribute("cy", cy);
if (is_circle)
- elem->addAttribute("r", XMLString(rx));
+ elem->addAttribute("r", rx);
else {
- elem->addAttribute("rx", XMLString(rx));
- elem->addAttribute("ry", XMLString(ry));
+ elem->addAttribute("rx", rx);
+ elem->addAttribute("ry", ry);
}
return elem;
}
@@ -102,7 +107,7 @@ static unique_ptr<XMLElement> create_ellipse_element (double cx, double cy, doub
* @param[in] actions object providing the actions that can be performed by the SpecialHandler */
void TpicSpecialHandler::drawLines (double ddist, SpecialActions &actions) {
if (!_points.empty() && (_penwidth > 0 || _grayLevel >= 0) && !actions.outputLocked()) {
- unique_ptr<XMLElement> elem;
+ unique_ptr<SVGElement> elem;
if (_points.size() == 1) {
const DPair &p = _points.back();
elem = create_ellipse_element(p.x()+actions.getX(), p.y()+actions.getY(), _penwidth/2.0, _penwidth/2.0);
@@ -110,26 +115,27 @@ void TpicSpecialHandler::drawLines (double ddist, SpecialActions &actions) {
}
else {
if (_points.size() == 2 || (_grayLevel < 0 && _points.front() != _points.back())) {
- elem = util::make_unique<XMLElement>("polyline");
- elem->addAttribute("fill", "none");
- elem->addAttribute("stroke-linecap", "round");
+ elem = util::make_unique<SVGElement>("polyline");
+ elem->setNoFillColor();
+ elem->setStrokeLineCap(SVGElement::LC_ROUND);
}
else {
while (_points.front() == _points.back())
_points.pop_back();
- elem = util::make_unique<XMLElement>("polygon");
- elem->addAttribute("fill", _grayLevel < 0 ? "none" : fillColor(false).svgColorString());
+ elem = util::make_unique<SVGElement>("polygon");
+ if (_grayLevel < 0)
+ elem->setNoFillColor();
+ else
+ elem->setFillColor(fillColor(false));
}
- ostringstream oss;
- for (auto it=_points.begin(); it != _points.end(); ++it) {
- if (it != _points.begin())
- oss << ' ';
- double x = it->x()+actions.getX();
- double y = it->y()+actions.getY();
- oss << XMLString(x) << ',' << XMLString(y);
+ vector<DPair> points;
+ for (const DPair &p : _points) {
+ double x = p.x()+actions.getX();
+ double y = p.y()+actions.getY();
+ points.emplace_back(x, y);
actions.embed(DPair(x, y));
}
- elem->addAttribute("points", oss.str());
+ elem->setPoints(points);
add_stroke_attribs(elem.get(), _penwidth, Color::BLACK, ddist);
}
actions.svgTree().appendToPage(std::move(elem));
@@ -175,8 +181,8 @@ void TpicSpecialHandler::drawSplines (double ddist, SpecialActions &actions) {
path.lineto(p+_points[numPoints-1]);
actions.embed(p+_points[numPoints-1]);
}
- auto pathElem = util::make_unique<XMLElement>("path");
- pathElem->addAttribute("fill", "none");
+ auto pathElem = util::make_unique<SVGElement>("path");
+ pathElem->setNoFillColor();
ostringstream oss;
path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
pathElem->addAttribute("d", oss.str());
@@ -200,7 +206,7 @@ void TpicSpecialHandler::drawArc (double cx, double cy, double rx, double ry, do
if ((_penwidth > 0 || _grayLevel >= 0) && !actions.outputLocked()) {
cx += actions.getX();
cy += actions.getY();
- unique_ptr<XMLElement> elem;
+ unique_ptr<SVGElement> elem;
bool closed=true;
if (abs(angle2-angle1) >= math::TWO_PI) // closed ellipse?
elem = create_ellipse_element(cx, cy, rx, ry);
@@ -213,18 +219,21 @@ void TpicSpecialHandler::drawArc (double cx, double cy, double rx, double ry, do
path.closepath();
else
closed = false;
- elem = util::make_unique<XMLElement>("path");
+ elem = util::make_unique<SVGElement>("path");
ostringstream oss;
path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
elem->addAttribute("d", oss.str());
}
if (_penwidth > 0) {
- elem->addAttribute("stroke-width", _penwidth);
- elem->addAttribute("stroke", actions.getColor().svgColorString());
+ elem->setStrokeWidth(_penwidth);
+ elem->setStrokeColor(actions.getColor());
if (!closed)
- elem->addAttribute("stroke-linecap", "round");
+ elem->setStrokeLineCap(SVGElement::LC_ROUND);
}
- elem->addAttribute("fill", _grayLevel < 0 ? "none" : fillColor(true).svgColorString());
+ if (_grayLevel < 0)
+ elem->setNoFillColor();
+ else
+ elem->setFillColor(fillColor(true));
actions.svgTree().appendToPage(std::move(elem));
double pw = _penwidth/2.0;
actions.embed(BoundingBox(cx-rx-pw, cy-ry-pw, cx+rx+pw, cy+ry+pw));
@@ -296,7 +305,7 @@ bool TpicSpecialHandler::process (const string &prefix, istream &is, SpecialActi
case cmd_id("pa"): { // add point to path
double x = ir.getDouble()*mi2bp;
double y = ir.getDouble()*mi2bp;
- _points.emplace_back(DPair(x,y));
+ _points.emplace_back(x, y);
break;
}
case cmd_id("fp"): // draw solid lines through recorded points; close and fill path if fill color was defined
diff --git a/dviware/dvisvgm/src/TpicSpecialHandler.hpp b/dviware/dvisvgm/src/TpicSpecialHandler.hpp
index f6ec271994..8a9b458056 100644
--- a/dviware/dvisvgm/src/TpicSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/TpicSpecialHandler.hpp
@@ -2,7 +2,7 @@
** TpicSpecialHandler.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TriangularPatch.cpp b/dviware/dvisvgm/src/TriangularPatch.cpp
index fadeb725ff..c57836d900 100644
--- a/dviware/dvisvgm/src/TriangularPatch.cpp
+++ b/dviware/dvisvgm/src/TriangularPatch.cpp
@@ -2,7 +2,7 @@
** TriangularPatch.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 **
@@ -31,7 +31,9 @@ TriangularPatch::TriangularPatch (const PointVec &points, const ColorVec &colors
void TriangularPatch::setPoints (const PointVec &points, int edgeflag, ShadingPatch *patch) {
- auto triangularPatch = dynamic_cast<TriangularPatch*>(patch);
+ TriangularPatch *triangularPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ triangularPatch = static_cast<TriangularPatch*>(patch);
if (edgeflag > 0 && !triangularPatch)
throw ShadingException("missing preceding data in definition of triangular patch");
if ((edgeflag == 0 && points.size() != 3) || (edgeflag > 0 && points.size() != 1))
@@ -62,7 +64,9 @@ void TriangularPatch::setPoints (const DPair &p1, const DPair &p2, const DPair &
void TriangularPatch::setColors (const ColorVec &colors, int edgeflag, ShadingPatch *patch) {
- auto triangularPatch = dynamic_cast<TriangularPatch*>(patch);
+ TriangularPatch *triangularPatch = nullptr;
+ if (patch && patch->psShadingType() == psShadingType())
+ triangularPatch = static_cast<TriangularPatch*>(patch);
if (edgeflag > 0 && !triangularPatch)
throw ShadingException("missing preceding data in definition of triangular patch");
if ((edgeflag == 0 && colors.size() != 3) || (edgeflag > 0 && colors.size() != 1))
diff --git a/dviware/dvisvgm/src/TriangularPatch.hpp b/dviware/dvisvgm/src/TriangularPatch.hpp
index 797068bacd..8d4453e5db 100644
--- a/dviware/dvisvgm/src/TriangularPatch.hpp
+++ b/dviware/dvisvgm/src/TriangularPatch.hpp
@@ -2,7 +2,7 @@
** TriangularPatch.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/TrueTypeFont.cpp b/dviware/dvisvgm/src/TrueTypeFont.cpp
index 2921af59ea..84b56c5850 100644
--- a/dviware/dvisvgm/src/TrueTypeFont.cpp
+++ b/dviware/dvisvgm/src/TrueTypeFont.cpp
@@ -2,7 +2,7 @@
** TrueTypeFont.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 **
@@ -56,7 +56,7 @@ bool TrueTypeFont::read (const string &fname) {
if ((offset | length) > _buffer.size() || offset+length > _buffer.size())
return false;
TTFTableRecord record = {tag, checksum, length, reinterpret_cast<const uint8_t*>(_buffer.data())+offset};
- _tableRecords.emplace_back(std::move(record));
+ _tableRecords.push_back(std::move(record));
}
return true;
}
@@ -94,7 +94,7 @@ void TrueTypeFont::writeWOFF (ostream &os) const {
woffRecord.compressTableData();
woffSize += woffRecord.paddedSize();
ttfSize += ttfRecord.paddedSize();
- woffRecords.emplace_back(std::move(woffRecord));
+ woffRecords.push_back(std::move(woffRecord));
}
// write WOFF header
StreamWriter writer(os);
diff --git a/dviware/dvisvgm/src/TrueTypeFont.hpp b/dviware/dvisvgm/src/TrueTypeFont.hpp
index 0ae155c52c..a287f305fa 100644
--- a/dviware/dvisvgm/src/TrueTypeFont.hpp
+++ b/dviware/dvisvgm/src/TrueTypeFont.hpp
@@ -2,7 +2,7 @@
** TrueTypeFont.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/Unicode.cpp b/dviware/dvisvgm/src/Unicode.cpp
index 0fea9c3daf..5b7fb3d238 100644
--- a/dviware/dvisvgm/src/Unicode.cpp
+++ b/dviware/dvisvgm/src/Unicode.cpp
@@ -2,7 +2,7 @@
** Unicode.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 **
diff --git a/dviware/dvisvgm/src/Unicode.hpp b/dviware/dvisvgm/src/Unicode.hpp
index e085bac54d..1547e3f7d4 100644
--- a/dviware/dvisvgm/src/Unicode.hpp
+++ b/dviware/dvisvgm/src/Unicode.hpp
@@ -2,7 +2,7 @@
** Unicode.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/VFActions.hpp b/dviware/dvisvgm/src/VFActions.hpp
index 2d4a2a2c5f..6939d8e710 100644
--- a/dviware/dvisvgm/src/VFActions.hpp
+++ b/dviware/dvisvgm/src/VFActions.hpp
@@ -2,7 +2,7 @@
** VFActions.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/VFReader.cpp b/dviware/dvisvgm/src/VFReader.cpp
index eb1193ddaa..6533333b5e 100644
--- a/dviware/dvisvgm/src/VFReader.cpp
+++ b/dviware/dvisvgm/src/VFReader.cpp
@@ -2,7 +2,7 @@
** VFReader.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 **
diff --git a/dviware/dvisvgm/src/VFReader.hpp b/dviware/dvisvgm/src/VFReader.hpp
index bbf4986d7f..dabad67460 100644
--- a/dviware/dvisvgm/src/VFReader.hpp
+++ b/dviware/dvisvgm/src/VFReader.hpp
@@ -2,7 +2,7 @@
** VFReader.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/VectorIterator.hpp b/dviware/dvisvgm/src/VectorIterator.hpp
index 0fb53d78e4..45009e4ea1 100644
--- a/dviware/dvisvgm/src/VectorIterator.hpp
+++ b/dviware/dvisvgm/src/VectorIterator.hpp
@@ -2,7 +2,7 @@
** VectorIterator.hpp **
** **
** 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 **
@@ -93,7 +93,7 @@ class VectorIterator {
bool operator >= (const VectorIterator &it) const {return _pos >= it._pos;}
bool operator < (const VectorIterator &it) const {return _pos < it._pos;}
bool operator > (const VectorIterator &it) const {return _pos > it._pos;}
- bool valid () const {return _pos >= 0 && _pos < _vector.size();}
+ bool valid () const {return _pos < _vector.size();}
void invalidate () {_pos = _vector.size();}
void reset () {_pos = 0;}
diff --git a/dviware/dvisvgm/src/VectorStream.hpp b/dviware/dvisvgm/src/VectorStream.hpp
index 0372d368d0..22709803ca 100644
--- a/dviware/dvisvgm/src/VectorStream.hpp
+++ b/dviware/dvisvgm/src/VectorStream.hpp
@@ -2,7 +2,7 @@
** VectorStream.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/XMLDocument.cpp b/dviware/dvisvgm/src/XMLDocument.cpp
index ffe23b1f80..8b3c7f31e9 100644
--- a/dviware/dvisvgm/src/XMLDocument.cpp
+++ b/dviware/dvisvgm/src/XMLDocument.cpp
@@ -2,7 +2,7 @@
** XMLDocument.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 **
@@ -39,7 +39,7 @@ void XMLDocument::append (unique_ptr<XMLNode> node) {
if (node->toElement())
_rootElement = util::static_unique_ptr_cast<XMLElement>(std::move(node));
else
- _nodes.emplace_back(std::move(node));
+ _nodes.push_back(std::move(node));
}
}
diff --git a/dviware/dvisvgm/src/XMLDocument.hpp b/dviware/dvisvgm/src/XMLDocument.hpp
index 2eaaee4a28..c6b5645226 100644
--- a/dviware/dvisvgm/src/XMLDocument.hpp
+++ b/dviware/dvisvgm/src/XMLDocument.hpp
@@ -2,7 +2,7 @@
** XMLDocument.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/XMLNode.cpp b/dviware/dvisvgm/src/XMLNode.cpp
index eb49b9c9db..8549593a13 100644
--- a/dviware/dvisvgm/src/XMLNode.cpp
+++ b/dviware/dvisvgm/src/XMLNode.cpp
@@ -2,7 +2,7 @@
** XMLNode.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 **
@@ -107,7 +107,7 @@ void XMLElement::addAttribute (const string &name, const string &value) {
if (Attribute *attr = getAttribute(name))
attr->value = value;
else
- _attributes.emplace_back(Attribute(name, value));
+ _attributes.emplace_back(name, value);
}
@@ -387,12 +387,12 @@ ostream& XMLElement::write (ostream &os) const {
os << '>';
// Insert newlines around children except text nodes. According to the
// SVG specification, pure whitespace nodes are ignored by the SVG renderer.
- if (WRITE_NEWLINES && !_firstChild->toText())
+ if (WRITE_NEWLINES && name() != "text" && !_firstChild->toText())
os << '\n';
for (XMLNode *child = _firstChild.get(); child; child = child->next()) {
child->write(os);
if (!child->toText()) {
- if (WRITE_NEWLINES && (!child->next() || !child->next()->toText()))
+ if (WRITE_NEWLINES && name() != "text" && (!child->next() || !child->next()->toText()))
os << '\n';
}
}
diff --git a/dviware/dvisvgm/src/XMLNode.hpp b/dviware/dvisvgm/src/XMLNode.hpp
index 65bd69fab8..aeab862130 100644
--- a/dviware/dvisvgm/src/XMLNode.hpp
+++ b/dviware/dvisvgm/src/XMLNode.hpp
@@ -2,7 +2,7 @@
** XMLNode.hpp **
** **
** 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 **
@@ -128,7 +128,7 @@ class XMLElement : public XMLNode {
explicit XMLElement (std::string name);
XMLElement (const XMLElement &node);
XMLElement (XMLElement &&node) noexcept;
- ~XMLElement ();
+ ~XMLElement () override;
std::unique_ptr<XMLNode> clone () const override {return util::make_unique<XMLElement>(*this);}
void clear () override;
void addAttribute (const std::string &name, const std::string &value);
diff --git a/dviware/dvisvgm/src/XMLString.cpp b/dviware/dvisvgm/src/XMLString.cpp
index 31de6a7b33..72026bdd76 100644
--- a/dviware/dvisvgm/src/XMLString.cpp
+++ b/dviware/dvisvgm/src/XMLString.cpp
@@ -2,7 +2,7 @@
** XMLString.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 **
diff --git a/dviware/dvisvgm/src/XMLString.hpp b/dviware/dvisvgm/src/XMLString.hpp
index 52c227ae8a..36ef2bee55 100644
--- a/dviware/dvisvgm/src/XMLString.hpp
+++ b/dviware/dvisvgm/src/XMLString.hpp
@@ -2,7 +2,7 @@
** XMLString.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/XXHashFunction.hpp b/dviware/dvisvgm/src/XXHashFunction.hpp
index d26a4e4984..4478a2204c 100644
--- a/dviware/dvisvgm/src/XXHashFunction.hpp
+++ b/dviware/dvisvgm/src/XXHashFunction.hpp
@@ -2,7 +2,7 @@
** XXHashFunction.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/ZLibOutputStream.hpp b/dviware/dvisvgm/src/ZLibOutputStream.hpp
index c1c065e357..a995dbf01e 100644
--- a/dviware/dvisvgm/src/ZLibOutputStream.hpp
+++ b/dviware/dvisvgm/src/ZLibOutputStream.hpp
@@ -2,7 +2,7 @@
** ZLibOutputStream.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/dvisvgm.cpp b/dviware/dvisvgm/src/dvisvgm.cpp
index 803e34e717..5cf833dd82 100644
--- a/dviware/dvisvgm/src/dvisvgm.cpp
+++ b/dviware/dvisvgm/src/dvisvgm.cpp
@@ -2,7 +2,7 @@
** dvisvgm.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 **
@@ -244,7 +244,7 @@ class VersionInfo {
protected:
void append (const string &name, const string &version) {
- _versionPairs.emplace_back(pair<string,string>(name, version));
+ _versionPairs.emplace_back(name, version);
}
private:
@@ -349,7 +349,8 @@ static void set_variables (const CommandLine &cmdline) {
string msg = "unknown font format '"+cmdline.fontFormatOpt.value()+"' (supported formats: ";
for (const string &format : FontWriter::supportedFormats())
msg += format + ", ";
- msg.erase(msg.end()-2);
+ msg.erase(msg.end()-2, msg.end());
+ msg += ")";
throw CL::CommandLineException(msg);
}
SVGTree::CREATE_USE_ELEMENTS = cmdline.noFontsOpt.value() < 1;
diff --git a/dviware/dvisvgm/src/ffwrapper.c b/dviware/dvisvgm/src/ffwrapper.c
index 61f17fdc6d..4f89c2b6d1 100644
--- a/dviware/dvisvgm/src/ffwrapper.c
+++ b/dviware/dvisvgm/src/ffwrapper.c
@@ -2,7 +2,7 @@
** ffwrapper.c **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/ffwrapper.h b/dviware/dvisvgm/src/ffwrapper.h
index e3e2f98832..6474d854a2 100644
--- a/dviware/dvisvgm/src/ffwrapper.h
+++ b/dviware/dvisvgm/src/ffwrapper.h
@@ -2,7 +2,7 @@
** ffwrapper.h **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/macros.hpp b/dviware/dvisvgm/src/macros.hpp
index 0a03776057..907e402c8c 100644
--- a/dviware/dvisvgm/src/macros.hpp
+++ b/dviware/dvisvgm/src/macros.hpp
@@ -2,7 +2,7 @@
** macros.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp b/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
index 28046e45a2..e5f3b95536 100644
--- a/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
+++ b/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
@@ -2,7 +2,7 @@
** AttributeExtractor.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 **
diff --git a/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp b/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
index b4c6f2775c..c8ab6bd61a 100644
--- a/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
+++ b/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
@@ -2,7 +2,7 @@
** AttributeExtractor.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp b/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
index 98d2a8d699..912d4a9110 100644
--- a/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
+++ b/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
@@ -2,7 +2,7 @@
** DependencyGraph.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp b/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
index c3060be788..c5954d705c 100644
--- a/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
+++ b/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
@@ -2,7 +2,7 @@
** GroupCollapser.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 **
@@ -107,7 +107,7 @@ void GroupCollapser::execute (XMLElement *context) {
* @return true if all attributes have been moved */
bool GroupCollapser::moveAttributes (XMLElement &source, XMLElement &dest) {
vector<string> movedAttributes;
- for (const XMLElement::Attribute &attr : source.attributes()) {
+ for (const auto &attr : source.attributes()) {
if (attr.name == "transform") {
string transform;
if (const char *destvalue = dest.getAttributeValue("transform"))
diff --git a/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp b/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
index 08db518a90..2694c4f355 100644
--- a/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
+++ b/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
@@ -2,7 +2,7 @@
** GroupCollapser.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/Makefile.in b/dviware/dvisvgm/src/optimizer/Makefile.in
index 0913c8462f..26731769a2 100644
--- a/dviware/dvisvgm/src/optimizer/Makefile.in
+++ b/dviware/dvisvgm/src/optimizer/Makefile.in
@@ -346,6 +346,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp b/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
index 276cfa5578..91f0263bb8 100644
--- a/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
+++ b/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
@@ -2,7 +2,7 @@
** OptimizerModule.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
index a8aca1a993..f8d040a329 100644
--- a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
+++ b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
@@ -2,7 +2,7 @@
** RedundantElementRemover.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 **
diff --git a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
index 8d5a6b689f..52ce905c8e 100644
--- a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
+++ b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
@@ -2,7 +2,7 @@
** RedundantElementRemover.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp b/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
index ac4a78fe20..8f9635a836 100644
--- a/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
+++ b/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
@@ -2,7 +2,7 @@
** SVGOptimizer.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 **
diff --git a/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp b/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
index 0da157fbbb..b15723d9ea 100644
--- a/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
+++ b/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
@@ -2,7 +2,7 @@
** SVGOptimizer.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp b/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
index b94ab9458e..2b778dadbc 100644
--- a/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
+++ b/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
@@ -2,7 +2,7 @@
** TextSimplifier.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 **
@@ -39,7 +39,7 @@ static XMLElement::Attributes common_inheritable_attributes (const vector<XMLEle
if (commonAttribs.empty()) {
if (intersected)
break;
- for (const auto attrib : elem->attributes()) {
+ for (const auto &attrib : elem->attributes()) {
if (AttributeExtractor::inheritable(attrib))
commonAttribs.push_back(attrib);
}
@@ -94,11 +94,11 @@ void TextSimplifier::execute (XMLElement *context) {
vector<XMLElement::Attribute> attribs = common_inheritable_attributes(tspans);
if (!tspans.empty() && !attribs.empty()) {
// move all common tspan attributes to the parent text element
- for (const XMLElement::Attribute &attr : attribs)
+ for (const auto &attr : attribs)
context->addAttribute(attr.name, attr.value);
// remove all common attributes from the tspan elements
for (XMLElement *tspan : tspans) {
- for (const XMLElement::Attribute &attr : attribs)
+ for (const auto &attr : attribs)
tspan->removeAttribute(attr.name);
// unwrap the tspan if there are no remaining attributes
if (tspan->attributes().empty())
diff --git a/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp b/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
index cfdd548e87..9ad3e0edb0 100644
--- a/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
+++ b/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
@@ -2,7 +2,7 @@
** TextSimplifier.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp b/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
index 2541631b0e..ce0a6d8d7a 100644
--- a/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
+++ b/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
@@ -2,7 +2,7 @@
** TransformSimplifier.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 **
diff --git a/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp b/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
index 5d503635ba..10591dc271 100644
--- a/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
+++ b/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
@@ -2,7 +2,7 @@
** TransformSimplifier.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp b/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
index 3f83011f5a..09de2f19bb 100644
--- a/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
+++ b/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
@@ -2,7 +2,7 @@
** WSNodeRemover.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 **
diff --git a/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp b/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
index 8c21ce2b6e..438c21c8fd 100644
--- a/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
+++ b/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
@@ -2,7 +2,7 @@
** WSNodeRemover.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/options.dtd b/dviware/dvisvgm/src/options.dtd
index d2806badce..21c33a168a 100644
--- a/dviware/dvisvgm/src/options.dtd
+++ b/dviware/dvisvgm/src/options.dtd
@@ -3,7 +3,7 @@
** options.dtd **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/options.xml b/dviware/dvisvgm/src/options.xml
index b1911694dd..1d0d09e3d6 100644
--- a/dviware/dvisvgm/src/options.xml
+++ b/dviware/dvisvgm/src/options.xml
@@ -3,7 +3,7 @@
** options.xml **
** **
** 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 **
@@ -26,7 +26,7 @@
<usage>--eps [options] epsfile</usage>
<usage>--pdf [options] pdffile</usage>
<description>This program converts DVI files, as created by TeX/LaTeX, as well as\nEPS and PDF files to the XML-based scalable vector graphics format SVG.</description>
- <copyright>Copyright (C) 2005-2020 Martin Gieseking &lt;martin.gieseking@uos.de></copyright>
+ <copyright>Copyright (C) 2005-2021 Martin Gieseking &lt;martin.gieseking@uos.de></copyright>
</program>
<options>
<section title="Input options">
diff --git a/dviware/dvisvgm/src/psdefs.cpp b/dviware/dvisvgm/src/psdefs.cpp
index 8cc5a10cb9..baa8b09a6c 100644
--- a/dviware/dvisvgm/src/psdefs.cpp
+++ b/dviware/dvisvgm/src/psdefs.cpp
@@ -2,7 +2,7 @@
** psdefs.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 **
@@ -115,47 +115,51 @@ const char *PSInterpreter::PSDEFS =
"rgbcolor 3(setrgbcolor)prcmd}def/printgstate{@dodraw @GD/@nulldev get not and{"
"matrix currentmatrix aload pop 6(setmatrix)prcmd applyscalevals currentlinewid"
"th 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentlinejoin 1(se"
-"tlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd prcolor currentdash ma"
-"rk 3 1 roll exch aload length 1 add -1 roll counttomark(setdash)prcmd pop}if}d"
-"ef/strconcat{exch dup length 2 index length add string dup dup 4 2 roll copy l"
-"ength 4 -1 roll putinterval}def/setgstate{/setgstate sysexec printgstate}def/s"
-"ave{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)prcmd}def/"
-"restore{:restore @checknulldev printgstate @UD/@saveID known{@UD begin @saveID"
-" end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore @checknull"
-"dev printgstate 0(grestore)prcmd}def/grestoreall{:grestoreall @checknulldev se"
-"tstate 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne @dodraw and{dup 1("
-"rotate)prcmd}if/rotate sysexec applyscalevals}def/scale{dup type/arraytype ne "
-"@dodraw and{2 copy 2(scale)prcmd}if/scale sysexec applyscalevals}def/translate"
-"{dup type/arraytype ne @dodraw and{2 copy 2(translate)prcmd}if/translate sysex"
-"ec}def/setmatrix{dup/setmatrix sysexec @dodraw{aload pop 6(setmatrix)prcmd app"
-"lyscalevals}{pop}ifelse}def/initmatrix{matrix setmatrix}def/concat{matrix curr"
-"entmatrix matrix concatmatrix setmatrix}def/makepattern{gsave<</mx 3 -1 roll>>"
-"begin<</XUID[1000000 @patcnt]>>copy mx/makepattern sysexec dup begin PatternTy"
-"pe 2 lt{PatternType @patcnt BBox aload pop XStep YStep PaintType mx aload pop "
-"15(makepattern)prcmd :newpath matrix setmatrix dup PaintProc 0 1(makepattern)p"
-"rcmd @GD/@patcnt @patcnt 1 add put}if end end grestore}def/setpattern{begin Pa"
-"tternType 1 eq{PaintType 1 eq{XUID aload pop exch pop 1}{:gsave[currentcolorsp"
-"ace aload length -1 roll pop]/setcolorspace sysexec/setcolor sysexec XUID aloa"
-"d pop exch pop currentrgbcolor :grestore 4}ifelse(setpattern)prcmd currentcolo"
-"rspace 0 get/Pattern ne{[/Pattern currentcolorspace]/setcolorspace sysexec}if "
-"currentcolorspace @setcolorspace}{/setpattern sysexec}ifelse end}def/setcolor{"
-"dup type/dicttype eq{setpattern}{/setcolor sysexec/currentrgbcolor sysexec set"
-"rgbcolor}ifelse}def/setcolorspace{dup/setcolorspace sysexec @setcolorspace}def"
-"/@setcolorspace{dup type/arraytype eq{0 get}if/Pattern eq{1}{0}ifelse 1(setcol"
-"orspace)prcmd}def/setgray 1 defpr/setcmykcolor 4 defpr/sethsbcolor 3 defpr/set"
-"rgbcolor 3 defpr/.setalphaisshape{@SD/.setalphaisshape known{dup/.setalphaissh"
-"ape sysexec}if{1}{0}ifelse 1(setisshapealpha)prcmd}bind def/.setfillconstantal"
-"pha{@SD/.setfillconstantalpha known{dup/.setfillconstantalpha sysexec}if 1(set"
-"fillconstantalpha)prcmd}bind def/.setstrokeconstantalpha{@SD/.setstrokeconstan"
-"talpha known{dup/.setstrokeconstantalpha sysexec}if 1(setstrokeconstantalpha)p"
-"rcmd}bind def/.setopacityalpha{false .setalphaisshape dup .setfillconstantalph"
-"a .setstrokeconstantalpha}bind def/.setshapealpha{true .setalphaisshape dup .s"
-"etfillconstantalpha .setstrokeconstantalpha}bind def/.setblendmode{dup/.setble"
-"ndmode sysexec<</Normal 0/Compatible 0/Multiply 1/Screen 2/Overlay 3/SoftLight"
-" 4/HardLight 5/ColorDodge 6/ColorBurn 7/Darken 8/Lighten 9/Difference 10/Exclu"
-"sion 11/Hue 12/Saturation 13/Color 14/Luminosity 15/CompatibleOverprint 16>>ex"
-"ch get 1(setblendmode)prcmd}def/@pdfpagecount{(r)file runpdfbegin pdfpagecount"
-" runpdfend}def/@pdfpagebox{(r)file runpdfbegin dup dup 1 lt exch pdfpagecount "
-"gt or{pop}{pdfgetpage/MediaBox pget pop aload pop}ifelse runpdfend}def DELAYBI"
-"ND{.bindnow}if ";
+"tlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd revision dup 952 lt{po"
+"p}{.currentblendmode .setblendmode 952 eq{.currentopacityalpha .setopacityalph"
+"a .currentshapealpha .setshapealpha}{.currentalphaisshape{1}{0}ifelse 1(setalp"
+"haisshape)prcmd .currentstrokeconstantalpha 1(setstrokeconstantalpha)prcmd .cu"
+"rrentfillconstantalpha 1(setfillconstantalpha)prcmd}ifelse}ifelse prcolor curr"
+"entdash mark 3 1 roll exch aload length 1 add -1 roll counttomark(setdash)prcm"
+"d pop}if}def/strconcat{exch dup length 2 index length add string dup dup 4 2 r"
+"oll copy length 4 -1 roll putinterval}def/setgstate{/setgstate sysexec printgs"
+"tate}def/save{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)"
+"prcmd}def/restore{:restore @checknulldev printgstate @UD/@saveID known{@UD beg"
+"in @saveID end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore "
+"@checknulldev printgstate 0(grestore)prcmd}def/grestoreall{:grestoreall @check"
+"nulldev setstate 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne @dodraw "
+"and{dup 1(rotate)prcmd}if/rotate sysexec applyscalevals}def/scale{dup type/arr"
+"aytype ne @dodraw and{2 copy 2(scale)prcmd}if/scale sysexec applyscalevals}def"
+"/translate{dup type/arraytype ne @dodraw and{2 copy 2(translate)prcmd}if/trans"
+"late sysexec}def/setmatrix{dup/setmatrix sysexec @dodraw{aload pop 6(setmatrix"
+")prcmd applyscalevals}{pop}ifelse}def/initmatrix{matrix setmatrix}def/concat{m"
+"atrix currentmatrix matrix concatmatrix setmatrix}def/makepattern{gsave<</mx 3"
+" -1 roll>>begin<</XUID[1000000 @patcnt]>>copy mx/makepattern sysexec dup begin"
+" PatternType 2 lt{PatternType @patcnt BBox aload pop XStep YStep PaintType mx "
+"aload pop 15(makepattern)prcmd :newpath matrix setmatrix dup PaintProc 0 1(mak"
+"epattern)prcmd @GD/@patcnt @patcnt 1 add put}if end end grestore}def/setpatter"
+"n{dup begin PatternType end 1 eq{begin PaintType 1 eq{XUID aload pop exch pop "
+"1}{:gsave[currentcolorspace aload length -1 roll pop]/setcolorspace sysexec/se"
+"tcolor sysexec XUID aload pop exch pop currentrgbcolor :grestore 4}ifelse(setp"
+"attern)prcmd currentcolorspace 0 get/Pattern ne{[/Pattern currentcolorspace]/s"
+"etcolorspace sysexec}if currentcolorspace @setcolorspace end}{/setpattern syse"
+"xec}ifelse}def/setcolor{dup type/dicttype eq{setpattern}{/setcolor sysexec/cur"
+"rentrgbcolor sysexec setrgbcolor}ifelse}def/setcolorspace{dup/setcolorspace sy"
+"sexec @setcolorspace}def/@setcolorspace{dup type/arraytype eq{0 get}if/Pattern"
+" eq{1}{0}ifelse 1(setcolorspace)prcmd}def/setgray 1 defpr/setcmykcolor 4 defpr"
+"/sethsbcolor 3 defpr/setrgbcolor 3 defpr/.setalphaisshape{@SD/.setalphaisshape"
+" known{dup/.setalphaisshape sysexec}if{1}{0}ifelse 1(setalphaisshape)prcmd}bin"
+"d def/.setfillconstantalpha{@SD/.setfillconstantalpha known{dup/.setfillconsta"
+"ntalpha sysexec}if 1(setfillconstantalpha)prcmd}bind def/.setstrokeconstantalp"
+"ha{@SD/.setstrokeconstantalpha known{dup/.setstrokeconstantalpha sysexec}if 1("
+"setstrokeconstantalpha)prcmd}bind def/.setopacityalpha{false .setalphaisshape "
+"dup .setfillconstantalpha .setstrokeconstantalpha}bind def/.setshapealpha{true"
+" .setalphaisshape dup .setfillconstantalpha .setstrokeconstantalpha}bind def/."
+"setblendmode{dup/.setblendmode sysexec<</Normal 0/Compatible 0/Multiply 1/Scre"
+"en 2/Overlay 3/SoftLight 4/HardLight 5/ColorDodge 6/ColorBurn 7/Darken 8/Light"
+"en 9/Difference 10/Exclusion 11/Hue 12/Saturation 13/Color 14/Luminosity 15/Co"
+"mpatibleOverprint 16>>exch get 1(setblendmode)prcmd}def/@pdfpagecount{(r)file "
+"runpdfbegin pdfpagecount runpdfend}def/@pdfpagebox{(r)file runpdfbegin dup dup"
+" 1 lt exch pdfpagecount gt or{pop}{pdfgetpage/MediaBox pget pop aload pop}ifel"
+"se runpdfend}def DELAYBIND{.bindnow}if ";
diff --git a/dviware/dvisvgm/src/utility.cpp b/dviware/dvisvgm/src/utility.cpp
index 8fe31fcf2d..37055f2cb8 100644
--- a/dviware/dvisvgm/src/utility.cpp
+++ b/dviware/dvisvgm/src/utility.cpp
@@ -2,7 +2,7 @@
** utility.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 **
@@ -134,17 +134,17 @@ string util::replace (string str, const string &find, const string &repl) {
vector<string> util::split (const string &str, const string &sep) {
vector<string> parts;
if (str.empty() || sep.empty())
- parts.emplace_back(str);
+ parts.push_back(str);
else {
size_t left=0;
while (left <= str.length()) {
size_t right = str.find(sep, left);
if (right == string::npos) {
- parts.emplace_back(str.substr(left));
+ parts.push_back(str.substr(left));
left = string::npos;
}
else {
- parts.emplace_back(str.substr(left, right-left));
+ parts.push_back(str.substr(left, right-left));
left = right+sep.length();
}
}
diff --git a/dviware/dvisvgm/src/utility.hpp b/dviware/dvisvgm/src/utility.hpp
index 7ad3bc8d69..275da3cc3a 100644
--- a/dviware/dvisvgm/src/utility.hpp
+++ b/dviware/dvisvgm/src/utility.hpp
@@ -2,7 +2,7 @@
** utility.hpp **
** **
** 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 **
@@ -25,6 +25,7 @@
#include <memory>
#include <sstream>
#include <string>
+#include <type_traits>
#include <vector>
namespace math {
@@ -145,6 +146,17 @@ std::unique_ptr<T> static_unique_ptr_cast (std::unique_ptr<U> &&old){
return std::unique_ptr<T>{static_cast<T*>(old.release())};
}
+template <typename T>
+struct set_const_of {
+ template <typename U>
+ struct by {
+ using type = typename std::conditional<
+ std::is_const<U>::value,
+ typename std::add_const<T>::type,
+ typename std::remove_const<T>::type
+ >::type;
+ };
+};
} // namespace util
#endif
diff --git a/dviware/dvisvgm/src/version.hpp.in b/dviware/dvisvgm/src/version.hpp.in
index 20ba32bbd5..70d27f6e48 100644
--- a/dviware/dvisvgm/src/version.hpp.in
+++ b/dviware/dvisvgm/src/version.hpp.in
@@ -2,7 +2,7 @@
** version.hpp **
** **
** 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 **
diff --git a/dviware/dvisvgm/src/windows.hpp b/dviware/dvisvgm/src/windows.hpp
index 114420c3d5..5f71bbed1e 100644
--- a/dviware/dvisvgm/src/windows.hpp
+++ b/dviware/dvisvgm/src/windows.hpp
@@ -2,7 +2,7 @@
** windows.hpp **
** **
** 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 **