From 2eec8af74453f6a52c6cba1ff56bea80e4196e67 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 24 Jun 2013 09:11:37 +0000 Subject: dvisvfm 1.3 (potracelib now in libs/potrace) git-svn-id: svn://tug.org/texlive/trunk@30888 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvisvgm/ChangeLog | 6 + Build/source/texk/dvisvgm/Makefile.am | 22 +- Build/source/texk/dvisvgm/Makefile.in | 224 ++-- Build/source/texk/dvisvgm/ac/withenable.ac | 4 +- Build/source/texk/dvisvgm/aclocal.m4 | 288 +++-- Build/source/texk/dvisvgm/configure | 290 ++++- Build/source/texk/dvisvgm/configure.ac | 5 +- .../texk/dvisvgm/dvisvgm-1.2.2-PATCHES/ChangeLog | 27 - .../texk/dvisvgm/dvisvgm-1.2.2-PATCHES/TL-Changes | 14 - .../dvisvgm/dvisvgm-1.2.2-PATCHES/patch-01-cpp | 13 - Build/source/texk/dvisvgm/dvisvgm-1.2.2/AUTHORS | 10 - Build/source/texk/dvisvgm/dvisvgm-1.2.2/COPYING | 674 ----------- Build/source/texk/dvisvgm/dvisvgm-1.2.2/INSTALL | 229 ---- .../source/texk/dvisvgm/dvisvgm-1.2.2/LGPL-2.1.txt | 504 -------- .../source/texk/dvisvgm/dvisvgm-1.2.2/Makefile.am | 15 - Build/source/texk/dvisvgm/dvisvgm-1.2.2/NEWS | 288 ----- Build/source/texk/dvisvgm/dvisvgm-1.2.2/README | 112 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/config.h.in | 166 --- .../source/texk/dvisvgm/dvisvgm-1.2.2/config.rpath | 0 .../source/texk/dvisvgm/dvisvgm-1.2.2/configure.ac | 158 --- .../texk/dvisvgm/dvisvgm-1.2.2/doc/Makefile.am | 39 - .../texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.1 | 1038 ---------------- .../texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.txt.in | 629 ---------- .../dvisvgm/dvisvgm-1.2.2/potracelib/Makefile.am | 13 - .../dvisvgm/dvisvgm-1.2.2/potracelib/auxiliary.h | 78 -- .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/bitmap.h | 97 -- .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.c | 108 -- .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.h | 77 -- .../dvisvgm/dvisvgm-1.2.2/potracelib/decompose.c | 514 -------- .../dvisvgm/dvisvgm-1.2.2/potracelib/decompose.h | 16 - .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/lists.h | 285 ----- .../dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.c | 114 -- .../dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.h | 139 --- .../dvisvgm/dvisvgm-1.2.2/potracelib/progress.h | 79 -- .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.c | 1245 -------------------- .../texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.h | 15 - .../dvisvgm-1.2.2/src/BgColorSpecialHandler.cpp | 37 - .../dvisvgm-1.2.2/src/BgColorSpecialHandler.h | 34 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.cpp | 124 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.h | 109 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.cpp | 262 ---- .../texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.h | 86 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.cpp | 112 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.h | 51 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.cpp | 178 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.h | 57 - .../dvisvgm-1.2.2/src/CmdLineParserBase.cpp | 369 ------ .../dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.h | 97 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Color.cpp | 127 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.h | 64 - .../dvisvgm-1.2.2/src/ColorSpecialHandler.cpp | 269 ----- .../dvisvgm-1.2.2/src/ColorSpecialHandler.h | 43 - .../texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.cpp | 297 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.h | 166 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.cpp | 56 - .../texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.h | 52 - .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.cpp | 26 - .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.h | 56 - .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.cpp | 682 ----------- .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.h | 147 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.cpp | 359 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.h | 63 - .../dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.cpp | 343 ------ .../dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.h | 102 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Directory.cpp | 116 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Directory.h | 54 - .../dvisvgm-1.2.2/src/DvisvgmSpecialHandler.cpp | 202 ---- .../dvisvgm-1.2.2/src/DvisvgmSpecialHandler.h | 35 - .../texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.cpp | 114 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.h | 46 - .../texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.cpp | 78 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.h | 65 - .../dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.cpp | 231 ---- .../dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.h | 58 - .../texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.cpp | 256 ---- .../texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.h | 34 - .../texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.cpp | 257 ---- .../texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.h | 59 - .../texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.cpp | 333 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.h | 48 - .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.cpp | 444 ------- Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.h | 280 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.cpp | 387 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.h | 74 -- .../dvisvgm/dvisvgm-1.2.2/src/FontEncoding.cpp | 164 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.h | 48 - .../texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.cpp | 379 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.h | 73 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.cpp | 296 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.h | 82 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.cpp | 302 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.h | 75 -- .../dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.cpp | 92 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.h | 60 - .../texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.cpp | 352 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.h | 110 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.cpp | 102 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.h | 47 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.cpp | 269 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.h | 104 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Glyph.h | 28 - .../dvisvgm-1.2.2/src/GlyphTracerMessages.h | 65 - .../texk/dvisvgm/dvisvgm-1.2.2/src/GraphicPath.h | 340 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.cpp | 137 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.h | 145 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.cpp | 342 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.h | 89 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Length.cpp | 84 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.h | 62 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Makefile.am | 52 - .../texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.cpp | 275 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.h | 72 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.cpp | 465 -------- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.h | 104 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/Message.cpp | 273 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/Message.h | 114 -- .../dvisvgm/dvisvgm-1.2.2/src/MessageException.h | 39 - .../dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.cpp | 133 --- .../dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.h | 43 - .../texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.cpp | 89 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.h | 51 - .../dvisvgm-1.2.2/src/NoPsSpecialHandler.cpp | 45 - .../dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.h | 43 - .../dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.cpp | 324 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.h | 121 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.cpp | 178 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.h | 100 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.cpp | 135 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.h | 49 - .../texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.cpp | 156 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.h | 48 - Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Pair.h | 79 -- .../dvisvgm-1.2.2/src/PdfSpecialHandler.cpp | 76 -- .../dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.h | 39 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Process.cpp | 142 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/Process.h | 41 - .../dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.cpp | 806 ------------- .../dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.h | 140 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/SVGOutputBase.h | 33 - .../texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.cpp | 341 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.h | 104 -- .../dvisvgm/dvisvgm-1.2.2/src/SignalHandler.cpp | 85 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.h | 50 - .../dvisvgm/dvisvgm-1.2.2/src/SpecialActions.h | 80 -- .../dvisvgm/dvisvgm-1.2.2/src/SpecialHandler.h | 58 - .../dvisvgm/dvisvgm-1.2.2/src/SpecialManager.cpp | 151 --- .../dvisvgm/dvisvgm-1.2.2/src/SpecialManager.h | 71 -- .../dvisvgm/dvisvgm-1.2.2/src/StreamReader.cpp | 164 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.h | 64 - .../dvisvgm/dvisvgm-1.2.2/src/StreamWriter.cpp | 81 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.h | 46 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.cpp | 265 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.h | 102 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/System.cpp | 53 - .../source/texk/dvisvgm/dvisvgm-1.2.2/src/System.h | 29 - .../source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.cpp | 149 --- Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.h | 59 - .../texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.cpp | 191 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.h | 56 - .../dvisvgm-1.2.2/src/TpicSpecialHandler.cpp | 323 ----- .../dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.h | 51 - .../texk/dvisvgm/dvisvgm-1.2.2/src/VFActions.h | 38 - .../texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.cpp | 190 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.h | 65 - .../texk/dvisvgm/dvisvgm-1.2.2/src/VectorStream.h | 46 - .../dvisvgm/dvisvgm-1.2.2/src/XMLDocTypeNode.h | 41 - .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.cpp | 100 -- .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.h | 44 - .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.cpp | 343 ------ .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.h | 134 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.cpp | 134 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.h | 40 - .../texk/dvisvgm/dvisvgm-1.2.2/src/dvisvgm.cpp | 424 ------- .../texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.cpp | 172 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.h | 121 -- Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/iapi.h | 300 ----- .../texk/dvisvgm/dvisvgm-1.2.2/src/ierrors.h | 153 --- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/macros.h | 42 - .../texk/dvisvgm/dvisvgm-1.2.2/src/options.xml | 147 --- .../texk/dvisvgm/dvisvgm-1.2.2/src/psdefs.cpp | 84 -- .../source/texk/dvisvgm/dvisvgm-1.2.2/src/types.h | 84 -- .../dvisvgm-1.2.2/tests/BoundingBoxTest.cpp | 53 - .../texk/dvisvgm/dvisvgm-1.2.2/tests/CRC32Test.cpp | 71 -- .../dvisvgm/dvisvgm-1.2.2/tests/CalculatorTest.cpp | 60 - .../dvisvgm-1.2.2/tests/ColorSpecialTest.cpp | 91 -- .../dvisvgm-1.2.2/tests/CommandLineTest.cpp | 216 ---- .../dvisvgm/dvisvgm-1.2.2/tests/DirectoryTest.cpp | 66 -- .../dvisvgm/dvisvgm-1.2.2/tests/FileFinderTest.cpp | 82 -- .../dvisvgm/dvisvgm-1.2.2/tests/FilePathTest.cpp | 107 -- .../dvisvgm/dvisvgm-1.2.2/tests/FileSystemTest.cpp | 121 -- .../dvisvgm-1.2.2/tests/FontManagerTest.cpp | 76 -- .../dvisvgm/dvisvgm-1.2.2/tests/FontMapTest.cpp | 70 -- .../dvisvgm/dvisvgm-1.2.2/tests/GFReaderTest.cpp | 252 ---- .../dvisvgm-1.2.2/tests/GraphicPathTest.cpp | 82 -- .../dvisvgm/dvisvgm-1.2.2/tests/LengthTest.cpp | 120 -- .../texk/dvisvgm/dvisvgm-1.2.2/tests/Makefile.am | 155 --- .../dvisvgm/dvisvgm-1.2.2/tests/MapLineTest.cpp | 131 -- .../dvisvgm/dvisvgm-1.2.2/tests/MatrixTest.cpp | 151 --- .../dvisvgm-1.2.2/tests/MessageExceptionTest.cpp | 78 -- .../dvisvgm-1.2.2/tests/PSInterpreterTest.cpp | 180 --- .../dvisvgm/dvisvgm-1.2.2/tests/PageRagesTest.cpp | 167 --- .../dvisvgm/dvisvgm-1.2.2/tests/PageSizeTest.cpp | 73 -- .../texk/dvisvgm/dvisvgm-1.2.2/tests/PairTest.cpp | 125 -- .../tests/SplittedCharInputBufferTest.cpp | 181 --- .../dvisvgm-1.2.2/tests/StreamInputBufferTest.cpp | 230 ---- .../dvisvgm-1.2.2/tests/StreamReaderTest.cpp | 100 -- .../dvisvgm-1.2.2/tests/StreamWriterTest.cpp | 114 -- .../dvisvgm/dvisvgm-1.2.2/tests/SubfontTest.cpp | 96 -- .../texk/dvisvgm/dvisvgm-1.2.2/tests/TypesTest.cpp | 57 - .../dvisvgm-1.2.2/tests/VectorStreamTest.cpp | 42 - .../texk/dvisvgm/dvisvgm-1.2.2/tests/check-conv | 50 - .../texk/dvisvgm/dvisvgm-1.2.2/tests/cmr10.600gf | Bin 24244 -> 0 bytes .../dvisvgm/dvisvgm-1.2.2/tests/frktest-nf-cmp.svg | 1223 ------------------- .../dvisvgm/dvisvgm-1.2.2/tests/frktest-wf-cmp.svg | 348 ------ .../texk/dvisvgm/dvisvgm-1.2.2/tests/frktest.dvi | Bin 2072 -> 0 bytes .../texk/dvisvgm/dvisvgm-1.2.2/tests/normalize.xsl | 135 --- .../dvisvgm/dvisvgm-1.2.2/tests/sample-nf-cmp.svg | 204 ---- .../dvisvgm/dvisvgm-1.2.2/tests/sample-wf-cmp.svg | 201 ---- .../texk/dvisvgm/dvisvgm-1.2.2/tests/sample.dvi | Bin 1320 -> 0 bytes .../texk/dvisvgm/dvisvgm-1.2.2/tests/sample.sfd | 293 ----- .../texk/dvisvgm/dvisvgm-1.3-PATCHES/ChangeLog | 29 + .../texk/dvisvgm/dvisvgm-1.3-PATCHES/TL-Changes | 15 + .../texk/dvisvgm/dvisvgm-1.3-PATCHES/patch-01-cpp | 26 + Build/source/texk/dvisvgm/dvisvgm-1.3/AUTHORS | 7 + Build/source/texk/dvisvgm/dvisvgm-1.3/COPYING | 674 +++++++++++ Build/source/texk/dvisvgm/dvisvgm-1.3/INSTALL | 229 ++++ Build/source/texk/dvisvgm/dvisvgm-1.3/LGPL-2.1.txt | 504 ++++++++ Build/source/texk/dvisvgm/dvisvgm-1.3/Makefile.am | 9 + Build/source/texk/dvisvgm/dvisvgm-1.3/NEWS | 299 +++++ Build/source/texk/dvisvgm/dvisvgm-1.3/README | 110 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/config.h.in | 166 +++ Build/source/texk/dvisvgm/dvisvgm-1.3/config.rpath | 0 Build/source/texk/dvisvgm/dvisvgm-1.3/configure.ac | 155 +++ .../texk/dvisvgm/dvisvgm-1.3/doc/Makefile.am | 39 + .../source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.1 | 1061 +++++++++++++++++ .../texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.txt.in | 641 ++++++++++ .../dvisvgm-1.3/src/BgColorSpecialHandler.cpp | 37 + .../dvisvgm-1.3/src/BgColorSpecialHandler.h | 34 + .../source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.cpp | 124 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.h | 109 ++ .../texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.cpp | 262 ++++ .../texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.h | 86 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.cpp | 112 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.h | 51 + .../texk/dvisvgm/dvisvgm-1.3/src/Calculator.cpp | 178 +++ .../texk/dvisvgm/dvisvgm-1.3/src/Calculator.h | 57 + .../dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.cpp | 369 ++++++ .../dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.h | 97 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Color.cpp | 127 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.h | 64 + .../dvisvgm-1.3/src/ColorSpecialHandler.cpp | 269 +++++ .../dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.h | 43 + .../texk/dvisvgm/dvisvgm-1.3/src/CommandLine.cpp | 306 +++++ .../texk/dvisvgm/dvisvgm-1.3/src/CommandLine.h | 171 +++ .../texk/dvisvgm/dvisvgm-1.3/src/DLLoader.cpp | 56 + .../source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.h | 52 + .../texk/dvisvgm/dvisvgm-1.3/src/DVIActions.cpp | 26 + .../texk/dvisvgm/dvisvgm-1.3/src/DVIActions.h | 56 + .../texk/dvisvgm/dvisvgm-1.3/src/DVIReader.cpp | 682 +++++++++++ .../texk/dvisvgm/dvisvgm-1.3/src/DVIReader.h | 147 +++ .../texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.cpp | 363 ++++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.h | 63 + .../dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.cpp | 347 ++++++ .../texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.h | 105 ++ .../texk/dvisvgm/dvisvgm-1.3/src/Directory.cpp | 116 ++ .../texk/dvisvgm/dvisvgm-1.3/src/Directory.h | 54 + .../dvisvgm-1.3/src/DvisvgmSpecialHandler.cpp | 202 ++++ .../dvisvgm-1.3/src/DvisvgmSpecialHandler.h | 35 + .../texk/dvisvgm/dvisvgm-1.3/src/EPSFile.cpp | 114 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.h | 46 + .../texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.cpp | 78 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.h | 68 ++ .../dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.cpp | 231 ++++ .../dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.h | 57 + .../texk/dvisvgm/dvisvgm-1.3/src/FileFinder.cpp | 248 ++++ .../texk/dvisvgm/dvisvgm-1.3/src/FileFinder.h | 34 + .../texk/dvisvgm/dvisvgm-1.3/src/FilePath.cpp | 257 ++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.h | 59 + .../texk/dvisvgm/dvisvgm-1.3/src/FileSystem.cpp | 333 ++++++ .../texk/dvisvgm/dvisvgm-1.3/src/FileSystem.h | 48 + Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.cpp | 453 +++++++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.h | 280 +++++ .../texk/dvisvgm/dvisvgm-1.3/src/FontCache.cpp | 387 ++++++ .../texk/dvisvgm/dvisvgm-1.3/src/FontCache.h | 74 ++ .../texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.cpp | 164 +++ .../texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.h | 48 + .../texk/dvisvgm/dvisvgm-1.3/src/FontEngine.cpp | 379 ++++++ .../texk/dvisvgm/dvisvgm-1.3/src/FontEngine.h | 73 ++ .../texk/dvisvgm/dvisvgm-1.3/src/FontManager.cpp | 296 +++++ .../texk/dvisvgm/dvisvgm-1.3/src/FontManager.h | 81 ++ .../texk/dvisvgm/dvisvgm-1.3/src/FontMap.cpp | 302 +++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.h | 75 ++ .../texk/dvisvgm/dvisvgm-1.3/src/FontMetric.cpp | 40 + .../texk/dvisvgm/dvisvgm-1.3/src/FontMetric.h | 62 + .../texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.cpp | 92 ++ .../texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.h | 60 + .../texk/dvisvgm/dvisvgm-1.3/src/GFReader.cpp | 352 ++++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.h | 110 ++ .../texk/dvisvgm/dvisvgm-1.3/src/GFTracer.cpp | 102 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.h | 47 + .../texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.cpp | 269 +++++ .../texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.h | 104 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Glyph.h | 28 + .../dvisvgm/dvisvgm-1.3/src/GlyphTracerMessages.h | 65 + .../texk/dvisvgm/dvisvgm-1.3/src/GraphicPath.h | 340 ++++++ .../dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.cpp | 205 ++++ .../dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.h | 69 ++ .../texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.cpp | 137 +++ .../texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.h | 145 +++ .../texk/dvisvgm/dvisvgm-1.3/src/InputReader.cpp | 329 ++++++ .../texk/dvisvgm/dvisvgm-1.3/src/InputReader.h | 89 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.cpp | 96 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.h | 42 + .../source/texk/dvisvgm/dvisvgm-1.3/src/Length.cpp | 84 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.h | 62 + .../texk/dvisvgm/dvisvgm-1.3/src/Makefile.am | 52 + .../texk/dvisvgm/dvisvgm-1.3/src/MapLine.cpp | 275 +++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.h | 72 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.cpp | 465 ++++++++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.h | 104 ++ .../texk/dvisvgm/dvisvgm-1.3/src/Message.cpp | 273 +++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Message.h | 114 ++ .../dvisvgm/dvisvgm-1.3/src/MessageException.h | 39 + .../dvisvgm/dvisvgm-1.3/src/MetafontWrapper.cpp | 133 +++ .../texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.h | 43 + .../texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.cpp | 101 ++ .../texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.h | 52 + .../dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.cpp | 45 + .../dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.h | 42 + .../texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.cpp | 324 +++++ .../texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.h | 121 ++ .../texk/dvisvgm/dvisvgm-1.3/src/PSPattern.cpp | 178 +++ .../texk/dvisvgm/dvisvgm-1.3/src/PSPattern.h | 100 ++ .../texk/dvisvgm/dvisvgm-1.3/src/PageRanges.cpp | 135 +++ .../texk/dvisvgm/dvisvgm-1.3/src/PageRanges.h | 49 + .../texk/dvisvgm/dvisvgm-1.3/src/PageSize.cpp | 156 +++ .../source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.h | 48 + Build/source/texk/dvisvgm/dvisvgm-1.3/src/Pair.h | 79 ++ .../dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.cpp | 76 ++ .../dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.h | 39 + .../texk/dvisvgm/dvisvgm-1.3/src/Process.cpp | 142 +++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Process.h | 41 + .../dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.cpp | 806 +++++++++++++ .../dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.h | 140 +++ .../texk/dvisvgm/dvisvgm-1.3/src/SVGOutputBase.h | 33 + .../texk/dvisvgm/dvisvgm-1.3/src/SVGTree.cpp | 378 ++++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.h | 108 ++ .../texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.cpp | 85 ++ .../texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.h | 50 + .../texk/dvisvgm/dvisvgm-1.3/src/SpecialActions.h | 88 ++ .../texk/dvisvgm/dvisvgm-1.3/src/SpecialHandler.h | 65 + .../dvisvgm/dvisvgm-1.3/src/SpecialManager.cpp | 151 +++ .../texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.h | 71 ++ .../texk/dvisvgm/dvisvgm-1.3/src/StreamReader.cpp | 164 +++ .../texk/dvisvgm/dvisvgm-1.3/src/StreamReader.h | 65 + .../texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.cpp | 81 ++ .../texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.h | 46 + .../texk/dvisvgm/dvisvgm-1.3/src/Subfont.cpp | 265 +++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.h | 102 ++ .../source/texk/dvisvgm/dvisvgm-1.3/src/System.cpp | 53 + Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.h | 29 + Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.cpp | 154 +++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.h | 65 + .../texk/dvisvgm/dvisvgm-1.3/src/Terminal.cpp | 211 ++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.h | 58 + .../dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.cpp | 323 +++++ .../dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.h | 50 + .../texk/dvisvgm/dvisvgm-1.3/src/VFActions.h | 38 + .../texk/dvisvgm/dvisvgm-1.3/src/VFReader.cpp | 190 +++ .../source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.h | 65 + .../texk/dvisvgm/dvisvgm-1.3/src/VectorStream.h | 46 + .../texk/dvisvgm/dvisvgm-1.3/src/XMLDocTypeNode.h | 41 + .../texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.cpp | 100 ++ .../texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.h | 44 + .../texk/dvisvgm/dvisvgm-1.3/src/XMLNode.cpp | 343 ++++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.h | 134 +++ .../texk/dvisvgm/dvisvgm-1.3/src/XMLString.cpp | 134 +++ .../texk/dvisvgm/dvisvgm-1.3/src/XMLString.h | 40 + .../texk/dvisvgm/dvisvgm-1.3/src/dvisvgm.cpp | 447 +++++++ .../texk/dvisvgm/dvisvgm-1.3/src/gzstream.cpp | 172 +++ .../source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.h | 121 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/iapi.h | 300 +++++ .../source/texk/dvisvgm/dvisvgm-1.3/src/ierrors.h | 153 +++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/macros.h | 42 + .../texk/dvisvgm/dvisvgm-1.3/src/options.xml | 151 +++ .../source/texk/dvisvgm/dvisvgm-1.3/src/psdefs.cpp | 84 ++ Build/source/texk/dvisvgm/dvisvgm-1.3/src/types.h | 84 ++ Build/source/texk/dvisvgm/version.ac | 2 +- 388 files changed, 26157 insertions(+), 33653 deletions(-) delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/ChangeLog delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/TL-Changes delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/patch-01-cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/AUTHORS delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/COPYING delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/INSTALL delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/LGPL-2.1.txt delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/Makefile.am delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/NEWS delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/README delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.h.in delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.rpath delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/configure.ac delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/Makefile.am delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.1 delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.txt.in delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/Makefile.am delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/auxiliary.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/bitmap.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.c delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.c delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/lists.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.c delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/progress.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.c delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Glyph.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GlyphTracerMessages.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GraphicPath.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Makefile.am delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MessageException.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Pair.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGOutputBase.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialActions.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFActions.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VectorStream.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocTypeNode.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/dvisvgm.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/iapi.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ierrors.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/macros.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/options.xml delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/psdefs.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/types.h delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/BoundingBoxTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CRC32Test.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CalculatorTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/ColorSpecialTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CommandLineTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/DirectoryTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileFinderTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FilePathTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileSystemTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontManagerTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontMapTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GFReaderTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GraphicPathTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/LengthTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/Makefile.am delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MapLineTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MatrixTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MessageExceptionTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PSInterpreterTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageRagesTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageSizeTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PairTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SplittedCharInputBufferTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamInputBufferTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamReaderTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamWriterTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SubfontTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/TypesTest.cpp delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/VectorStreamTest.cpp delete mode 100755 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/check-conv delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/cmr10.600gf delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-nf-cmp.svg delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-wf-cmp.svg delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest.dvi delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/normalize.xsl delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-nf-cmp.svg delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-wf-cmp.svg delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.dvi delete mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.sfd create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/ChangeLog create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/TL-Changes create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/patch-01-cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/AUTHORS create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/COPYING create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/INSTALL create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/LGPL-2.1.txt create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/Makefile.am create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/NEWS create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/README create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/config.h.in create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/config.rpath create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/configure.ac create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/doc/Makefile.am create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.1 create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.txt.in create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Glyph.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GlyphTracerMessages.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/GraphicPath.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Makefile.am create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MessageException.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Pair.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGOutputBase.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialActions.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFActions.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/VectorStream.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocTypeNode.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/dvisvgm.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/iapi.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/ierrors.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/macros.h create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/options.xml create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/psdefs.cpp create mode 100644 Build/source/texk/dvisvgm/dvisvgm-1.3/src/types.h (limited to 'Build/source/texk') diff --git a/Build/source/texk/dvisvgm/ChangeLog b/Build/source/texk/dvisvgm/ChangeLog index 310d9b0142c..1fdfa1a2d34 100644 --- a/Build/source/texk/dvisvgm/ChangeLog +++ b/Build/source/texk/dvisvgm/ChangeLog @@ -1,3 +1,9 @@ +2013-05-17 Peter Breitenlohner + + * Imported release 1.3. + * version.ac: Adapted. + * Makefile.am: Adjusted. + 2013-05-21 Peter Breitenlohner * Imported release 1.2.2. diff --git a/Build/source/texk/dvisvgm/Makefile.am b/Build/source/texk/dvisvgm/Makefile.am index 1100fd818ec..b3d1723151e 100644 --- a/Build/source/texk/dvisvgm/Makefile.am +++ b/Build/source/texk/dvisvgm/Makefile.am @@ -25,8 +25,7 @@ dist-hook: rm -rf `find $(distdir) -name .svn -o -name .deps -o -name .dirstamp -o -name '*.$(OBJEXT)'` AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/src -AM_CPPFLAGS += -I$(top_srcdir)/$(DVISVGM_TREE)/potracelib -AM_CPPFLAGS += $(KPATHSEA_INCLUDES) $(FREETYPE2_INCLUDES) +AM_CPPFLAGS += $(KPATHSEA_INCLUDES) $(POTRACE_INCLUDES) $(FREETYPE2_INCLUDES) AM_CPPFLAGS += $(ZLIB_INCLUDES) $(LIBGS_INCLUDES) if WIN32 AM_CPPFLAGS += -DTEXLIVEWIN32 @@ -47,10 +46,10 @@ dvisvgm_dependencies = $(KPATHSEA_DEPEND) $(ZLIB_DEPEND) $(FREETYPE2_DEPEND) $(dvisvgm_OBJECTS): libdvisvgm.a -LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(FREETYPE2_LIBS) +LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(POTRACE_LIBS) $(FREETYPE2_LIBS) LDADD += $(ZLIB_LIBS) $(LIBGS_LIBS) -noinst_LIBRARIES = libdvisvgm.a libpotrace.a +noinst_LIBRARIES = libdvisvgm.a nodist_libdvisvgm_a_SOURCES = \ @DVISVGM_TREE@/src/BgColorSpecialHandler.cpp \ @@ -80,12 +79,15 @@ nodist_libdvisvgm_a_SOURCES = \ @DVISVGM_TREE@/src/FontEngine.cpp \ @DVISVGM_TREE@/src/FontManager.cpp \ @DVISVGM_TREE@/src/FontMap.cpp \ + @DVISVGM_TREE@/src/FontMetric.cpp \ @DVISVGM_TREE@/src/GFReader.cpp \ @DVISVGM_TREE@/src/GFGlyphTracer.cpp \ @DVISVGM_TREE@/src/GFTracer.cpp \ @DVISVGM_TREE@/src/Ghostscript.cpp \ + @DVISVGM_TREE@/src/HtmlSpecialHandler.cpp \ @DVISVGM_TREE@/src/InputBuffer.cpp \ @DVISVGM_TREE@/src/InputReader.cpp \ + @DVISVGM_TREE@/src/JFM.cpp \ @DVISVGM_TREE@/src/Length.cpp \ @DVISVGM_TREE@/src/MapLine.cpp \ @DVISVGM_TREE@/src/Matrix.cpp \ @@ -120,15 +122,7 @@ nodist_libdvisvgm_a_SOURCES += \ @DVISVGM_TREE@/src/DLLoader.cpp endif dlloader -$(libdvisvgm_a_OBJECTS): libpotrace.a - -nodist_libpotrace_a_SOURCES = \ - @DVISVGM_TREE@/potracelib/curve.c \ - @DVISVGM_TREE@/potracelib/decompose.c \ - @DVISVGM_TREE@/potracelib/potracelib.c \ - @DVISVGM_TREE@/potracelib/trace.c - -$(libpotrace_a_OBJECTS): config.force +$(libdvisvgm_a_OBJECTS): $(POTRACE_DEPEND) config.force: $(dvisvgm_dependencies) echo timestamp >config.force @@ -138,6 +132,8 @@ DISTCLEANFILES = config.force CXXLD.sh ## Rebuild libkpathsea @KPATHSEA_RULE@ +## Rebuild libpotrace +@POTRACE_RULE@ ## Rebuild libfreetype @FREETYPE2_RULE@ ## Rebuild libz diff --git a/Build/source/texk/dvisvgm/Makefile.in b/Build/source/texk/dvisvgm/Makefile.in index 522c80cb1d7..fd8c477e01a 100644 --- a/Build/source/texk/dvisvgm/Makefile.in +++ b/Build/source/texk/dvisvgm/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.13.1 from Makefile.am. +# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,23 +16,51 @@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ - test $$am__dry = yes; \ - } + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -61,10 +89,12 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in $(top_srcdir)/../../build-aux/depcomp \ $(top_srcdir)/../../build-aux/test-driver ChangeLog \ - ../../build-aux/config.guess ../../build-aux/config.sub \ - ../../build-aux/depcomp ../../build-aux/install-sh \ - ../../build-aux/missing ../../build-aux/texinfo.tex \ - ../../build-aux/ylwrap ../../build-aux/ltmain.sh \ + ../../build-aux/compile ../../build-aux/config.guess \ + ../../build-aux/config.sub ../../build-aux/depcomp \ + ../../build-aux/install-sh ../../build-aux/missing \ + ../../build-aux/texinfo.tex ../../build-aux/ylwrap \ + ../../build-aux/ltmain.sh \ + $(top_srcdir)/../../build-aux/compile \ $(top_srcdir)/../../build-aux/config.guess \ $(top_srcdir)/../../build-aux/config.sub \ $(top_srcdir)/../../build-aux/install-sh \ @@ -75,6 +105,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ $(top_srcdir)/../../m4/kpse-kpathsea-flags.m4 \ + $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ + $(top_srcdir)/../../m4/kpse-visibility.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ $(top_srcdir)/../../m4/kpse-win32.m4 \ $(top_srcdir)/../../m4/kpse-zlib-flags.m4 \ @@ -130,12 +162,15 @@ nodist_libdvisvgm_a_OBJECTS = \ @DVISVGM_TREE@/src/FontEngine.$(OBJEXT) \ @DVISVGM_TREE@/src/FontManager.$(OBJEXT) \ @DVISVGM_TREE@/src/FontMap.$(OBJEXT) \ + @DVISVGM_TREE@/src/FontMetric.$(OBJEXT) \ @DVISVGM_TREE@/src/GFReader.$(OBJEXT) \ @DVISVGM_TREE@/src/GFGlyphTracer.$(OBJEXT) \ @DVISVGM_TREE@/src/GFTracer.$(OBJEXT) \ @DVISVGM_TREE@/src/Ghostscript.$(OBJEXT) \ + @DVISVGM_TREE@/src/HtmlSpecialHandler.$(OBJEXT) \ @DVISVGM_TREE@/src/InputBuffer.$(OBJEXT) \ @DVISVGM_TREE@/src/InputReader.$(OBJEXT) \ + @DVISVGM_TREE@/src/JFM.$(OBJEXT) \ @DVISVGM_TREE@/src/Length.$(OBJEXT) \ @DVISVGM_TREE@/src/MapLine.$(OBJEXT) \ @DVISVGM_TREE@/src/Matrix.$(OBJEXT) \ @@ -165,14 +200,6 @@ nodist_libdvisvgm_a_OBJECTS = \ @DVISVGM_TREE@/src/XMLNode.$(OBJEXT) \ @DVISVGM_TREE@/src/XMLString.$(OBJEXT) $(am__objects_1) libdvisvgm_a_OBJECTS = $(nodist_libdvisvgm_a_OBJECTS) -libpotrace_a_AR = $(AR) $(ARFLAGS) -libpotrace_a_LIBADD = -nodist_libpotrace_a_OBJECTS = \ - @DVISVGM_TREE@/potracelib/curve.$(OBJEXT) \ - @DVISVGM_TREE@/potracelib/decompose.$(OBJEXT) \ - @DVISVGM_TREE@/potracelib/potracelib.$(OBJEXT) \ - @DVISVGM_TREE@/potracelib/trace.$(OBJEXT) -libpotrace_a_OBJECTS = $(nodist_libpotrace_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) nodist_dvisvgm_OBJECTS = @DVISVGM_TREE@/src/dvisvgm.$(OBJEXT) \ @@ -182,7 +209,7 @@ dvisvgm_LDADD = $(LDADD) am__DEPENDENCIES_1 = dvisvgm_DEPENDENCIES = $(noinst_LIBRARIES) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent @@ -203,24 +230,6 @@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/../../build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ @@ -238,8 +247,7 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = -SOURCES = $(nodist_libdvisvgm_a_SOURCES) \ - $(nodist_libpotrace_a_SOURCES) $(nodist_dvisvgm_SOURCES) +SOURCES = $(nodist_libdvisvgm_a_SOURCES) $(nodist_dvisvgm_SOURCES) DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -562,12 +570,17 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +POTRACE_DEPEND = @POTRACE_DEPEND@ +POTRACE_INCLUDES = @POTRACE_INCLUDES@ +POTRACE_LIBS = @POTRACE_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@ +VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@ WARNING_CFLAGS = @WARNING_CFLAGS@ WARNING_CXXFLAGS = @WARNING_CXXFLAGS@ ZLIB_DEPEND = @ZLIB_DEPEND@ @@ -635,9 +648,8 @@ top_srcdir = @top_srcdir@ #************************************************************************ ACLOCAL_AMFLAGS = -I ../../m4 EXTRA_DIST = $(DVISVGM_TREE) $(DVISVGM_TREE)-PATCHES $(TESTS) -AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/src \ - -I$(top_srcdir)/$(DVISVGM_TREE)/potracelib \ - $(KPATHSEA_INCLUDES) $(FREETYPE2_INCLUDES) $(ZLIB_INCLUDES) \ +AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/src $(KPATHSEA_INCLUDES) \ + $(POTRACE_INCLUDES) $(FREETYPE2_INCLUDES) $(ZLIB_INCLUDES) \ $(LIBGS_INCLUDES) $(am__append_1) AM_CFLAGS = $(WARNING_CFLAGS) AM_CXXFLAGS = $(WARNING_CXXFLAGS) @@ -649,9 +661,9 @@ nodist_dvisvgm_SOURCES = \ @DVISVGM_TREE@/src/gzstream.cpp dvisvgm_dependencies = $(KPATHSEA_DEPEND) $(ZLIB_DEPEND) $(FREETYPE2_DEPEND) -LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(FREETYPE2_LIBS) \ - $(ZLIB_LIBS) $(LIBGS_LIBS) -noinst_LIBRARIES = libdvisvgm.a libpotrace.a +LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(POTRACE_LIBS) \ + $(FREETYPE2_LIBS) $(ZLIB_LIBS) $(LIBGS_LIBS) +noinst_LIBRARIES = libdvisvgm.a nodist_libdvisvgm_a_SOURCES = \ @DVISVGM_TREE@/src/BgColorSpecialHandler.cpp \ @DVISVGM_TREE@/src/Bitmap.cpp \ @@ -676,12 +688,15 @@ nodist_libdvisvgm_a_SOURCES = \ @DVISVGM_TREE@/src/FontEncoding.cpp \ @DVISVGM_TREE@/src/FontEngine.cpp \ @DVISVGM_TREE@/src/FontManager.cpp \ - @DVISVGM_TREE@/src/FontMap.cpp @DVISVGM_TREE@/src/GFReader.cpp \ + @DVISVGM_TREE@/src/FontMap.cpp \ + @DVISVGM_TREE@/src/FontMetric.cpp \ + @DVISVGM_TREE@/src/GFReader.cpp \ @DVISVGM_TREE@/src/GFGlyphTracer.cpp \ @DVISVGM_TREE@/src/GFTracer.cpp \ @DVISVGM_TREE@/src/Ghostscript.cpp \ + @DVISVGM_TREE@/src/HtmlSpecialHandler.cpp \ @DVISVGM_TREE@/src/InputBuffer.cpp \ - @DVISVGM_TREE@/src/InputReader.cpp \ + @DVISVGM_TREE@/src/InputReader.cpp @DVISVGM_TREE@/src/JFM.cpp \ @DVISVGM_TREE@/src/Length.cpp @DVISVGM_TREE@/src/MapLine.cpp \ @DVISVGM_TREE@/src/Matrix.cpp @DVISVGM_TREE@/src/Message.cpp \ @DVISVGM_TREE@/src/MetafontWrapper.cpp \ @@ -704,19 +719,13 @@ nodist_libdvisvgm_a_SOURCES = \ @DVISVGM_TREE@/src/XMLDocument.cpp \ @DVISVGM_TREE@/src/XMLNode.cpp \ @DVISVGM_TREE@/src/XMLString.cpp $(am__append_2) -nodist_libpotrace_a_SOURCES = \ - @DVISVGM_TREE@/potracelib/curve.c \ - @DVISVGM_TREE@/potracelib/decompose.c \ - @DVISVGM_TREE@/potracelib/potracelib.c \ - @DVISVGM_TREE@/potracelib/trace.c - DISTCLEANFILES = config.force CXXLD.sh TESTS = tests/dvisvgm.test all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .c .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @@ -753,8 +762,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): config.h: stamp-h1 - @if test ! -f $@; then rm -f stamp-h1; else :; fi - @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 @@ -855,6 +864,9 @@ clean-noinstLIBRARIES: @DVISVGM_TREE@/src/FontMap.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) +@DVISVGM_TREE@/src/FontMetric.$(OBJEXT): \ + @DVISVGM_TREE@/src/$(am__dirstamp) \ + @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @DVISVGM_TREE@/src/GFReader.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @@ -867,12 +879,17 @@ clean-noinstLIBRARIES: @DVISVGM_TREE@/src/Ghostscript.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) +@DVISVGM_TREE@/src/HtmlSpecialHandler.$(OBJEXT): \ + @DVISVGM_TREE@/src/$(am__dirstamp) \ + @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @DVISVGM_TREE@/src/InputBuffer.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @DVISVGM_TREE@/src/InputReader.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) +@DVISVGM_TREE@/src/JFM.$(OBJEXT): @DVISVGM_TREE@/src/$(am__dirstamp) \ + @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @DVISVGM_TREE@/src/Length.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) @@ -959,32 +976,11 @@ clean-noinstLIBRARIES: @DVISVGM_TREE@/src/DLLoader.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) + libdvisvgm.a: $(libdvisvgm_a_OBJECTS) $(libdvisvgm_a_DEPENDENCIES) $(EXTRA_libdvisvgm_a_DEPENDENCIES) $(AM_V_at)-rm -f libdvisvgm.a $(AM_V_AR)$(libdvisvgm_a_AR) libdvisvgm.a $(libdvisvgm_a_OBJECTS) $(libdvisvgm_a_LIBADD) $(AM_V_at)$(RANLIB) libdvisvgm.a -@DVISVGM_TREE@/potracelib/$(am__dirstamp): - @$(MKDIR_P) @DVISVGM_TREE@/potracelib - @: > @DVISVGM_TREE@/potracelib/$(am__dirstamp) -@DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) @DVISVGM_TREE@/potracelib/$(DEPDIR) - @: > @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) -@DVISVGM_TREE@/potracelib/curve.$(OBJEXT): \ - @DVISVGM_TREE@/potracelib/$(am__dirstamp) \ - @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) -@DVISVGM_TREE@/potracelib/decompose.$(OBJEXT): \ - @DVISVGM_TREE@/potracelib/$(am__dirstamp) \ - @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) -@DVISVGM_TREE@/potracelib/potracelib.$(OBJEXT): \ - @DVISVGM_TREE@/potracelib/$(am__dirstamp) \ - @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) -@DVISVGM_TREE@/potracelib/trace.$(OBJEXT): \ - @DVISVGM_TREE@/potracelib/$(am__dirstamp) \ - @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) -libpotrace.a: $(libpotrace_a_OBJECTS) $(libpotrace_a_DEPENDENCIES) $(EXTRA_libpotrace_a_DEPENDENCIES) - $(AM_V_at)-rm -f libpotrace.a - $(AM_V_AR)$(libpotrace_a_AR) libpotrace.a $(libpotrace_a_OBJECTS) $(libpotrace_a_LIBADD) - $(AM_V_at)$(RANLIB) libpotrace.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ @@ -1040,22 +1036,18 @@ clean-binPROGRAMS: @DVISVGM_TREE@/src/gzstream.$(OBJEXT): \ @DVISVGM_TREE@/src/$(am__dirstamp) \ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) + dvisvgm$(EXEEXT): $(dvisvgm_OBJECTS) $(dvisvgm_DEPENDENCIES) $(EXTRA_dvisvgm_DEPENDENCIES) @rm -f dvisvgm$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(dvisvgm_OBJECTS) $(dvisvgm_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f @DVISVGM_TREE@/potracelib/*.$(OBJEXT) -rm -f @DVISVGM_TREE@/src/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/potracelib/$(DEPDIR)/curve.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/potracelib/$(DEPDIR)/decompose.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/potracelib/$(DEPDIR)/potracelib.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/potracelib/$(DEPDIR)/trace.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/BgColorSpecialHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Bitmap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/BoundingBox.Po@am__quote@ @@ -1084,12 +1076,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/FontEngine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/FontManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/FontMap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/FontMetric.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/GFGlyphTracer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/GFReader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/GFTracer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Ghostscript.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/HtmlSpecialHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/InputBuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/InputReader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/JFM.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Length.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/MapLine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Matrix.Po@am__quote@ @@ -1121,30 +1116,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/gzstream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/psdefs.Po@am__quote@ -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @@ -1289,7 +1260,7 @@ distclean-tags: $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not -# exand to empty, as could happen e.g. with make check TESTS=''. +# expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: @@ -1495,10 +1466,16 @@ dist-xz: distdir $(am__post_remove_distdir) dist-tarZ: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) @@ -1632,8 +1609,6 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f @DVISVGM_TREE@/potracelib/$(DEPDIR)/$(am__dirstamp) - -rm -f @DVISVGM_TREE@/potracelib/$(am__dirstamp) -rm -f @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp) -rm -f @DVISVGM_TREE@/src/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) @@ -1648,7 +1623,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf @DVISVGM_TREE@/potracelib/$(DEPDIR) @DVISVGM_TREE@/src/$(DEPDIR) + -rm -rf @DVISVGM_TREE@/src/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -1696,7 +1671,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf @DVISVGM_TREE@/potracelib/$(DEPDIR) @DVISVGM_TREE@/src/$(DEPDIR) + -rm -rf @DVISVGM_TREE@/src/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1745,15 +1720,14 @@ dist-hook: $(dvisvgm_OBJECTS): libdvisvgm.a -$(libdvisvgm_a_OBJECTS): libpotrace.a - -$(libpotrace_a_OBJECTS): config.force +$(libdvisvgm_a_OBJECTS): $(POTRACE_DEPEND) config.force: $(dvisvgm_dependencies) echo timestamp >config.force $(SHELL) ./config.status --recheck @KPATHSEA_RULE@ +@POTRACE_RULE@ @FREETYPE2_RULE@ @ZLIB_RULE@ diff --git a/Build/source/texk/dvisvgm/ac/withenable.ac b/Build/source/texk/dvisvgm/ac/withenable.ac index 78220e06e04..83b1cb0f397 100644 --- a/Build/source/texk/dvisvgm/ac/withenable.ac +++ b/Build/source/texk/dvisvgm/ac/withenable.ac @@ -1,9 +1,9 @@ ## texk/dvisvgm/ac/withenable.ac: configure.ac fragment for the TeX Live subdirectory texk/dvisvgm/ dnl -dnl Copyright (C) 2009 Peter Breitenlohner +dnl Copyright (C) 2009-2013 Peter Breitenlohner dnl You may freely use, modify and/or distribute this file. dnl ## configure options and TL libraries required for dvisvgm -KPSE_ENABLE_PROG([dvisvgm], [kpathsea freetype2 zlib]) +KPSE_ENABLE_PROG([dvisvgm], [kpathsea potrace freetype2 zlib]) m4_include(kpse_TL[texk/dvisvgm/ac/dvisvgm.ac]) m4_include(kpse_TL[texk/dvisvgm/ac/libgs.ac]) diff --git a/Build/source/texk/dvisvgm/aclocal.m4 b/Build/source/texk/dvisvgm/aclocal.m4 index 2316811d4ef..01f86c5b2ce 100644 --- a/Build/source/texk/dvisvgm/aclocal.m4 +++ b/Build/source/texk/dvisvgm/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.13.1 -*- Autoconf -*- +# generated automatically by aclocal 1.14 -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.13' +[am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.13.1], [], +m4_if([$1], [1.14], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.13.1])dnl +[AM_AUTOMAKE_VERSION([1.14])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) @@ -373,7 +373,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue + test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the @@ -418,6 +418,12 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -526,7 +532,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further @@ -534,7 +581,6 @@ dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. @@ -752,6 +798,70 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) +# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. @@ -961,76 +1071,114 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar +# AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. + +# We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of '-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR @@ -1039,6 +1187,8 @@ m4_include([../../m4/kpse-common.m4]) m4_include([../../m4/kpse-cxx-hack.m4]) m4_include([../../m4/kpse-freetype2-flags.m4]) m4_include([../../m4/kpse-kpathsea-flags.m4]) +m4_include([../../m4/kpse-potrace-flags.m4]) +m4_include([../../m4/kpse-visibility.m4]) m4_include([../../m4/kpse-warnings.m4]) m4_include([../../m4/kpse-win32.m4]) m4_include([../../m4/kpse-zlib-flags.m4]) diff --git a/Build/source/texk/dvisvgm/configure b/Build/source/texk/dvisvgm/configure index 75e135b7ac1..bff4e6f1533 100755 --- a/Build/source/texk/dvisvgm/configure +++ b/Build/source/texk/dvisvgm/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dvisvgm 1.2.2. +# Generated by GNU Autoconf 2.69 for dvisvgm for TeX Live 1.3. # # Report bugs to . # @@ -588,14 +588,14 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='dvisvgm' -PACKAGE_TARNAME='dvisvgm' -PACKAGE_VERSION='1.2.2' -PACKAGE_STRING='dvisvgm 1.2.2' +PACKAGE_NAME='dvisvgm for TeX Live' +PACKAGE_TARNAME='dvisvgm-for-tex-live' +PACKAGE_VERSION='1.3' +PACKAGE_STRING='dvisvgm for TeX Live 1.3' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="dvisvgm-1.2.2/src/dvisvgm.cpp" +ac_unique_file="dvisvgm-1.3/src/dvisvgm.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -641,6 +641,10 @@ dlloader_FALSE dlloader_TRUE LIBGS_LIBS LIBGS_INCLUDES +POTRACE_RULE +POTRACE_DEPEND +POTRACE_LIBS +POTRACE_INCLUDES FREETYPE2_RULE FREETYPE2_DEPEND FREETYPE2_LIBS @@ -657,6 +661,7 @@ KPATHSEA_INCLUDES WIN32_FALSE WIN32_TRUE CXXLD +VISIBILITY_CXXFLAGS CXXCPP WARNING_CXXFLAGS am__fastdepCXX_FALSE @@ -665,6 +670,7 @@ CXXDEPMODE ac_ct_CXX CXXFLAGS CXX +VISIBILITY_CFLAGS CPP OTOOL64 OTOOL @@ -808,6 +814,9 @@ with_system_zlib with_zlib_includes with_zlib_libdir with_system_freetype2 +with_system_potrace +with_potrace_includes +with_potrace_libdir ' ac_precious_vars='build_alias host_alias @@ -1362,7 +1371,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dvisvgm 1.2.2 to adapt to many kinds of systems. +\`configure' configures dvisvgm for TeX Live 1.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1410,7 +1419,8 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/dvisvgm] + --docdir=DIR documentation root + [DATAROOTDIR/doc/dvisvgm-for-tex-live] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1432,7 +1442,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvisvgm 1.2.2:";; + short | recursive ) echo "Configuration of dvisvgm for TeX Live 1.3:";; esac cat <<\_ACEOF @@ -1484,6 +1494,11 @@ Optional Packages: --with-zlib-libdir=DIR zlib library installed in DIR --with-system-freetype2 use installed freetype2 headers and library (requires freetype-config) + --with-system-potrace use installed potrace headers and library + --with-potrace-includes=DIR + potrace headers installed in DIR + --with-potrace-libdir=DIR + potrace library installed in DIR Some influential environment variables: CC C compiler command @@ -1564,7 +1579,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvisvgm configure 1.2.2 +dvisvgm for TeX Live configure 1.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2386,7 +2401,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dvisvgm $as_me 1.2.2, which was +It was created by dvisvgm for TeX Live $as_me 1.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2768,7 +2783,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Common code for all programs using libkpathsea. -am__api_version='1.13' +am__api_version='1.14' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -4084,6 +4099,65 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 @@ -7817,8 +7891,8 @@ fi # Define the identity of the package. - PACKAGE='dvisvgm' - VERSION='1.2.2' + PACKAGE='dvisvgm-for-tex-live' + VERSION='1.3' cat >>confdefs.h <<_ACEOF @@ -7858,6 +7932,10 @@ mkdir_p='$(MKDIR_P)' # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' @@ -7865,6 +7943,48 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. @@ -13097,6 +13217,56 @@ fi ac_config_headers="$ac_config_headers config.h" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for C to hide external symbols" >&5 +$as_echo_n "checking CFLAGS for C to hide external symbols... " >&6; } +if ${kpse_cv_visibility_cflags+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +kpse_cv_visibility_cflags=unknown +kpse_save_flags=$CFLAGS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + extern void foo(void); + void foo(void){printf("foo\n");} +_ACEOF +# FIXME: Add tests for non-GNU compilers +for kpse_flag in '-fvisibility=hidden'; do + CFLAGS="$kpse_save_flags $kpse_flag" + if ac_fn_c_try_compile "$LINENO"; then : + kpse_cv_visibility_cflags=$kpse_flag; break +fi +rm -f core conftest.err conftest.$ac_objext +done +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $kpse_cv_visibility_cflags" >&5 +$as_echo "$kpse_cv_visibility_cflags" >&6; } +CFLAGS=$kpse_save_flags +case $kpse_cv_visibility_cflags in #( + unknown) : + ;; #( + *) : + VISIBILITY_CFLAGS=$kpse_cv_visibility_cflags + ;; +esac + + + + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -16726,6 +16896,53 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for C++ to hide external symbols" >&5 +$as_echo_n "checking CXXFLAGS for C++ to hide external symbols... " >&6; } +if ${kpse_cv_visibility_cxxflags+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +kpse_cv_visibility_cxxflags=unknown +kpse_save_flags=$CXXFLAGS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + extern void foo(void); + void foo(void){printf("foo\n");} +_ACEOF +# FIXME: Add tests for non-GNU compilers +for kpse_flag in '-fvisibility=hidden'; do + CXXFLAGS="$kpse_save_flags $kpse_flag" + if ac_fn_cxx_try_compile "$LINENO"; then : + kpse_cv_visibility_cxxflags=$kpse_flag; break +fi +rm -f core conftest.err conftest.$ac_objext +done +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $kpse_cv_visibility_cxxflags" >&5 +$as_echo "$kpse_cv_visibility_cxxflags" >&6; } +CXXFLAGS=$kpse_save_flags +case $kpse_cv_visibility_cxxflags in #( + unknown) : + ;; #( + *) : + VISIBILITY_CXXFLAGS=$kpse_cv_visibility_cxxflags + ;; +esac + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -17528,7 +17745,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -dvisvgm config.lt 1.2.2 +dvisvgm for TeX Live config.lt 1.3 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -18988,6 +19205,41 @@ ${top_builddir}/../../libs/freetype2/ft2build.h: cd ${top_builddir}/../../libs/freetype2 && $(MAKE) $(AM_MAKEFLAGS) rebuild' fi +## _KPSE_LIB_FLAGS: Setup potrace (-lpotrace) flags + +# Check whether --with-system-potrace was given. +if test "${with_system_potrace+set}" = set; then : + withval=$with_system_potrace; +fi + +# Check whether --with-potrace-includes was given. +if test "${with_potrace_includes+set}" = set; then : + withval=$with_potrace_includes; +fi + +# Check whether --with-potrace-libdir was given. +if test "${with_potrace_libdir+set}" = set; then : + withval=$with_potrace_libdir; +fi +if test "x$with_system_potrace" = xyes; then + if test "x$with_potrace_includes" != x && test "x$with_potrace_includes" != xyes; then + POTRACE_INCLUDES="-I$with_potrace_includes" +fi +POTRACE_LIBS="-lpotrace" +if test "x$with_potrace_libdir" != x && test "x$with_potrace_libdir" != xyes; then + POTRACE_LIBS="-L$with_potrace_libdir $POTRACE_LIBS" +fi +else + POTRACE_INCLUDES="-I$kpse_BLD/libs/potrace/include" + POTRACE_LIBS="$kpse_BLD/libs/potrace/libpotrace.a" + POTRACE_DEPEND='${top_builddir}/../../libs/potrace/libpotrace.a' + POTRACE_RULE='# Rebuild libpotrace +$(POTRACE_DEPEND): ${top_builddir}/../../libs/potrace/include/potracelib.h + cd ${top_builddir}/../../libs/potrace && $(MAKE) $(AM_MAKEFLAGS) rebuild +${top_builddir}/../../libs/potrace/include/potracelib.h: + cd ${top_builddir}/../../libs/potrace && $(MAKE) $(AM_MAKEFLAGS) rebuild' +fi + kpse_save_CPPFLAGS=$CPPFLAGS kpse_save_LIBS=$LIBS @@ -19207,7 +19459,7 @@ CPPFLAGS=$kpse_save_CPPFLAGS LIBS=$kpse_save_LIBS -DVISVGM_TREE=dvisvgm-1.2.2 +DVISVGM_TREE=dvisvgm-1.3 ac_config_files="$ac_config_files Makefile" @@ -19759,7 +20011,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dvisvgm $as_me 1.2.2, which was +This file was extended by dvisvgm for TeX Live $as_me 1.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19825,7 +20077,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dvisvgm config.status 1.2.2 +dvisvgm for TeX Live config.status 1.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -20985,7 +21237,7 @@ $as_echo X"$mf" | DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue + test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the diff --git a/Build/source/texk/dvisvgm/configure.ac b/Build/source/texk/dvisvgm/configure.ac index 524e89bc1e6..469d7f5df89 100644 --- a/Build/source/texk/dvisvgm/configure.ac +++ b/Build/source/texk/dvisvgm/configure.ac @@ -14,7 +14,7 @@ dnl dnl ********************************************************************* dnl m4_include([version.ac])[] dnl define dvisvgm_version -AC_INIT([dvisvgm], dvisvgm_version, [tex-k@tug.org]) +AC_INIT([dvisvgm for TeX Live], dvisvgm_version, [tex-k@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([dvisvgm-]dvisvgm_version[/src/dvisvgm.cpp]) AC_CONFIG_AUX_DIR([../../build-aux]) @@ -28,6 +28,8 @@ m4_include([ac/dvisvgm.ac]) AC_CONFIG_HEADERS([config.h]) +KPSE_COMPILER_VISIBILITY + AC_PROG_CXX AC_PROG_CXXCPP KPSE_CXX_HACK @@ -46,6 +48,7 @@ AM_CONDITIONAL([WIN32], [test "x$kpse_cv_have_win32" != xno]) KPSE_KPATHSEA_FLAGS KPSE_ZLIB_FLAGS KPSE_FREETYPE2_FLAGS +KPSE_POTRACE_FLAGS KPSE_SAVE_FLAGS diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/ChangeLog b/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/ChangeLog deleted file mode 100644 index 55aad9a460b..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/ChangeLog +++ /dev/null @@ -1,27 +0,0 @@ -2013-05-21 Peter Breitenlohner - - * Import release 1.2.2. - - * patch-01-cpp (new): Adapted. - -2013-04-11 Peter Breitenlohner - - * Import release 1.2.1. - - * patch-1-cpp (removed): Renamed ... - * patch-01-cpp (new): ... and adapted. - -2013-04-02 Karl Berry - - * patch-1-cpp (new): Force __cplusplus to be 1, - for sake of g++ 4.7.x and including c-memstr.h and Solaris. - Patch from Apostolos, tlbuild 1 Apr 2013 00:34:43. - -2013-03-02 Peter Breitenlohner - - * Import release 1.2. - -2013-01-29 Peter Breitenlohner - - * Import release 1.1. - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/TL-Changes b/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/TL-Changes deleted file mode 100644 index 374cc38fe43..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/TL-Changes +++ /dev/null @@ -1,14 +0,0 @@ -Changes applied to the dvisvgm-1.2.2 tree as obtained from: - http://downloads.sourceforge.net/dvisvgm/dvisvgm-1.2.2.tar.gz - -Removed: - Makefile.in - aclocal.m4 - config.guess - config.sub - configure - depcomp - install-sh - missing - */Makefile.in - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/patch-01-cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/patch-01-cpp deleted file mode 100644 index 5c33270f2a4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2-PATCHES/patch-01-cpp +++ /dev/null @@ -1,13 +0,0 @@ -diff -ur dvisvgm-1.2.2.orig/src/FileFinder.cpp dvisvgm-1.2.2/src/FileFinder.cpp ---- dvisvgm-1.2.2.orig/src/FileFinder.cpp 2013-04-19 15:05:25.000000000 +0200 -+++ dvisvgm-1.2.2/src/FileFinder.cpp 2013-05-21 15:05:40.000000000 +0200 -@@ -18,6 +18,9 @@ - ** along with this program; if not, see . ** - *************************************************************************/ - -+#undef __cplusplus -+#define __cplusplus 1 -+ - #include - #include - #include diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/AUTHORS b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/AUTHORS deleted file mode 100644 index 837e1e96bfb..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ -Martin Gieseking - author of dvisvgm - -Peter Selinger - author of the potrace library - -Deepak Bandyopadhyay, Lutz Kettner - authors of gzstream library - dvisvgm uses a slightly modified version - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/COPYING b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/COPYING deleted file mode 100644 index 94a9ed024d3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/INSTALL b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/INSTALL deleted file mode 100644 index a4b34144dcf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/INSTALL +++ /dev/null @@ -1,229 +0,0 @@ -Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/LGPL-2.1.txt b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/LGPL-2.1.txt deleted file mode 100644 index 602bfc94635..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/LGPL-2.1.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/Makefile.am deleted file mode 100644 index 21666db93cf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## This file is part of dvisvgm -## Copyright (C) 2005-2013 Martin Gieseking -## -## Process this file with automake. - -AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = COPYING LGPL-2.1.txt -if HAVE_LIBPOTRACE -SUBDIRS = -else -SUBDIRS = potracelib -endif - -SUBDIRS += src tests doc - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/NEWS b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/NEWS deleted file mode 100644 index aa2ae98c22c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/NEWS +++ /dev/null @@ -1,288 +0,0 @@ -dvisvgm-1.2.2 (2013-04-26) -- fixed a bug that prevented the lookup of fontmap files -- avoid throwing an exception but print a warning message if MiKTeX is not available -- print a warning message if PostScript specials are found but ignored -- added information about "dvisvgm -E" to the --help text and to the manpage -- various code refactorings and cleanups - -dvisvgm-1.2.1 (2013-04-09) -- updated bundled potrace library to version 1.11 -- avoid building bundled potracelib if system library is present (patch by Alexis Ballier) -- allow background color specials to create white background rectangles -- code refactorings and cleanup - -dvisvgm-1.2 (2013-03-01) -- PostScript handler: added support of tiling patterns -- PostScript handler: added support for EPS files with binary headers/footers -- added option --eps to directly convert EPS files to SVG -- added option --precision to select the number of decimal places used in the generated SVG files -- added an optional argument to --help to choose a display variant -- fixed the text alignment of the --help output -- improved handling of PostScript operator "show" -- choose the correct output location if the input file argument contains path specifiers (Windows only) - -dvisvgm-1.1 (2013-01-22) -- added evaluation of pdf:mapline and pdf:mapfile specials -- added evaluation of subfont file definitions (.sfd files) -- added support for TTC (TrueType collection) fonts -- added evaluation of font style parameters given in a font map definition -- renamed option --map-file to --fontmap -- the new option --fontmap allows multiple mapfile arguments and optional mode specifiers -- if a PostScript error occurs, dvisvgm prints an error message together with the - PS operand stack, as generated by Ghostscript -- if font checksums don't match, dvisvgm prints a warning now -- avoid throwing exceptions if referenced encoding files are not available -- added support for 64bit Windows builds -- removed compilation error when using a C++11 compiler (patch by Peter Breitenlohner) -- some code refactorings and improvements - -dvisvgm-1.0.12 (2012-09-27) -- print a message if the processing of PostScript specials is disabled -- the resulting SVG is now scaled to bp ("big point" units) properly -- added the evaluation of PS operators rectclip, rectfill, and rectstroke -- ignore dvips operator bop if present in a PS special -- fixed processing of special strings that contain newline characters - -dvisvgm-1.0.11 (2012-03-09) -- added Ghostscript to library list printed by --version=yes -- fixed a bug in the number parser that could lead to displaced objects (SF bug #3471097) -- corrected the computation of bounding boxes of DVI rules (lp bug #948713) -- improved code compatibility to make dvisvgm compile with clang++ (patch by Vladimir Lomov) -- fixed formatting issues in the manual page -- updated information about bug reporting (tracker moved to Launchpad) - -dvisvgm-1.0.10 (2011-12-18) -- introduced environment variable DVISVGM_COLORS to allow user-defined message colors -- fixed linking issue concerning libfreetype -- fixed potential clashes of character IDs - -dvisvgm-1.0.9 (2011-10-13) -- fixed segfault occurred in TeX Live Win32 caused by mf.exe being unavailable - (thanks to Akira Kakuto for tracking down the issue) -- updated bundled potrace library to version 1.10 -- some minor code improvements - -dvisvgm-1.0.8 (2011-05-31) -- PS handler: added evaluation of PS operators save, restore, and grestoreall -- PS handler: fixed potential segfault caused by invisible zero-length paths -- fixed computation of current drawing position influenced by PS and DVI actions -- don't stop Metafont conversions on errors any longer in order to convert - buggy MF fonts properly - -dvisvgm-1.0.7 (2011-05-06) -- improved overall handling of PS specials -- fixed broken PS special subset 'ps::' -- fixed scaling of PS line properties (width, dash distance, etc.) -- fixed semantics of TPIC special 'ip' (doesn't draw polygon outlines any longer) - -dvisvgm-1.0.6 (2011-04-21) -- fixed segfault occurred if a (malformed) DVI file calls set_char/put_char - without preceding font definition -- added CTRL-C handler -- MiKTeX support updated to version 2.9 -- some code refactorings - -dvisvgm-1.0.5 (2011-03-01) -- added optional integer argument to option -n to disable generation of elements -- added missing unit to width/height attributes of svg root element (SF bug #3185773) -- added integrity check to font cache files -- updated bundled potrace library to version 1.9 -- fixed a couple of minor issues - -dvisvgm-1.0.4 (2010-12-18) -- added missing line width/dash pattern scaling to PS handler -- fixed scaling issue in PS positioning -- fixed compilation issue related to FreeType 2.4.0 - -dvisvgm-1.0.3 (2010-08-06) -- applied some more portability patches for TeX Live -- fixed a potential memory issue -- fixed a transformation issue regarding special 'psfile' (SF bug #3037372) - -dvisvgm-1.0.2 (2010-06-22) -- applied latest TeX Live portability patches sent by Peter Breitenlohner and Karl Berry -- fixed a potrace name clash occurred on Mac OS X Tiger -- fixed putchar() name clash occurred on Solaris -- fixed a couple of conversion warnings -- updated the test suite - -dvisvgm-1.0.1 (2010-06-11) -- fixed a memory issue in the PS handler that could lead to a segfault (SF bug #3013392) -- fixed a recursion issue in the PS handler -- suppress ANSI color code when terminating - -dvisvgm-1.0 (2010-06-08) -- conversion of multiple pages (must be enabled explicitly, see option --pages) -- added transparency support to the PS handler -- improved conversion results of the PS handler -- added support for computation of local bounding boxes -- optional colorization of dvisvgm messages (option --color) -- improved progress indicator (option --progress) -- a couple of improvements of the build system - -dvisvgm-0.9.1 (2010-04-23) -- CSS style definitions omit unnecessary fonts now -- SVG validity was broken when using font elements -- fixed two memory issues that could lead to segfaults - -dvisvgm-0.9 (2010-03-25) -- added option --exact and corresponding algorithms to compute the exact - bounding boxes of characters -- added option --keep that prevents deleting temporary font files -- extended option --trace-all by an optional boolean argument controlling - the re-tracing of glyphs -- fixed bug in evaluation of embedded PS headers -- several code refactorings - -dvisvgm-0.8.8 (2010-02-02) -- added option --libgs and evaluation of environment variable LIBGS - to overwrite the expected file name of the GS shared library - (only available if dvisvgm isn't linked against libgs and GS support - isn't completely disabled) -- option --bbox can now be used to enlarge the minimal bounding box by - a given amount -- fixed bug in evaluation of option --page -- applied patches sent by Peter Breitenlohner to prepare the integration of - dvisvgm into TeX Live -- some code refactorings - -dvisvgm-0.8.7 (2009-11-09) -- fixed a bounding box issue concerning italic corrections -- PS handler: zero-length paths are now drawn as dots -- PS handler: fixed a path positioning issue -- PS handler: colors set by color specials are now considered properly -- added macro {?nl} to be used with special dvisvgm:raw - -dvisvgm-0.8.6 (2009-10-13) -- renamed command-line option --bbox-format to --bbox -- option --bbox can now be used to set an arbitrary bounding box -- added the two special variants "dvisvgm:bbox abs" and "dvisvgm:bbox fix" -- PS clipping path sequences and intersections are now handled correctly -- fixed a PS bounding box bug -- fixed a couple of PS positioning issues reported by John Bowman -- fixed a bit shift overflow in the font tracer occurred on 64-bit systems - -dvisvgm-0.8.5 (2009-10-01) -- added an optional depth parameter to special dvisvgm:raw -- updated the man page -- added LGPL license text needed for the gzstream wrapper classes - -dvisvgm-0.8.4 (2009-09-17) -- improved the command-line parser to be more POSIX-compliant -- added a simple progress indicator for time-consuming special operations -- option --cache prints more information about the cached fonts -- fixed a clipping bug in the PostScript handler - (thanks to John Bowman for also providing a patch for this issue) -- fixed a bug in computation of the PS bounding box -- fixed a memory bug in the GF tracer module - -dvisvgm-0.8.3 (2009-08-28) -- added basic evaluation of the PostScript "show" operator - (handles PSTricks Type 3 fonts properly now) -- improved checks for Ghostscript and potrace library in configure script -- external Ghostscript and potrace development files are used if available -- PostScript header/prologue files are now loaded regardless of converted page -- replaced command-line option variant --cache=? by --cache - -dvisvgm-0.8.2 (2009-08-24) -- changed license of dvisvgm to GPL version 3 or later -- replaced getopt-based command-line parser by own implementation - in order to simplify future internationalizations -- fixed memory bug in fontmap reader - -dvisvgm-0.8.1 (2009-08-02) -- added evaluation of more psfile parameters -- fixed computation of bounding box in psfile special -- fixed compilation errors and a conversion bug occurred on x64 systems - -dvisvgm-0.8 (2009-07-27) -- experimental evaluation of PostScript specials has been added (requires - a recent version of the Ghostscript shared library libgs.so or gsdll32.dll) -- several code improvements and refactorings -- fixed compilation bug occurred when using GCC 4.4.x - -dvisvgm-0.7.3 (2009-04-24) -- fixed bug in font map reader that could cause a segmentation fault -- fixed bug in creation of shorthand path drawing commands -- fixed bug in TPIC special handler - -dvisvgm-0.7.2 (2009-04-02) -- font caching has been added (speeds up embedding of bitmap fonts) -- added option --trace-all that enables tracing of all glyphs of all - bitmap fonts used in the current DVI file. Even glyphs that are currently - not needed are considered. This avoids multiple calls of Metafont for the - same fonts. In combination with the new caching functionality this can - drastically increase the speed of successive dvisvgm calls. -- if option --no-fonts is used, all glyph sizes are now computed correctly -- use shorthand path commands in SVG fonts if possible - -dvisvgm-0.7.1 (2009-03-09) -- evaluation of a subset of emTeX specials has been added -- specials for embedding of raw SVG snippets have been added -- evaluation of TPIC specials has been added -- added background color support -- added option -n, --no-fonts that replaces fonts by paths - (enables applications w/o SVG font support to render dvisvgm's output properly) -- moved defs to top of SVG file to make Firefox's SVG renderer happy -- fixed bug in color handler - -dvisvgm-0.7 (2009-02-16) -- basic support for evaluation of specials has been added -- evaluation of color specials has been added -- renamed command-line option -S to --no-specials and inverted previous behavior -- selected special sets can be disabled by optional arguments to --no-specials - (currently only color specials) -- added option --no-style (see manpage for further details) -- added optional '+' flag to option --map-file (see manpage for further details) -- fixed \magnificaton bug (dvi magnification factor is now applied properly) -- fixed buggy call of maketfm/makemf in Windows/MiKTeX version -- fixed buggy evaluation of command-line argument -m/--map-file -- several internal code improvements - -dvisvgm-0.6.1 (2009-01-29) -- added support for dvips map files -- removed dependency on dvipdfm's map file (now ps2pk.map, psfonts.map or dvipdfm.map is used by default) -- fixed compilation bug #2535497 -- some internal refactorings - -dvisvgm-0.6 (2009-01-23) -- added support for varying font encodings -- updated MiKTeX support using its COM interface -- fixed incomplete handling of nested virtual fonts -- fixed a font handling bug that could cause segmentation faults -- fixed bug in matrix transformation code -- updated bundled potrace library to version 1.8 - -dvisvgm-0.5 (2007-03-26) -- redesigned and improved font handling -- added support for virtual fonts -- evaluation of dvipdfm's map file to find font files with differing - names (e.g. cork-lmr10 => lmr10) -- automatic invocation of mktexmf etc. in case of missing font files (tfm, mf) -- command-line option -m has been renamed to -M -- added command-line options -m/--map-file and -n/--no-mktexmf -- memory bug in StreamCounter class has been fixed -- added sources of Peter Selinger's potrace library (part of potrace, http://potrace.sourceforge.net) - to simplify the build process - -dvisvgm-0.4.3 (2007-01-03) -- problem with changed freetype API (freetype version >= 2.2.1) has been fixed -- updated MiKTeX support to version 2.5 -- minor code improvements -- some unit tests based on CxxTest (http://cxxtest.sourceforge.net) have been added - -dvisvgm-0.4.2 (2005-09-22) -- added SVG transformation options -- some bugfixes in command line frontend and TFM handling -- code refactorings to improve modularity and extensibility - -dvisvgm-0.4.1 (2005-09-02) -- added option -b to specify the bounding box -- added a manual page - -dvisvgm-0.4 (2005-08-24) -- Added a glyph tracing module that vectorizes Metafont's bitmap output - if no corresponding Type 1 font file is available. - -dvisvgm-0.3 (2005-08-10) -- Initial public release with basic conversion functionality. diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/README b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/README deleted file mode 100644 index 6356881cd9f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/README +++ /dev/null @@ -1,112 +0,0 @@ -dvisvgm -- A DVI to SVG converter - -DESCRIPTION - - dvisvgm is a utility for TeX/LaTeX users. It converts - DVI files to the XML-based scalable vector graphics format SVG. - - -DEPENDENCIES - - dvisvgm relies on the following free libraries: - * FreeType 2 (http://www.freetype.org) - This library is used to extract glyph outlines - from PFB files. - - * Ghostscript (http://pages.cs.wisc.edu/~ghost) - The PostScript special handler requires the Ghostscript - library libgs.so (Linux) or gsdll32.dll/gsdll64.dll (Windows) - to be installed. If the configure script finds the corresponding - Ghostscript development files on the system, it directly - links against libgs.so. Otherwise, the library is looked up - at runtime and PostScript support is enabled only if libgs.so - could be found. - Due to incompatible changes of the Ghostscript API, dvisvgm - requires Ghostscript 8.31 or later. - - * kpathsea - This library is part of the Web2C package and is - usually installed in conjunction with a TeX distribution. - kpathsea provides functions for searching files in the - large texmf tree. - - * potracelib (http://potrace.sourceforge.net) - Peter Selinger's bitmap tracing library is utilized to - vectorize Metafont's bitmap output. - The latest version of the library is bundled with the - source tarball. - - * zlib (http://www.zlib.org) - Compressed SVG files are produced by using functions - of this library and the Gzstream wrapper classes - (http://www.cs.unc.edu/Research/compgeom/gzstream) - which are licensed under LGPL version 2.1 (or optionally any - later version) and should be included with this package. - - If you want to build and run the testsuite located in the tests - subdirectory, you also need the googletest libraries - (http://code.google.com/p/googletest). - - -COMPILATION - - Quick installation info: - * type "./configure" - * type "make" - * type "make install" as root (or "sudo make install") - - For generic configuration instructions see the file INSTALL. - - The configure script should recognize all necessary parameters. - If a library is installed but not detected, specify its location - as commandline parameter of configure, e.g. - ./configure --with-freetype=/usr/local/freetype - (all available options can be displayed with ./configure --help) - - The tracer module calls Metafont in case of lacking TFM or PFB files - via a system call. Please ensure that Metafont is installed and - reachable through the search path. - - If you don't like compiling the sources yourself, you can - download pre-compiled executables for Windows and MiKTeX - from sourceforge.net instead (see below). - - -USAGE - Information about the command-line interface and the available options - can be found in the manual page. - - -ADDITIONAL INFORMATION - This package is available from CTAN (dviware/dvisvgm) and can - be downloaded from the project website at sourceforge.net as well: - - http://dvisvgm.sourceforge.net - - Here you can find the sources, pre-compiled binaries and further additional - information about the converter and related topics. - - If you've found a bug, please let me know. You can either send me an - email or preferably use the bug tracker at Launchpad - (see https://launchpad.net/dvisvgm). - - -COPYRIGHT - - Copyright (C) 2005-2013 Martin Gieseking - - 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 . - - See the file COPYING for details. - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.h.in b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.h.in deleted file mode 100644 index b027999e9b3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.h.in +++ /dev/null @@ -1,166 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if the `closedir' function returns void instead of `int'. */ -#undef CLOSEDIR_VOID - -/* Set to 1 if PostScript support should be disabled */ -#undef DISABLE_GS - -/* Define to 1 if `TIOCGWINSZ' requires . */ -#undef GWINSZ_IN_SYS_IOCTL - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT - -/* Define to 1 if you have the `ftime' function. */ -#undef HAVE_FTIME - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `dl' library (-ldl). */ -#undef HAVE_LIBDL - -/* Define to 1 if you have the `gs' library (-lgs). */ -#undef HAVE_LIBGS - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIBINTL_H - -/* Define to 1 if you have the `kpathsea' library (-lkpathsea). */ -#undef HAVE_LIBKPATHSEA - -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the `potrace' library (-lpotrace). */ -#undef HAVE_LIBPOTRACE - -/* Define to 1 if you have the `z' library (-lz). */ -#undef HAVE_LIBZ - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if `stat' has the bug that it succeeds when given the - zero-length file name argument. */ -#undef HAVE_STAT_EMPTY_STRING_BUG - -/* Define to 1 if stdbool.h conforms to C99. */ -#undef HAVE_STDBOOL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIMEB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - -/* Define to 1 if the system has the type `_Bool'. */ -#undef HAVE__BOOL - -/* Define to 1 if `lstat' dereferences a symlink specified with a trailing - slash. */ -#undef LSTAT_FOLLOWS_SLASHED_SYMLINK - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* The machine triplet of the target system */ -#undef TARGET_SYSTEM - -/* Define to 1 if your declares `struct tm'. */ -#undef TM_IN_SYS_TIME - -/* Version number of package */ -#undef VERSION - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.rpath b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/config.rpath deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/configure.ac b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/configure.ac deleted file mode 100644 index 3d077b1941e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/configure.ac +++ /dev/null @@ -1,158 +0,0 @@ -# This file is part of dvisvgm -# Copyright (C) 2005-2013 Martin Gieseking -# -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT([dvisvgm],[1.2.2],[martin.gieseking@uos.de]) -DATE="April 2013" -AC_CONFIG_SRCDIR(src) -AC_CONFIG_HEADER(config.h) -AC_CANONICAL_HOST -AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE - -AH_TEMPLATE([TARGET_SYSTEM], [The machine triplet of the target system]) -AC_DEFINE_UNQUOTED([TARGET_SYSTEM], ["$target"]) - -# Checks for programs. -AC_PROG_CXX -AC_PROG_CC - -AC_PROG_RANLIB -AC_LANG(C) - -AC_CHECK_FUNCS([ftime gettimeofday]) -AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) -AC_HEADER_TIOCGWINSZ - -AC_CHECK_HEADER([kpathsea/kpathsea.h], , - [AC_MSG_ERROR([please install the kpathsea development package])]) -AC_CHECK_LIB(kpathsea, kpse_find_file, , - [AC_MSG_ERROR([libkpathsea not found, please install the corresponding package first])]) - -AC_MSG_CHECKING([kpathsea version]) -AC_RUN_IFELSE([AC_LANG_SOURCE([#include - #include - int main() { - FILE *f; - f = fopen("kpseversion", "w"); - if(!f) exit(1); - fprintf(f, "%s\n", KPSEVERSION); - fclose(f); - exit(0); - }])], - [kpseversion=`cat kpseversion|sed 's/kpathsea version //'`], [kpseversion=], [kpseversion=unknown]) -AC_MSG_RESULT("$kpseversion") -rm -f kpseversion -if test -z "$kpseversion"; then - AC_MSG_ERROR([Could not compile a simple kpathsea program -- check your installation]) -fi - - -# Check how to link potracelib -HAVE_LIBPOTRACE=1 -AC_CHECK_HEADER([potracelib.h], - [AC_CHECK_LIB(m, sqrt) # required to pass potrace check - AC_CHECK_LIB(potrace, potrace_trace, , HAVE_LIBPOTRACE=0)], HAVE_LIBPOTRACE=0) - -if test "$HAVE_LIBPOTRACE" -eq 0; then - AM_CPPFLAGS="$AM_CXXFLAGS -I\${srcdir}/../potracelib -I\${srcdir}/../../potracelib" - EXTRA_LIBS="$EXTRA_LIBS ../potracelib/libpotrace.a " - AC_MSG_NOTICE([Using bundled potrace library]) -fi -AM_CONDITIONAL(HAVE_LIBPOTRACE, test "x$HAVE_LIBPOTRACE" = "x1") - - -# Check how to link Ghostscript -HAVE_LIBGS=1 -AC_CHECK_HEADER([ghostscript/iapi.h], - AC_CHECK_LIB(gs, gsapi_new_instance, , HAVE_LIBGS=0), HAVE_LIBGS=0) - -if test "$HAVE_LIBGS" -eq 0; then - AC_CHECK_LIB(dl, dlopen, , - [AC_DEFINE(DISABLE_GS, 1, [Set to 1 if PostScript support is to be disabled]) - AC_MSG_WARN(PostScript support disabled)]) -else - # query Ghostscript version - AC_MSG_CHECKING([Ghostscript version]) - AC_RUN_IFELSE([AC_LANG_SOURCE([#include - #include - int main () { - gsapi_revision_t r; - if (gsapi_revision(&r, sizeof(gsapi_revision_t)) == 0) { - FILE *f; - f = fopen("gsversion", "w"); - if (!f) exit(1); - fprintf(f, "%ld\n", r.revision); - fclose(f); - exit(0); - } - }])], - [gsversion=`cat gsversion`], [gsversion=], [gsversion=unknown]) - AC_MSG_RESULT("$gsversion") - rm -f gsversion - if test "$gsversion" -lt 831; then - # current Ghostscript API was introduced in version 8.31 - # older versions are not supported - LIBS=`echo $LIBS | sed "s/-lgs //" $LIBS` - AC_DEFINE(DISABLE_GS, 1, [Set to 1 if PostScript support should be disabled]) - AC_MSG_WARN([Ghostscript version < 8.31 found; PostScript support disabled]) - fi -fi - -# Check for pkg-config -PKG_PROG_PKG_CONFIG - -# Check for libraries. -PKG_CHECK_MODULES([FREETYPE], [freetype2]) -CXXFLAGS="$CXXFLAGS ${FREETYPE_CFLAGS}" -LIBS="$LIBS ${FREETYPE_LIBS}" - -AC_CHECK_LIB(z, gzopen) - -# Check for header files. -AC_HEADER_DIRENT -AC_HEADER_STDC -AC_CHECK_HEADERS([libintl.h stdlib.h string.h strings.h unistd.h]) - -# Check for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_C_CONST -AC_C_INLINE -AC_TYPE_SIZE_T -AC_STRUCT_TM - -# Check for library functions. -AC_FUNC_CLOSEDIR_VOID -AC_FUNC_ERROR_AT_LINE -AC_FUNC_MALLOC -AC_FUNC_STAT -AC_FUNC_VPRINTF -AC_CHECK_FUNCS([memset strcasecmp strtol]) - -# add options for selection of "optional" library locations -# currently these libraries are mandatory; the --with-foo options -# are used to specify the locations explicitely - -AC_ARG_WITH(zlib,[ --with-zlib=DIR location of the zlib library], - [if test "$withval" != no; then - if test "$withval" != yes; then - ZLIB_DIR=$withval - fi - fi]) - -if test "$withval" != no; then - if test -n "$ZLIB_DIR"; then - CPPFLAGS="$CPPFLAGS -I$ZLIB_DIR -I$ZLIB_DIR/include" - LDFLAGS="$LDFLAGS -L$ZLIB_DIR/lib" - fi -fi - -AC_SUBST(DATE) -AC_SUBST(EXTRA_LIBS) -AC_SUBST(AM_CPPFLAGS) -AC_SUBST(AM_LDFLAGS) -AC_CONFIG_FILES([Makefile potracelib/Makefile src/Makefile tests/Makefile doc/dvisvgm.txt doc/Makefile]) -AC_OUTPUT - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/Makefile.am deleted file mode 100644 index fb5c56ffedf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -## This file is part of dvisvgm -## Copyright (C) 2005-2013 Martin Gieseking -## -## Process this file with automake. - -man_MANS = dvisvgm.1 -EXTRA_DIST = $(man_MANS) - -dvisvgm.1: dvisvgm.txt - if [ `type -p a2x` ]; then \ - a2x -dmanpage -fmanpage -L -a icons -a 'iconsdir=.' $<; \ - rm -f dvisvgm.xml; \ - fi - -dvisvgm.pdf: dvisvgm.1 - echo '[ /Author (Martin Gieseking) /Title (dvisvgm manual page) /Subject (manual page of dvisvgm @VERSION@) /DOCINFO pdfmark' >tmp.ps - man -t ./$< >>tmp.ps - ps2pdf tmp.ps $@ - rm -f tmp.ps - -dvi-pdf: dvisvgm.dvi - dvipdfm $< - rm -f $< - -dvisvgm.dvi: dvisvgm.1 - groff -Tdvi -mandoc ./$< >$@ - -dvisvgm.html: dvisvgm.txt - asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -dmanpage $< - -html: dvisvgm.html -man: dvisvgm.1 -pdf: dvisvgm.pdf - -clean: - rm -f dvisvgm.pdf dvisvgm.html dvisvgm.xml dvisvgm.txt - -distclean-local: - rm -f dvisvgm.pdf dvisvgm.html dvisvgm.xml dvisvgm.txt dvisvgm.1 diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.1 b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.1 deleted file mode 100644 index f71ef16e44f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.1 +++ /dev/null @@ -1,1038 +0,0 @@ -'\" t -.\" Title: dvisvgm -.\" Author: Martin Gieseking -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 04/25/2013 -.\" Manual: dvisvgm Manual -.\" Source: dvisvgm 1.2.2 -.\" Language: English -.\" -.TH "DVISVGM" "1" "04/25/2013" "dvisvgm 1\&.2\&.2" "dvisvgm Manual" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "NAME" -dvisvgm \- converts DVI files to the XML\-based SVG format -.SH "SYNOPSIS" -.sp -\fBdvisvgm\fR [ \fIoptions\fR ] \fIfile\fR [\&.dvi] -.sp -\fBdvisvgm\fR \-E [ \fIoptions\fR ] \fIfile\fR [\&.eps] -.SH "DESCRIPTION" -.sp -The command\-line utility \fBdvisvgm\fR converts DVI files, as generated by TeX/LaTeX, to the XML\-based scalable vector graphics format SVG\&. Since the current SVG standard 1\&.1 doesn\(cqt specify multi\-page graphics, dvisvgm creates separate SVG files for each DVI page\&. Because of compatibility reasons, only the first page is converted by default\&. In order to select a different page or arbitrary page sequences, use option \fB\-p\fR which is described below\&. -.sp -dvisvgm should properly convert all pages that are made up of fonts and rules only\&. However, the utility also supports a couple of DVI extensions defined in terms of \fIDVI specials\fR\&. For a more detailed overview, see section \fBsupport of specials\fR below\&. -.sp -As SVG is a vector based graphics format, dvisvgm tries to convert the glyph outlines of all used fonts into scalable path descriptions\&. The fastest way to do that is to extract the path information from PFB (PostScript Type 1) files\&. So, if dvisvgm is able to find a PFB file for a required font, it will read the necessary information from this file\&. -.sp -TeX\(cqs main source for font descriptions is Metafont though, which produces bitmap output\&. That\(cqs why not all obtainable TeX fonts are available in PFB format\&. In these cases, dvisvgm tries to vectorize Metafont\(cqs output (GF fonts) by tracing the glyph bitmaps\&. The results are not as perfect as most (manually optimized) PFB outlines but are nonetheless really nice in most cases\&. -.SH "OPTIONS" -.PP -\fB\-a, \-\-trace\-all\fR=[\fIretrace\fR] -.RS 4 -This option forces dvisvgm to trace not only the actually needed glyphs but all glyphs of all bitmap fonts used in the DVI file\&. Since the tracing results are stored in the font cache, all following DVI conversions (without option -\fB\-\-trace\-all\fR) where these fonts are involved, will be much faster\&. By default, dvisvgm traces only the actually needed glyphs, and adds them to the cache\&. The boolean option -\fIretrace\fR -determines how to handle glyphs already stored in the cache\&. By default, these glyphs are skipped\&. Setting argument -\fIretrace\fR -to -\fIyes\fR -or -\fItrue\fR -forces dvisvgm to trace the corresponding bitmaps again\&. -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -This option only takes affect if font caching is active\&. Thus, -\fB\-\-trace\-all\fR -cannot be combined with option -\fB\-\-cache=none\fR\&. -.sp .5v -.RE -.RE -.PP -\fB\-b, \-\-bbox\fR=\fIfmt\fR -.RS 4 -Sets the bounding box of the generated graphic to the specified format\&. The parameter -\fIfmt\fR -takes either one of the format specifiers listed below, or a sequence of four comma\- or whitespace\-separated length values -\fIx1\fR, -\fIy1\fR, -\fIx2\fR -and -\fIy2\fR\&. The latter define two diagonal corners of the bounding box\&. Each length value consists of a floating point number and an optional length unit (pt, bp, cm, mm, in, or pc)\&. If the unit is omitted, TeX points (pt) are assumed\&. -.sp -It\(cqs also possible to give only one length value -\fIl\fR\&. In this case, the minimal bounding box is computed and enlarged by adding (\-\fIl\fR,\-\fIl\fR) to the upper left and (\fIl\fR,\fIl\fR) to the lower right corner\&. -.sp -Alternatively, the following format specifiers are supported: -.PP -\fBInternational DIN/ISO paper sizes\fR -.RS 4 -A\fIn\fR, B\fIn\fR, C\fIn\fR, D\fIn\fR, where -\fIn\fR -is a non\-negative integer, e\&.g\&. A4 or a4 for DIN/ISO A4 format (210mm \(mu 297mm)\&. -.RE -.PP -\fBNorth American paper sizes\fR -.RS 4 -invoice, executive, legal, letter, ledger -.RE -.PP -\fBSpecial bounding box sizes\fR -.RS 4 -.TS -tab(:); -lt lt -lt lt -lt lt. -T{ -\fBdvi\fR -T}:T{ -page size stored in the DVI file -T} -T{ -\fBmin\fR -T}:T{ -computes the minimal/tightest bounding box -T} -T{ -\fBnone\fR -T}:T{ -no bounding box is assigned -T} -.TE -.sp 1 -.RE -.RE -.PP -\fBPage orientation\fR -.RS 4 -The default page orientation for DIN/ISO and American paper sizes is -\fIportrait\fR, i\&.e\&. -\fIwidth\fR -< -\fIheight\fR\&. Appending -\fB\-landscape\fR -or simply -\fB\-l\fR -to the format string switches to -\fIlandscape\fR -mode (\fIwidth\fR -> -\fIheight\fR)\&. For symmetry reasons you can also explicitly add -\fB\-portrait\fR -or -\fB\-p\fR -to indicate the default portrait format\&. Note that these suffixes are part of the size string and not separate options\&. Thus, they must directly follow the size specifier without additional blanks\&. Furthermore, the orientation suffixes can\(cqt be used with -\fBdvi\fR, -\fBmin\fR, and -\fBnone\fR\&. -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -Option -\fB\-b, \-\-bbox\fR -only affects the bounding box and does not transform the page content\&. Hence, if you choose a landscape format, the page won\(cqt be rotated\&. -.sp .5v -.RE -.RE -.PP -\fB\-C, \-\-cache\fR[=\fIdir\fR] -.RS 4 -To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion information in cache files\&. By default, these files are stored in $HOME/\&.dvisvgm/cache\&. If you prefer a different location, use option -\fB\-\-cache\fR -to overwrite the default\&. Furthermore, it is also possible to disable the font caching mechanism completely with option -\fB\-\-cache=none\fR\&. If argument -\fIdir\fR -is omitted, dvisvgm prints the path of the default cache directory and some information about the stored fonts\&. Additionally, outdated and corrupted cache files are removed\&. -.RE -.PP -\fB\-\-color\fR -.RS 4 -Enables colorization of messages printed during the conversion process\&. The colors can be customized via the environment variable -DVISVGM_COLORS\&. See the ENVIRONMENT section below for further information\&. -.RE -.PP -\fB\-E, \-\-eps\fR -.RS 4 -If this option is given, dvisvgm does not expect a DVI but an EPS input file, and tries to convert it to SVG\&. In order to do so, a single -\fIpsfile\fR -special command is created and forwarded to the PostScript special handler\&. This option is only available if dvisvgm was built with PostScript support enabled, and requires Ghostscript to be available\&. See option -\fB\-\-libgs\fR -for further information\&. -.RE -.PP -\fB\-e, \-\-exact\fR -.RS 4 -If this option is given, dvisvgm computes the precise bounding box of each character\&. By default, the values stored in a font\(cqs TFM file are used to determine a glyph\(cqs extent\&. As these values are intended to realize optimal character placements and are not designed to represent the exact dimensions, they don\(cqt necessarily correspond with the bounds of the visual glyphs\&. Thus, width and/or height of some glyphs may be larger than the respective TFM values\&. As a result, this can lead to clipped characters at the bounds of the SVG graphic\&. With option -\fB\-\-exact\fR, dvisvgm analyzes the actual shape of each character and derives a usually tight bounding box\&. -.RE -.PP -\fB\-m, \-\-fontmap\fR=\fIfilenames\fR -.RS 4 -Loads and evaluates a single or multiple font map files\&. These files are required to resolve font file names and encodings\&. dvisvgm does not provide its own map file but tries to read available ones coming with dvips or dvipdfm\&. If option -\fB\-\-fonrmapm\fR -is not given, dvisvgm looks for the default map files -ps2pk\&.map, -dvipdfm\&.map, and -psfonts\&.map -(in this order)\&. Otherwise, the listed files are used\&. Multiple filenames must be separated by commas without leading and/or trailing whitespace\&. The map files are evaluated in the given order\&. By default, redefined mappings do not replace previous ones\&. However, each filename can be preceded by an optional mode specifier (\fB+\fR, -\fB\-\fR, or -\fB=\fR) to change this behavior: -.PP -+mapfile -.RS 4 -Only those entries in the given map file that don\(cqt redefine a font mapping are applied\&. That\(cqs also the default mode if no mode specifier is given\&. -.RE -.PP -\-mapfile -.RS 4 -Ensures that none of the font mappings defined in the given map file are used, i\&.e\&. previously defined mappings for the specified fonts are removed\&. -.RE -.PP -=mapfile -.RS 4 -All mappings defined in the map file are applied\&. Previously defined settings for the same font are replaced\&. -.sp -If the first filename in the filename sequence is preceded by a mode specifier, dvisvgm loads the default font map (see above) and applies the other map files afterwards\&. Otherwise, none of default map files will be loaded automatically\&. -.sp -Examples: -\fB\-\-fontmap=myfile1\&.map,+myfile2\&.map\fR -loads -myfile1\&.map -followed by -myfile2\&.map -where all redefinitions of -myfile2\&.map -are ignored\&. -\fB\-\-fontmap==myfile1\&.map,\-myfile2\&.map\fR -loads the default map file followed by -myfile1\&.map -and -myfile2\&.map -where all redefinitions of -myfile1\&.map -replace previous entries\&. Afterwards, all definitions for the fonts given in -myfile2\&.map -are removed again\&. -.sp -For further information about the map file formats, see the manuals of dvips and dvipdfm\&. -.RE -.RE -.PP -\fB\-h, \-\-help\fR[=\fImode\fR] -.RS 4 -Prints a short summary of all available command\-line options\&. The optional -\fImode\fR -parameter is an integer value between 0 and 2\&. It selects the display variant of the help text\&. Mode 0 lists all options divided into categories with section headers\&. This is also the default if dvisvgm is called without parameters\&. Mode 1 lists all options ordered by the short option name, while mode 2 sorts the lines by the long option name\&. -.RE -.PP -\fB\-\-keep\fR -.RS 4 -Disables the removal of temporary files as created by Metafont (usually \&.gf, \&.tfm, and \&.log files)\&. -.RE -.PP -\fB\-\-libgs\fR=\fIfilename\fR -.RS 4 -This option is only available if the Ghostscript library is not directly linked to dvisvgm and if PostScript support was not completely disabled during compilation\&. In this case, dvisvgm tries to load the shared GS library dynamically during runtime\&. By default, it expects the library\(cqs name to be libgs\&.so (on Unix\-like systems) or gsdll32\&.dll/gsdll64\&.dll (Windows)\&. Option -\fB\-\-libgs\fR -can be used to give a different name\&. Alternatively, it\(cqs also possible to set the GS library name by the environment variable -LIBGS\&. The latter has less precedence than the command\-line option\&. -.RE -.PP -\fB\-l, \-\-list\-specials\fR -.RS 4 -Prints a list of registered special handlers and exits\&. Each handler processes a set of special statements belonging to the same category\&. In most cases, the categories are identified by the prefix of the special statements\&. It\(cqs usually a leading word separated from the rest of the statement by a colon or a blank, e\&.g\&. -\fIcolor\fR -or -\fIps\fR\&. -.RE -.PP -\fB\-M, \-\-mag\fR=\fIfactor\fR -.RS 4 -Sets the magnification factor applied in conjunction with Metafont calls prior tracing the glyphs\&. The larger this value, the better the tracing results\&. Nevertheless, large magnification values can cause Metafont arithmetic errors due to number overflows\&. So, use this option with care\&. The default setting usually produces nice results\&. -.RE -.PP -\fB\-\-no\-mktexmf\fR -.RS 4 -Suppresses the generation of missing font files\&. If dvisvgm can\(cqt find a font file through the kpathsea lookup mechanism, it calls the external tools mktextfm or mktexmf by\&. This option disables these calls\&. -.RE -.PP -\fB\-n, \-\-no\-fonts\fR[=\fIvariant\fR] -.RS 4 -If this option is given, dvisvgm doesn\(cqt create SVG -\fIfont\fR -elements but uses -\fIpaths\fR -instead\&. The resulting SVG files tends to be larger but concurrently more compatible with most applications that don\(cqt support SVG fonts yet\&. The optional argument -\fIvariant\fR -selects the method how to substitute fonts by paths\&. Variant 0 creates -\fIpath\fR -and -\fIuse\fR -elements\&. Variant 1 creates -\fIpath\fR -elements only\&. Option -\fB\-\-no\-fonts\fR -implies -\fB\-\-no\-styles\fR\&. -.RE -.PP -\fB\-c, \-\-scale\fR=\fIsx\fR[,\fIsy\fR] -.RS 4 -Scales the page content horizontally by -\fIsx\fR -and vertically by -\fIsy\fR\&. This option is equivalent to -\fB\-TS\fR\fIsx\fR,\fIsy\fR\&. -.RE -.PP -\fB\-S, \-\-no\-specials\fR[=\fInames\fR] -.RS 4 -Disable processing of special commands embedded in the DVI file\&. If no further parameter is given, all specials are ignored\&. To selectively disable sets of specials, an optional comma\-separated list of names can be appended to this option\&. A -\fIname\fR -is the unique identifier referencing the intended special handler\&. Option -\fB\-\-list\-specials\fR -lists all currently available handlers and their names\&. All unsupported special statements are silently ignored\&. -.RE -.PP -\fB\-\-no\-styles\fR -.RS 4 -By default, dvisvgm creates CSS styles and class attributes to reference fonts because it\(cqs more compact than repeatedly set the complete font information in each text element\&. However, if you prefer direct font references, the default behavior can be disabled with option -\fB\-\-no\-styles\fR\&. -.RE -.PP -\fB\-o, \-\-output\fR=\fIpattern\fR -.RS 4 -Sets the name pattern of the output file\&. Parameter -\fIpattern\fR -is a string that may contain the variables -\fB%f\fR -and -\fB%p\fR\&. -\fB%f\fR -stands for the base name of the DVI file, i\&.e\&. the DVI filename without suffix, and -\fB%p\fR -is the current page number\&. The default pattern is -\fB%f\-%p\&.svg\fR -if the DVI file consists of more than one page, and -\fB%f\&.svg\fR -otherwise\&. That means, a DVI file -\fIfoo\&.dvi\fR -is converted to -\fIfoo\&.svg\fR -if -\fIfoo\&.dvi\fR -is a single\-page document\&. Otherwise, multiple SVG files -\fIfoo\-01\&.svg\fR, -\fIfoo\-02\&.svg\fR, etc\&. are produced\&. In Windows environments, the percent sign indicates dereferenced environment variables, and must therefore be protected by a second percent sign, e\&.g\&. -\fB\-\-output=%%f\-%%p\fR\&. -.RE -.PP -\fB\-p, \-\-page\fR=\fIranges\fR -.RS 4 -This option sets the pages to be processed\&. Parameter -\fIranges\fR -consists of a comma\-separated list of single page numbers and/or page ranges\&. A page range is a pair of numbers separated by a hyphen, e\&.g\&. 5\-12\&. Thus, a page sequence might look like this: 2\-4,6,9\-12,15\&. It doesn\(cqt matter if a page is given more than once or if page ranges overlap\&. dvisvgm always extracts the page numbers in ascending order and converts them only once\&. In order to stay compatible with previous versions, the default page sequence is 1\&. dvisvgm therefore converts only the first page and not the whole document in case option -\fB\-\-page\fR -is omitted\&. Usually, page ranges consist of two numbers denoting the first and last page to be converted\&. If the conversion is to be started at page 1, or if it should continue up to the last DVI page, the first or second range number can be omitted, respectively\&. Example: -\fB\-\-page=\-10\fR -converts all pages up to page 10, -\fB\-\-page=10\-\fR -converts all pages starting with page 10\&. Please consider that the page values don\(cqt refer to the page numbers printed on the page\&. Instead, the physical page count is expected, where the first page always gets number 1\&. -.RE -.PP -\fB\-d, \-\-precision\fR=\fIdigits\fR -.RS 4 -Specifies the maximal number of decimal places applied to floating\-point attribute values\&. All attribute values written to the generated SVG file(s) are rounded accordingly\&. The parameter -\fIdigits\fR -allows integer values from 0 to 6, where 0 enables the automatic selection of significant decimal places\&. This is also the default value if dvisvgm is called without option -\fB\-\-precision\fR\&. -.RE -.PP -\fB\-P, \-\-progress\fR[=\fIdelay\fR] -.RS 4 -Enables a simple progress indicator shown when time\-consuming operations like PostScript specials are processed\&. The indicator doesn\(cqt appear before the given delay (in seconds) has elapsed\&. The default delay value is 0\&.5 seconds\&. -.RE -.PP -\fB\-r, \-\-rotate\fR=\fIangle\fR -.RS 4 -Rotates the page content clockwise by -\fIangle\fR -degrees around the page center\&. This option is equivalent to -\fB\-TR\fR\fIangle\fR\&. -.RE -.PP -\fB\-s, \-\-stdout\fR -.RS 4 -Don\(cqt write the SVG output to a file but redirect it to -\fBstdout\fR\&. -.RE -.PP -\fB\-T, \-\-transform\fR=\fIcommands\fR -.RS 4 -Applies a sequence of transformations to the SVG content\&. Each transformation is described by a -\fIcommand\fR -beginning with a capital letter followed by a list of comma\-separated parameters\&. Following transformation commands are supported: -.PP -\fBT\fR \fItx\fR[,\fIty\fR] -.RS 4 -Translates (moves) the page in direction of vector (\fItx\fR,\fIty\fR)\&. If -\fIty\fR -is omitted, -\fIty\fR=0 is assumed\&. The expected unit length of -\fItx\fR -and -\fIty\fR -are TeX points (1pt = 1/72\&.27in)\&. However, there are several constants defined to simplify the unit conversion (see below)\&. -.RE -.PP -\fBS\fR \fIsx\fR[,\fIsy\fR] -.RS 4 -Scales the page horizontally by -\fIsx\fR -and vertically by -\fIsy\fR\&. If -\fIsy\fR -is omitted, -\fIsy\fR=\fIsx\fR -is assumed\&. -.RE -.PP -\fBR\fR \fIangle\fR[,\fIx\fR,\fIy\fR] -.RS 4 -Rotates the page clockwise by -\fIangle\fR -degrees around point (\fIx\fR,\fIy\fR)\&. If the optional arguments -\fIx\fR -and -\fIy\fR -are omitted, the page will be rotated around its center depending on the chosen page format\&. When option -\fB\-bnone\fR -is given, the rotation center is origin (0,0)\&. -.RE -.PP -\fBKX\fR \fIangle\fR -.RS 4 -Skews the page along the -\fIx\fR\-axis by -\fIangle\fR -degrees\&. Argument -\fIangle\fR -can take any value except 90+180\fIk\fR, where -\fIk\fR -is an integer\&. -.RE -.PP -\fBKY\fR \fIangle\fR -.RS 4 -Skews the page along the -\fIy\fR\-axis by -\fIangle\fR -degrees\&. Argument -\fIangle\fR -can take any value except 90+180\fIk\fR, where -\fIk\fR -is an integer\&. -.RE -.PP -\fBFH\fR [\fIy\fR] -.RS 4 -Mirrors (flips) the page at the horizontal line through point (0,\fIy\fR)\&. Omitting the optional argument leads to -\fIy\fR=\fIh\fR/2, where -\fIh\fR -denotes the page height (see -\fIpre\-defined constants\fR -below)\&. -.RE -.PP -\fBFV\fR [\fIx\fR] -.RS 4 -Mirrors (flips) the page at the vertical line through point (\fIx\fR,0)\&. Omitting the optional argument leads to -\fIx\fR=\fIw\fR/2, where -\fIw\fR -denotes the page width (see -\fIpre\-defined constants\fR -below)\&. -.RE -.PP -\fBM\fR \fIm1\fR,\&...,\fIm6\fR -.RS 4 -Applies a transformation described by the 3\(mu3 matrix ((\fIm1\fR,\fIm2\fR,\fIm3\fR),(\fIm4\fR,\fIm5\fR,\fIm6\fR),(0,0,1)), where the inner triples denote the rows\&. -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -All transformation commands of option -\fB\-T, \-\-transform\fR -are applied in the order of their appearance\&. Multiple commands can optionally be separated by spaces\&. In this case the whole transformation string has to be enclosed in double quotes\&. All parameters are expressions of floating point type\&. You can either give plain numbers or arithmetic terms combined by the operators -\fB+\fR -(addition), -\fB\-\fR -(subtraction), -\fB*\fR -(multiplication), -\fB/\fR -(division) or -\fB%\fR -(modulo) with common associativity and precedence rules\&. Parentheses may be used as well\&. -.sp -Additionally, some pre\-defined constants are provided: -.TS -tab(:); -lt lt -lt lt -lt lt -lt lt. -T{ -\fBux\fR -T}:T{ -horizontal position of upper left page corner in TeX point units -T} -T{ -\fBuy\fR -T}:T{ -vertical position of upper left page corner in TeX point units -T} -T{ -\fBh\fR -T}:T{ -page height in TeX point units (0 in case of -\fB\-bnone\fR) -T} -T{ -\fBw\fR -T}:T{ -page width in TeX point units (0 in case of -\fB\-bnone\fR) -T} -.TE -.sp 1 -Furthermore, you can use the length constants -\fBpt\fR, -\fBmm\fR, -\fBcm\fR -and -\fBin\fR, e\&.g\&. -2cm -or -1\&.6in\&. Thus, option -\-TT1in,0R45 -moves the page content 1 inch to the right and rotates it by 45 degrees around the page center afterwards\&. -.sp -For single transformations you can also use options -\fB\-c\fR, -\fB\-t\fR -and -\fB\-r\fR\&. Note that the order in which these options are given is not significant, i\&.e\&. you can\(cqt use them to describe transformation sequences\&. They are simply independent shorthand options for common transformations\&. -.sp .5v -.RE -.RE -.RE -.PP -\fB\-t, \-\-translate\fR=\fItx\fR[,\fIty\fR] -.RS 4 -Translates (moves) the page content in direction of vector (\fItx\fR,\fIty\fR)\&. This option is equivalent to -\fB\-TT\fR\fItx\fR,\fIty\fR\&. -.RE -.PP -\fB\-v, \-\-verbosity\fR=\fIlevel\fR -.RS 4 -Controls the type of messages printed during a dvisvgm run: -.TS -tab(:); -lt lt -lt lt -lt lt -lt lt. -T{ -\fB0\fR -T}:T{ -no message output -T} -T{ -\fB1\fR -T}:T{ -error messages only -T} -T{ -\fB2\fR -T}:T{ -warning messages only -T} -T{ -\fB4\fR -T}:T{ -informational messages only -T} -.TE -.sp 1 -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -By adding these values you can combine the categories\&. The default level is 7, i\&.e\&. all messages are printed\&. -.sp .5v -.RE -.RE -.PP -\fB\-V, \-\-version\fR[=\fIextended\fR] -.RS 4 -Prints the version of dvisvgm and exits\&. If the optional argument is set to -\fIyes\fR, the version numbers of the linked libraries are printed as well\&. -.RE -.PP -\fB\-z, \-\-zip\fR[=\fIlevel\fR] -.RS 4 -Creates a compressed SVG file with suffix \&.svgz\&. The optional argument specifies the compression level\&. Valid values are in the range of 1 to 9 (default value is 9)\&. Larger values cause better compression results but take more computation time\&. -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBCaution\fR -.ps -1 -.br -This option cannot be combined with -\fB\-s, \-\-stdout\fR\&. -.sp .5v -.RE -.RE -.SH "SUPPORT OF SPECIALS" -.sp -dvisvgm supports several sets of \fIspecial commands\fR that can be used to enrich DVI files with additional features, like color, graphics or hyperlinks\&. The evaluation of special commands is delegated to various handlers\&. Each handler is responsible for all special statements of the same command set, i\&.e\&. commands beginning with the same prefix\&. To get a list of actually provided special handlers, use option \fB\-\-list\-specials\fR (see above)\&. -.PP -\fBbgcolor\fR -.RS 4 -Special statement for changing the background/page color\&. Since SVG 1\&.1 doesn\(cqt support background colors, dvisvgm inserts a rectangle of the chosen color into the generated SVG document\&. This rectangle always gets the same size as the selected or computed bounding box\&. This background color command is part of the color special set but is handled separately in order to let the user turn it off\&. For an overview of the command syntax, see the documentation of dvips, for instance\&. -.RE -.PP -\fBcolor\fR -.RS 4 -Statements of this command set provide instructions to change the text/paint color\&. For an overview of the exact syntax, see the documentation of dvips, for instance\&. -.RE -.PP -\fBdvisvgm\fR -.RS 4 -dvisvgm offers its own small set of specials\&. The following list gives a brief overview\&. -.PP -\fBdvisvgm:raw\fR \fItext\fR -.RS 4 -Adds an arbitrary sequence of characters to the SVG output\&. dvisvgm does not perform any validation here, thus the user has to ensure that the resulting SVG is still valid\&. Parameter -\fItext\fR -may contain the macros -\fB{?x}\fR, -\fB{?y}\fR, and -\fB{?color}\fR -that are expanded to the current -\fIx\fR -or -\fIy\fR -coordinate and the current color, respectively\&. Also, macro -\fB{?nl}\fR -expands to a newline character\&. -.RE -.PP -\fBdvisvgm:img\fR \fIwidth\fR \fIheight\fR \fIfile\fR -.RS 4 -Creates an image element at the current graphic position referencing the given file\&. JPEG, PNG, and SVG images can be used here\&. However, dvisvgm does not check the file format or the file name suffix\&. The lengths -\fIwidth\fR -and -\fIheight\fR -must be given as plain floating point numbers in TeX point units (1in = 72\&.27pt)\&. -.RE -.PP -\fBdvisvgm:bbox\fR n[ew] \fIname\fR -.RS 4 -Defines or resets a local bounding box called -\fIname\fR\&. The name may consist of letters and digits\&. While processing a DVI page, dvisvgm continuously updates the (global) bounding box of the current page in order to determine the minimal rectangle containing all visible page components (characters, images, drawing elements etc\&.) Additionally to the global bounding box, the user can request an arbitrary number of named local bounding boxes\&. Once defined, these boxes are updated together with the global bounding box starting with the first character that follows the definition\&. Thus, the local boxes can be used to compute the extent of parts of the page\&. This is useful for scenarios where the generated SVG file is post\-processed\&. In conjunction with special dvisvgm:raw, the macro -\fB{?bbox \fR\fB\fIname\fR\fR\fB}\fR -expands to the four values -\fIx\fR, -\fIy\fR, -\fIw\fR, and -\fIh\fR -(separated by spaces) specifying the coordinates of the upper left corner, width, and height of the local box -\fIname\fR\&. If box -\fIname\fR -wasn\(cqt previously defined, all four values equal zero\&. -.RE -.PP -\fBdvisvgm:bbox\fR \fIwidth\fR \fIheight\fR [\fIdepth\fR] -.RS 4 -Updates the bounding box of the current page by embedding a virtual rectangle (\fIx\fR, -\fIy\fR, -\fIwidth\fR, -\fIheight\fR) where the lower left corner is located at the current DVI drawing position (\fIx\fR,\fIy\fR)\&. If the optional parameter -\fIdepth\fR -is specified, dvisvgm embeds a second rectangle (\fIx\fR, -\fIy\fR, -\fIwidth\fR, \-\fIdepth\fR)\&. The lengths -\fIwidth\fR, -\fIheight\fR -and -\fIdepth\fR -must be given as plain floating point numbers in TeX point units (1in = 72\&.27pt)\&. Depending on size and position of the virtual rectangle, this command either enlarges the overall bounding box or leaves it as is\&. It\(cqs not possible to reduce its extent\&. This special should be used in conjunction with -\fBdvisvgm:raw\fR -in order to update the viewport of the page properly\&. -.RE -.PP -\fBdvisvgm:bbox\fR a[bs] \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR -.RS 4 -This variant of the bbox special updates the bounding box by embedding a virtual rectangle (\fIx1\fR,\fIy1\fR,\fIx2\fR,\fIy2\fR)\&. The points (\fIx1\fR,\fIy1\fR) and (\fIx2\fR,\fIy2\fR) denote two diagonal corners of the rectangle given in TeX point units\&. -.RE -.PP -\fBdvisvgm:bbox\fR f[ix] \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR -.RS 4 -This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG\&. After executing this command, dvisvgm doesn\(cqt further alter the bounding box coordinates, except this special is called again later\&. The points (\fIx1\fR,\fIy1\fR) and (\fIx2\fR,\fIy2\fR) denote two diagonal corners of the rectangle given in TeX point units\&. -.sp -The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\especial{dvisvgm:raw } -\especial{dvisvgm:bbox 20 10 10} - -\especial{dvisvgm:raw } -\especial{dvisvgm:bbox abs 10 200 100 250} -.fi -.if n \{\ -.RE -.\} -.RE -.RE -.PP -\fBem\fR -.RS 4 -These specials were introduced with the emTeX distribution by Eberhard Mattes\&. They provide line drawing statements, instructions for embedding MSP, PCX, and BMP image files, as well as two PCL commands\&. dvisvgm supports only the line drawing statements and ignores all other em specials silently\&. A description of the command syntax can be found in the DVI driver documentation coming with emTeX (see CTAN)\&. -.RE -.PP -\fBpdf\fR -.RS 4 -pdfTeX and dvipdfmx introduced several special commands related to the generation of PDF files\&. Currently, only two of them, -\fIpdf:mapfile\fR -and -\fIpdf:mapline\fR -are supported by dvisvgm\&. These specials allow modifying the font map tree during the processing of DVI files\&. They are used by CTeX, for example\&. dvisvgm supports both, the dvips and dvipdfm font map format\&. For further information on the command syntax and semantics, see the documentation of \epdfmapfile in the pdfTeX user manual\&. -.RE -.PP -\fBps\fR -.RS 4 -The famous DVI driver dvips introduced its own set of specials in order to embed PostScript code into DVI files, which greatly improves the capabilities of DVI documents\&. One aim of dvisvgm is to completely evaluate all PostScript snippets and to convert a large amount of it to SVG\&. However, in contrast to dvips, dvisvgm uses floating point arithmetics to compute the precise position of each graphic element, i\&.e\&. it doesn\(cqt round the coordinates\&. Therefore, the relative locations of the graphic elements may slightly differ from those computed by dvips\&. -.sp -Since PostScript is a rather complex language, dvisvgm does not try to implement its own PostScript interpreter but relies on Ghostscript instead\&. If the Ghostscript library was not linked while building dvisvgm, it is looked up and loaded dynamically during runtime\&. In this case, dvisvgm looks for -\fIlibgs\&.so\fR -on Unix\-like systems, and for -\fIgsdll32\&.dll\fR -or -\fIgsdll64\&.dll\fR -on Windows\&. You can override these default file names with environment variable -LIBGS -or the command\-line option -\fB\-\-libgs\fR\&. The library must be installed and reachable through the ld search path (*nix) or the PATH environment variable (Windows)\&. If it cannot be found, the processing of PostScript specials is disabled\&. Use option -\fB\-\-list\-specials\fR -to check whether PS support is available, i\&.e\&. the entry -\fIps\fR -is present\&. -.RE -.PP -\fBtpic\fR -.RS 4 -The TPIC special set defines instructions for drawing simple geometric objects\&. Some LaTeX packages, like eepic and tplot, use these specials to describe graphics\&. -.RE -.SH "EXAMPLES" -.sp -.if n \{\ -.RS 4 -.\} -.nf -dvisvgm file -.fi -.if n \{\ -.RE -.\} -.sp -Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svg\fR\&. -.sp -.if n \{\ -.RS 4 -.\} -.nf -dvisvgm \-z file -.fi -.if n \{\ -.RE -.\} -.sp -Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svgz\fR with default compression level 9\&. -.sp -.if n \{\ -.RS 4 -.\} -.nf -dvisvgm \-p5 \-z3 \-ba4\-l \-onewfile file -.fi -.if n \{\ -.RE -.\} -.sp -Converts the fifth page of \fIfile\&.dvi\fR to \fInewfile\&.svgz\fR with compression level 3\&. The bounding box is set to DIN/ISO A4 in landscape format\&. -.sp -.if n \{\ -.RS 4 -.\} -.nf -dvisvgm \-\-transform="R20,w/3,2h/5 T1cm,1cm S2,3" file -.fi -.if n \{\ -.RE -.\} -.sp -Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svg\fR where three transformations are applied\&. -.SH "ENVIRONMENT" -.sp -dvisvgm uses the \fBkpathsea\fR library for locating the files that it opens\&. Hence, the environment variables described in the library\(cqs documentation influence the converter\&. -.sp -If dvisvgm was linked without the Ghostscript library, and if PostScript support has not been disabled, the shared Ghostscript library is looked up during runtime via dlopen()\&. The environment variable LIBGS can be used to specify path and file name of the library\&. -.sp -The pre\-compiled Windows versions of dvisvgm require a working installation of MiKTeX 2\&.9 or above\&. dvisvgm does not work together with the portable edition of MiKTeX because it relies on MiKTeX\(cqs COM interface only accessible in a local installation\&. To enable the evaluation of PostScript specials, the original Ghostscript DLL \fIgsdll32\&.dll\fR must be present and reachable through the search path\&. 64\-bit Windows builds require the 64\-bit Ghostscript DLL \fIgsdll64\&.dll\fR\&. Both DLLs come with the corresponding Ghostscript installers available from www\&.ghostscript\&.com\&. -.sp -The environment variable DVISVGM_COLORS specifies the colors used to highlight various parts of dvisvgm\(cqs message output\&. It is only evaluated if option \fB\-\-color\fR is given\&. The value of DVISVGM_COLORS is a list of colon\-separated entries of the form \fIgg\fR=\fIBF\fR, where \fIgg\fR denotes one of the color group indicators listed below, and \fIBF\fR are two hexadecimal digits specifying the background (first digit) and foreground/text color (second digit)\&. The color color values are defined as follows: 0=black, 1=red, 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, 7=gray, 8=bright red, 9=bright green, A=bright yellow, B=bright blue, C=bright magenta, D=bright cyan, E=bright gray, F=white\&. Depending on the terminal, the colors may differ\&. Rather than changing both the text and background color, it\(cqs also possible to change only one of them: An asterisk (*) in place of a hexadecimal digit indicates the default text or background color of the terminal\&. -.sp -All malformed entries in the list are silently ignored\&. -.TS -tab(:); -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt. -T{ -.sp -\fBer\fR -T}:T{ -.sp -error messages -T} -T{ -.sp -\fBwn\fR -T}:T{ -.sp -warning messages -T} -T{ -.sp -\fBpn\fR -T}:T{ -.sp -messages about page numbers -T} -T{ -.sp -\fBps\fR -T}:T{ -.sp -page size messages -T} -T{ -.sp -\fBfw\fR -T}:T{ -.sp -information about the files written -T} -T{ -.sp -\fBsm\fR -T}:T{ -.sp -state messages -T} -T{ -.sp -\fBtr\fR -T}:T{ -.sp -messages of the glyph tracer -T} -T{ -.sp -\fBpi\fR -T}:T{ -.sp -progress indicator -T} -.TE -.sp 1 -.sp -\fBExample:\fR er=01:pi=*5 sets the colors of error messages (er) to red (1) on black (0), and those of progress indicators (pi) to cyan (5) on default background (*)\&. -.SH "FILES" -.sp -The location of the following files is determined by the kpathsea library\&. To check the actual kpathsea configuration you can use the \fBkpsewhich\fR utility\&. -.TS -tab(:); -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt -lt lt. -T{ -.sp -\fB*\&.enc\fR -T}:T{ -.sp -Font encoding files -T} -T{ -.sp -\fB*\&.fgd\fR -T}:T{ -.sp -Font glyph data files (cache files created by dvisvgm) -T} -T{ -.sp -\fB*\&.map\fR -T}:T{ -.sp -Font map files -T} -T{ -.sp -\fB*\&.mf\fR -T}:T{ -.sp -Metafont input files -T} -T{ -.sp -\fB*\&.pfb\fR -T}:T{ -.sp -PostScript Type 1 font files -T} -T{ -.sp -\fB*\&.pro\fR -T}:T{ -.sp -PostScript header/prologue files -T} -T{ -.sp -\fB*\&.tfm\fR -T}:T{ -.sp -TeX font metric files -T} -T{ -.sp -\fB*\&.ttf\fR -T}:T{ -.sp -TrueType font files -T} -T{ -.sp -\fB*\&.vf\fR -T}:T{ -.sp -Virtual font files -T} -.TE -.sp 1 -.SH "SEE ALSO" -.sp -\fBtex(1), mf(1), mktexmf(1), grodvi(1), potrace(1)\fR, and the \fBkpathsea library\fR info documentation\&. -.SH "RESOURCES" -.PP -Project home page -.RS 4 -http://dvisvgm\&.sourceforge\&.net -.RE -.PP -SourceForge project site -.RS 4 -http://sourceforge\&.net/projects/dvisvgm -.RE -.SH "BUGS" -.sp -Please report bugs using the bug tracker at Launchpad (see https://launchpad\&.net/dvisvgm)\&. -.SH "AUTHOR" -.sp -Written by Martin Gieseking -.SH "COPYING" -.sp -Copyright \(co 2005\-2013 Martin Gieseking\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 3 or, (at your option) any later version\&. -.SH "AUTHOR" -.PP -\fBMartin Gieseking\fR <\&martin\&.gieseking@uos\&.de\&> -.RS 4 -Author. -.RE diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.txt.in b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.txt.in deleted file mode 100644 index a09f37152e8..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/doc/dvisvgm.txt.in +++ /dev/null @@ -1,629 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// This file is part of dvisvgm -- the DVI to SVG converter // -// Copyright (C) 2005-2013 Martin Gieseking // -// // -// 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 . // -////////////////////////////////////////////////////////////////////////// - -dvisvgm(1) -========== -Martin Gieseking <@PACKAGE_BUGREPORT@> -:man source: dvisvgm -:man version: @VERSION@ -:man manual: dvisvgm Manual - -NAME ----- -dvisvgm - converts DVI files to the XML-based SVG format - - -SYNOPSIS --------- -*dvisvgm* [ 'options' ] 'file' [.dvi] - -*dvisvgm* -E [ 'options' ] 'file' [.eps] - - -DESCRIPTION ------------ -The command-line utility *dvisvgm* converts DVI files, as generated by TeX/LaTeX, to the -XML-based scalable vector graphics format SVG. Since the current SVG standard 1.1 doesn't -specify multi-page graphics, dvisvgm creates separate SVG files for each DVI page. -Because of compatibility reasons, only the first page is converted by default. In order -to select a different page or arbitrary page sequences, use option *-p* which is described below. - -dvisvgm should properly convert all pages that are made up of fonts and rules only. -However, the utility also supports a couple of DVI extensions defined in terms of 'DVI specials'. -For a more detailed overview, see section *support of specials* below. - -As SVG is a vector based graphics format, dvisvgm tries to convert the glyph -outlines of all used fonts into scalable path descriptions. The fastest way to do that -is to extract the path information from PFB (PostScript Type 1) files. So, if dvisvgm is able -to find a PFB file for a required font, it will read the necessary information from this file. - -TeX's main source for font descriptions is Metafont though, which produces bitmap output. That's why -not all obtainable TeX fonts are available in PFB format. In these cases, dvisvgm tries -to vectorize Metafont's output (GF fonts) by tracing the glyph bitmaps. The results are not -as perfect as most (manually optimized) PFB outlines but are nonetheless really nice in most cases. - - -OPTIONS -------- -*-a, --trace-all*=['retrace']:: -This option forces dvisvgm to trace not only the actually needed glyphs but all -glyphs of all bitmap fonts used in the DVI file. Since the tracing results are stored in -the font cache, all following DVI conversions (without option *--trace-all*) where these -fonts are involved, will be much faster. By default, dvisvgm traces only the actually -needed glyphs, and adds them to the cache. -The boolean option 'retrace' determines how to handle glyphs already stored in the cache. -By default, these glyphs are skipped. Setting argument 'retrace' to 'yes' or -'true' forces dvisvgm to trace the corresponding bitmaps again. -+ -[NOTE] -This option only takes affect if font caching is active. Thus, *--trace-all* cannot be -combined with option *--cache=none*. -+ - - -*-b, --bbox*='fmt':: -Sets the bounding box of the generated graphic to the specified format. The parameter 'fmt' -takes either one of the format specifiers listed below, or a sequence of four comma- or -whitespace-separated length values 'x1', 'y1', 'x2' and 'y2'. The latter define two diagonal -corners of the bounding box. Each length value consists of a floating point number and an optional -length unit (pt, bp, cm, mm, in, or pc). If the unit is omitted, TeX points (pt) are assumed. -+ -It's also possible to give only one length value 'l'. In this case, the minimal bounding box -is computed and enlarged by adding (-'l',-'l') to the upper left and ('l','l') to the lower -right corner. -+ -Alternatively, the following format specifiers are supported: - - *International DIN/ISO paper sizes*;; - A__n__, B__n__, C__n__, D__n__, where 'n' is a non-negative integer, e.g. A4 or a4 for DIN/ISO A4 - format (210mm × 297mm). - - *North American paper sizes*;; - invoice, executive, legal, letter, ledger - - *Special bounding box sizes*;; -[horizontal] - *dvi*::: page size stored in the DVI file - *min*::: computes the minimal/tightest bounding box - *none*::: no bounding box is assigned - -// - *Page orientation*;; - The default page orientation for DIN/ISO and American paper sizes is 'portrait', - i.e. 'width' < 'height'. Appending *-landscape* or simply *-l* to the format - string switches to 'landscape' mode ('width' > 'height'). For symmetry reasons you can - also explicitly add *-portrait* or *-p* to indicate the default portrait format. - Note that these suffixes are part of the size string and not separate options. Thus, - they must directly follow the size specifier without additional blanks. - Furthermore, the orientation suffixes can't be used with *dvi*, *min*, and *none*. -+ -[NOTE] -Option *-b, --bbox* only affects the bounding box and does not transform the page content. -Hence, if you choose a landscape format, the page won't be rotated. -+ -// - -// -*-C, --cache*[='dir']:: -To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion -information in cache files. By default, these files are stored in $HOME/.dvisvgm/cache. If you prefer -a different location, use option *--cache* to overwrite the default. Furthermore, it is also possible -to disable the font caching mechanism completely with option *--cache=none*. If argument 'dir' is omitted, -dvisvgm prints the path of the default cache directory and some information about the stored fonts. -Additionally, outdated and corrupted cache files are removed. - - -*--color*:: -Enables colorization of messages printed during the conversion process. The colors can be customized -via the environment variable +DVISVGM_COLORS+. See the ENVIRONMENT section below for further information. - - -*-E, --eps*:: -If this option is given, dvisvgm does not expect a DVI but an EPS input file, and tries to convert -it to SVG. In order to do so, a single 'psfile' special command is created and forwarded to the -PostScript special handler. -This option is only available if dvisvgm was built with PostScript support enabled, and requires -Ghostscript to be available. See option *--libgs* for further information. - - -*-e, --exact*:: -If this option is given, dvisvgm computes the precise bounding box of each character. By default, -the values stored in a font's TFM file are used to determine a glyph's extent. As these values are -intended to realize optimal character placements and are not designed to represent the exact dimensions, -they don't necessarily correspond with the bounds of the visual glyphs. Thus, width and/or height -of some glyphs may be larger than the respective TFM values. As a result, this can lead to clipped -characters at the bounds of the SVG graphic. With option *--exact*, dvisvgm analyzes the actual shape -of each character and derives a usually tight bounding box. - - -*-m, --fontmap*='filenames':: -Loads and evaluates a single or multiple font map files. These files are required to resolve -font file names and encodings. dvisvgm does not provide its own map file but tries to read -available ones coming with dvips or dvipdfm. If option *--fonrmapm* is not given, dvisvgm looks for the -default map files +ps2pk.map+, +dvipdfm.map+, and +psfonts.map+ (in this order). Otherwise, the -listed files are used. Multiple filenames must be separated by commas without leading and/or trailing -whitespace. -The map files are evaluated in the given order. By default, redefined mappings do not replace previous ones. -However, each filename can be preceded by an optional mode specifier (*+*, *-*, or *=*) to change this behavior: - - +mapfile;; - Only those entries in the given map file that don't redefine a font mapping are applied. - That's also the default mode if no mode specifier is given. - - -mapfile;; - Ensures that none of the font mappings defined in the given map file are used, i.e. previously - defined mappings for the specified fonts are removed. - - =mapfile;; - All mappings defined in the map file are applied. Previously defined settings for the same font - are replaced. -+ -If the first filename in the filename sequence is preceded by a mode specifier, dvisvgm loads the -default font map (see above) and applies the other map files afterwards. Otherwise, none of default -map files will be loaded automatically. -+ -Examples: *--fontmap=myfile1.map,+myfile2.map* loads `myfile1.map` followed by `myfile2.map` where all -redefinitions of `myfile2.map` are ignored. -*--fontmap==myfile1.map,-myfile2.map* loads the default map file followed by `myfile1.map` and `myfile2.map` -where all redefinitions of `myfile1.map` replace previous entries. Afterwards, all definitions for the fonts -given in `myfile2.map` are removed again. -+ -For further information about the map file formats, see the manuals of dvips and dvipdfm. - - -*-h, --help*[='mode']:: -Prints a short summary of all available command-line options. The optional 'mode' parameter is -an integer value between 0 and 2. It selects the display variant of the help text. Mode 0 -lists all options divided into categories with section headers. This is also the default if -dvisvgm is called without parameters. Mode 1 lists all options ordered by the short option name, -while mode 2 sorts the lines by the long option name. - - -*--keep*:: -Disables the removal of temporary files as created by Metafont (usually .gf, .tfm, and .log files). - - -*--libgs*='filename':: -This option is only available if the Ghostscript library is not directly linked to dvisvgm and if -PostScript support was not completely disabled during compilation. In this case, dvisvgm tries -to load the shared GS library dynamically during runtime. By default, it expects the library's name -to be libgs.so (on Unix-like systems) or gsdll32.dll/gsdll64.dll (Windows). Option *--libgs* can be -used to give a different name. Alternatively, it's also possible to set the GS library name by the -environment variable +LIBGS+. The latter has less precedence than the command-line option. - - -*-l, --list-specials*:: -Prints a list of registered special handlers and exits. Each handler processes a set of special -statements belonging to the same category. In most cases, the categories are identified by the -prefix of the special statements. It's usually a leading word separated from the rest of the -statement by a colon or a blank, e.g. 'color' or 'ps'. - - -*-M, --mag*='factor':: -Sets the magnification factor applied in conjunction with Metafont calls prior tracing the glyphs. -The larger this value, the better the tracing results. Nevertheless, large magnification values -can cause Metafont arithmetic errors due to number overflows. So, use this option with care. -The default setting usually produces nice results. - - -*--no-mktexmf*:: -Suppresses the generation of missing font files. If dvisvgm can't find a font file -through the kpathsea lookup mechanism, it calls the external tools mktextfm or mktexmf by. -This option disables these calls. - - -*-n, --no-fonts*[='variant']:: -If this option is given, dvisvgm doesn't create SVG 'font' elements but uses 'paths' instead. The -resulting SVG files tends to be larger but concurrently more compatible with most applications that -don't support SVG fonts yet. The optional argument 'variant' selects the method how to substitute fonts -by paths. Variant 0 creates 'path' and 'use' elements. Variant 1 creates 'path' elements only. -Option *--no-fonts* implies *--no-styles*. - - -*-c, --scale*='sx'[,'sy']:: -Scales the page content horizontally by 'sx' and vertically by 'sy'. This option is equivalent -to *-TS*'sx','sy'. - - -*-S, --no-specials*[='names']:: -Disable processing of special commands embedded in the DVI file. If no further -parameter is given, all specials are ignored. To selectively disable sets of specials, -an optional comma-separated list of names can be appended to this option. A 'name' is the unique -identifier referencing the intended special handler. Option *--list-specials* lists all currently -available handlers and their names. -All unsupported special statements are silently ignored. - - -*--no-styles*:: -By default, dvisvgm creates CSS styles and class attributes to reference fonts because it's more -compact than repeatedly set the complete font information in each text element. However, if you -prefer direct font references, the default behavior can be disabled with option *--no-styles*. - - -*-o, --output*='pattern':: -Sets the name pattern of the output file. Parameter 'pattern' is a string that may -contain the variables *%f* and *%p*. *%f* stands for the base name of the DVI file, i.e. -the DVI filename without suffix, and *%p* is the current page number. -The default pattern is *%f-%p.svg* if the DVI file consists of more than one page, and -*%f.svg* otherwise. That means, a DVI file 'foo.dvi' is converted to 'foo.svg' if 'foo.dvi' -is a single-page document. Otherwise, multiple SVG files 'foo-01.svg', 'foo-02.svg', etc. are -produced. In Windows environments, the percent sign indicates dereferenced environment -variables, and must therefore be protected by a second percent sign, e.g. *--output=%%f-%%p*. - - -*-p, --page*='ranges':: -This option sets the pages to be processed. Parameter 'ranges' consists of a comma-separated list -of single page numbers and/or page ranges. A page range is a pair of numbers separated by a hyphen, -e.g. 5-12. Thus, a page sequence might look like this: 2-4,6,9-12,15. It doesn't matter if a page -is given more than once or if page ranges overlap. dvisvgm always extracts the page numbers in -ascending order and converts them only once. -In order to stay compatible with previous versions, the default page sequence is 1. dvisvgm -therefore converts only the first page and not the whole document in case option *--page* is omitted. -Usually, page ranges consist of two numbers denoting the first and last page to be converted. -If the conversion is to be started at page 1, or if it should continue up to the last DVI page, the -first or second range number can be omitted, respectively. Example: *--page=-10* converts all -pages up to page 10, *--page=10-* converts all pages starting with page 10. -Please consider that the page values don't refer to the page numbers printed on the page. -Instead, the physical page count is expected, where the first page always gets number 1. - - -*-d, --precision*='digits':: -Specifies the maximal number of decimal places applied to floating-point attribute values. -All attribute values written to the generated SVG file(s) are rounded accordingly. The -parameter 'digits' allows integer values from 0 to 6, where 0 enables the automatic selection -of significant decimal places. This is also the default value if dvisvgm is called without -option *--precision*. - - -*-P, --progress*[='delay']:: -Enables a simple progress indicator shown when time-consuming operations like -PostScript specials are processed. The indicator doesn't appear before the given -delay (in seconds) has elapsed. The default delay value is 0.5 seconds. - - -*-r, --rotate*='angle':: -Rotates the page content clockwise by 'angle' degrees around the page center. -This option is equivalent to *-TR*'angle'. - - -*-s, --stdout*:: -Don't write the SVG output to a file but redirect it to *stdout*. - - -*-T, --transform*='commands':: -Applies a sequence of transformations to the SVG content. Each transformation is described -by a 'command' beginning with a capital letter followed by a list of comma-separated -parameters. Following transformation commands are supported: - - *T* 'tx'[,'ty'];; - Translates (moves) the page in direction of vector ('tx','ty'). If 'ty' is omitted, - 'ty'=0 is assumed. - The expected unit length of 'tx' and 'ty' are TeX points (1pt = 1/72.27in). However, there - are several constants defined to simplify the unit conversion (see below). - - *S* 'sx'[,'sy'];; - Scales the page horizontally by 'sx' and vertically by 'sy'. If 'sy' is omitted, - 'sy'='sx' is assumed. - - *R* 'angle'[,'x','y'];; - Rotates the page clockwise by 'angle' degrees around point ('x','y'). If the optional - arguments 'x' and 'y' are omitted, the page will be rotated around its center depending on - the chosen page format. When option *-bnone* is given, the rotation center is origin (0,0). - - *KX* 'angle';; - Skews the page along the 'x'-axis by 'angle' degrees. Argument 'angle' can take any value - except 90+180__k__, where 'k' is an integer. - - *KY* 'angle';; - Skews the page along the 'y'-axis by 'angle' degrees. Argument 'angle' can take any value - except 90+180__k__, where 'k' is an integer. - - *FH* ['y'];; - Mirrors (flips) the page at the horizontal line through point (0,'y'). Omitting the optional argument - leads to 'y'='h'/2, where 'h' denotes the page height (see 'pre-defined constants' below). - - *FV* ['x'];; - Mirrors (flips) the page at the vertical line through point ('x',0). Omitting the optional argument - leads to 'x'='w'/2, where 'w' denotes the page width (see 'pre-defined constants' below). - - *M* 'm1',...,'m6';; - Applies a transformation described by the 3×3 matrix - \(('m1','m2','m3'),('m4','m5','m6'),(0,0,1)), where the inner triples denote - the rows. -+ -[NOTE] -================================================================================================= -All transformation commands of option *-T, --transform* are applied in the order of their appearance. -Multiple commands can optionally be separated by spaces. In this case the whole transformation string -has to be enclosed in double quotes. All parameters are expressions of floating point type. You can either -give plain numbers or arithmetic terms combined by the operators *+* (addition), *-* (subtraction), -*** (multiplication), */* (division) or *%* (modulo) with common associativity and -precedence rules. Parentheses may be used as well. - -Additionally, some pre-defined constants are provided: - -[horizontal] -*ux*:: horizontal position of upper left page corner in TeX point units -*uy*:: vertical position of upper left page corner in TeX point units -*h*:: page height in TeX point units (0 in case of *-bnone*) -*w*:: page width in TeX point units (0 in case of *-bnone*) - -Furthermore, you can use the length constants *pt*, *mm*, *cm* and *in*, e.g. -+2cm+ or +1.6in+. Thus, option +-TT1in,0R45+ moves the page content 1 inch to the right and rotates it -by 45 degrees around the page center afterwards. - -For single transformations you can also use options *-c*, *-t* and *-r*. Note that -the order in which these options are given is not significant, i.e. you can't use them to describe -transformation sequences. They are simply independent shorthand options for common transformations. - -================================================================================================= -+ -// - -// -*-t, --translate*='tx'[,'ty']:: -Translates (moves) the page content in direction of vector ('tx','ty'). This option is -equivalent to *-TT*'tx','ty'. - - -*-v, --verbosity*='level':: -Controls the type of messages printed during a dvisvgm run: -[horizontal] - *0*;; no message output - *1*;; error messages only - *2*;; warning messages only - *4*;; informational messages only - -+ -[NOTE] -By adding these values you can combine the categories. The default level is 7, i.e. all -messages are printed. -+ - - -*-V, --version*[='extended']:: -Prints the version of dvisvgm and exits. If the optional argument is set to 'yes', the -version numbers of the linked libraries are printed as well. - - -*-z, --zip*[='level']:: -Creates a compressed SVG file with suffix .svgz. The optional argument specifies the compression -level. Valid values are in the range of 1 to 9 (default value is 9). Larger values cause better -compression results but take more computation time. -+ -CAUTION: This option cannot be combined with *-s, --stdout*. - - -SUPPORT OF SPECIALS -------------------- -dvisvgm supports several sets of 'special commands' that can be used to enrich DVI files with additional -features, like color, graphics or hyperlinks. The evaluation of special commands is delegated to various handlers. -Each handler is responsible for all special statements of the same command set, i.e. commands beginning -with the same prefix. To get a list of actually provided special handlers, use option *--list-specials* (see above). - -*bgcolor*:: -Special statement for changing the background/page color. Since SVG 1.1 doesn't support background colors, -dvisvgm inserts a rectangle of the chosen color into the generated SVG document. This rectangle always gets -the same size as the selected or computed bounding box. This background color command is part of the color -special set but is handled separately in order to let the user turn it off. For an overview of the command -syntax, see the documentation of dvips, for instance. - -*color*:: -Statements of this command set provide instructions to change the text/paint color. For an overview of the -exact syntax, see the documentation of dvips, for instance. - -*dvisvgm*:: -dvisvgm offers its own small set of specials. The following list gives a brief overview. - *dvisvgm:raw* 'text';; - Adds an arbitrary sequence of characters to the SVG output. dvisvgm does not perform any validation here, - thus the user has to ensure that the resulting SVG is still valid. Parameter 'text' may - contain the macros *{?x}*, *{?y}*, and *{?color}* that are expanded to the current 'x' or 'y' coordinate - and the current color, respectively. Also, macro *{?nl}* expands to a newline character. - - *dvisvgm:img* 'width' 'height' 'file';; - Creates an image element at the current graphic position referencing the given file. JPEG, PNG, and SVG images - can be used here. However, dvisvgm does not check the file format or the file name suffix. The lengths 'width' - and 'height' must be given as plain floating point numbers in TeX point units (1in = 72.27pt). - - *dvisvgm:bbox* n[ew] 'name';; - Defines or resets a local bounding box called 'name'. The name may consist of letters and digits. - While processing a DVI page, dvisvgm continuously updates the (global) bounding box of the current page in order to - determine the minimal rectangle containing all visible page components (characters, images, drawing elements etc.) - Additionally to the global bounding box, the user can request an arbitrary number of named local bounding boxes. - Once defined, these boxes are updated together with the global bounding box starting with the first character that - follows the definition. Thus, the local boxes can be used to compute the extent of parts of the page. This is useful - for scenarios where the generated SVG file is post-processed. - In conjunction with special dvisvgm:raw, the macro *{?bbox 'name'}* expands to the four values 'x', 'y', 'w', and 'h' - (separated by spaces) specifying the coordinates of the upper left corner, width, and height of the local box 'name'. - If box 'name' wasn't previously defined, all four values equal zero. - - *dvisvgm:bbox* 'width' 'height' ['depth'];; - Updates the bounding box of the current page by embedding a virtual rectangle ('x', 'y', 'width', 'height') - where the lower left corner is located at the current DVI drawing position ('x','y'). If the optional parameter 'depth' - is specified, dvisvgm embeds a second rectangle ('x', 'y', 'width', -__depth__). The lengths 'width', 'height' and - 'depth' must be given as plain floating point numbers in TeX point units (1in = 72.27pt). Depending on size and position - of the virtual rectangle, this command either enlarges the overall bounding box or leaves it as is. It's not possible - to reduce its extent. This special should be used in conjunction with *dvisvgm:raw* in order to update the viewport - of the page properly. - - *dvisvgm:bbox* a[bs] 'x1' 'y1' 'x2' 'y2';; - This variant of the bbox special updates the bounding box by embedding a virtual rectangle ('x1','y1','x2','y2'). - The points ('x1','y1') and ('x2','y2') denote two diagonal corners of the rectangle given in TeX point units. - - *dvisvgm:bbox* f[ix] 'x1' 'y1' 'x2' 'y2';; - This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG. After executing - this command, dvisvgm doesn't further alter the bounding box coordinates, except this special is called again later. - The points ('x1','y1') and ('x2','y2') denote two diagonal corners of the rectangle given in TeX point units. -+ -The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: -+ ------------------------------------------------------------------------------------- -\special{dvisvgm:raw } -\special{dvisvgm:bbox 20 10 10} - -\special{dvisvgm:raw } -\special{dvisvgm:bbox abs 10 200 100 250} ------------------------------------------------------------------------------------- -+ - -*em*:: -These specials were introduced with the emTeX distribution by Eberhard Mattes. They provide line drawing -statements, instructions for embedding MSP, PCX, and BMP image files, as well as two PCL commands. -dvisvgm supports only the line drawing statements and ignores all other em specials silently. -A description of the command syntax can be found in the DVI driver documentation coming with emTeX (see CTAN). - -// *html*:: -// The hyperref package uses a set of HTML anchor tags to indicate hyperlinks in DVI files. -// dvisvgm converts them to corresponding SVG elements. - -*pdf*:: -pdfTeX and dvipdfmx introduced several special commands related to the generation of PDF files. Currently, only -two of them, 'pdf:mapfile' and 'pdf:mapline' are supported by dvisvgm. These specials allow modifying the font map -tree during the processing of DVI files. They are used by CTeX, for example. dvisvgm supports both, the dvips and -dvipdfm font map format. For further information on the command syntax and semantics, see the documentation of -\pdfmapfile in the pdfTeX user manual. - -*ps*:: -The famous DVI driver dvips introduced its own set of specials in order to embed PostScript code into DVI files, -which greatly improves the capabilities of DVI documents. One aim of dvisvgm is to completely evaluate all -PostScript snippets and to convert a large amount of it to SVG. However, in contrast to dvips, dvisvgm uses floating point -arithmetics to compute the precise position of each graphic element, i.e. it doesn't round the coordinates. Therefore, -the relative locations of the graphic elements may slightly differ from those computed by dvips. -+ -Since PostScript is a rather complex language, dvisvgm does not try to implement its own PostScript interpreter but relies on -Ghostscript instead. If the Ghostscript library was not linked while building dvisvgm, it is looked up and loaded dynamically -during runtime. In this case, dvisvgm looks for 'libgs.so' on Unix-like systems, and for 'gsdll32.dll' or 'gsdll64.dll' on Windows. -You can override these default file names with environment variable +LIBGS+ or the command-line option *--libgs*. -The library must be installed and reachable through the ld search path (\*nix) or the PATH environment -variable (Windows). If it cannot be found, the processing of PostScript specials is disabled. -Use option *--list-specials* to check whether PS support is available, i.e. the entry 'ps' is present. - -*tpic*:: -The TPIC special set defines instructions for drawing simple geometric objects. Some LaTeX packages, like -eepic and tplot, use these specials to describe graphics. - - -EXAMPLES --------- --------------- -dvisvgm file --------------- -Converts the first page of 'file.dvi' to 'file.svg'. - ---------------- -dvisvgm -z file ---------------- -Converts the first page of 'file.dvi' to 'file.svgz' with default compression level 9. - -------------------------------------- -dvisvgm -p5 -z3 -ba4-l -onewfile file -------------------------------------- -Converts the fifth page of 'file.dvi' to 'newfile.svgz' with compression level 3. -The bounding box is set to DIN/ISO A4 in landscape format. - ------------------------------------------------------ -dvisvgm --transform="R20,w/3,2h/5 T1cm,1cm S2,3" file ------------------------------------------------------ -Converts the first page of 'file.dvi' to 'file.svg' where three transformations are applied. - - -ENVIRONMENT ------------ -dvisvgm uses the *kpathsea* library for locating the files that it opens. -Hence, the environment variables described in the library's documentation influence the converter. - -If dvisvgm was linked without the Ghostscript library, and if PostScript support has not been disabled, -the shared Ghostscript library is looked up during runtime via dlopen(). The environment variable +LIBGS+ -can be used to specify path and file name of the library. - -The pre-compiled Windows versions of dvisvgm require a working installation of MiKTeX 2.9 or above. -dvisvgm does not work together with the portable edition of MiKTeX because it relies on MiKTeX's COM -interface only accessible in a local installation. -To enable the evaluation of PostScript specials, the original Ghostscript DLL 'gsdll32.dll' must be present -and reachable through the search path. 64-bit Windows builds require the 64-bit Ghostscript DLL 'gsdll64.dll'. -Both DLLs come with the corresponding Ghostscript installers available from www.ghostscript.com. - -The environment variable +DVISVGM_COLORS+ specifies the colors used to highlight various parts of dvisvgm's -message output. It is only evaluated if option *--color* is given. The value of +DVISVGM_COLORS+ is a list of -colon-separated entries of the form 'gg'='BF', where 'gg' denotes one of the color group indicators listed -below, and 'BF' are two hexadecimal digits specifying the background (first digit) and foreground/text color -(second digit). The color color values are defined as follows: 0=black, 1=red, 2=green, 3=yellow, 4=blue, -5=magenta, 6=cyan, 7=gray, 8=bright red, 9=bright green, A=bright yellow, B=bright blue, C=bright magenta, -D=bright cyan, E=bright gray, F=white. Depending on the terminal, the colors may differ. Rather than changing -both the text and background color, it's also possible to change only one of them: An asterisk (*) in -place of a hexadecimal digit indicates the default text or background color of the terminal. - -All malformed entries in the list are silently ignored. - -[horizontal] -*er*:: error messages -*wn*:: warning messages -*pn*:: messages about page numbers -*ps*:: page size messages -*fw*:: information about the files written -*sm*:: state messages -*tr*:: messages of the glyph tracer -*pi*:: progress indicator - -*Example:* +er=01:pi=\*5+ sets the colors of error messages (+er+) to red (+1+) on black (+0+), and those -of progress indicators (+pi+) to cyan (+5+) on default background (+*+). - -FILES ------ -The location of the following files is determined by the kpathsea library. -To check the actual kpathsea configuration you can use the *kpsewhich* utility. - -[horizontal] -**.enc*:: Font encoding files -**.fgd*:: Font glyph data files (cache files created by dvisvgm) -**.map*:: Font map files -**.mf*:: Metafont input files -**.pfb*:: PostScript Type 1 font files -**.pro*:: PostScript header/prologue files -**.tfm*:: TeX font metric files -**.ttf*:: TrueType font files -**.vf*:: Virtual font files - -SEE ALSO --------- -*tex(1), mf(1), mktexmf(1), grodvi(1), potrace(1)*, and the *kpathsea library* info documentation. - - -RESOURCES ---------- -Project home page::: http://dvisvgm.sourceforge.net -SourceForge project site::: http://sourceforge.net/projects/dvisvgm - - -BUGS ----- -Please report bugs using the bug tracker at Launchpad (see https://launchpad.net/dvisvgm). - - -AUTHOR ------- -Written by {author} <{email}> - - -COPYING -------- -Copyright (C) 2005-2013 Martin Gieseking. Free use of this software is -granted under the terms of the GNU General Public License (GPL) version 3 -or, (at your option) any later version. - -// vim: set syntax=asciidoc: diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/Makefile.am deleted file mode 100644 index 97bf78f50f4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -VERSION=1.8 -noinst_LIBRARIES = libpotrace.a -libpotrace_a_SOURCES = curve.c curve.h trace.c trace.h decompose.c \ - decompose.h potracelib.c potracelib.h lists.h auxiliary.h bitmap.h \ - progress.h - -curve.o: potracelib.h lists.h curve.h auxiliary.h -decompose.o: potracelib.h curve.h auxiliary.h lists.h bitmap.h decompose.h -decompose.o: progress.h -potracelib.o: potracelib.h curve.h auxiliary.h decompose.h progress.h trace.h -potracelib.o: ../config.h -trace.o: potracelib.h curve.h auxiliary.h lists.h trace.h progress.h - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/auxiliary.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/auxiliary.h deleted file mode 100644 index c4c610cd4ef..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/auxiliary.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -/* This header file collects some general-purpose macros (and static - inline functions) that are used in various places. */ - -#ifndef AUXILIARY_H -#define AUXILIARY_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* ---------------------------------------------------------------------- */ -/* point arithmetic */ - -#include "potracelib.h" - -struct point_s { - long x; - long y; -}; -typedef struct point_s point_t; - -typedef potrace_dpoint_t dpoint_t; - -/* convert point_t to dpoint_t */ -static inline dpoint_t dpoint(point_t p) { - dpoint_t res; - res.x = p.x; - res.y = p.y; - return res; -} - -/* range over the straight line segment [a,b] when lambda ranges over [0,1] */ -static inline dpoint_t interval(double lambda, dpoint_t a, dpoint_t b) { - dpoint_t res; - - res.x = a.x + lambda * (b.x - a.x); - res.y = a.y + lambda * (b.y - a.y); - return res; -} - -/* ---------------------------------------------------------------------- */ -/* some useful macros. Note: the "mod" macro works correctly for - negative a. Also note that the test for a>=n, while redundant, - speeds up the mod function by 70% in the average case (significant - since the program spends about 16% of its time here - or 40% - without the test). The "floordiv" macro returns the largest integer - <= a/n, and again this works correctly for negative a, as long as - a,n are integers and n>0. */ - -/* integer arithmetic */ - -static inline int mod(int a, int n) { - return a>=n ? a%n : a>=0 ? a : n-1-(-1-a)%n; -} - -static inline int floordiv(int a, int n) { - return a>=0 ? a/n : -1-(-1-a)/n; -} - -/* Note: the following work for integers and other numeric types. */ -#undef sign -#undef abs -#undef min -#undef max -#undef sq -#undef cu -#define sign(x) ((x)>0 ? 1 : (x)<0 ? -1 : 0) -#define abs(a) ((a)>0 ? (a) : -(a)) -#define min(a,b) ((a)<(b) ? (a) : (b)) -#define max(a,b) ((a)>(b) ? (a) : (b)) -#define sq(a) ((a)*(a)) -#define cu(a) ((a)*(a)*(a)) - -#endif /* AUXILIARY_H */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/bitmap.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/bitmap.h deleted file mode 100644 index 1ce13d61e2d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/bitmap.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -#ifndef BITMAP_H -#define BITMAP_H - -#include -#include - -/* The bitmap type is defined in potracelib.h */ -#include "potracelib.h" - -/* The present file defines some convenient macros and static inline - functions for accessing bitmaps. Since they only produce inline - code, they can be conveniently shared by the library and frontends, - if desired */ - -/* ---------------------------------------------------------------------- */ -/* some measurements */ - -#define BM_WORDSIZE ((int)sizeof(potrace_word)) -#define BM_WORDBITS (8*BM_WORDSIZE) -#define BM_HIBIT (((potrace_word)1)<<(BM_WORDBITS-1)) -#define BM_ALLBITS (~(potrace_word)0) - -/* macros for accessing pixel at index (x,y). U* macros omit the - bounds check. */ - -#define bm_scanline(bm, y) ((bm)->map + (y)*(bm)->dy) -#define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x)/BM_WORDBITS]) -#define bm_mask(x) (BM_HIBIT >> ((x) & (BM_WORDBITS-1))) -#define bm_range(x, a) ((int)(x) >= 0 && (int)(x) < (a)) -#define bm_safe(bm, x, y) (bm_range(x, (bm)->w) && bm_range(y, (bm)->h)) -#define BM_UGET(bm, x, y) ((*bm_index(bm, x, y) & bm_mask(x)) != 0) -#define BM_USET(bm, x, y) (*bm_index(bm, x, y) |= bm_mask(x)) -#define BM_UCLR(bm, x, y) (*bm_index(bm, x, y) &= ~bm_mask(x)) -#define BM_UINV(bm, x, y) (*bm_index(bm, x, y) ^= bm_mask(x)) -#define BM_UPUT(bm, x, y, b) ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y)) -#define BM_GET(bm, x, y) (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0) -#define BM_SET(bm, x, y) (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0) -#define BM_CLR(bm, x, y) (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0) -#define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0) -#define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0) - -/* free the given bitmap. Leaves errno untouched. */ -static inline void bm_free(potrace_bitmap_t *bm) { - if (bm) { - free(bm->map); - } - free(bm); -} - -/* return new un-initialized bitmap. NULL with errno on error */ -static inline potrace_bitmap_t *bm_new(int w, int h) { - potrace_bitmap_t *bm; - int dy = (w + BM_WORDBITS - 1) / BM_WORDBITS; - - bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t)); - if (!bm) { - return NULL; - } - bm->w = w; - bm->h = h; - bm->dy = dy; - bm->map = (potrace_word *) malloc(dy * h * BM_WORDSIZE); - if (!bm->map) { - free(bm); - return NULL; - } - return bm; -} - -/* clear the given bitmap. Set all bits to c. */ -static inline void bm_clear(potrace_bitmap_t *bm, int c) { - memset(bm->map, c ? -1 : 0, bm->dy * bm->h * BM_WORDSIZE); -} - -/* duplicate the given bitmap. Return NULL on error with errno set. */ -static inline potrace_bitmap_t *bm_dup(const potrace_bitmap_t *bm) { - potrace_bitmap_t *bm1 = bm_new(bm->w, bm->h); - if (!bm1) { - return NULL; - } - memcpy(bm1->map, bm->map, bm->dy * bm->h * BM_WORDSIZE); - return bm1; -} - -/* invert the given bitmap. */ -static inline void bm_invert(potrace_bitmap_t *bm) { - int i; - for (i = 0; i < bm->dy * bm->h; i++) { - bm->map[i] ^= BM_ALLBITS; - } -} - -#endif /* BITMAP_H */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.c b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.c deleted file mode 100644 index 2bfc4ab3bf4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -/* private part of the path and curve data structures */ - -#include -#include -#include - -#include "potracelib.h" -#include "lists.h" -#include "curve.h" - -#define SAFE_MALLOC(var, n, typ) \ - if ((var = (typ *)malloc((n)*sizeof(typ))) == NULL) goto malloc_error - -/* ---------------------------------------------------------------------- */ -/* allocate and free path objects */ - -path_t *potrace_path_new(void) { - path_t *p = NULL; - privpath_t *priv = NULL; - - SAFE_MALLOC(p, 1, path_t); - memset(p, 0, sizeof(path_t)); - SAFE_MALLOC(priv, 1, privpath_t); - memset(priv, 0, sizeof(privpath_t)); - p->priv = priv; - return p; - - malloc_error: - free(p); - free(priv); - return NULL; -} - -/* free the members of the given curve structure. Leave errno unchanged. */ -static void privcurve_free_members(privcurve_t *curve) { - free(curve->tag); - free(curve->c); - free(curve->vertex); - free(curve->alpha); - free(curve->alpha0); - free(curve->beta); -} - -/* free a path. Leave errno untouched. */ -void potrace_path_free(path_t *p) { - if (p) { - if (p->priv) { - free(p->priv->pt); - free(p->priv->lon); - free(p->priv->sums); - free(p->priv->po); - privcurve_free_members(&p->priv->curve); - privcurve_free_members(&p->priv->ocurve); - } - free(p->priv); - /* do not free p->fcurve ! */ - } - free(p); -} - -/* free a pathlist, leaving errno untouched. */ -void pathlist_free(path_t *plist) { - path_t *p; - - list_forall_unlink(p, plist) { - potrace_path_free(p); - } -} - -/* ---------------------------------------------------------------------- */ -/* initialize and finalize curve structures */ - -typedef dpoint_t dpoint3_t[3]; - -/* initialize the members of the given curve structure to size m. - Return 0 on success, 1 on error with errno set. */ -int privcurve_init(privcurve_t *curve, int n) { - memset(curve, 0, sizeof(privcurve_t)); - curve->n = n; - SAFE_MALLOC(curve->tag, n, int); - SAFE_MALLOC(curve->c, n, dpoint3_t); - SAFE_MALLOC(curve->vertex, n, dpoint_t); - SAFE_MALLOC(curve->alpha, n, double); - SAFE_MALLOC(curve->alpha0, n, double); - SAFE_MALLOC(curve->beta, n, double); - return 0; - - malloc_error: - free(curve->tag); - free(curve->c); - free(curve->vertex); - free(curve->alpha); - free(curve->alpha0); - free(curve->beta); - return 1; -} - -/* copy private to public curve structure */ -void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c) { - c->n = pc->n; - c->tag = pc->tag; - c->c = pc->c; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.h deleted file mode 100644 index 7ba2a46439e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/curve.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -#ifndef CURVE_H -#define CURVE_H - -#include "auxiliary.h" - -/* vertex is c[1] for tag=POTRACE_CORNER, and the intersection of - .c[-1][2]..c[0] and c[1]..c[2] for tag=POTRACE_CURVETO. alpha is only - defined for tag=POTRACE_CURVETO and is the alpha parameter of the curve: - .c[-1][2]..c[0] = alpha*(.c[-1][2]..vertex), and - c[2]..c[1] = alpha*(c[2]..vertex). - Beta is so that (.beta[i])[.vertex[i],.vertex[i+1]] = .c[i][2]. -*/ - -struct privcurve_s { - int n; /* number of segments */ - int *tag; /* tag[n]: POTRACE_CORNER or POTRACE_CURVETO */ - dpoint_t (*c)[3]; /* c[n][i]: control points. - c[n][0] is unused for tag[n]=POTRACE_CORNER */ - /* the remainder of this structure is special to privcurve, and is - used in EPS debug output and special EPS "short coding". These - fields are valid only if "alphacurve" is set. */ - int alphacurve; /* have the following fields been initialized? */ - dpoint_t *vertex; /* for POTRACE_CORNER, this equals c[1] */ - double *alpha; /* only for POTRACE_CURVETO */ - double *alpha0; /* "uncropped" alpha parameter - for debug output only */ - double *beta; -}; -typedef struct privcurve_s privcurve_t; - -struct sums_s { - double x; - double y; - double x2; - double xy; - double y2; -}; -typedef struct sums_s sums_t; - -/* the path structure is filled in with information about a given path - as it is accumulated and passed through the different stages of the - Potrace algorithm. Backends only need to read the fcurve and fm - fields of this data structure, but debugging backends may read - other fields. */ -struct potrace_privpath_s { - int len; - point_t *pt; /* pt[len]: path as extracted from bitmap */ - int *lon; /* lon[len]: (i,lon[i]) = longest straight line from i */ - - int x0, y0; /* origin for sums */ - sums_t *sums; /* sums[len+1]: cache for fast summing */ - - int m; /* length of optimal polygon */ - int *po; /* po[m]: optimal polygon */ - - privcurve_t curve; /* curve[m]: array of curve elements */ - privcurve_t ocurve; /* ocurve[om]: array of curve elements */ - privcurve_t *fcurve; /* final curve: this points to either curve or - ocurve. Do not free this separately. */ -}; -typedef struct potrace_privpath_s potrace_privpath_t; - -/* shorter names */ -typedef potrace_privpath_t privpath_t; -typedef potrace_path_t path_t; - -path_t *potrace_path_new(void); -void potrace_path_free(path_t *p); -void pathlist_free(path_t *plist); -int privcurve_init(privcurve_t *curve, int n); -void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c); - -#endif /* CURVE_H */ - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.c b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.c deleted file mode 100644 index adcdc1c2cab..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.c +++ /dev/null @@ -1,514 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - - -#include -#include -#include -#include - -#include "potracelib.h" -#include "curve.h" -#include "lists.h" -#include "bitmap.h" -#include "decompose.h" -#include "progress.h" - -/* ---------------------------------------------------------------------- */ -/* deterministically and efficiently hash (x,y) into a pseudo-random bit */ - -static inline int detrand(int x, int y) { - unsigned int z; - static const unsigned char t[256] = { - /* non-linear sequence: constant term of inverse in GF(8), - mod x^8+x^4+x^3+x+1 */ - 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, - 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, - 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, - 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, - 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, - 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - }; - - /* 0x04b3e375 and 0x05a8ef93 are chosen to contain every possible - 5-bit sequence */ - z = ((0x04b3e375 * x) ^ y) * 0x05a8ef93; - z = t[z & 0xff] ^ t[(z>>8) & 0xff] ^ t[(z>>16) & 0xff] ^ t[(z>>24) & 0xff]; - return z; -} - -/* ---------------------------------------------------------------------- */ -/* auxiliary bitmap manipulations */ - -/* set the excess padding to 0 */ -static void bm_clearexcess(potrace_bitmap_t *bm) { - potrace_word mask; - int y; - - if (bm->w % BM_WORDBITS != 0) { - mask = BM_ALLBITS << (BM_WORDBITS - (bm->w % BM_WORDBITS)); - for (y=0; yh; y++) { - *bm_index(bm, bm->w, y) &= mask; - } - } -} - -struct bbox_s { - int x0, x1, y0, y1; /* bounding box */ -}; -typedef struct bbox_s bbox_t; - -/* clear the bm, assuming the bounding box is set correctly (faster - than clearing the whole bitmap) */ -static void clear_bm_with_bbox(potrace_bitmap_t *bm, bbox_t *bbox) { - int imin = (bbox->x0 / BM_WORDBITS); - int imax = ((bbox->x1 + BM_WORDBITS-1) / BM_WORDBITS); - int i, y; - - for (y=bbox->y0; yy1; y++) { - for (i=imin; i0) { - return 1; - } else if (ct<0) { - return 0; - } - } - return 0; -} - -/* ---------------------------------------------------------------------- */ -/* decompose image into paths */ - -/* efficiently invert bits [x,infty) and [xa,infty) in line y. Here xa - must be a multiple of BM_WORDBITS. */ -static void xor_to_ref(potrace_bitmap_t *bm, int x, int y, int xa) { - int xhi = x & -BM_WORDBITS; - int xlo = x & (BM_WORDBITS-1); /* = x % BM_WORDBITS */ - int i; - - if (xhipriv->len <= 0) { /* a path of length 0 is silly, but legal */ - return; - } - - y1 = p->priv->pt[p->priv->len-1].y; - - xa = p->priv->pt[0].x & -BM_WORDBITS; - for (k=0; kpriv->len; k++) { - x = p->priv->pt[k].x; - y = p->priv->pt[k].y; - - if (y != y1) { - /* efficiently invert the rectangle [x,xa] x [y,y1] */ - xor_to_ref(bm, x, min(y,y1), xa); - y1 = y; - } - } -} - -/* Find the bounding box of a given path. Path is assumed to be of - non-zero length. */ -static void setbbox_path(bbox_t *bbox, path_t *p) { - int x, y; - int k; - - bbox->y0 = INT_MAX; - bbox->y1 = 0; - bbox->x0 = INT_MAX; - bbox->x1 = 0; - - for (k=0; kpriv->len; k++) { - x = p->priv->pt[k].x; - y = p->priv->pt[k].y; - - if (x < bbox->x0) { - bbox->x0 = x; - } - if (x > bbox->x1) { - bbox->x1 = x; - } - if (y < bbox->y0) { - bbox->y0 = y; - } - if (y > bbox->y1) { - bbox->y1 = y; - } - } -} - -/* compute a path in the given pixmap, separating black from white. - Start path at the point (x0,x1), which must be an upper left corner - of the path. Also compute the area enclosed by the path. Return a - new path_t object, or NULL on error (note that a legitimate path - cannot have length 0). Sign is required for correct interpretation - of turnpolicies. */ -static path_t *findpath(potrace_bitmap_t *bm, int x0, int y0, int sign, int turnpolicy) { - int x, y, dirx, diry, len, size, area; - int c, d, tmp; - point_t *pt, *pt1; - path_t *p = NULL; - - x = x0; - y = y0; - dirx = 0; - diry = -1; - - len = size = 0; - pt = NULL; - area = 0; - - while (1) { - /* add point to path */ - if (len>=size) { - size += 100; - size = (int)(1.3 * size); - pt1 = (point_t *)realloc(pt, size * sizeof(point_t)); - if (!pt1) { - goto error; - } - pt = pt1; - } - pt[len].x = x; - pt[len].y = y; - len++; - - /* move to next point */ - x += dirx; - y += diry; - area += x*diry; - - /* path complete? */ - if (x==x0 && y==y0) { - break; - } - - /* determine next direction */ - c = BM_GET(bm, x + (dirx+diry-1)/2, y + (diry-dirx-1)/2); - d = BM_GET(bm, x + (dirx-diry-1)/2, y + (diry+dirx-1)/2); - - if (c && !d) { /* ambiguous turn */ - if (turnpolicy == POTRACE_TURNPOLICY_RIGHT - || (turnpolicy == POTRACE_TURNPOLICY_BLACK && sign == '+') - || (turnpolicy == POTRACE_TURNPOLICY_WHITE && sign == '-') - || (turnpolicy == POTRACE_TURNPOLICY_RANDOM && detrand(x,y)) - || (turnpolicy == POTRACE_TURNPOLICY_MAJORITY && majority(bm, x, y)) - || (turnpolicy == POTRACE_TURNPOLICY_MINORITY && !majority(bm, x, y))) { - tmp = dirx; /* right turn */ - dirx = diry; - diry = -tmp; - } else { - tmp = dirx; /* left turn */ - dirx = -diry; - diry = tmp; - } - } else if (c) { /* right turn */ - tmp = dirx; - dirx = diry; - diry = -tmp; - } else if (!d) { /* left turn */ - tmp = dirx; - dirx = -diry; - diry = tmp; - } - } /* while this path */ - - /* allocate new path object */ - p = potrace_path_new(); - if (!p) { - goto error; - } - - p->priv->pt = pt; - p->priv->len = len; - p->area = area; - p->sign = sign; - - return p; - - error: - free(pt); - return NULL; -} - -/* Give a tree structure to the given path list, based on "insideness" - testing. I.e., path A is considered "below" path B if it is inside - path B. The input pathlist is assumed to be ordered so that "outer" - paths occur before "inner" paths. The tree structure is stored in - the "childlist" and "sibling" components of the path_t - structure. The linked list structure is also changed so that - negative path components are listed immediately after their - positive parent. Note: some backends may ignore the tree - structure, others may use it e.g. to group path components. We - assume that in the input, point 0 of each path is an "upper left" - corner of the path, as returned by bm_to_pathlist. This makes it - easy to find an "interior" point. The bm argument should be a - bitmap of the correct size (large enough to hold all the paths), - and will be used as scratch space. Return 0 on success or -1 on - error with errno set. */ - -static void pathlist_to_tree(path_t *plist, potrace_bitmap_t *bm) { - path_t *p, *p1; - path_t *heap, *heap1; - path_t *cur; - path_t *head; - path_t **plist_hook; /* for fast appending to linked list */ - path_t **hook_in, **hook_out; /* for fast appending to linked list */ - bbox_t bbox; - - bm_clear(bm, 0); - - /* save original "next" pointers */ - list_forall(p, plist) { - p->sibling = p->next; - p->childlist = NULL; - } - - heap = plist; - - /* the heap holds a list of lists of paths. Use "childlist" field - for outer list, "next" field for inner list. Each of the sublists - is to be turned into a tree. This code is messy, but it is - actually fast. Each path is rendered exactly once. We use the - heap to get a tail recursive algorithm: the heap holds a list of - pathlists which still need to be transformed. */ - - while (heap) { - /* unlink first sublist */ - cur = heap; - heap = heap->childlist; - cur->childlist = NULL; - - /* unlink first path */ - head = cur; - cur = cur->next; - head->next = NULL; - - /* render path */ - xor_path(bm, head); - setbbox_path(&bbox, head); - - /* now do insideness test for each element of cur; append it to - head->childlist if it's inside head, else append it to - head->next. */ - hook_in=&head->childlist; - hook_out=&head->next; - list_forall_unlink(p, cur) { - if (p->priv->pt[0].y <= bbox.y0) { - list_insert_beforehook(p, hook_out); - /* append the remainder of the list to hook_out */ - *hook_out = cur; - break; - } - if (BM_GET(bm, p->priv->pt[0].x, p->priv->pt[0].y-1)) { - list_insert_beforehook(p, hook_in); - } else { - list_insert_beforehook(p, hook_out); - } - } - - /* clear bm */ - clear_bm_with_bbox(bm, &bbox); - - /* now schedule head->childlist and head->next for further - processing */ - if (head->next) { - head->next->childlist = heap; - heap = head->next; - } - if (head->childlist) { - head->childlist->childlist = heap; - heap = head->childlist; - } - } - - /* copy sibling structure from "next" to "sibling" component */ - p = plist; - while (p) { - p1 = p->sibling; - p->sibling = p->next; - p = p1; - } - - /* reconstruct a new linked list ("next") structure from tree - ("childlist", "sibling") structure. This code is slightly messy, - because we use a heap to make it tail recursive: the heap - contains a list of childlists which still need to be - processed. */ - heap = plist; - if (heap) { - heap->next = NULL; /* heap is a linked list of childlists */ - } - plist = NULL; - plist_hook = &plist; - while (heap) { - heap1 = heap->next; - for (p=heap; p; p=p->sibling) { - /* p is a positive path */ - /* append to linked list */ - list_insert_beforehook(p, plist_hook); - - /* go through its children */ - for (p1=p->childlist; p1; p1=p1->sibling) { - /* append to linked list */ - list_insert_beforehook(p1, plist_hook); - /* append its childlist to heap, if non-empty */ - if (p1->childlist) { - list_append(path_t, heap1, p1->childlist); - } - } - } - heap = heap1; - } - - return; -} - -/* find the next set pixel in a row <= y. Pixels are searched first - left-to-right, then top-down. In other words, (x,y)<(x',y') if y>y' - or y=y' and x=0; y--) { - for (x=x0; xw; x+=BM_WORDBITS) { - if (*bm_index(bm, x, y)) { - while (!BM_GET(bm, x, y)) { - x++; - } - /* found */ - *xp = x; - *yp = y; - return 0; - } - } - x0 = 0; - } - /* not found */ - return 1; -} - -/* Decompose the given bitmap into paths. Returns a linked list of - path_t objects with the fields len, pt, area, sign filled - in. Returns 0 on success with plistp set, or -1 on error with errno - set. */ - -int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_param_t *param, progress_t *progress) { - int x; - int y; - path_t *p; - path_t *plist = NULL; /* linked list of path objects */ - path_t **plist_hook = &plist; /* used to speed up appending to linked list */ - potrace_bitmap_t *bm1 = NULL; - int sign; - - bm1 = bm_dup(bm); - if (!bm1) { - goto error; - } - - /* be sure the byte padding on the right is set to 0, as the fast - pixel search below relies on it */ - bm_clearexcess(bm1); - - /* iterate through components */ - x = 0; - y = bm1->h - 1; - while (findnext(bm1, &x, &y) == 0) { - /* calculate the sign by looking at the original */ - sign = BM_GET(bm, x, y) ? '+' : '-'; - - /* calculate the path */ - p = findpath(bm1, x, y+1, sign, param->turnpolicy); - if (p==NULL) { - goto error; - } - - /* update buffered image */ - xor_path(bm1, p); - - /* if it's a turd, eliminate it, else append it to the list */ - if (p->area <= param->turdsize) { - potrace_path_free(p); - } else { - list_insert_beforehook(p, plist_hook); - } - - if (bm1->h > 0) { /* to be sure */ - progress_update(1-y/(double)bm1->h, progress); - } - } - - pathlist_to_tree(plist, bm1); - bm_free(bm1); - *plistp = plist; - - progress_update(1.0, progress); - - return 0; - - error: - bm_free(bm1); - list_forall_unlink(p, plist) { - potrace_path_free(p); - } - return -1; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.h deleted file mode 100644 index feec07a46b3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/decompose.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - - -#ifndef DECOMPOSE_H -#define DECOMPOSE_H - -#include "potracelib.h" -#include "progress.h" -#include "curve.h" - -int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_param_t *param, progress_t *progress); - -#endif /* DECOMPOSE_H */ - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/lists.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/lists.h deleted file mode 100644 index b67b9662356..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/lists.h +++ /dev/null @@ -1,285 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - - -#ifndef _PS_LISTS_H -#define _PS_LISTS_H - -/* here we define some general list macros. Because they are macros, - they should work on any datatype with a "->next" component. Some of - them use a "hook". If elt and list are of type t* then hook is of - type t**. A hook stands for an insertion point in the list, i.e., - either before the first element, or between two elements, or after - the last element. If an operation "sets the hook" for an element, - then the hook is set to just before the element. One can insert - something at a hook. One can also unlink at a hook: this means, - unlink the element just after the hook. By "to unlink", we mean the - element is removed from the list, but not deleted. Thus, it and its - components still need to be freed. */ - -/* Note: these macros are somewhat experimental. Only the ones that - are actually *used* have been tested. So be careful to test any - that you use. Looking at the output of the preprocessor, "gcc -E" - (possibly piped though "indent"), might help too. Also: these - macros define some internal (local) variables that start with - "_". */ - -/* we enclose macro definitions whose body consists of more than one - statement in MACRO_BEGIN and MACRO_END, rather than '{' and '}'. The - reason is that we want to be able to use the macro in a context - such as "if (...) macro(...); else ...". If we didn't use this obscure - trick, we'd have to omit the ";" in such cases. */ - -#define MACRO_BEGIN do { -#define MACRO_END } while (0) - -/* ---------------------------------------------------------------------- */ -/* macros for singly-linked lists */ - -/* traverse list. At the end, elt is set to NULL. */ -#define list_forall(elt, list) for (elt=list; elt!=NULL; elt=elt->next) - -/* set elt to the first element of list satisfying boolean condition - c, or NULL if not found */ -#define list_find(elt, list, c) \ - MACRO_BEGIN list_forall(elt, list) if (c) break; MACRO_END - -/* like forall, except also set hook for elt. */ -#define list_forall2(elt, list, hook) \ - for (elt=list, hook=&list; elt!=NULL; hook=&elt->next, elt=elt->next) - -/* same as list_find, except also set hook for elt. */ -#define list_find2(elt, list, c, hook) \ - MACRO_BEGIN list_forall2(elt, list, hook) if (c) break; MACRO_END - -/* same, except only use hook. */ -#define _list_forall_hook(list, hook) \ - for (hook=&list; *hook!=NULL; hook=&(*hook)->next) - -/* same, except only use hook. Note: c may only refer to *hook, not elt. */ -#define _list_find_hook(list, c, hook) \ - MACRO_BEGIN _list_forall_hook(list, hook) if (c) break; MACRO_END - -/* insert element after hook */ -#define list_insert_athook(elt, hook) \ - MACRO_BEGIN elt->next = *hook; *hook = elt; MACRO_END - -/* insert element before hook */ -#define list_insert_beforehook(elt, hook) \ - MACRO_BEGIN elt->next = *hook; *hook = elt; hook=&elt->next; MACRO_END - -/* unlink element after hook, let elt be unlinked element, or NULL. - hook remains. */ -#define list_unlink_athook(list, elt, hook) \ - MACRO_BEGIN \ - elt = hook ? *hook : NULL; if (elt) { *hook = elt->next; elt->next = NULL; }\ - MACRO_END - -/* unlink the specific element, if it is in the list. Otherwise, set - elt to NULL */ -#define list_unlink(listtype, list, elt) \ - MACRO_BEGIN \ - listtype **_hook; \ - _list_find_hook(list, *_hook==elt, _hook); \ - list_unlink_athook(list, elt, _hook); \ - MACRO_END - -/* prepend elt to list */ -#define list_prepend(list, elt) \ - MACRO_BEGIN elt->next = list; list = elt; MACRO_END - -/* append elt to list. */ -#define list_append(listtype, list, elt) \ - MACRO_BEGIN \ - listtype **_hook; \ - _list_forall_hook(list, _hook) {} \ - list_insert_athook(elt, _hook); \ - MACRO_END - -/* unlink the first element that satisfies the condition. */ -#define list_unlink_cond(listtype, list, elt, c) \ - MACRO_BEGIN \ - listtype **_hook; \ - list_find2(elt, list, c, _hook); \ - list_unlink_athook(list, elt, _hook); \ - MACRO_END - -/* let elt be the nth element of the list, starting to count from 0. - Return NULL if out of bounds. */ -#define list_nth(elt, list, n) \ - MACRO_BEGIN \ - int _x; /* only evaluate n once */ \ - for (_x=(n), elt=list; _x && elt; _x--, elt=elt->next) {} \ - MACRO_END - -/* let elt be the nth element of the list, starting to count from 0. - Return NULL if out of bounds. */ -#define list_nth_hook(elt, list, n, hook) \ - MACRO_BEGIN \ - int _x; /* only evaluate n once */ \ - for (_x=(n), elt=list, hook=&list; _x && elt; _x--, hook=&elt->next, elt=elt->next) {} \ - MACRO_END - -/* set n to the length of the list */ -#define list_length(listtype, list, n) \ - MACRO_BEGIN \ - listtype *_elt; \ - n=0; \ - list_forall(_elt, list) \ - n++; \ - MACRO_END - -/* set n to the index of the first element satisfying cond, or -1 if - none found. Also set elt to the element, or NULL if none found. */ -#define list_index(list, n, elt, c) \ - MACRO_BEGIN \ - n=0; \ - list_forall(elt, list) { \ - if (c) break; \ - n++; \ - } \ - if (!elt) \ - n=-1; \ - MACRO_END - -/* set n to the number of elements in the list that satisfy condition c */ -#define list_count(list, n, elt, c) \ - MACRO_BEGIN \ - n=0; \ - list_forall(elt, list) { \ - if (c) n++; \ - } \ - MACRO_END - -/* let elt be each element of the list, unlinked. At the end, set list=NULL. */ -#define list_forall_unlink(elt, list) \ - for (elt=list; elt ? (list=elt->next, elt->next=NULL), 1 : 0; elt=list) - -/* reverse a list (efficient) */ -#define list_reverse(listtype, list) \ - MACRO_BEGIN \ - listtype *_list1=NULL, *elt; \ - list_forall_unlink(elt, list) \ - list_prepend(_list1, elt); \ - list = _list1; \ - MACRO_END - -/* insert the element ELT just before the first element TMP of the - list for which COND holds. Here COND must be a condition of ELT and - TMP. Typical usage is to insert an element into an ordered list: - for instance, list_insert_ordered(listtype, list, elt, tmp, - elt->size <= tmp->size). Note: if we give a "less than or equal" - condition, the new element will be inserted just before a sequence - of equal elements. If we give a "less than" condition, the new - element will be inserted just after a list of equal elements. - Note: it is much more efficient to construct a list with - list_prepend and then order it with list_merge_sort, than to - construct it with list_insert_ordered. */ -#define list_insert_ordered(listtype, list, elt, tmp, cond) \ - MACRO_BEGIN \ - listtype **_hook; \ - _list_find_hook(list, (tmp=*_hook, (cond)), _hook); \ - list_insert_athook(elt, _hook); \ - MACRO_END - -/* sort the given list, according to the comparison condition. - Typical usage is list_sort(listtype, list, a, b, a->size < - b->size). Note: if we give "less than or equal" condition, each - segment of equal elements will be reversed in order. If we give a - "less than" condition, each segment of equal elements will retain - the original order. The latter is slower but sometimes - prettier. Average running time: n*n/2. */ -#define list_sort(listtype, list, a, b, cond) \ - MACRO_BEGIN \ - listtype *_newlist=NULL; \ - list_forall_unlink(a, list) \ - list_insert_ordered(listtype, _newlist, a, b, cond); \ - list = _newlist; \ - MACRO_END - -/* a much faster sort algorithm (merge sort, n log n worst case). It - is required that the list type has an additional, unused next1 - component. Note there is no curious reversal of order of equal - elements as for list_sort. */ - -#define list_mergesort(listtype, list, a, b, cond) \ - MACRO_BEGIN \ - listtype *_elt, **_hook1; \ - \ - for (_elt=list; _elt; _elt=_elt->next1) { \ - _elt->next1 = _elt->next; \ - _elt->next = NULL; \ - } \ - do { \ - _hook1 = &(list); \ - while ((a = *_hook1) != NULL && (b = a->next1) != NULL ) { \ - _elt = b->next1; \ - _list_merge_cond(listtype, a, b, cond, *_hook1); \ - _hook1 = &((*_hook1)->next1); \ - *_hook1 = _elt; \ - } \ - } while (_hook1 != &(list)); \ - MACRO_END - -/* merge two sorted lists. Store result at &result */ -#define _list_merge_cond(listtype, a, b, cond, result) \ - MACRO_BEGIN \ - listtype **_hook; \ - _hook = &(result); \ - while (1) { \ - if (a==NULL) { \ - *_hook = b; \ - break; \ - } else if (b==NULL) { \ - *_hook = a; \ - break; \ - } else if (cond) { \ - *_hook = a; \ - _hook = &(a->next); \ - a = a->next; \ - } else { \ - *_hook = b; \ - _hook = &(b->next); \ - b = b->next; \ - } \ - } \ - MACRO_END - -/* ---------------------------------------------------------------------- */ -/* macros for doubly-linked lists */ - -#define dlist_append(head, end, elt) \ - MACRO_BEGIN \ - elt->prev = end; \ - elt->next = NULL; \ - if (end) { \ - end->next = elt; \ - } else { \ - head = elt; \ - } \ - end = elt; \ - MACRO_END - -/* let elt be each element of the list, unlinked. At the end, set list=NULL. */ -#define dlist_forall_unlink(elt, head, end) \ - for (elt=head; elt ? (head=elt->next, elt->next=NULL, elt->prev=NULL), 1 : (end=NULL, 0); elt=head) - -/* unlink the first element of the list */ -#define dlist_unlink_first(head, end, elt) \ - MACRO_BEGIN \ - elt = head; \ - if (head) { \ - head = head->next; \ - if (head) { \ - head->prev = NULL; \ - } else { \ - end = NULL; \ - } \ - elt->prev = NULL; \ - elt->next = NULL; \ - } \ - MACRO_END - -#endif /* _PS_LISTS_H */ - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.c b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.c deleted file mode 100644 index 95901bcb53f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -#include -#include - -#include "potracelib.h" -#include "curve.h" -#include "decompose.h" -#include "trace.h" -#include "progress.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* default parameters */ -static const potrace_param_t param_default = { - 2, /* turdsize */ - POTRACE_TURNPOLICY_MINORITY, /* turnpolicy */ - 1.0, /* alphamax */ - 1, /* opticurve */ - 0.2, /* opttolerance */ - { - NULL, /* callback function */ - NULL, /* callback data */ - 0.0, 1.0, /* progress range */ - 0.0, /* granularity */ - }, -}; - -/* Return a fresh copy of the set of default parameters, or NULL on - failure with errno set. */ -potrace_param_t *potrace_param_default(void) { - potrace_param_t *p; - - p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); - if (!p) { - return NULL; - } - memcpy(p, ¶m_default, sizeof(potrace_param_t)); - return p; -} - -/* On success, returns a Potrace state st with st->status == - POTRACE_STATUS_OK. On failure, returns NULL if no Potrace state - could be created (with errno set), or returns an incomplete Potrace - state (with st->status == POTRACE_STATUS_INCOMPLETE, and with errno - set). Complete or incomplete Potrace state can be freed with - potrace_state_free(). */ -potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm) { - int r; - path_t *plist = NULL; - potrace_state_t *st; - progress_t prog; - progress_t subprog; - - /* prepare private progress bar state */ - prog.callback = param->progress.callback; - prog.data = param->progress.data; - prog.min = param->progress.min; - prog.max = param->progress.max; - prog.epsilon = param->progress.epsilon; - prog.d_prev = param->progress.min; - - /* allocate state object */ - st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); - if (!st) { - return NULL; - } - - progress_subrange_start(0.0, 0.1, &prog, &subprog); - - /* process the image */ - r = bm_to_pathlist(bm, &plist, param, &subprog); - if (r) { - free(st); - return NULL; - } - - st->status = POTRACE_STATUS_OK; - st->plist = plist; - st->priv = NULL; /* private state currently unused */ - - progress_subrange_end(&prog, &subprog); - - progress_subrange_start(0.1, 1.0, &prog, &subprog); - - /* partial success. */ - r = process_path(plist, param, &subprog); - if (r) { - st->status = POTRACE_STATUS_INCOMPLETE; - } - - progress_subrange_end(&prog, &subprog); - - return st; -} - -/* free a Potrace state, without disturbing errno. */ -void potrace_state_free(potrace_state_t *st) { - pathlist_free(st->plist); - free(st); -} - -/* free a parameter list, without disturbing errno. */ -void potrace_param_free(potrace_param_t *p) { - free(p); -} - -const char *potrace_version(void) { - return "potracelib 1.11"; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.h deleted file mode 100644 index 5c628a2bdbd..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/potracelib.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -#ifndef POTRACELIB_H -#define POTRACELIB_H - -/* this file defines the API for the core Potrace library. For a more - detailed description of the API, see potracelib.pdf */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------------------------------------------------------------------- */ -/* tracing parameters */ - -/* turn policies */ -#define POTRACE_TURNPOLICY_BLACK 0 -#define POTRACE_TURNPOLICY_WHITE 1 -#define POTRACE_TURNPOLICY_LEFT 2 -#define POTRACE_TURNPOLICY_RIGHT 3 -#define POTRACE_TURNPOLICY_MINORITY 4 -#define POTRACE_TURNPOLICY_MAJORITY 5 -#define POTRACE_TURNPOLICY_RANDOM 6 - -/* structure to hold progress bar callback data */ -struct potrace_progress_s { - void (*callback)(double progress, void *privdata); /* callback fn */ - void *data; /* callback function's private data */ - double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */ - double epsilon; /* granularity: can skip smaller increments */ -}; -typedef struct potrace_progress_s potrace_progress_t; - -/* structure to hold tracing parameters */ -struct potrace_param_s { - int turdsize; /* area of largest path to be ignored */ - int turnpolicy; /* resolves ambiguous turns in path decomposition */ - double alphamax; /* corner threshold */ - int opticurve; /* use curve optimization? */ - double opttolerance; /* curve optimization tolerance */ - potrace_progress_t progress; /* progress callback function */ -}; -typedef struct potrace_param_s potrace_param_t; - -/* ---------------------------------------------------------------------- */ -/* bitmaps */ - -/* native word size */ -typedef unsigned long potrace_word; - -/* Internal bitmap format. The n-th scanline starts at scanline(n) = - (map + n*dy). Raster data is stored as a sequence of potrace_words - (NOT bytes). The leftmost bit of scanline n is the most significant - bit of scanline(n)[0]. */ -struct potrace_bitmap_s { - int w, h; /* width and height, in pixels */ - int dy; /* words per scanline (not bytes) */ - potrace_word *map; /* raw data, dy*h words */ -}; -typedef struct potrace_bitmap_s potrace_bitmap_t; - -/* ---------------------------------------------------------------------- */ -/* curves */ - -/* point */ -struct potrace_dpoint_s { - double x, y; -}; -typedef struct potrace_dpoint_s potrace_dpoint_t; - -/* segment tags */ -#define POTRACE_CURVETO 1 -#define POTRACE_CORNER 2 - -/* closed curve segment */ -struct potrace_curve_s { - int n; /* number of segments */ - int *tag; /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */ - potrace_dpoint_t (*c)[3]; /* c[n][3]: control points. - c[n][0] is unused for tag[n]=POTRACE_CORNER */ -}; -typedef struct potrace_curve_s potrace_curve_t; - -/* Linked list of signed curve segments. Also carries a tree structure. */ -struct potrace_path_s { - int area; /* area of the bitmap path */ - int sign; /* '+' or '-', depending on orientation */ - potrace_curve_t curve; /* this path's vector data */ - - struct potrace_path_s *next; /* linked list structure */ - - struct potrace_path_s *childlist; /* tree structure */ - struct potrace_path_s *sibling; /* tree structure */ - - struct potrace_privpath_s *priv; /* private state */ -}; -typedef struct potrace_path_s potrace_path_t; - -/* ---------------------------------------------------------------------- */ -/* Potrace state */ - -#define POTRACE_STATUS_OK 0 -#define POTRACE_STATUS_INCOMPLETE 1 - -struct potrace_state_s { - int status; - potrace_path_t *plist; /* vector data */ - - struct potrace_privstate_s *priv; /* private state */ -}; -typedef struct potrace_state_s potrace_state_t; - -/* ---------------------------------------------------------------------- */ -/* API functions */ - -/* get default parameters */ -potrace_param_t *potrace_param_default(void); - -/* free parameter set */ -void potrace_param_free(potrace_param_t *p); - -/* trace a bitmap*/ -potrace_state_t *potrace_trace(const potrace_param_t *param, - const potrace_bitmap_t *bm); - -/* free a Potrace state */ -void potrace_state_free(potrace_state_t *st); - -/* return a static plain text version string identifying this version - of potracelib */ -const char *potrace_version(void); - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* POTRACELIB_H */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/progress.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/progress.h deleted file mode 100644 index 166209a5226..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/progress.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -/* operations on potrace_progress_t objects, which are defined in - potracelib.h. Note: the code attempts to minimize runtime overhead - when no progress monitoring was requested. It also tries to - minimize excessive progress calculations beneath the "epsilon" - threshold. */ - -#ifndef PROGRESS_H -#define PROGRESS_H - -/* structure to hold progress bar callback data */ -struct progress_s { - void (*callback)(double progress, void *privdata); /* callback fn */ - void *data; /* callback function's private data */ - double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */ - double epsilon; /* granularity: can skip smaller increments */ - double b; /* upper limit of subrange in superrange units */ - double d_prev; /* previous value of d */ -}; -typedef struct progress_s progress_t; - -/* notify given progress object of current progress. Note that d is - given in the 0.0-1.0 range, which will be scaled and translated to - the progress object's range. */ -static inline void progress_update(double d, progress_t *prog) { - double d_scaled; - - if (prog != NULL && prog->callback != NULL) { - d_scaled = prog->min * (1-d) + prog->max * d; - if (d == 1.0 || d_scaled >= prog->d_prev + prog->epsilon) { - prog->callback(prog->min * (1-d) + prog->max * d, prog->data); - prog->d_prev = d_scaled; - } - } -} - -/* start a subrange of the given progress object. The range is - narrowed to [a..b], relative to 0.0-1.0 coordinates. If new range - is below granularity threshold, disable further subdivisions. */ -static inline void progress_subrange_start(double a, double b, const progress_t *prog, progress_t *sub) { - double min, max; - - if (prog == NULL || prog->callback == NULL) { - sub->callback = NULL; - return; - } - - min = prog->min * (1-a) + prog->max * a; - max = prog->min * (1-b) + prog->max * b; - - if (max - min < prog->epsilon) { - sub->callback = NULL; /* no further progress info in subrange */ - sub->b = b; - return; - } - sub->callback = prog->callback; - sub->data = prog->data; - sub->epsilon = prog->epsilon; - sub->min = min; - sub->max = max; - sub->d_prev = prog->d_prev; - return; -} - -static inline void progress_subrange_end(progress_t *prog, progress_t *sub) { - if (prog != NULL && prog->callback != NULL) { - if (sub->callback == NULL) { - progress_update(sub->b, prog); - } else { - prog->d_prev = sub->d_prev; - } - } -} - -#endif /* PROGRESS_H */ - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.c b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.c deleted file mode 100644 index 1464bd32948..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.c +++ /dev/null @@ -1,1245 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - -/* transform jaggy paths into smooth curves */ - -#include -#include -#include -#include - -#include "potracelib.h" -#include "curve.h" -#include "lists.h" -#include "auxiliary.h" -#include "trace.h" -#include "progress.h" - -#define INFTY 10000000 /* it suffices that this is longer than any - path; it need not be really infinite */ -#define COS179 -0.999847695156 /* the cosine of 179 degrees */ - -/* ---------------------------------------------------------------------- */ -#define SAFE_MALLOC(var, n, typ) \ - if ((var = (typ *)malloc((n)*sizeof(typ))) == NULL) goto malloc_error - -/* ---------------------------------------------------------------------- */ -/* auxiliary functions */ - -/* return a direction that is 90 degrees counterclockwise from p2-p0, - but then restricted to one of the major wind directions (n, nw, w, etc) */ -static inline point_t dorth_infty(dpoint_t p0, dpoint_t p2) { - point_t r; - - r.y = sign(p2.x-p0.x); - r.x = -sign(p2.y-p0.y); - - return r; -} - -/* return (p1-p0)x(p2-p0), the area of the parallelogram */ -static inline double dpara(dpoint_t p0, dpoint_t p1, dpoint_t p2) { - double x1, y1, x2, y2; - - x1 = p1.x-p0.x; - y1 = p1.y-p0.y; - x2 = p2.x-p0.x; - y2 = p2.y-p0.y; - - return x1*y2 - x2*y1; -} - -/* ddenom/dpara have the property that the square of radius 1 centered - at p1 intersects the line p0p2 iff |dpara(p0,p1,p2)| <= ddenom(p0,p2) */ -static inline double ddenom(dpoint_t p0, dpoint_t p2) { - point_t r = dorth_infty(p0, p2); - - return r.y*(p2.x-p0.x) - r.x*(p2.y-p0.y); -} - -/* return 1 if a <= b < c < a, in a cyclic sense (mod n) */ -static inline int cyclic(int a, int b, int c) { - if (a<=c) { - return (a<=b && blen; - sums_t *sums = pp->sums; - - double x, y, x2, xy, y2; - double k; - double a, b, c, lambda2, l; - int r=0; /* rotations from i to j */ - - while (j>=n) { - j-=n; - r+=1; - } - while (i>=n) { - i-=n; - r-=1; - } - while (j<0) { - j+=n; - r-=1; - } - while (i<0) { - i+=n; - r+=1; - } - - x = sums[j+1].x-sums[i].x+r*sums[n].x; - y = sums[j+1].y-sums[i].y+r*sums[n].y; - x2 = sums[j+1].x2-sums[i].x2+r*sums[n].x2; - xy = sums[j+1].xy-sums[i].xy+r*sums[n].xy; - y2 = sums[j+1].y2-sums[i].y2+r*sums[n].y2; - k = j+1-i+r*n; - - ctr->x = x/k; - ctr->y = y/k; - - a = (x2-(double)x*x/k)/k; - b = (xy-(double)x*y/k)/k; - c = (y2-(double)y*y/k)/k; - - lambda2 = (a+c+sqrt((a-c)*(a-c)+4*b*b))/2; /* larger e.value */ - - /* now find e.vector for lambda2 */ - a -= lambda2; - c -= lambda2; - - if (fabs(a) >= fabs(c)) { - l = sqrt(a*a+b*b); - if (l!=0) { - dir->x = -b/l; - dir->y = a/l; - } - } else { - l = sqrt(c*c+b*b); - if (l!=0) { - dir->x = -c/l; - dir->y = b/l; - } - } - if (l==0) { - dir->x = dir->y = 0; /* sometimes this can happen when k=4: - the two eigenvalues coincide */ - } -} - -/* the type of (affine) quadratic forms, represented as symmetric 3x3 - matrices. The value of the quadratic form at a vector (x,y) is v^t - Q v, where v = (x,y,1)^t. */ -typedef double quadform_t[3][3]; - -/* Apply quadratic form Q to vector w = (w.x,w.y) */ -static inline double quadform(quadform_t Q, dpoint_t w) { - double v[3]; - int i, j; - double sum; - - v[0] = w.x; - v[1] = w.y; - v[2] = 1; - sum = 0.0; - - for (i=0; i<3; i++) { - for (j=0; j<3; j++) { - sum += v[i] * Q[i][j] * v[j]; - } - } - return sum; -} - -/* calculate p1 x p2 */ -static inline int xprod(point_t p1, point_t p2) { - return p1.x*p2.y - p1.y*p2.x; -} - -/* calculate (p1-p0)x(p3-p2) */ -static inline double cprod(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double x1, y1, x2, y2; - - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p3.x - p2.x; - y2 = p3.y - p2.y; - - return x1*y2 - x2*y1; -} - -/* calculate (p1-p0)*(p2-p0) */ -static inline double iprod(dpoint_t p0, dpoint_t p1, dpoint_t p2) { - double x1, y1, x2, y2; - - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p2.x - p0.x; - y2 = p2.y - p0.y; - - return x1*x2 + y1*y2; -} - -/* calculate (p1-p0)*(p3-p2) */ -static inline double iprod1(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double x1, y1, x2, y2; - - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p3.x - p2.x; - y2 = p3.y - p2.y; - - return x1*x2 + y1*y2; -} - -/* calculate distance between two points */ -static inline double ddist(dpoint_t p, dpoint_t q) { - return sqrt(sq(p.x-q.x)+sq(p.y-q.y)); -} - -/* calculate point of a bezier curve */ -static inline dpoint_t bezier(double t, dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double s = 1-t; - dpoint_t res; - - /* Note: a good optimizing compiler (such as gcc-3) reduces the - following to 16 multiplications, using common subexpression - elimination. */ - - res.x = s*s*s*p0.x + 3*(s*s*t)*p1.x + 3*(t*t*s)*p2.x + t*t*t*p3.x; - res.y = s*s*s*p0.y + 3*(s*s*t)*p1.y + 3*(t*t*s)*p2.y + t*t*t*p3.y; - - return res; -} - -/* calculate the point t in [0..1] on the (convex) bezier curve - (p0,p1,p2,p3) which is tangent to q1-q0. Return -1.0 if there is no - solution in [0..1]. */ -static double tangent(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3, dpoint_t q0, dpoint_t q1) { - double A, B, C; /* (1-t)^2 A + 2(1-t)t B + t^2 C = 0 */ - double a, b, c; /* a t^2 + b t + c = 0 */ - double d, s, r1, r2; - - A = cprod(p0, p1, q0, q1); - B = cprod(p1, p2, q0, q1); - C = cprod(p2, p3, q0, q1); - - a = A - 2*B + C; - b = -2*A + 2*B; - c = A; - - d = b*b - 4*a*c; - - if (a==0 || d<0) { - return -1.0; - } - - s = sqrt(d); - - r1 = (-b + s) / (2 * a); - r2 = (-b - s) / (2 * a); - - if (r1 >= 0 && r1 <= 1) { - return r1; - } else if (r2 >= 0 && r2 <= 1) { - return r2; - } else { - return -1.0; - } -} - -/* ---------------------------------------------------------------------- */ -/* Preparation: fill in the sum* fields of a path (used for later - rapid summing). Return 0 on success, 1 with errno set on - failure. */ -static int calc_sums(privpath_t *pp) { - int i, x, y; - int n = pp->len; - - SAFE_MALLOC(pp->sums, pp->len+1, sums_t); - - /* origin */ - pp->x0 = pp->pt[0].x; - pp->y0 = pp->pt[0].y; - - /* preparatory computation for later fast summing */ - pp->sums[0].x2 = pp->sums[0].xy = pp->sums[0].y2 = pp->sums[0].x = pp->sums[0].y = 0; - for (i=0; ipt[i].x - pp->x0; - y = pp->pt[i].y - pp->y0; - pp->sums[i+1].x = pp->sums[i].x + x; - pp->sums[i+1].y = pp->sums[i].y + y; - pp->sums[i+1].x2 = pp->sums[i].x2 + x*x; - pp->sums[i+1].xy = pp->sums[i].xy + x*y; - pp->sums[i+1].y2 = pp->sums[i].y2 + y*y; - } - return 0; - - malloc_error: - return 1; -} - -/* ---------------------------------------------------------------------- */ -/* Stage 1: determine the straight subpaths (Sec. 2.2.1). Fill in the - "lon" component of a path object (based on pt/len). For each i, - lon[i] is the furthest index such that a straight line can be drawn - from i to lon[i]. Return 1 on error with errno set, else 0. */ - -/* this algorithm depends on the fact that the existence of straight - subpaths is a triplewise property. I.e., there exists a straight - line through squares i0,...,in iff there exists a straight line - through i,j,k, for all i0<=i= 0 and xprod(constraint[1], - cur) <= 0. */ - -/* Remark for Potrace 1.1: the current implementation of calc_lon is - more complex than the implementation found in Potrace 1.0, but it - is considerably faster. The introduction of the "nc" data structure - means that we only have to test the constraints for "corner" - points. On a typical input file, this speeds up the calc_lon - function by a factor of 31.2, thereby decreasing its time share - within the overall Potrace algorithm from 72.6% to 7.82%, and - speeding up the overall algorithm by a factor of 3.36. On another - input file, calc_lon was sped up by a factor of 6.7, decreasing its - time share from 51.4% to 13.61%, and speeding up the overall - algorithm by a factor of 1.78. In any case, the savings are - substantial. */ - -/* returns 0 on success, 1 on error with errno set */ -static int calc_lon(privpath_t *pp) { - point_t *pt = pp->pt; - int n = pp->len; - int i, j, k, k1; - int ct[4], dir; - point_t constraint[2]; - point_t cur; - point_t off; - int *pivk = NULL; /* pivk[n] */ - int *nc = NULL; /* nc[n]: next corner */ - point_t dk; /* direction of k-k1 */ - int a, b, c, d; - - SAFE_MALLOC(pivk, n, int); - SAFE_MALLOC(nc, n, int); - - /* initialize the nc data structure. Point from each point to the - furthest future point to which it is connected by a vertical or - horizontal segment. We take advantage of the fact that there is - always a direction change at 0 (due to the path decomposition - algorithm). But even if this were not so, there is no harm, as - in practice, correctness does not depend on the word "furthest" - above. */ - k = 0; - for (i=n-1; i>=0; i--) { - if (pt[i].x != pt[k].x && pt[i].y != pt[k].y) { - k = i+1; /* necessarily ilon, n, int); - - /* determine pivot points: for each i, let pivk[i] be the furthest k - such that all j with i=0; i--) { - ct[0] = ct[1] = ct[2] = ct[3] = 0; - - /* keep track of "directions" that have occurred */ - dir = (3+3*(pt[mod(i+1,n)].x-pt[i].x)+(pt[mod(i+1,n)].y-pt[i].y))/2; - ct[dir]++; - - constraint[0].x = 0; - constraint[0].y = 0; - constraint[1].x = 0; - constraint[1].y = 0; - - /* find the next k such that no straight line from i to k */ - k = nc[i]; - k1 = i; - while (1) { - - dir = (3+3*sign(pt[k].x-pt[k1].x)+sign(pt[k].y-pt[k1].y))/2; - ct[dir]++; - - /* if all four "directions" have occurred, cut this path */ - if (ct[0] && ct[1] && ct[2] && ct[3]) { - pivk[i] = k1; - goto foundk; - } - - cur.x = pt[k].x - pt[i].x; - cur.y = pt[k].y - pt[i].y; - - /* see if current constraint is violated */ - if (xprod(constraint[0], cur) < 0 || xprod(constraint[1], cur) > 0) { - goto constraint_viol; - } - - /* else, update constraint */ - if (abs(cur.x) <= 1 && abs(cur.y) <= 1) { - /* no constraint */ - } else { - off.x = cur.x + ((cur.y>=0 && (cur.y>0 || cur.x<0)) ? 1 : -1); - off.y = cur.y + ((cur.x<=0 && (cur.x<0 || cur.y<0)) ? 1 : -1); - if (xprod(constraint[0], off) >= 0) { - constraint[0] = off; - } - off.x = cur.x + ((cur.y<=0 && (cur.y<0 || cur.x<0)) ? 1 : -1); - off.y = cur.y + ((cur.x>=0 && (cur.x>0 || cur.y<0)) ? 1 : -1); - if (xprod(constraint[1], off) <= 0) { - constraint[1] = off; - } - } - k1 = k; - k = nc[k1]; - if (!cyclic(k,i,k1)) { - break; - } - } - constraint_viol: - /* k1 was the last "corner" satisfying the current constraint, and - k is the first one violating it. We now need to find the last - point along k1..k which satisfied the constraint. */ - dk.x = sign(pt[k].x-pt[k1].x); - dk.y = sign(pt[k].y-pt[k1].y); - cur.x = pt[k1].x - pt[i].x; - cur.y = pt[k1].y - pt[i].y; - /* find largest integer j such that xprod(constraint[0], cur+j*dk) - >= 0 and xprod(constraint[1], cur+j*dk) <= 0. Use bilinearity - of xprod. */ - a = xprod(constraint[0], cur); - b = xprod(constraint[0], dk); - c = xprod(constraint[1], cur); - d = xprod(constraint[1], dk); - /* find largest integer j such that a+j*b>=0 and c+j*d<=0. This - can be solved with integer arithmetic. */ - j = INFTY; - if (b<0) { - j = floordiv(a,-b); - } - if (d>0) { - j = min(j, floordiv(-c,d)); - } - pivk[i] = mod(k1+j,n); - foundk: - ; - } /* for i */ - - /* clean up: for each i, let lon[i] be the largest k such that for - all i' with i<=i'lon[n-1]=j; - for (i=n-2; i>=0; i--) { - if (cyclic(i+1,pivk[i],j)) { - j=pivk[i]; - } - pp->lon[i]=j; - } - - for (i=n-1; cyclic(mod(i+1,n),j,pp->lon[i]); i--) { - pp->lon[i] = j; - } - - free(pivk); - free(nc); - return 0; - - malloc_error: - free(pivk); - free(nc); - return 1; -} - - -/* ---------------------------------------------------------------------- */ -/* Stage 2: calculate the optimal polygon (Sec. 2.2.2-2.2.4). */ - -/* Auxiliary function: calculate the penalty of an edge from i to j in - the given path. This needs the "lon" and "sum*" data. */ - -static double penalty3(privpath_t *pp, int i, int j) { - int n = pp->len; - point_t *pt = pp->pt; - sums_t *sums = pp->sums; - - /* assume 0<=i=n) { - j -= n; - r = 1; - } - - /* critical inner loop: the "if" gives a 4.6 percent speedup */ - if (r == 0) { - x = sums[j+1].x - sums[i].x; - y = sums[j+1].y - sums[i].y; - x2 = sums[j+1].x2 - sums[i].x2; - xy = sums[j+1].xy - sums[i].xy; - y2 = sums[j+1].y2 - sums[i].y2; - k = j+1 - i; - } else { - x = sums[j+1].x - sums[i].x + sums[n].x; - y = sums[j+1].y - sums[i].y + sums[n].y; - x2 = sums[j+1].x2 - sums[i].x2 + sums[n].x2; - xy = sums[j+1].xy - sums[i].xy + sums[n].xy; - y2 = sums[j+1].y2 - sums[i].y2 + sums[n].y2; - k = j+1 - i + n; - } - - px = (pt[i].x + pt[j].x) / 2.0 - pt[0].x; - py = (pt[i].y + pt[j].y) / 2.0 - pt[0].y; - ey = (pt[j].x - pt[i].x); - ex = -(pt[j].y - pt[i].y); - - a = ((x2 - 2*x*px) / k + px*px); - b = ((xy - x*py - y*px) / k + px*py); - c = ((y2 - 2*y*py) / k + py*py); - - s = ex*ex*a + 2*ex*ey*b + ey*ey*c; - - return sqrt(s); -} - -/* find the optimal polygon. Fill in the m and po components. Return 1 - on failure with errno set, else 0. Non-cyclic version: assumes i=0 - is in the polygon. Fixme: implement cyclic version. */ -static int bestpolygon(privpath_t *pp) -{ - int i, j, m, k; - int n = pp->len; - double *pen = NULL; /* pen[n+1]: penalty vector */ - int *prev = NULL; /* prev[n+1]: best path pointer vector */ - int *clip0 = NULL; /* clip0[n]: longest segment pointer, non-cyclic */ - int *clip1 = NULL; /* clip1[n+1]: backwards segment pointer, non-cyclic */ - int *seg0 = NULL; /* seg0[m+1]: forward segment bounds, m<=n */ - int *seg1 = NULL; /* seg1[m+1]: backward segment bounds, m<=n */ - double thispen; - double best; - int c; - - SAFE_MALLOC(pen, n+1, double); - SAFE_MALLOC(prev, n+1, int); - SAFE_MALLOC(clip0, n, int); - SAFE_MALLOC(clip1, n+1, int); - SAFE_MALLOC(seg0, n+1, int); - SAFE_MALLOC(seg1, n+1, int); - - /* calculate clipped paths */ - for (i=0; ilon[mod(i-1,n)]-1,n); - if (c == i) { - c = mod(i+1,n); - } - if (c < i) { - clip0[i] = n; - } else { - clip0[i] = c; - } - } - - /* calculate backwards path clipping, non-cyclic. j <= clip0[i] iff - clip1[j] <= i, for i,j=0..n. */ - j = 1; - for (i=0; i0; j--) { - seg1[j] = i; - i = clip1[i]; - } - seg1[0] = 0; - - /* now find the shortest path with m segments, based on penalty3 */ - /* note: the outer 2 loops jointly have at most n iterations, thus - the worst-case behavior here is quadratic. In practice, it is - close to linear since the inner loop tends to be short. */ - pen[0]=0; - for (j=1; j<=m; j++) { - for (i=seg1[j]; i<=seg0[j]; i++) { - best = -1; - for (k=seg0[j-1]; k>=clip1[i]; k--) { - thispen = penalty3(pp, k, i) + pen[k]; - if (best < 0 || thispen < best) { - prev[i] = k; - best = thispen; - } - } - pen[i] = best; - } - } - - pp->m = m; - SAFE_MALLOC(pp->po, m, int); - - /* read off shortest path */ - for (i=n, j=m-1; i>0; j--) { - i = prev[i]; - pp->po[j] = i; - } - - free(pen); - free(prev); - free(clip0); - free(clip1); - free(seg0); - free(seg1); - return 0; - - malloc_error: - free(pen); - free(prev); - free(clip0); - free(clip1); - free(seg0); - free(seg1); - return 1; -} - -/* ---------------------------------------------------------------------- */ -/* Stage 3: vertex adjustment (Sec. 2.3.1). */ - -/* Adjust vertices of optimal polygon: calculate the intersection of - the two "optimal" line segments, then move it into the unit square - if it lies outside. Return 1 with errno set on error; 0 on - success. */ - -static int adjust_vertices(privpath_t *pp) { - int m = pp->m; - int *po = pp->po; - int n = pp->len; - point_t *pt = pp->pt; - int x0 = pp->x0; - int y0 = pp->y0; - - dpoint_t *ctr = NULL; /* ctr[m] */ - dpoint_t *dir = NULL; /* dir[m] */ - quadform_t *q = NULL; /* q[m] */ - double v[3]; - double d; - int i, j, k, l; - dpoint_t s; - int r; - - SAFE_MALLOC(ctr, m, dpoint_t); - SAFE_MALLOC(dir, m, dpoint_t); - SAFE_MALLOC(q, m, quadform_t); - - r = privcurve_init(&pp->curve, m); - if (r) { - goto malloc_error; - } - - /* calculate "optimal" point-slope representation for each line - segment */ - for (i=0; iQ[1][1]) { - v[0] = -Q[0][1]; - v[1] = Q[0][0]; - } else if (Q[1][1]) { - v[0] = -Q[1][1]; - v[1] = Q[1][0]; - } else { - v[0] = 1; - v[1] = 0; - } - d = sq(v[0]) + sq(v[1]); - v[2] = - v[1] * s.y - v[0] * s.x; - for (l=0; l<3; l++) { - for (k=0; k<3; k++) { - Q[l][k] += v[l] * v[k] / d; - } - } - } - dx = fabs(w.x-s.x); - dy = fabs(w.y-s.y); - if (dx <= .5 && dy <= .5) { - pp->curve.vertex[i].x = w.x+x0; - pp->curve.vertex[i].y = w.y+y0; - continue; - } - - /* the minimum was not in the unit square; now minimize quadratic - on boundary of square */ - min = quadform(Q, s); - xmin = s.x; - ymin = s.y; - - if (Q[0][0] == 0.0) { - goto fixx; - } - for (z=0; z<2; z++) { /* value of the y-coordinate */ - w.y = s.y-0.5+z; - w.x = - (Q[0][1] * w.y + Q[0][2]) / Q[0][0]; - dx = fabs(w.x-s.x); - cand = quadform(Q, w); - if (dx <= .5 && cand < min) { - min = cand; - xmin = w.x; - ymin = w.y; - } - } - fixx: - if (Q[1][1] == 0.0) { - goto corners; - } - for (z=0; z<2; z++) { /* value of the x-coordinate */ - w.x = s.x-0.5+z; - w.y = - (Q[1][0] * w.x + Q[1][2]) / Q[1][1]; - dy = fabs(w.y-s.y); - cand = quadform(Q, w); - if (dy <= .5 && cand < min) { - min = cand; - xmin = w.x; - ymin = w.y; - } - } - corners: - /* check four corners */ - for (l=0; l<2; l++) { - for (k=0; k<2; k++) { - w.x = s.x-0.5+l; - w.y = s.y-0.5+k; - cand = quadform(Q, w); - if (cand < min) { - min = cand; - xmin = w.x; - ymin = w.y; - } - } - } - - pp->curve.vertex[i].x = xmin + x0; - pp->curve.vertex[i].y = ymin + y0; - continue; - } - - free(ctr); - free(dir); - free(q); - return 0; - - malloc_error: - free(ctr); - free(dir); - free(q); - return 1; -} - -/* ---------------------------------------------------------------------- */ -/* Stage 4: smoothing and corner analysis (Sec. 2.3.3) */ - -/* reverse orientation of a path */ -static void reverse(privcurve_t *curve) { - int m = curve->n; - int i, j; - dpoint_t tmp; - - for (i=0, j=m-1; ivertex[i]; - curve->vertex[i] = curve->vertex[j]; - curve->vertex[j] = tmp; - } -} - -/* Always succeeds */ -static void smooth(privcurve_t *curve, double alphamax) { - int m = curve->n; - - int i, j, k; - double dd, denom, alpha; - dpoint_t p2, p3, p4; - - /* examine each vertex and find its best fit */ - for (i=0; ivertex[k], curve->vertex[j]); - - denom = ddenom(curve->vertex[i], curve->vertex[k]); - if (denom != 0.0) { - dd = dpara(curve->vertex[i], curve->vertex[j], curve->vertex[k]) / denom; - dd = fabs(dd); - alpha = dd>1 ? (1 - 1.0/dd) : 0; - alpha = alpha / 0.75; - } else { - alpha = 4/3.0; - } - curve->alpha0[j] = alpha; /* remember "original" value of alpha */ - - if (alpha >= alphamax) { /* pointed corner */ - curve->tag[j] = POTRACE_CORNER; - curve->c[j][1] = curve->vertex[j]; - curve->c[j][2] = p4; - } else { - if (alpha < 0.55) { - alpha = 0.55; - } else if (alpha > 1) { - alpha = 1; - } - p2 = interval(.5+.5*alpha, curve->vertex[i], curve->vertex[j]); - p3 = interval(.5+.5*alpha, curve->vertex[k], curve->vertex[j]); - curve->tag[j] = POTRACE_CURVETO; - curve->c[j][0] = p2; - curve->c[j][1] = p3; - curve->c[j][2] = p4; - } - curve->alpha[j] = alpha; /* store the "cropped" value of alpha */ - curve->beta[j] = 0.5; - } - curve->alphacurve = 1; - - return; -} - -/* ---------------------------------------------------------------------- */ -/* Stage 5: Curve optimization (Sec. 2.4) */ - -/* a private type for the result of opti_penalty */ -struct opti_s { - double pen; /* penalty */ - dpoint_t c[2]; /* curve parameters */ - double t, s; /* curve parameters */ - double alpha; /* curve parameter */ -}; -typedef struct opti_s opti_t; - -/* calculate best fit from i+.5 to j+.5. Assume icurve.n; - int k, k1, k2, conv, i1; - double area, alpha, d, d1, d2; - dpoint_t p0, p1, p2, p3, pt; - double A, R, A1, A2, A3, A4; - double s, t; - - /* check convexity, corner-freeness, and maximum bend < 179 degrees */ - - if (i==j) { /* sanity - a full loop can never be an opticurve */ - return 1; - } - - k = i; - i1 = mod(i+1, m); - k1 = mod(k+1, m); - conv = convc[k1]; - if (conv == 0) { - return 1; - } - d = ddist(pp->curve.vertex[i], pp->curve.vertex[i1]); - for (k=k1; k!=j; k=k1) { - k1 = mod(k+1, m); - k2 = mod(k+2, m); - if (convc[k1] != conv) { - return 1; - } - if (sign(cprod(pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], pp->curve.vertex[k2])) != conv) { - return 1; - } - if (iprod1(pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], pp->curve.vertex[k2]) < d * ddist(pp->curve.vertex[k1], pp->curve.vertex[k2]) * COS179) { - return 1; - } - } - - /* the curve we're working in: */ - p0 = pp->curve.c[mod(i,m)][2]; - p1 = pp->curve.vertex[mod(i+1,m)]; - p2 = pp->curve.vertex[mod(j,m)]; - p3 = pp->curve.c[mod(j,m)][2]; - - /* determine its area */ - area = areac[j] - areac[i]; - area -= dpara(pp->curve.vertex[0], pp->curve.c[i][2], pp->curve.c[j][2])/2; - if (i>=j) { - area += areac[m]; - } - - /* find intersection o of p0p1 and p2p3. Let t,s such that o = - interval(t,p0,p1) = interval(s,p3,p2). Let A be the area of the - triangle (p0,o,p3). */ - - A1 = dpara(p0, p1, p2); - A2 = dpara(p0, p1, p3); - A3 = dpara(p0, p2, p3); - /* A4 = dpara(p1, p2, p3); */ - A4 = A1+A3-A2; - - if (A2 == A1) { /* this should never happen */ - return 1; - } - - t = A3/(A3-A4); - s = A2/(A2-A1); - A = A2 * t / 2.0; - - if (A == 0.0) { /* this should never happen */ - return 1; - } - - R = area / A; /* relative area */ - alpha = 2 - sqrt(4 - R / 0.3); /* overall alpha for p0-o-p3 curve */ - - res->c[0] = interval(t * alpha, p0, p1); - res->c[1] = interval(s * alpha, p3, p2); - res->alpha = alpha; - res->t = t; - res->s = s; - - p1 = res->c[0]; - p2 = res->c[1]; /* the proposed curve is now (p0,p1,p2,p3) */ - - res->pen = 0; - - /* calculate penalty */ - /* check tangency with edges */ - for (k=mod(i+1,m); k!=j; k=k1) { - k1 = mod(k+1,m); - t = tangent(p0, p1, p2, p3, pp->curve.vertex[k], pp->curve.vertex[k1]); - if (t<-.5) { - return 1; - } - pt = bezier(t, p0, p1, p2, p3); - d = ddist(pp->curve.vertex[k], pp->curve.vertex[k1]); - if (d == 0.0) { /* this should never happen */ - return 1; - } - d1 = dpara(pp->curve.vertex[k], pp->curve.vertex[k1], pt) / d; - if (fabs(d1) > opttolerance) { - return 1; - } - if (iprod(pp->curve.vertex[k], pp->curve.vertex[k1], pt) < 0 || iprod(pp->curve.vertex[k1], pp->curve.vertex[k], pt) < 0) { - return 1; - } - res->pen += sq(d1); - } - - /* check corners */ - for (k=i; k!=j; k=k1) { - k1 = mod(k+1,m); - t = tangent(p0, p1, p2, p3, pp->curve.c[k][2], pp->curve.c[k1][2]); - if (t<-.5) { - return 1; - } - pt = bezier(t, p0, p1, p2, p3); - d = ddist(pp->curve.c[k][2], pp->curve.c[k1][2]); - if (d == 0.0) { /* this should never happen */ - return 1; - } - d1 = dpara(pp->curve.c[k][2], pp->curve.c[k1][2], pt) / d; - d2 = dpara(pp->curve.c[k][2], pp->curve.c[k1][2], pp->curve.vertex[k1]) / d; - d2 *= 0.75 * pp->curve.alpha[k1]; - if (d2 < 0) { - d1 = -d1; - d2 = -d2; - } - if (d1 < d2 - opttolerance) { - return 1; - } - if (d1 < d2) { - res->pen += sq(d1 - d2); - } - } - - return 0; -} - -/* optimize the path p, replacing sequences of Bezier segments by a - single segment when possible. Return 0 on success, 1 with errno set - on failure. */ -static int opticurve(privpath_t *pp, double opttolerance) { - int m = pp->curve.n; - int *pt = NULL; /* pt[m+1] */ - double *pen = NULL; /* pen[m+1] */ - int *len = NULL; /* len[m+1] */ - opti_t *opt = NULL; /* opt[m+1] */ - int om; - int i,j,r; - opti_t o; - dpoint_t p0; - int i1; - double area; - double alpha; - double *s = NULL; - double *t = NULL; - - int *convc = NULL; /* conv[m]: pre-computed convexities */ - double *areac = NULL; /* cumarea[m+1]: cache for fast area computation */ - - SAFE_MALLOC(pt, m+1, int); - SAFE_MALLOC(pen, m+1, double); - SAFE_MALLOC(len, m+1, int); - SAFE_MALLOC(opt, m+1, opti_t); - SAFE_MALLOC(convc, m, int); - SAFE_MALLOC(areac, m+1, double); - - /* pre-calculate convexity: +1 = right turn, -1 = left turn, 0 = corner */ - for (i=0; icurve.tag[i] == POTRACE_CURVETO) { - convc[i] = sign(dpara(pp->curve.vertex[mod(i-1,m)], pp->curve.vertex[i], pp->curve.vertex[mod(i+1,m)])); - } else { - convc[i] = 0; - } - } - - /* pre-calculate areas */ - area = 0.0; - areac[0] = 0.0; - p0 = pp->curve.vertex[0]; - for (i=0; icurve.tag[i1] == POTRACE_CURVETO) { - alpha = pp->curve.alpha[i1]; - area += 0.3*alpha*(4-alpha)*dpara(pp->curve.c[i][2], pp->curve.vertex[i1], pp->curve.c[i1][2])/2; - area += dpara(p0, pp->curve.c[i][2], pp->curve.c[i1][2])/2; - } - areac[i+1] = area; - } - - pt[0] = -1; - pen[0] = 0; - len[0] = 0; - - /* Fixme: we always start from a fixed point -- should find the best - curve cyclically */ - - for (j=1; j<=m; j++) { - /* calculate best path from 0 to j */ - pt[j] = j-1; - pen[j] = pen[j-1]; - len[j] = len[j-1]+1; - - for (i=j-2; i>=0; i--) { - r = opti_penalty(pp, i, mod(j,m), &o, opttolerance, convc, areac); - if (r) { - break; - } - if (len[j] > len[i]+1 || (len[j] == len[i]+1 && pen[j] > pen[i] + o.pen)) { - pt[j] = i; - pen[j] = pen[i] + o.pen; - len[j] = len[i] + 1; - opt[j] = o; - } - } - } - om = len[m]; - r = privcurve_init(&pp->ocurve, om); - if (r) { - goto malloc_error; - } - SAFE_MALLOC(s, om, double); - SAFE_MALLOC(t, om, double); - - j = m; - for (i=om-1; i>=0; i--) { - if (pt[j]==j-1) { - pp->ocurve.tag[i] = pp->curve.tag[mod(j,m)]; - pp->ocurve.c[i][0] = pp->curve.c[mod(j,m)][0]; - pp->ocurve.c[i][1] = pp->curve.c[mod(j,m)][1]; - pp->ocurve.c[i][2] = pp->curve.c[mod(j,m)][2]; - pp->ocurve.vertex[i] = pp->curve.vertex[mod(j,m)]; - pp->ocurve.alpha[i] = pp->curve.alpha[mod(j,m)]; - pp->ocurve.alpha0[i] = pp->curve.alpha0[mod(j,m)]; - pp->ocurve.beta[i] = pp->curve.beta[mod(j,m)]; - s[i] = t[i] = 1.0; - } else { - pp->ocurve.tag[i] = POTRACE_CURVETO; - pp->ocurve.c[i][0] = opt[j].c[0]; - pp->ocurve.c[i][1] = opt[j].c[1]; - pp->ocurve.c[i][2] = pp->curve.c[mod(j,m)][2]; - pp->ocurve.vertex[i] = interval(opt[j].s, pp->curve.c[mod(j,m)][2], pp->curve.vertex[mod(j,m)]); - pp->ocurve.alpha[i] = opt[j].alpha; - pp->ocurve.alpha0[i] = opt[j].alpha; - s[i] = opt[j].s; - t[i] = opt[j].t; - } - j = pt[j]; - } - - /* calculate beta parameters */ - for (i=0; iocurve.beta[i] = s[i] / (s[i] + t[i1]); - } - pp->ocurve.alphacurve = 1; - - free(pt); - free(pen); - free(len); - free(opt); - free(s); - free(t); - free(convc); - free(areac); - return 0; - - malloc_error: - free(pt); - free(pen); - free(len); - free(opt); - free(s); - free(t); - free(convc); - free(areac); - return 1; -} - -/* ---------------------------------------------------------------------- */ - -#define TRY(x) if (x) goto try_error - -/* return 0 on success, 1 on error with errno set. */ -int process_path(path_t *plist, const potrace_param_t *param, progress_t *progress) { - path_t *p; - double nn = 0, cn = 0; - - if (progress->callback) { - /* precompute task size for progress estimates */ - nn = 0; - list_forall (p, plist) { - nn += p->priv->len; - } - cn = 0; - } - - /* call downstream function with each path */ - list_forall (p, plist) { - TRY(calc_sums(p->priv)); - TRY(calc_lon(p->priv)); - TRY(bestpolygon(p->priv)); - TRY(adjust_vertices(p->priv)); - if (p->sign == '-') { /* reverse orientation of negative paths */ - reverse(&p->priv->curve); - } - smooth(&p->priv->curve, param->alphamax); - if (param->opticurve) { - TRY(opticurve(p->priv, param->opttolerance)); - p->priv->fcurve = &p->priv->ocurve; - } else { - p->priv->fcurve = &p->priv->curve; - } - privcurve_to_curve(p->priv->fcurve, &p->curve); - - if (progress->callback) { - cn += p->priv->len; - progress_update(cn/nn, progress); - } - } - - progress_update(1.0, progress); - - return 0; - - try_error: - return 1; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.h deleted file mode 100644 index d24ffb354ec..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/potracelib/trace.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2001-2013 Peter Selinger. - This file is part of Potrace. It is free software and it is covered - by the GNU General Public License. See the file COPYING for details. */ - - -#ifndef TRACE_H -#define TRACE_H - -#include "potracelib.h" -#include "progress.h" -#include "curve.h" - -int process_path(path_t *plist, const potrace_param_t *param, progress_t *progress); - -#endif /* TRACE_H */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.cpp deleted file mode 100644 index a225d360910..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************* -** BgColorSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "BgColorSpecialHandler.h" -#include "ColorSpecialHandler.h" -#include "SpecialActions.h" - -using namespace std; - - -bool BgColorSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - ColorSpecialHandler csh; - return csh.process(prefix, is, actions); -} - - -const char** BgColorSpecialHandler::prefixes () const { - static const char *pfx[] = {"background", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.h deleted file mode 100644 index 98dd814ba9e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BgColorSpecialHandler.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************* -** BgColorSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef BGCOLORSPECIALHANDLER_H -#define BGCOLORSPECIALHANDLER_H - -#include "SpecialManager.h" - -struct BgColorSpecialHandler : SpecialHandler -{ - const char* info () const {return "background color special";} - const char* name () const {return "bgcolor";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &is, SpecialActions *actions); -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.cpp deleted file mode 100644 index e72d5ee34ac..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* -** Bitmap.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "Bitmap.h" -#include "macros.h" - -using namespace std; - -Bitmap::Bitmap () : _rows(0), _cols(0), _xshift(0), _yshift(0), _bpr(0), _bytes(0) -{ -} - - -/** Constructs a Bitmap */ -Bitmap::Bitmap (int minx, int maxx, int miny , int maxy) { - resize(minx, maxx, miny, maxy); -} - - -/** Resizes the bitmap and clears all pixels. - * @param[in] minx index of leftmost pixel column - * @param[in] maxx index of rightmost pixel column - * @param[in] miny index of bottom row - * @param[in] maxy index of top row */ -void Bitmap::resize (int minx, int maxx, int miny , int maxy) { - _rows = abs(maxy-miny)+1; - _cols = abs(maxx-minx)+1; - _xshift = minx; - _yshift = miny; - _bpr = _cols/8 + (_cols % 8 ? 1 : 0); // bytes per row - _bytes.resize(_rows*_bpr); - FORALL(_bytes, vector::iterator, it) - *it = 0; -} - - -/** Sets n pixels of row r to 1 starting at pixel c. - * @param[in] r number of row - * @param[in] c number of column (pixel) - * @param[in] n number of bits to be set */ -void Bitmap::setBits (int r, int c, int n) { - r -= _yshift; - c -= _xshift; - UInt8 *byte = &_bytes[r*_bpr + c/8];// + (c%8 ? 1 : 0); - while (n > 0) { - int b = 7 - c%8; // number of leftmost bit in current byte to be set - int m = min(n, b+1); // number of bits to be set in current byte - int bitseq = (1 << m)-1; // sequence of n set bits (bits 0..n-1 are set) - bitseq <<= b-m+1; // move bit sequence so that bit b is the leftmost set bit - *byte |= UInt8(bitseq); // apply bit sequence to current byte - byte++; - n -= m; - c += m; - } -} - - -void Bitmap::forAllPixels (ForAllData &data) const { - for (int y=_rows-1; y >= 0 ; y--) { - for (int c=0; c < _bpr; c++) { - UInt8 byte = _bytes[y*_bpr+c]; - int x; - for (int b=7; (b >= 0) && ((x = 8*c+(7-b)) < _cols); b--) { - data.pixel(x, y, byte & (1 << b), *this); - } - } - } -} - - -struct BBoxData : public Bitmap::ForAllData -{ - BBoxData () : maxx(0), maxy(0) {} - void pixel (int x, int y, bool set, const Bitmap &bm) { - if (set) { - maxx = max(maxx, x); - maxy = max(maxy, y); - } - } - int maxx, maxy; -}; - - -void Bitmap::bbox (int &w, int &h) const { - BBoxData data; - forAllPixels(data); - w = data.maxx+1; - h = data.maxy+1; -} - - -ostream& Bitmap::write (ostream &os) const { -#if 0 - for (int r=_rows-1; r >= 0 ; r--) { - for (int c=0; c < _bpr; c++) { - UInt8 byte = _bytes[r*_bpr+c]; - for (int b=128; b; b>>=1) - os << (byte & b ? '*' : '-'); - os << ' '; - } - os << endl; - } -#endif - return os; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.h deleted file mode 100644 index 1a1f19caf15..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Bitmap.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************* -** Bitmap.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef BITMAP_H -#define BITMAP_H - -#include -#include -#include "types.h" - - -class Bitmap -{ - public: - struct ForAllData { - virtual ~ForAllData() {} - virtual void pixel (int x, int y, bool set, Bitmap &bm) {} - virtual void pixel (int x, int y, bool set, const Bitmap &bm) {} - }; - - public: - Bitmap (); - Bitmap (int minx, int maxx, int miny , int maxy); - void resize (int minx, int maxx, int miny , int maxy); - void setBits(int r, int c, int n); - const UInt8* operator[] (int r) const {return &_bytes[r*_bpr];} - int height () const {return _rows;} - int width () const {return _cols;} - int xshift () const {return _xshift;} - int yshift () const {return _yshift;} - int bytesPerRow () const {return _bpr;} - bool empty () const {return (!_rows && !_cols) || _bytes.empty();} - void bbox (int &w, int &h) const; - void forAllPixels (ForAllData &data) const; - - template - int copy (std::vector &target, bool vflip=false) const; - -// template -// void write (std::ostream &os, const std::vector &v) const; - - std::ostream& write (std::ostream &os) const; - - private: - int _rows, _cols; ///< number of rows, columns - int _xshift, _yshift; ///< horizontal/vertical shift - int _bpr; ///< number of bytes per row - std::vector _bytes; -}; - - -/** Copies the bitmap to a new target area and reorganize the bits. - * @param[out] target points to first T of new bitmap (must be deleted after usage) - * @param[in] vflip true if the new bitmap should be flipped vertically - * @return number of Ts per row */ -template -int Bitmap::copy (std::vector &target, bool vflip) const { - const int s = sizeof(T); - const int tpr = _bpr/s + (_bpr%s ? 1 : 0); // number of Ts per row - target.resize(_rows*tpr); - for (int r=0; r < _rows; r++) { - int targetrow = vflip ? _rows-r-1 : r; - for (int b=0; b < _bpr; b++) { - T &t = target[targetrow*tpr + b/s]; - T chunk = (T)_bytes[r*_bpr+b] << (8*(s-1-b%s)); - if (b % s == 0) - t = chunk; - else - t |= chunk; - } - } - return tpr; -} - - -/* -template -void Bitmap::write (std::ostream &os, const std::vector &v) const { - const int s = sizeof(T); - const int tpr = _bpr/s + (_bpr%s ? 1 : 0); // number of Ts per row - for (int r=_rows-1; r >= 0; r--) { - for (int t=0; t < tpr; t++) { - for (T b=(T)1<<(8*s-1); b; b>>=1) - os << ((v[r*tpr+t] & b) ? '*' : '-'); - os << ' '; - } - os << std::endl; - } -}*/ - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.cpp deleted file mode 100644 index 85ec9c4c452..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************************* -** BoundingBox.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "BoundingBox.h" -#include "Matrix.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -BoundingBox::BoundingBox () - : _ulx(0), _uly(0), _lrx(0), _lry(0), _valid(false), _locked(false) -{ -} - - -BoundingBox::BoundingBox (double ulxx, double ulyy, double lrxx, double lryy) - : _ulx(min(ulxx,lrxx)), _uly(min(ulyy,lryy)), - _lrx(max(ulxx,lrxx)), _lry(max(ulyy,lryy)), - _valid(true), _locked(false) -{ -} - - -BoundingBox::BoundingBox (const DPair &p1, const DPair &p2) - : _ulx(min(p1.x(), p2.x())), _uly(min(p1.y(), p2.y())), - _lrx(max(p1.x(), p2.x())), _lry(max(p1.y(), p2.y())), - _valid(true), _locked(false) -{ -} - - -BoundingBox::BoundingBox (const Length &ulxx, const Length &ulyy, const Length &lrxx, const Length &lryy) - : _ulx(min(ulxx.pt(),lrxx.pt())), _uly(min(ulyy.pt(),lryy.pt())), - _lrx(max(ulxx.pt(),lrxx.pt())), _lry(max(ulyy.pt(),lryy.pt())), - _valid(true), _locked(false) -{ -} - - -BoundingBox::BoundingBox (const string &boxstr) - : _valid(false), _locked(false) -{ - set(boxstr); -} - - -/** Removes leading and trailing whitespace from the given string. */ -static string& strip (string &str) { - size_t n=0; - while (n < str.length() && isspace(str[n])) - ++n; - str.erase(0, n); - n=str.length()-1; - while (n > 0 && isspace(str[n])) - --n; - str.erase(n+1); - return str; -} - - -/** Sets or modifies the bounding box. If 'boxstr' consists of 4 length values, - * they denote the absolute position of two diagonal corners of the box. In case - * of a single length value l the current box is enlarged by adding (-l,-l) the upper - * left and (l,l) to the lower right corner. - * @param[in] boxstr whitespace and/or comma separated string of lengths. */ -void BoundingBox::set (string boxstr) { - vector coord; - const size_t len = boxstr.length(); - size_t l=0; - strip(boxstr); - string lenstr; - do { - while (l < len && isspace(boxstr[l])) - l++; - size_t r=l; - while (r < len && !isspace(boxstr[r]) && boxstr[r] != ',') - r++; - lenstr = boxstr.substr(l, r-l); - if (!lenstr.empty()) { - coord.push_back(Length(lenstr)); - if (boxstr[r] == ',') - r++; - l = r; - } - } while (!lenstr.empty() && coord.size() < 4); - - switch (coord.size()) { - case 1: - _ulx -= coord[0].pt(); - _uly -= coord[0].pt(); - _lrx += coord[0].pt(); - _lry += coord[0].pt(); - break; - case 2: - _ulx -= coord[0].pt(); - _uly -= coord[1].pt(); - _lrx += coord[0].pt(); - _lry += coord[1].pt(); - break; - case 4: - _ulx = min(coord[0].pt(), coord[2].pt()); - _uly = min(coord[1].pt(), coord[3].pt()); - _lrx = max(coord[0].pt(), coord[2].pt()); - _lry = max(coord[1].pt(), coord[3].pt()); - break; - default: - throw BoundingBoxException("1, 2 or 4 length parameters expected"); - } - _valid = true; -} - - -/** Enlarges the box so that point (x,y) is enclosed. */ -void BoundingBox::embed (double x, double y) { - if (!_locked) { - if (_valid) { - if (x < _ulx) - _ulx = x; - else if (x > _lrx) - _lrx = x; - if (y < _uly) - _uly = y; - else if (y > _lry) - _lry = y; - } - else { - _ulx = _lrx = x; - _uly = _lry = y; - _valid = true; - } - } -} - - -/** Enlarges the box so that box bb is enclosed. */ -void BoundingBox::embed (const BoundingBox &bb) { - if (!_locked && bb._valid) { - if (_valid) { - embed(bb._ulx, bb._uly); - embed(bb._lrx, bb._lry); - } - else { - _ulx = bb._ulx; - _uly = bb._uly; - _lrx = bb._lrx; - _lry = bb._lry; - _valid = true; - } - } -} - - -void BoundingBox::embed (const DPair &c, double r) { - embed(BoundingBox(c.x()-r, c.y()-r, c.x()+r, c.y()+r)); -} - - -void BoundingBox::expand (double m) { - if (!_locked) { - _ulx -= m; - _uly -= m; - _lrx += m; - _lry += m; - } -} - - -/** Intersects the current box with bbox and applies the result to *this. - * If both boxes are disjoint, *this is not altered. - * @param[in] bbox box to intersect with - * @return false if *this is locked or both boxes are disjoint */ -bool BoundingBox::intersect (const BoundingBox &bbox) { - if (_locked || _lrx < bbox._ulx || _lry < bbox._uly || _ulx > bbox._lrx || _uly > bbox._lry) - return false; - _ulx = max(_ulx, bbox._ulx); - _uly = max(_uly, bbox._uly); - _lrx = min(_lrx, bbox._lrx); - _lry = min(_lry, bbox._lry); - return true; -} - - -void BoundingBox::operator += (const BoundingBox &bb) { - if (!_locked) { - _ulx += bb._ulx; - _uly += bb._uly; - _lrx += bb._lrx; - _lry += bb._lry; - } -} - - -void BoundingBox::scale (double sx, double sy) { - if (!_locked) { - _ulx *= sx; - _lrx *= sx; - if (sx < 0) swap(_ulx, _lrx); - _uly *= sy; - _lry *= sy; - if (sy < 0) swap(_uly, _lry); - } -} - - -void BoundingBox::transform (const Matrix &tm) { - if (!_locked) { - DPair ul = tm * DPair(_lrx, _lry); - DPair lr = tm * DPair(_ulx, _uly); - DPair ll = tm * DPair(_ulx, _lry); - DPair ur = tm * DPair(_lrx, _uly); - _ulx = min(min(ul.x(), lr.x()), min(ur.x(), ll.x())); - _uly = min(min(ul.y(), lr.y()), min(ur.y(), ll.y())); - _lrx = max(max(ul.x(), lr.x()), max(ur.x(), ll.x())); - _lry = max(max(ul.y(), lr.y()), max(ur.y(), ll.y())); - } -} - - -string BoundingBox::toSVGViewBox () const { - ostringstream oss; - oss << XMLString(_ulx) << ' ' << XMLString(_uly) << ' ' << XMLString(width()) << ' ' << XMLString(height()); - return oss.str(); -} - - -ostream& BoundingBox::write (ostream &os) const { - return os << '(' << _ulx << ", " << _uly - << ", " << _lrx << ", " << _lry << ')'; -} - - -XMLElementNode* BoundingBox::toSVGRect () const { - XMLElementNode *rect = new XMLElementNode("rect"); - rect->addAttribute("x", minX()); - rect->addAttribute("y", minY()); - rect->addAttribute("width", width()); - rect->addAttribute("height", height()); - rect->addAttribute("fill", "none"); - return rect; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.h deleted file mode 100644 index b3a4016f52a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/BoundingBox.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************* -** BoundingBox.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef BOUNDINGBOX_H -#define BOUNDINGBOX_H - -#include -#include -#include "Length.h" -#include "MessageException.h" -#include "Pair.h" -#include "macros.h" -#include "types.h" - - -class Matrix; -class XMLElementNode; - - -struct BoundingBoxException : MessageException -{ - BoundingBoxException (const std::string &msg) : MessageException(msg) {} -}; - - -class BoundingBox -{ - public: - BoundingBox (); - BoundingBox (double ulxx, double ulyy, double lrxx, double lryy); - BoundingBox (const DPair &p1, const DPair &p2); - BoundingBox (const Length &ulxx, const Length &ulyy, const Length &lrxx, const Length &lryy); - BoundingBox (const std::string &boxstr); - void set (std::string boxstr); - void embed (double x, double y); - void embed (const BoundingBox &bb); - void embed (const DPair &p) {embed(p.x(), p.y());} - void embed (const DPair &c, double r); - - template - void embed (const Pair &p) {embed(p.x(), p.y());} - - void expand (double m); - bool intersect (const BoundingBox &bbox); - double minX () const {return _ulx;} - double minY () const {return _uly;} - double maxX () const {return _lrx;} - double maxY () const {return _lry;} - double width () const {return _lrx-_ulx;} - double height () const {return _lry-_uly;} - void lock () {_locked = true;} - void unlock () {_locked = false;} - void operator += (const BoundingBox &bb); - void scale (double sx, double sy); - void transform (const Matrix &tm); - std::string toSVGViewBox () const; - std::ostream& write (std::ostream &os) const; - XMLElementNode* toSVGRect () const; - - private: - double _ulx, _uly; ///< coordinates of upper left vertex (in TeX point units) - double _lrx, _lry; ///< coordinates of lower right vertex (in TeX point unitx) - bool _valid : 1; ///< true if the box coordinates are properly set - bool _locked : 1; ///< if true, the box data is read-only -}; - -IMPLEMENT_OUTPUT_OPERATOR(BoundingBox) - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.cpp deleted file mode 100644 index 2295ab17bde..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************* -** CRC32.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "CRC32.h" - -using namespace std; - - -CRC32::CRC32 () : _crc32(0xFFFFFFFF) -{ - const UInt32 poly = 0xEDB88320; - for (int i = 0; i < 256; i++) { - UInt32 crc=i; - for (int j=8; j > 0; j--) { - if (crc & 1) - crc = (crc >> 1) ^ poly; - else - crc >>= 1; - } - _tab[i] = crc; - } -} - - -/** Resets CRC32 sum to 0. */ -void CRC32::reset () { - _crc32 = 0xFFFFFFFF; -} - - -/** Appends string bytes to the previous data and computes the resulting checksum. - * @param[in] data string to update the checksum with */ -void CRC32::update (const char *data) { - update((const UInt8*)data, strlen(data)); -} - - -/** Appends a single value to the previous data and computes the resulting checksum. - * @param[in] n value to update the checksum with - * @param[in] bytes number of bytes to consider (0-4) */ -void CRC32::update (UInt32 n, int bytes) { - for (int i=bytes-1; i >= 0; --i) { - UInt8 byte = UInt8((n >> (8*i)) & 0xff); - update(&byte, 1); - } -} - - -/** Appends a sequence of bytes to the previous data and computes the resulting checksum. - * @param[in] bytes pointer to array of bytes - * @param[in] len number of bytes in array */ -void CRC32::update (const UInt8 *bytes, size_t len) { - for (size_t i=0; i < len; ++i) - _crc32 = ((_crc32 >> 8) & 0x00FFFFFF) ^ _tab[(_crc32 ^ *bytes++) & 0xFF]; -} - - -void CRC32::update (istream &is) { - char buf [4096]; - while (is) { - is.read(buf, 4096); - update((UInt8*)buf, is.gcount()); - } -} - - -/** Returns the checksum computed from values added with the update functions. */ -UInt32 CRC32::get () const { - return _crc32 ^ 0xFFFFFFFF; -} - - -/** Computes the CRC32 checksum of a sequence of bytes. - * @param[in] bytes pointer to array of bytes - * @param[in] len number of bytes in array - * @return CRC32 checksum */ -UInt32 CRC32::compute (const UInt8 *bytes, size_t len) { - CRC32 crc32; - crc32.update(bytes, len); - return crc32.get(); -} - - -/** Computes the CRC32 checksum of a string. */ -UInt32 CRC32::compute (const char *str) { - return compute((const UInt8*)str, strlen(str)); -} - - -UInt32 CRC32::compute (istream &is) { - CRC32 crc32; - crc32.update(is); - return crc32.get(); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.h deleted file mode 100644 index ca8ec359d0f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CRC32.h +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* -** CRC32.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef CRC32_H -#define CRC32_H - -#include -#include -#include "types.h" - -class CRC32 -{ - public: - CRC32 (); - void update (const UInt8 *bytes, size_t len); - void update (UInt32 n, int bytes=4); - void update (const char *str); - void update (std::istream &is); - UInt32 get () const; - void reset (); - static UInt32 compute (const UInt8 *bytes, size_t len); - static UInt32 compute (const char *str); - static UInt32 compute (std::istream &is); - - protected: - CRC32 (const CRC32 &crc32) {} - - private: - UInt32 _crc32; - UInt32 _tab[256]; -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.cpp deleted file mode 100644 index 2814cc286e0..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* -** Calculator.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "Calculator.h" - -using namespace std; - -// token types -const char END = 0; -const char NUMBER = 1; -const char NAME = 2; - - -#include - - -/** Evaluates a given arithmetic expression and returns its value. - * The evaluator is implemented as a recursive descendent parser. - * @param[in] is reads expression from this stream - * @return expression value */ -double Calculator::eval (istream &is) { - double ret = expr(is, false); - if (lookAhead(is) > 0) - throw CalculatorException("expression syntax error"); - return ret; -} - - -/** Evaluates a given arithmetic expression and returns its value. - * @param[in] expr expression to evaluate - * @return expression value */ -double Calculator::eval (const string &expr) { - istringstream iss; - iss.str(expr); - return eval(iss); -} - - -/** Evaluates the root rule of the expression grammar. */ -double Calculator::expr (istream &is, bool skip) { // expr: - double left = term(is, skip); - while (1) - 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 - } -} - - -double Calculator::term (istream &is, bool skip) { // term: - double left = prim(is, skip); - while (1) - switch (lookAhead(is)) { - case '*': left *= prim(is, true); 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: // prim => $1 - return left; - } -} - - -double Calculator::prim (istream &is, bool skip) { // 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); - } - 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"); - } -} - - -/** Determines type of next token without swallowing it. That means - * the same token will be read again next time. */ -char Calculator::lookAhead (istream &is) { - while (isspace(is.peek())) // skip whitespace - is.get(); - if (is.eof()) - return END; - int c = is.peek(); - if (isdigit(c) || c == '.') - return NUMBER; - if (isalpha(c)) - return NAME; - 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. - * @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: - is >> _numValue; - break; - case NAME: { - _strValue.clear(); - while (isalpha(is.peek())) - _strValue += char(is.get()); - break; - } - 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 { - map::const_iterator it = _variables.find(name); - if (it == _variables.end()) - throw CalculatorException("undefined variable '" + name + "'"); - return it->second; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.h deleted file mode 100644 index 36bb39d679c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Calculator.h +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************************* -** Calculator.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef CALCULATOR_H -#define CALCULATOR_H - -#include -#include -#include -#include "MessageException.h" - - -struct CalculatorException : public MessageException -{ - CalculatorException (const std::string &msg) : MessageException(msg) {} -}; - -class Calculator -{ - public: - Calculator () : _numValue(0) {} - double eval (std::istream &is); - double eval (const std::string &expr); - 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); - - private: - std::map _variables; - double _numValue; - std::string _strValue; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.cpp deleted file mode 100644 index 27b607555b9..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/************************************************************************* -** CmdLineParserBase.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "CmdLineParserBase.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "Message.h" - -using namespace std; - -void CmdLineParserBase::init () { - _error = false; - _files.clear(); -} - - -/** Parses all options given on the command line. - * @param[in] printErrors enable/disable printing of error messages */ -void CmdLineParserBase::parse (int argc, char **argv, bool printErrors) { - init(); - _printErrors = printErrors; - bool filesOnly = false; // - for (int i=1; i < argc; i++) { - CharInputBuffer ib(argv[i], strlen(argv[i])); - BufferInputReader ir(ib); - if (filesOnly || ir.peek() != '-') - _files.push_back(argv[i]); - else { - ir.get(); - if (ir.peek() == '-') { - // scan long option - ir.get(); - if (ir.eof()) // "--" only - filesOnly = true; // treat all following options as filenames - else { - string longname; - while (isalnum(ir.peek()) || ir.peek() == '-') - longname += char(ir.get()); - if (const Option *opt = option(longname)) - (*opt->handler)(this, ir, *opt, true); - else if (!_error) { - if (printErrors) - Message::estream(false) << "unknown option --" << longname << '\n'; - _error = true; - } - } - } - else { - // scan short option(s) - bool combined = false; // multiple short options combined, e.g -abc - do { - int shortname = ir.get(); - if (const Option *opt = option(shortname)) { - if (!combined || opt->argmode == 0) { - if (opt->argmode == 'r' && strlen(argv[i]) == 2) { // required argument separated by whitespace? - if (i+1 < argc && argv[i+1][0] != '-') - ib.assign(argv[++i]); - } - (*opt->handler)(this, ir, *opt, false); - if (opt->argmode == 0) - combined = true; - } - else { - if (printErrors) - Message::estream(false) << "option -" << char(shortname) << " must be given separately\n"; - _error = true; - } - } - else if (shortname > 0) { - if (printErrors) - Message::estream(false) << "unknown option -" << char(shortname) << '\n'; - _error = true; - } - } - while (!_error && combined && !ir.eof()); - } - } - } -} - - -/** Prints an error message to stdout. - * @param[in] opt error occurred in this option - * @param[in] longopt the long option name was scanned - * @param[in] msg message to be printed */ -void CmdLineParserBase::error (const Option &opt, bool longopt, const char *msg) const { - if (_printErrors) { - Message::estream(false) << "option "; - if (longopt) - Message::estream(false) << "--" << opt.longname; - else - Message::estream(false) << '-' << opt.shortname; - Message::estream(false) << ": " << msg << '\n'; - } - _error = true; -} - - -#if 0 -#include - -/** Lists the scanned filenames. Just for debugging purposes. */ -void CmdLineParserBase::status () const { - cout << "file names:\n"; - for (size_t i=0; i < _files.size(); i++) - cout << " " << _files[i] << endl; - cout << endl; -} -#endif - - -/** Returns the option information of a given short option name. - * If the option name can't be found 0 is returned. - * @param[in] longname long version of the option without leading hyphen (e.g. p, not -p) */ -const CmdLineParserBase::Option* CmdLineParserBase::option (char shortname) const { - size_t numopts; // number of available options - for (const Option *opts = options(&numopts); numopts > 0; ++opts) { - if (opts->shortname == shortname) - return opts; - numopts--; - } - return 0; -} - - -/** Returns the option information of a given long option name. - * Parameter 'longname' hasn't to be the complete long option name. The function looks up - * all options that start with 'longname'. If a unique or an exact match was found, it's returned. - * Otherwise, the return value is 0. - * @param[in] longname long version of the option without leading hyphens (e.g. param, not --param) */ -const CmdLineParserBase::Option* CmdLineParserBase::option (const string &longname) const { - vector matches; // all matching options - size_t len = longname.length(); - size_t numopts; // number of available options - for (const Option *opts = options(&numopts); numopts > 0; ++opts) { - if (string(opts->longname, len) == longname) { - if (len == strlen(opts->longname)) // exact match? - return opts; - matches.push_back(opts); - } - numopts--; - } - switch (matches.size()) { - default: - if (_printErrors) { - Message::estream(false) << "option --" << longname << " is ambiguous ("; - for (size_t i=0; i < matches.size(); i++) { - if (i > 0) - Message::estream(false) << ", "; - Message::estream(false) << matches[i]->longname; - } - Message::estream(false) << ")\n"; - } - _error = true; - - case 0 : return 0; - case 1 : return matches[0]; - } -} - - -/** Returns true if a valid separator between option and argument was found. - * Arguments of long options are preceded by a '='. The argument of a short option - * directly follows the option without a separation character. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given */ -bool CmdLineParserBase::checkArgPrefix (InputReader &ir, const Option &opt, bool longopt) const { - if (longopt) { - if (ir.peek() == '=') - ir.get(); - else { - error(opt, longopt, "'=' expected"); - return false; - } - } - return true; -} - - -/** Returns true if a given option has no argument, .e.g. -p or --param. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given */ -bool CmdLineParserBase::checkNoArg (InputReader &ir, const Option &opt, bool longopt) const { - if (ir.eof()) - return true; - error(opt, longopt, "no argument expected"); - return false; -} - - -/** Gets an integer argument of a given option, e.g. -p5 or --param=5. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getIntArg (InputReader &ir, const Option &opt, bool longopt, int &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - if (ir.parseInt(arg) && ir.eof()) - return true; - error(opt, longopt, "integer value expected"); - } - return false; -} - - -/** Gets an unsigned integer argument of a given option, e.g. -p5 or --param=5. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getUIntArg (InputReader &ir, const Option &opt, bool longopt, unsigned &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - if (ir.parseUInt(arg) && ir.eof()) - return true; - error(opt, longopt, "unsigned integer value expected"); - } - return false; -} - - -/** Gets a double (floating point) argument of a given option, e.g. -p2.5 or --param=2.5. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getDoubleArg (InputReader &ir, const Option &opt, bool longopt, double &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - if (ir.parseDouble(arg) != 0 && ir.eof()) - return true; - error(opt, longopt, "floating point value expected"); - } - return false; -} - - -/** Gets a string argument of a given option, e.g. -pstr or --param=str. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getStringArg (InputReader &ir, const Option &opt, bool longopt, string &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - arg.clear(); - while (!ir.eof()) - arg += char(ir.get()); - if (!arg.empty()) - return true; - error(opt, longopt, "string argument expected"); - } - return false; -} - - -/** Gets a boolean argument of a given option, e.g. -pyes or --param=yes. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getBoolArg (InputReader &ir, const Option &opt, bool longopt, bool &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - string str; - while (!ir.eof()) - str += char(ir.get()); - if (str == "yes" || str == "y" || str == "true" || str == "1") { - arg = true; - return true; - } - else if (str == "no" || str == "n" || str == "false" || str == "0") { - arg = false; - return true; - } - error(opt, longopt, "boolean argument expected (yes, no, true, false, 0, 1)"); - } - return false; -} - - -/** Gets a (single) character argument of a given option, e.g. -pc or --param=c. - * @param[in] ir argument is read from this InputReader - * @param[in] opt scans argument of this option - * @param[in] longopt true if the long option name was given - * @param[out] arg the scanned option argument - * @return true if argument could be scanned without errors */ -bool CmdLineParserBase::getCharArg (InputReader &ir, const Option &opt, bool longopt, char &arg) const { - if (checkArgPrefix(ir, opt, longopt)) { - arg = char(ir.get()); - if (arg >= 0 && ir.eof()) - return true; - error(opt, longopt, "character argument expected"); - } - return false; -} - - -/** Compares the short option characters of two help lines. - * @return true if line1 should appear before line2 */ -static bool cmp_short (const char *line1, const char *line2) { - if (*line1 != 'o' || *line2 != 'o' || (line1[1] == ' ' && line2[1] == ' ')) - return strcmp(line1, line2) < 0; - char lopt1 = tolower(line1[2]); - char lopt2 = tolower(line2[2]); - if (lopt1 == lopt2) // same character but different case? - return line1[2] > line2[2]; // line with lower-case letter first - return lopt1 < lopt2; -} - - -/** Compares the long option names of two help lines. - * @return true if line1 should appear before line2 */ -static bool cmp_long (const char *line1, const char *line2) { - if (*line1 != 'o' || *line2 != 'o') - return strcmp(line1, line2) < 0; - return strcmp(line1+6, line2+6) < 0; -} - - -/** Prints the help text to stdout. - * @param[in] mode format of help text */ -void CmdLineParserBase::help (int mode) const { - size_t numlines; - const char **lines = helplines(&numlines); - if (mode == 0) { // list options with section headers - for (size_t i=0; i < numlines; i++) { - switch (*lines[i]) { - case 's': fputc('\n', stdout); break; // section header - case 'o': fputs(" ", stdout); break; // option info - } - puts(lines[i]+1); - } - } - else { - vector linevec(lines, lines+numlines); - sort(linevec.begin(), linevec.end(), mode == 1 ? cmp_short : cmp_long); - for (vector::iterator it=linevec.begin(); it != linevec.end(); ++it) { - if (**it != 's') { // skip section headers - puts(*it+1); - if (**it == 'd') - puts("\nOptions:"); - } - } - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.h deleted file mode 100644 index 35e20e3735c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CmdLineParserBase.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************* -** CmdLineParserBase.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef CMDLINEPARSERBASE_H -#define CMDLINEPARSERBASE_H - -#include -#include - -class InputReader; - -class CmdLineParserBase -{ - protected: - struct Option; - - struct OptionHandler { - virtual ~OptionHandler () {} - virtual void operator () (CmdLineParserBase *obj, InputReader &ir, const Option &opt, bool longopt) const=0; - }; - - template - class OptionHandlerImpl : public OptionHandler { - protected: - typedef void (T::*LocalHandler)(InputReader &ir, const Option &opt, bool longopt); - - public: - OptionHandlerImpl (LocalHandler handler) : _handler(handler) {} - - void operator () (CmdLineParserBase *obj, InputReader &ir, const Option &opt, bool longopt) const { - if (T *tobj = dynamic_cast(obj)) - (tobj->*_handler)(ir, opt, longopt); - } - - private: - LocalHandler _handler; - }; - - struct Option { - ~Option () {delete handler;} - char shortname; - const char *longname; - char argmode; // mode of option argument: '\0'=none, 'o'=optional, 'r'=required - const OptionHandler *handler; - }; - - public: - virtual void parse (int argc, char **argv, bool printErrors=true); - virtual void help (int mode=0) const; - virtual int numFiles () const {return _files.size();} - virtual const char* file (size_t n) {return n < _files.size() ? _files[n].c_str() : 0;} -// virtual void status () const; - virtual bool error () const {return _error;} - - protected: - CmdLineParserBase () : _printErrors(true), _error(false) {} - CmdLineParserBase (const CmdLineParserBase &cmd) : _printErrors(true), _error(false) {} - virtual ~CmdLineParserBase () {} - virtual void init (); - virtual void error (const Option &opt, bool longopt, const char *msg) const; - virtual const Option* options (size_t *numopts) const =0; - virtual const char** helplines (size_t *numlines) const =0; - bool checkArgPrefix (InputReader &ir, const Option &opt, bool longopt) const; - bool checkNoArg (InputReader &ir, const Option &opt, bool longopt) const; - bool getIntArg (InputReader &ir, const Option &opt, bool longopt, int &arg) const; - bool getUIntArg (InputReader &ir, const Option &opt, bool longopt, unsigned &arg) const; - bool getDoubleArg (InputReader &ir, const Option &opt, bool longopt, double &arg) const; - bool getStringArg (InputReader &ir, const Option &opt, bool longopt, std::string &arg) const; - bool getBoolArg (InputReader &ir, const Option &opt, bool longopt, bool &arg) const; - bool getCharArg (InputReader &ir, const Option &opt, bool longopt, char &arg) const; - const Option* option (char shortname) const; - const Option* option (const std::string &longname) const; - - private: - bool _printErrors; ///< if true, print error messages - mutable bool _error; ///< error occured while parsing options - std::vector _files; ///< filename parameters -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.cpp deleted file mode 100644 index 45d5ce453da..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************************* -** Color.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "Color.h" - -using namespace std; - - - -const Color Color::BLACK(0); -const Color Color::WHITE(UInt8(255), UInt8(255), UInt8(255)); -const Color Color::TRANSPARENT(0xff000000); - - -static inline UInt8 float_to_byte (float v) { - return (UInt8) (floor(255*v+0.5)); -} - - -void Color::set (float r, float g, float b) { - set(float_to_byte(r), float_to_byte(g), float_to_byte(b)); -} - - -void Color::setHSB (float h, float s, float b) { - vector hsb(3), rgb(3); - hsb[0] = h; - hsb[1] = s; - hsb[2] = b; - HSB2RGB(hsb, rgb); - set(rgb[0], rgb[1], rgb[2]); -} - - -void Color::setCMYK (float c, float m, float y, float k) { - vector cmyk(4), rgb(3); - cmyk[0] = c; - cmyk[1] = m; - cmyk[2] = y; - cmyk[3] = k; - CMYK2RGB(cmyk, rgb); - set(rgb[0], rgb[1], rgb[2]); -} - - -void Color::operator *= (double c) { - UInt32 rgb=0; - for (int i=0; i < 3; i++) { - rgb |= UInt32(floor((_rgb & 0xff)*c+0.5)) << (8*i); - _rgb >>= 8; - } - _rgb = rgb; -} - - -string Color::rgbString () const { - ostringstream oss; - oss << '#'; - for (int i=2; i >= 0; i--) { - oss << setbase(16) << setfill('0') << setw(2) - << (((_rgb >> (8*i)) & 0xff)); - } - return oss.str(); -} - - -/** Approximates a CMYK color by an RGB triple. The component values - * are expected to be normalized, i.e. 0 <= cmyk[i],rgb[j] <= 1. - * @param[in] cmyk color in CMYK space - * @param[out] rgb RGB approximation */ -void Color::CMYK2RGB (const vector &cmyk, vector &rgb) { - for (int i=0; i < 3; i++) - rgb[i] = 1.0f-min(1.0f, cmyk[i]+cmyk[3]); -} - - -/** Converts a color given in HSB coordinates to RGB. - * @param[in] hsb color in HSB space - * @param[out] rgb color in RGB space */ -void Color::HSB2RGB (const vector &hsb, vector &rgb) { - if (hsb[1] == 0) - rgb[0] = rgb[1] = rgb[2] = hsb[2]; - else { - float h = hsb[0]-floor(hsb[0]); - int i = int(6*h); - float f = float(6.0*h-i); - float p = hsb[2]*(1-hsb[1]); - float q = hsb[2]*(1-hsb[1]*f); - float t = hsb[2]*(1-hsb[1]*(1-f)); - switch (i) { - case 0 : rgb[0]=hsb[2]; rgb[1]=t; rgb[2]=p; break; - case 1 : rgb[0]=q; rgb[1]=hsb[2]; rgb[2]=p; break; - case 2 : rgb[0]=p; rgb[1]=hsb[2]; rgb[2]=t; break; - case 3 : rgb[0]=p; rgb[1]=q; rgb[2]=hsb[2]; break; - case 4 : rgb[0]=t; rgb[1]=p; rgb[2]=hsb[2]; break; - case 5 : rgb[0]=hsb[2]; rgb[1]=p; rgb[2]=q; break; - default: ; // prevent compiler warning - } - } -} - - -void Color::getRGB (float &r, float &g, float &b) const { - r = float(((_rgb >> 16) & 255) / 255.0); - g = float(((_rgb >> 8) & 255) / 255.0); - b = float((_rgb & 255) / 255.0); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.h deleted file mode 100644 index 24b33c7bb95..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Color.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* -** Color.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef COLOR_H -#define COLOR_H - -#include -#include -#include "types.h" - -#ifdef TRANSPARENT -#undef TRANSPARENT -#endif - -class Color -{ - public: - static const Color BLACK; - static const Color WHITE; - static const Color TRANSPARENT; - - public: - Color () : _rgb(0) {} - Color (UInt32 rgb) : _rgb(rgb) {} - Color (UInt8 r, UInt8 g, UInt8 b) {set(r,g,b);} - Color (float r, float g, float b) {set(r,g,b);} - Color (const std::vector &rgb) {set(rgb[0], rgb[1], rgb[2]);} - operator UInt32 () const {return _rgb;} - bool operator == (const Color &c) {return _rgb == c._rgb;} - bool operator != (const Color &c) {return _rgb != c._rgb;} - void set (UInt8 r, UInt8 g, UInt8 b) {_rgb = (r << 16) | (g << 8) | b;} - void set (float r, float g, float b); - void setGray (UInt8 g) {set(g,g,g);} - void setGray (float g) {set(g,g,g);} - void setHSB (float h, float s, float b); - void setCMYK (float c, float m, float y, float k); - void getRGB (float &r, float &g, float &b) const; - void operator *= (double c); - std::string rgbString () const; - static void CMYK2RGB (const std::vector &cmyk, std::vector &rgb); - static void HSB2RGB (const std::vector &hsb, std::vector &rgb); - - private: - UInt32 _rgb; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.cpp deleted file mode 100644 index d156a43770f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************************* -** ColorSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "ColorSpecialHandler.h" -#include "SpecialActions.h" - -using namespace std; - - - -/** Approximates a CMYK color by an RGB triple. The component values - * are expected to be normalized, i.e. 0 <= cmyk[i],rgb[j] <= 1. - * @param[in] cmyk color in CMYK space - * @param[out] rgb RGB approximation */ -static void cmyk_to_rgb (const vector &cmyk, vector &rgb) { - for (int i=0; i < 3; i++) - rgb[i] = 1.0f-min(1.0f, cmyk[i]+cmyk[3]); -} - - -/** Converts a color given in HSB coordinates to RGB. - * @param[in] hsb color in HSB space - * @param[out] rgb color in RGB space */ -static void hsb_to_rgb (const vector &hsb, vector &rgb) { - if (hsb[1] == 0) - rgb[0] = rgb[1] = rgb[2] = hsb[2]; - else { - float h = hsb[0]-floor(hsb[0]); - float i = floor(6*h); - float f = 6.0f*h-i; - float p = hsb[2]*(1-hsb[1]); - float q = hsb[2]*(1-hsb[1]*f); - float t = hsb[2]*(1-hsb[1]*(1-f)); - switch (int(i)) { - case 0 : rgb[0]=hsb[2]; rgb[1]=t; rgb[2]=p; break; - case 1 : rgb[0]=q; rgb[1]=hsb[2]; rgb[2]=p; break; - case 2 : rgb[0]=p; rgb[1]=hsb[2]; rgb[2]=t; break; - case 3 : rgb[0]=p; rgb[1]=q; rgb[2]=hsb[2]; break; - case 4 : rgb[0]=t; rgb[1]=p; rgb[2]=hsb[2]; break; - case 5 : rgb[0]=hsb[2]; rgb[1]=p; rgb[2]=q; break; - default: ; // prevent compiler warning - } - } -} - - -/** Converts a gray value to RGB. - * @param[in] gray normalized gray value (0 <= gray <= 1) - * @param[out] rgb resulting RGB triple */ -static void gray_to_rgb (const float gray, vector &rgb) { - for (int i=0; i < 3; i++) - rgb[i] = gray; -} - - -static float read_float (istream &is) { - is.clear(); - float v; - is >> v; - if (is.fail()) - throw SpecialException("number expected"); - return v; -} - - -/** Reads multiple float values from a given stream. The number of - * values read is determined by the size of the result vector. - * @param[in] is stream to be read from - * @param[out] v the resulting floats */ -static void read_floats (istream &is, vector &v) { - for (size_t i=0; i < v.size(); i++) - v[i] = read_float(is); -} - - -static bool color_constant (const string &c, vector &rgb) { - // converted color constants from color.pro - const struct { - const char *name; - const float rgb[3]; - } - constants[] = { - {"Apricot", {1, 0.68f, 0.48f}}, - {"Aquamarine", {0.18f, 1, 0.7f}}, - {"Bittersweet", {0.76f, 0.01f, 0}}, - {"Black", {0, 0, 0}}, - {"Blue", {0, 0, 1}}, - {"BlueGreen", {0.15f, 1, 0.67f}}, - {"BlueViolet", {0.1f, 0.05f, 0.96f}}, - {"BrickRed", {0.72f, 0, 0}}, - {"Brown", {0.4f, 0, 0}}, - {"BurntOrange", {1, 0.49f, 0}}, - {"CadetBlue", {0.38f, 0.43f, 0.77f}}, - {"CarnationPink", {1, 0.37f, 1}}, - {"Cerulean", {0.06f, 0.89f, 1}}, - {"CornflowerBlue", {0.35f, 0.87f, 1}}, - {"Cyan", {0, 1, 1}}, - {"Dandelion", {1, 0.71f, 0.16f}}, - {"DarkOrchid", {0.6f, 0.2f, 0.8f}}, - {"Emerald", {0, 1, 0.5f}}, - {"ForestGreen", {0, 0.88f, 0}}, - {"Fuchsia", {0.45f, 0.01f, 0.92f}}, - {"Goldenrod", {1, 0.9f, 0.16f}}, - {"Gray", {0.5f, 0.5f, 0.5f}}, - {"Green", {0, 1, 0}}, - {"GreenYellow", {0.85f, 1, 0.31f}}, - {"JungleGreen", {0.01f, 1, 0.48f}}, - {"Lavender", {1, 0.52f, 1}}, - {"LimeGreen", {0.5f, 1, 0}}, - {"Magenta", {1, 0, 1}}, - {"Mahogany", {0.65f, 0, 0}}, - {"Maroon", {0.68f, 0, 0}}, - {"Melon", {1, 0.54f, 0.5f}}, - {"MidnightBlue", {0, 0.44f, 0.57f}}, - {"Mulberry", {0.64f, 0.08f, 0.98f}}, - {"NavyBlue", {0.06f, 0.46f, 1}}, - {"OliveGreen", {0, 0.6f, 0}}, - {"Orange", {1, 0.39f, 0.13f}}, - {"OrangeRed", {1, 0, 0.5f}}, - {"Orchid", {0.68f, 0.36f, 1}}, - {"Peach", {1, 0.5f, 0.3f}}, - {"Periwinkle", {0.43f, 0.45f, 1}}, - {"PineGreen", {0, 0.75f, 0.16f}}, - {"Plum", {0.5f, 0, 1}}, - {"ProcessBlue", {0.04f, 1, 1}}, - {"Purple", {0.55f, 0.14f, 1}}, - {"RawSienna", {0.55f, 0, 0}}, - {"Red", {1, 0, 0}}, - {"RedOrange", {1, 0.23f, 0.13f}}, - {"RedViolet", {0.59f, 0, 0.66f}}, - {"Rhodamine", {1, 0.18f, 1}}, - {"RoyalBlue", {0, 0.5f, 1}}, - {"RoyalPurple", {0.25f, 0.1f, 1}}, - {"RubineRed", {1, 0, 0.87f}}, - {"Salmon", {1, 0.47f, 0.62f}}, - {"SeaGreen", {0.31f, 1, 0.5f}}, - {"Sepia", {0.3f, 0, 0}}, - {"SkyBlue", {0.38f, 1, 0.88f}}, - {"SpringGreen", {0.74f, 1, 0.24f}}, - {"Tan", {0.86f, 0.58f, 0.44f}}, - {"TealBlue", {0.12f, 0.98f, 0.64f}}, - {"Thistle", {0.88f, 0.41f, 1}}, - {"Turquoise", {0.15f, 1, 0.8f}}, - {"Violet", {0.21f, 0.12f, 1}}, - {"VioletRed", {1, 0.19f, 1}}, - {"White", {1, 1, 1}}, - {"WildStrawberry", {1, 0.04f, 0.61f}}, - {"Yellow", {1, 1, 0}}, - {"YellowGreen", {0.56f, 1, 0.26f}}, - {"YellowOrange", {1, 0.58f, 0}} - }; - // binary search - int first=0, last=68-1; - while (first <= last) { - int mid = first+(last-first)/2; - int cmp = strcmp(constants[mid].name, c.c_str()); - if (cmp > 0) - last = mid-1; - else if (cmp < 0) - first = mid+1; - else { - rgb[0] = constants[mid].rgb[0]; - rgb[1] = constants[mid].rgb[1]; - rgb[2] = constants[mid].rgb[2]; - return true; - } - } - return false; -} - - -/** Reads a color statement from an input stream and converts it to RGB. - * A color statement has the following syntax: - * - * Currently, the following color models are supported: rgb, cmyk, hsb and gray. - * Examples: rgb 1 0.5 0, gray 0.5 - * @param[in] model if model != "" this value specifies the model, otherwise it's read from the stream - * @param[in] is stream to be read from - * @param[out] resulting RGB triple - * @return true if statement has successfully been read */ -static void read_color (string model, istream &is, vector &rgb) { - if (model.empty()) - is >> model; - if (model == "rgb") - read_floats(is, rgb); - else if (model == "cmyk") { - vector cmyk(4); - read_floats(is, cmyk); - cmyk_to_rgb(cmyk, rgb); - } - else if (model == "hsb") { - vector hsb(3); - read_floats(is, hsb); - hsb_to_rgb(hsb, rgb); - } - else if (model == "gray") - gray_to_rgb(read_float(is), rgb); - else if (!color_constant(model, rgb)) - throw SpecialException("unknown color statement"); - if (rgb[0] > 1 || rgb[1] > 1 || rgb[2] > 1) { - ostringstream oss; - oss << "invalid RGB value (" << rgb[0] << ',' << rgb[1] << ',' << rgb[2] << ')'; - throw SpecialException(oss.str()); - } -} - - -bool ColorSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - vector rgb(3); - if (prefix && strcmp(prefix, "background") == 0) { - read_color("", is, rgb); - actions->setBgColor(rgb); - } - else { - string cmd; - is >> cmd; - if (cmd == "push") { // color push - read_color("", is, rgb); - _colorStack.push(rgb); - } - else if (cmd == "pop") { - if (!_colorStack.empty()) // color pop - _colorStack.pop(); - } - else { // color - read_color(cmd, is, rgb); - while (!_colorStack.empty()) - _colorStack.pop(); - _colorStack.push(rgb); - } - if (actions) { - if (_colorStack.empty()) - actions->setColor(Color::BLACK); - else - actions->setColor(_colorStack.top()); - } - } - return true; -} - - -const char** ColorSpecialHandler::prefixes () const { - static const char *pfx[] = {"color", 0}; - return pfx; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.h deleted file mode 100644 index a9b73dc8b74..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ColorSpecialHandler.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************* -** ColorSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef COLORSPECIALHANDLER_H -#define COLORSPECIALHANDLER_H - -#include -#include -#include "SpecialHandler.h" - - -class ColorSpecialHandler : public SpecialHandler -{ - typedef std::vector RGB; - - public: - bool process (const char *prefix, std::istream &is, SpecialActions *actions); - const char* name () const {return "color";} - const char* info () const {return "complete support of color specials";} - const char** prefixes () const; - - private: - std::stack _colorStack; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.cpp deleted file mode 100644 index c62cfe1e6bb..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// This file was automatically generated by opt2cpp. -// 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. -// (C) 2009-2013 Martin Gieseking - -#include -#include -#include -#include "InputReader.h" -#include "CommandLine.h" - -using namespace std; - -const CmdLineParserBase::Option CommandLine::_options[] = { - {'b', "bbox", 'r', new OptionHandlerImpl(&CommandLine::handle_bbox)}, - {'C', "cache", 'o', new OptionHandlerImpl(&CommandLine::handle_cache)}, - {'\0', "color", 0, new OptionHandlerImpl(&CommandLine::handle_color)}, -#if !defined(DISABLE_GS) - {'E', "eps", 0, new OptionHandlerImpl(&CommandLine::handle_eps)}, -#endif - {'e', "exact", 0, new OptionHandlerImpl(&CommandLine::handle_exact)}, - {'m', "fontmap", 'r', new OptionHandlerImpl(&CommandLine::handle_fontmap)}, - {'h', "help", 'o', new OptionHandlerImpl(&CommandLine::handle_help)}, - {'\0', "keep", 0, new OptionHandlerImpl(&CommandLine::handle_keep)}, -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - {'\0', "libgs", 'r', new OptionHandlerImpl(&CommandLine::handle_libgs)}, -#endif - {'l', "list-specials", 0, new OptionHandlerImpl(&CommandLine::handle_list_specials)}, - {'M', "mag", 'r', new OptionHandlerImpl(&CommandLine::handle_mag)}, - {'n', "no-fonts", 'o', new OptionHandlerImpl(&CommandLine::handle_no_fonts)}, - {'\0', "no-mktexmf", 0, new OptionHandlerImpl(&CommandLine::handle_no_mktexmf)}, - {'S', "no-specials", 'o', new OptionHandlerImpl(&CommandLine::handle_no_specials)}, - {'\0', "no-styles", 0, new OptionHandlerImpl(&CommandLine::handle_no_styles)}, - {'o', "output", 'r', new OptionHandlerImpl(&CommandLine::handle_output)}, - {'p', "page", 'r', new OptionHandlerImpl(&CommandLine::handle_page)}, - {'d', "precision", 'r', new OptionHandlerImpl(&CommandLine::handle_precision)}, - {'P', "progress", 'o', new OptionHandlerImpl(&CommandLine::handle_progress)}, - {'r', "rotate", 'r', new OptionHandlerImpl(&CommandLine::handle_rotate)}, - {'c', "scale", 'r', new OptionHandlerImpl(&CommandLine::handle_scale)}, - {'s', "stdout", 0, new OptionHandlerImpl(&CommandLine::handle_stdout)}, - {'a', "trace-all", 'o', new OptionHandlerImpl(&CommandLine::handle_trace_all)}, - {'T', "transform", 'r', new OptionHandlerImpl(&CommandLine::handle_transform)}, - {'t', "translate", 'r', new OptionHandlerImpl(&CommandLine::handle_translate)}, - {'v', "verbosity", 'r', new OptionHandlerImpl(&CommandLine::handle_verbosity)}, - {'V', "version", 'o', new OptionHandlerImpl(&CommandLine::handle_version)}, - {'z', "zip", 'o', new OptionHandlerImpl(&CommandLine::handle_zip)}, -}; - -const CmdLineParserBase::Option* CommandLine::options (size_t *numopts) const { - *numopts = sizeof(_options)/sizeof(CmdLineParserBase::Option); - return _options; -} - -void CommandLine::init () { - CmdLineParserBase::init(); - - // disable all options by default - _bbox_given = false; - _cache_given = false; - _color_given = false; -#if !defined(DISABLE_GS) - _eps_given = false; -#endif - _exact_given = false; - _fontmap_given = false; - _help_given = false; - _keep_given = false; -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - _libgs_given = false; -#endif - _list_specials_given = false; - _mag_given = false; - _no_fonts_given = false; - _no_mktexmf_given = false; - _no_specials_given = false; - _no_styles_given = false; - _output_given = false; - _page_given = false; - _precision_given = false; - _progress_given = false; - _rotate_given = false; - _scale_given = false; - _stdout_given = false; - _trace_all_given = false; - _transform_given = false; - _translate_given = false; - _verbosity_given = false; - _version_given = false; - _zip_given = false; - - // set default option values - _bbox_arg = "min"; - _cache_arg.clear(); - _fontmap_arg.clear(); - _help_arg = 0; -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - _libgs_arg.clear(); -#endif - _mag_arg = 4; - _no_fonts_arg = 0; - _no_specials_arg.clear(); - _output_arg.clear(); - _page_arg = "1"; - _precision_arg = 0; - _progress_arg = 0.5; - _rotate_arg = 0; - _scale_arg.clear(); - _trace_all_arg = false; - _transform_arg.clear(); - _translate_arg.clear(); - _verbosity_arg = 7; - _version_arg = false; - _zip_arg = 9; -} - -const char** CommandLine::helplines (size_t *numlines) const { - static const char *lines[] = { - "dThis program converts DVI files, as created by TeX/LaTeX, to\nthe XML-based scalable vector graphics format SVG.\n\nUsage: dvisvgm [options] dvifile\n dvisvgm -E [options] epsfile", - "sInput options:", - "o-p, --page=ranges choose pages to convert [1]", - "o-m, --fontmap=filenames evaluate (additional) font map files", -#if !defined(DISABLE_GS) - "o-E, --eps convert an EPS file to SVG", -#endif - "sSVG output options:", - "o-b, --bbox=size set size of bounding box [min]", - "o-o, --output=pattern set name pattern of output files", - "o-d, --precision=number set number of decimal points (0-6) [0]", - "o-s, --stdout write SVG output to stdout", - "o-n, --no-fonts[=variant] draw glyphs by using path elements [0]", - "o --no-styles don't use styles to reference fonts", - "o-z, --zip[=level] create compressed .svgz file [9]", - "sSVG transformations:", - "o-r, --rotate=angle rotate page content clockwise", - "o-c, --scale=sx[,sy] scale page content", - "o-t, --translate=tx[,ty] shift page content", - "o-T, --transform=commands transform page content", - "sProcessing options:", - "o-C, --cache[=dir] set/print path of cache directory", - "o-e, --exact compute exact glyph boxes", - "o --keep keep temporary files", -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - "o --libgs=filename set name of Ghostscript shared library", -#endif - "o-M, --mag=factor magnification of Metafont output [4]", - "o --no-mktexmf don't try to create missing fonts", - "o-S, --no-specials[=prefixes] don't process [selected] specials", - "o-a, --trace-all[=retrace] trace all glyphs of bitmap fonts [no]", - "sMessage options:", - "o --color colorize messages", - "o-h, --help[=mode] print this summary of options and exit [0]", - "o-l, --list-specials print supported special sets and exit", - "o-P, --progress[=delay] enable progess indicator [0.5]", - "o-v, --verbosity=level set verbosity level (0-7) [7]", - "o-V, --version[=extended] print version and exit [no]", - }; - *numlines = sizeof(lines)/sizeof(char*); - return lines; -} - -void CommandLine::handle_bbox (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _bbox_arg)) - _bbox_given = true; -} - -void CommandLine::handle_cache (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getStringArg(ir, opt, longopt, _cache_arg)) - _cache_given = true; -} - -void CommandLine::handle_color (InputReader &ir, const Option &opt, bool longopt) { - _color_given = true; -} - -#if !defined(DISABLE_GS) -void CommandLine::handle_eps (InputReader &ir, const Option &opt, bool longopt) { - _eps_given = true; -} -#endif - -void CommandLine::handle_exact (InputReader &ir, const Option &opt, bool longopt) { - _exact_given = true; -} - -void CommandLine::handle_fontmap (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _fontmap_arg)) - _fontmap_given = true; -} - -void CommandLine::handle_help (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getIntArg(ir, opt, longopt, _help_arg)) - _help_given = true; -} - -void CommandLine::handle_keep (InputReader &ir, const Option &opt, bool longopt) { - _keep_given = true; -} - -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) -void CommandLine::handle_libgs (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _libgs_arg)) - _libgs_given = true; -} -#endif - -void CommandLine::handle_list_specials (InputReader &ir, const Option &opt, bool longopt) { - _list_specials_given = true; -} - -void CommandLine::handle_mag (InputReader &ir, const Option &opt, bool longopt) { - if (getDoubleArg(ir, opt, longopt, _mag_arg)) - _mag_given = true; -} - -void CommandLine::handle_no_fonts (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getIntArg(ir, opt, longopt, _no_fonts_arg)) - _no_fonts_given = true; -} - -void CommandLine::handle_no_mktexmf (InputReader &ir, const Option &opt, bool longopt) { - _no_mktexmf_given = true; -} - -void CommandLine::handle_no_specials (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getStringArg(ir, opt, longopt, _no_specials_arg)) - _no_specials_given = true; -} - -void CommandLine::handle_no_styles (InputReader &ir, const Option &opt, bool longopt) { - _no_styles_given = true; -} - -void CommandLine::handle_output (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _output_arg)) - _output_given = true; -} - -void CommandLine::handle_page (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _page_arg)) - _page_given = true; -} - -void CommandLine::handle_precision (InputReader &ir, const Option &opt, bool longopt) { - if (getIntArg(ir, opt, longopt, _precision_arg)) - _precision_given = true; -} - -void CommandLine::handle_progress (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getDoubleArg(ir, opt, longopt, _progress_arg)) - _progress_given = true; -} - -void CommandLine::handle_rotate (InputReader &ir, const Option &opt, bool longopt) { - if (getDoubleArg(ir, opt, longopt, _rotate_arg)) - _rotate_given = true; -} - -void CommandLine::handle_scale (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _scale_arg)) - _scale_given = true; -} - -void CommandLine::handle_stdout (InputReader &ir, const Option &opt, bool longopt) { - _stdout_given = true; -} - -void CommandLine::handle_trace_all (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getBoolArg(ir, opt, longopt, _trace_all_arg)) - _trace_all_given = true; -} - -void CommandLine::handle_transform (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _transform_arg)) - _transform_given = true; -} - -void CommandLine::handle_translate (InputReader &ir, const Option &opt, bool longopt) { - if (getStringArg(ir, opt, longopt, _translate_arg)) - _translate_given = true; -} - -void CommandLine::handle_verbosity (InputReader &ir, const Option &opt, bool longopt) { - if (getUIntArg(ir, opt, longopt, _verbosity_arg)) - _verbosity_given = true; -} - -void CommandLine::handle_version (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getBoolArg(ir, opt, longopt, _version_arg)) - _version_given = true; -} - -void CommandLine::handle_zip (InputReader &ir, const Option &opt, bool longopt) { - if (ir.eof() || getIntArg(ir, opt, longopt, _zip_arg)) - _zip_given = true; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.h deleted file mode 100644 index 67d00d4e20d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/CommandLine.h +++ /dev/null @@ -1,166 +0,0 @@ -// This file was automatically generated by opt2cpp. -// 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. -// (C) 2009-2013 Martin Gieseking - -#ifndef COMMANDLINE_H -#define COMMANDLINE_H - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "CmdLineParserBase.h" - -class CommandLine : public CmdLineParserBase -{ - public: - CommandLine () {init();} - CommandLine (int argc, char **argv, bool printErrors) {parse(argc, argv, printErrors);} - bool page_given () const {return _page_given;} - const std::string& page_arg () const {return _page_arg;} - bool fontmap_given () const {return _fontmap_given;} - const std::string& fontmap_arg () const {return _fontmap_arg;} -#if !defined(DISABLE_GS) - bool eps_given () const {return _eps_given;} -#endif - bool bbox_given () const {return _bbox_given;} - const std::string& bbox_arg () const {return _bbox_arg;} - bool output_given () const {return _output_given;} - const std::string& output_arg () const {return _output_arg;} - bool precision_given () const {return _precision_given;} - int precision_arg () const {return _precision_arg;} - bool stdout_given () const {return _stdout_given;} - bool no_fonts_given () const {return _no_fonts_given;} - int no_fonts_arg () const {return _no_fonts_arg;} - bool no_styles_given () const {return _no_styles_given;} - bool zip_given () const {return _zip_given;} - int zip_arg () const {return _zip_arg;} - bool rotate_given () const {return _rotate_given;} - double rotate_arg () const {return _rotate_arg;} - bool scale_given () const {return _scale_given;} - const std::string& scale_arg () const {return _scale_arg;} - bool translate_given () const {return _translate_given;} - const std::string& translate_arg () const {return _translate_arg;} - bool transform_given () const {return _transform_given;} - const std::string& transform_arg () const {return _transform_arg;} - bool cache_given () const {return _cache_given;} - const std::string& cache_arg () const {return _cache_arg;} - bool exact_given () const {return _exact_given;} - bool keep_given () const {return _keep_given;} -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - bool libgs_given () const {return _libgs_given;} - const std::string& libgs_arg () const {return _libgs_arg;} -#endif - bool mag_given () const {return _mag_given;} - double mag_arg () const {return _mag_arg;} - bool no_mktexmf_given () const {return _no_mktexmf_given;} - bool no_specials_given () const {return _no_specials_given;} - const std::string& no_specials_arg () const {return _no_specials_arg;} - bool trace_all_given () const {return _trace_all_given;} - bool trace_all_arg () const {return _trace_all_arg;} - bool color_given () const {return _color_given;} - bool help_given () const {return _help_given;} - int help_arg () const {return _help_arg;} - bool list_specials_given () const {return _list_specials_given;} - bool progress_given () const {return _progress_given;} - double progress_arg () const {return _progress_arg;} - bool verbosity_given () const {return _verbosity_given;} - unsigned verbosity_arg () const {return _verbosity_arg;} - bool version_given () const {return _version_given;} - bool version_arg () const {return _version_arg;} - - protected: - void init (); - const CmdLineParserBase::Option* options (size_t *numopts) const; - const char** helplines (size_t *numlines) const; - void handle_page (InputReader &ir, const Option &opt, bool longopt); - void handle_fontmap (InputReader &ir, const Option &opt, bool longopt); -#if !defined(DISABLE_GS) - void handle_eps (InputReader &ir, const Option &opt, bool longopt); -#endif - void handle_bbox (InputReader &ir, const Option &opt, bool longopt); - void handle_output (InputReader &ir, const Option &opt, bool longopt); - void handle_precision (InputReader &ir, const Option &opt, bool longopt); - void handle_stdout (InputReader &ir, const Option &opt, bool longopt); - void handle_no_fonts (InputReader &ir, const Option &opt, bool longopt); - void handle_no_styles (InputReader &ir, const Option &opt, bool longopt); - void handle_zip (InputReader &ir, const Option &opt, bool longopt); - void handle_rotate (InputReader &ir, const Option &opt, bool longopt); - void handle_scale (InputReader &ir, const Option &opt, bool longopt); - void handle_translate (InputReader &ir, const Option &opt, bool longopt); - void handle_transform (InputReader &ir, const Option &opt, bool longopt); - void handle_cache (InputReader &ir, const Option &opt, bool longopt); - void handle_exact (InputReader &ir, const Option &opt, bool longopt); - void handle_keep (InputReader &ir, const Option &opt, bool longopt); -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - void handle_libgs (InputReader &ir, const Option &opt, bool longopt); -#endif - void handle_mag (InputReader &ir, const Option &opt, bool longopt); - void handle_no_mktexmf (InputReader &ir, const Option &opt, bool longopt); - void handle_no_specials (InputReader &ir, const Option &opt, bool longopt); - void handle_trace_all (InputReader &ir, const Option &opt, bool longopt); - void handle_color (InputReader &ir, const Option &opt, bool longopt); - void handle_help (InputReader &ir, const Option &opt, bool longopt); - void handle_list_specials (InputReader &ir, const Option &opt, bool longopt); - void handle_progress (InputReader &ir, const Option &opt, bool longopt); - void handle_verbosity (InputReader &ir, const Option &opt, bool longopt); - void handle_version (InputReader &ir, const Option &opt, bool longopt); - - private: - static const CmdLineParserBase::Option _options[]; - bool _page_given; - std::string _page_arg; - bool _fontmap_given; - std::string _fontmap_arg; -#if !defined(DISABLE_GS) - bool _eps_given; -#endif - bool _bbox_given; - std::string _bbox_arg; - bool _output_given; - std::string _output_arg; - bool _precision_given; - int _precision_arg; - bool _stdout_given; - bool _no_fonts_given; - int _no_fonts_arg; - bool _no_styles_given; - bool _zip_given; - int _zip_arg; - bool _rotate_given; - double _rotate_arg; - bool _scale_given; - std::string _scale_arg; - bool _translate_given; - std::string _translate_arg; - bool _transform_given; - std::string _transform_arg; - bool _cache_given; - std::string _cache_arg; - bool _exact_given; - bool _keep_given; -#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) - bool _libgs_given; - std::string _libgs_arg; -#endif - bool _mag_given; - double _mag_arg; - bool _no_mktexmf_given; - bool _no_specials_given; - std::string _no_specials_arg; - bool _trace_all_given; - bool _trace_all_arg; - bool _color_given; - bool _help_given; - int _help_arg; - bool _list_specials_given; - bool _progress_given; - double _progress_arg; - bool _verbosity_given; - unsigned _verbosity_arg; - bool _version_given; - bool _version_arg; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.cpp deleted file mode 100644 index 30317455ba6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* -** DLLoader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "DLLoader.h" - - -DLLoader::DLLoader (const char *dlname) { -#ifdef __WIN32__ - _handle = LoadLibrary(dlname); -#else - _handle = dlopen(dlname, RTLD_LAZY); -#endif -} - - -DLLoader::~DLLoader () { - if (_handle) { -#ifdef __WIN32__ - FreeLibrary(_handle); -#else - dlclose(_handle); -#endif - } -} - - -/** Loads a function or variable from the dynamic/shared library. - * @param[in] name name of function/variable to load - * @return pointer to loaded symbol, or 0 if the symbol could not be loaded */ -void* DLLoader::loadSymbol (const char *name) { - if (_handle) { -#ifdef __WIN32__ - return (void*)GetProcAddress(_handle, name); -#else - return dlsym(_handle, name); -#endif - } - return 0; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.h deleted file mode 100644 index 3052d13714e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DLLoader.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* -** DLLoader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DLLOADER_H -#define DLLOADER_H - -#ifdef __WIN32__ - #undef NOMINMAX - #define NOMINMAX 1 - #include -#else - #include -#endif - - -class DLLoader -{ - public: - DLLoader (const char *dlname); - virtual ~DLLoader (); - bool loaded () const {return _handle != 0;} - - protected: - DLLoader () : _handle(0) {} - void* loadSymbol (const char *name); - - private: -#ifdef __WIN32__ - HINSTANCE _handle; -#else - void *_handle; -#endif -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.cpp deleted file mode 100644 index f9c95dc3754..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/************************************************************************* -** DVIActions.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "DVIActions.h" - -const double DVIActions::BP = 72.0/72.27; -const double DVIActions::IN = 1.0/72.27; -const double DVIActions::CM = 2.54*IN; -const double DVIActions::MM = 25.4*IN; diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.h deleted file mode 100644 index a3fa86a801c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIActions.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* -** DVIActions.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DVIACTIONS_H -#define DVIACTIONS_H - -#include -#include "Message.h" -#include "types.h" - -class BoundingBox; -struct Font; -class SpecialManager; - - -struct DVIActions -{ - static const double BP; - static const double IN; - static const double CM; - static const double MM; - virtual ~DVIActions () {} - virtual void setChar (double x, double y, unsigned c, const Font *f) {} - virtual void setRule (double x, double y, double height, double width) {} - virtual void moveToX (double x) {} - virtual void moveToY (double y) {} - virtual void defineFont (int num, const Font *font) {} - virtual void setFont (int num, const Font *font) {} - virtual void special (const std::string &s) {} - virtual void preamble (const std::string &cmt) {} - virtual void postamble () {} - virtual void beginPage (unsigned n, Int32 *c) {} - virtual void endPage () {} - virtual BoundingBox& bbox () =0; - virtual const SpecialManager* setProcessSpecials (const char *ignorelist) {return 0;} - virtual void progress (size_t current, size_t total, const char *id=0) {} -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.cpp deleted file mode 100644 index acdb8cd7351..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.cpp +++ /dev/null @@ -1,682 +0,0 @@ -/************************************************************************* -** DVIReader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "types.h" -#include "DVIActions.h" -#include "DVIReader.h" -#include "Font.h" -#include "FontManager.h" -#include "Message.h" -#include "SignalHandler.h" -#include "VectorStream.h" -#include "macros.h" - -using namespace std; - -bool DVIReader::COMPUTE_PAGE_LENGTH = false; - - -DVIReader::DVIReader (istream &is, DVIActions *a) : StreamReader(is), _actions(a) -{ - _inPage = false; - _pageHeight = _pageWidth = 0; - _scaleFactor = 0.0; - _tx = _ty = 0; // no cursor translation - _prevYPos = numeric_limits::min(); - _inPostamble = false; - _totalPages = 0; // we don't know the correct value yet - _currFontNum = 0; - _currPageNum = 0; - _pageLength = 0; - _pagePos = 0; -} - - -DVIActions* DVIReader::replaceActions (DVIActions *a) { - DVIActions *prev_actions = _actions; - _actions = a; - return prev_actions; -} - - -/** Evaluates the next DVI command, and computes the corresponding handler. - * @param[in] compute_size if true, the size of variable-length parameters is computed - * @param[out] handler handler for current DVI command - * @param[out] number of parameter bytes - * @param[out] param the handler must be called with this parameter - * @return opcode of current DVI command */ -int DVIReader::evalCommand (bool compute_size, CommandHandler &handler, int &length, int ¶m) { - struct DVICommand { - CommandHandler handler; - int length; // number of parameter bytes - }; - - /* Each cmdFOO command reads the necessary number of bytes from the stream, so executeCommand - doesn't need to know the exact DVI command format. Some cmdFOO methods are used for multiple - DVI commands because they only differ in length of their parameters. */ - static const DVICommand commands[] = { - {&DVIReader::cmdSetChar, 1}, {&DVIReader::cmdSetChar, 2}, {&DVIReader::cmdSetChar, 3}, {&DVIReader::cmdSetChar, 4}, // 128-131 - {&DVIReader::cmdSetRule, 8}, // 132 - {&DVIReader::cmdPutChar, 1}, {&DVIReader::cmdPutChar, 2}, {&DVIReader::cmdPutChar, 3}, {&DVIReader::cmdPutChar, 4}, // 133-136 - {&DVIReader::cmdPutRule, 8}, // 137 - {&DVIReader::cmdNop, 0}, // 138 - {&DVIReader::cmdBop, 44}, {&DVIReader::cmdEop, 0}, // 139-140 - {&DVIReader::cmdPush, 0}, {&DVIReader::cmdPop, 0}, // 141-142 - {&DVIReader::cmdRight, 1}, {&DVIReader::cmdRight, 2}, {&DVIReader::cmdRight, 3}, {&DVIReader::cmdRight, 4}, // 143-146 - {&DVIReader::cmdW0, 0}, // 147 - {&DVIReader::cmdW, 1}, {&DVIReader::cmdW, 2}, {&DVIReader::cmdW, 3}, {&DVIReader::cmdW, 4}, // 148-151 - {&DVIReader::cmdX0, 0}, // 152 - {&DVIReader::cmdX, 1}, {&DVIReader::cmdX, 2}, {&DVIReader::cmdX, 3}, {&DVIReader::cmdX, 4}, // 153-156 - {&DVIReader::cmdDown, 1}, {&DVIReader::cmdDown, 2}, {&DVIReader::cmdDown, 3}, {&DVIReader::cmdDown, 4}, // 157-160 - {&DVIReader::cmdY0, 0}, // 161 - {&DVIReader::cmdY, 1}, {&DVIReader::cmdY, 2}, {&DVIReader::cmdY, 3}, {&DVIReader::cmdY, 4}, // 162-165 - {&DVIReader::cmdZ0, 0}, // 166 - {&DVIReader::cmdZ, 1}, {&DVIReader::cmdZ, 2}, {&DVIReader::cmdZ, 3}, {&DVIReader::cmdZ, 4}, // 167-170 - {&DVIReader::cmdFontNum, 1}, {&DVIReader::cmdFontNum, 2}, {&DVIReader::cmdFontNum, 3}, {&DVIReader::cmdFontNum, 4}, // 235-238 - {&DVIReader::cmdXXX, 1}, {&DVIReader::cmdXXX, 2}, {&DVIReader::cmdXXX, 3}, {&DVIReader::cmdXXX, 4}, // 239-242 - {&DVIReader::cmdFontDef, 1}, {&DVIReader::cmdFontDef, 2}, {&DVIReader::cmdFontDef, 3}, {&DVIReader::cmdFontDef, 4}, // 243-246 - {&DVIReader::cmdPre, 0}, {&DVIReader::cmdPost, 0}, {&DVIReader::cmdPostPost, 0} // 247-249 - }; - - const int opcode = in().get(); - if (!in() || opcode < 0) // at end of file - throw InvalidDVIFileException("invalid file"); - - param = -1; - if (opcode >= 0 && opcode <= 127) { - handler = &DVIReader::cmdSetChar0; - length = 0; - param = opcode; - } - else if (opcode >= 171 && opcode <= 234) { - handler = &DVIReader::cmdFontNum0; - length = 0; - param = opcode-171; - } - else if (opcode >= 250) { - ostringstream oss; - oss << "undefined DVI command (opcode " << opcode << ')'; - throw DVIException(oss.str()); - } - else { - const int offset = opcode <= 170 ? 128 : 235-(170-128+1); - handler = commands[opcode-offset].handler; - if (!compute_size) - length = commands[opcode-offset].length; - else { - if (opcode >= 239 && opcode <= 242) { // specials - int len = opcode-238; - UInt32 bytes = readUnsigned(len); - in().seekg(-len, ios_base::cur); - length = len+bytes; - } - else if (opcode >= 243 && opcode <= 246) { // fontdefs - int len = opcode-242; - len += 12; - in().seekg(len, ios_base::cur); // skip fontnum, checksum, ssize, dsize - UInt32 bytes = readUnsigned(1); // length of font path - bytes += readUnsigned(1); // length of font name - in().seekg(-len-2, ios_base::cur); - length = len+bytes; - } - else - length = commands[opcode-offset].length; - } - } - if (param < 0) - param = length; - return opcode; -} - - -/** Reads a single DVI command from the current position of the input stream and calls the - * corresponding cmdFOO method. - * @return opcode of the executed command */ -int DVIReader::executeCommand () { - SignalHandler::instance().check(); - CommandHandler handler; - int len; // number of parameter bytes - int param; // parameter of handler - streampos pos = in().tellg(); - int opcode = evalCommand(false, handler, len, param); - (this->*handler)(param); - if (_currPos.v+_ty != _prevYPos) { - _tx = _ty = 0; - _prevYPos = _currPos.v; - } - if (COMPUTE_PAGE_LENGTH && _inPage && _actions) { - // ensure progress() is called at 0% - if (opcode == 139) // bop? - _actions->progress(0, _pageLength); - // ensure progress() is called at 100% - if (in().peek() == 140) // eop reached? - _pagePos = _pageLength; - else - _pagePos += in().tellg()-pos; - _actions->progress(_pagePos, _pageLength); - } - return opcode; -} - - -/** Executes all DVI commands read from the input stream. */ -void DVIReader::executeAll () { - int opcode = 0; - while (!in().eof() && opcode >= 0) { - try { - opcode = executeCommand(); - } - catch (const InvalidDVIFileException &e) { - // end of stream reached - opcode = -1; - } - } -} - - -#if 0 -/** Executes all DVI commands from the preamble to postpost. */ -bool DVIReader::executeDocument () { - in().clear(); // reset all status bits - if (!in()) - return false; - in().seekg(0); // move file pointer to first byte of the input stream - while (!in().eof() && executeCommand() != 249); // stop reading after postpost (249) - return true; -} - -bool DVIReader::executeAllPages () { - in().clear(); // reset all status bits - if (!in()) - return false; - in().seekg(0); // move file pointer to first byte of the input stream - while (!in().eof() && executeCommand() != 248); // stop reading when postamble (248) is reached - return true; -} -#endif - - -/** Reads and executes the commands of a single page. - * This methods stops reading after the page's eop command has been executed. - * @param[in] n number of page to be executed - * @returns true if page was read successfully */ -bool DVIReader::executePage (unsigned n) { - in().clear(); // reset all status bits - if (!in()) - throw DVIException("invalid DVI file"); - in().seekg(-1, ios_base::end); // stream pointer to last byte - while (in().peek() == 223) - in().seekg(-1, ios_base::cur); // skip fill bytes - in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) - UInt32 q = readUnsigned(4); // pointer to begin of postamble - in().seekg(q, ios_base::beg); // now on begin of postamble - if (executeCommand() != 248) // execute postamble command but not the fontdefs - return false; - if (n < 1 || n > _totalPages) - return false; - in().seekg(_prevBop, ios_base::beg); // now on last bop - _inPostamble = false; // we jumped out of the postamble - unsigned pageCount = _totalPages; - for (; pageCount > n && _prevBop > 0; pageCount--) { - in().seekg(41, ios_base::cur); // skip bop and 10*4 \count bytes => now on pointer to prev bop - _prevBop = readSigned(4); - in().seekg(_prevBop, ios_base::beg); - } - _currPageNum = n; - while (pageCount == n && executeCommand() != 140); // 140 == eop - return true; -} - - -bool DVIReader::executePages (unsigned first, unsigned last) { - in().clear(); - if (!in()) - throw DVIException("invalid DVI file"); - if (first > last) - swap(first, last); - in().seekg(-1, ios_base::end); // stream pointer to last byte - while (in().peek() == 223) - in().seekg(-1, ios_base::cur); // skip fill bytes - in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) - UInt32 q = readUnsigned(4); // pointer to begin of postamble - in().seekg(q, ios_base::beg); // now on begin of postamble - if (executeCommand() != 248) // execute postamble command but not the fontdefs - return false; - first = max(1u, min(first, _totalPages)); - last = max(1u, min(last, _totalPages)); - in().seekg(_prevBop, ios_base::beg); // now on last bop - _inPostamble = false; // we jumped out of the postamble - unsigned count = _totalPages; - for (; count > first && _prevBop > 0; count--) { - in().seekg(41, ios_base::cur); // skip bop and 10*4 \count bytes => now on pointer to prev bop - _prevBop = readSigned(4); - in().seekg(_prevBop, ios_base::beg); - } - while (first <= last) { - _currPageNum = first++; - while (executeCommand () != 140); // 140 == eop - } - return true; -} - - -void DVIReader::executePreamble () { - in().clear(); - if (!in()) - throw DVIException("invalid DVI file"); - in().seekg(0, ios_base::beg); - if (in().get() != 247) - throw DVIException("invalid DVI file"); - cmdPre(0); -} - - -/** Reads and executes the commands of the postamble. */ -void DVIReader::executePostamble () { - in().clear(); // reset all status bits - if (!in()) - throw DVIException("invalid DVI file"); - in().seekg(-1, ios_base::end); // stream pointer to last byte - while (in().peek() == 223) - in().seekg(-1, ios_base::cur); // skip fill bytes - - in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) - UInt32 q = readUnsigned(4); // pointer to begin of postamble - in().seekg(q, ios_base::beg); // now on begin of postamble - while (executeCommand() != 249); // read all commands until postpost (= 249) is reached -} - - -/** Returns the current x coordinate in TeX point units. - * This is the horizontal position where the next output would be placed. */ -double DVIReader::getXPos () const { - return _currPos.h+_tx; -} - - -/** Returns the current y coordinate in TeX point units. - * This is the vertical position where the next output would be placed. */ -double DVIReader::getYPos () const { - return _currPos.v+_ty; -} - - -double DVIReader::getPageHeight () const { - return _pageHeight; -} - - -double DVIReader::getPageWidth () const { - return _pageWidth; -} - -///////////////////////////////////// - -/** Reads and executes DVI preamble command. */ -void DVIReader::cmdPre (int) { - UInt32 i = readUnsigned(1); // identification number (should be 2) - UInt32 num = readUnsigned(4); // numerator units of measurement - UInt32 den = readUnsigned(4); // denominator units of measurement - _mag = readUnsigned(4); // magnification - UInt32 k = readUnsigned(1); // length of following comment - string cmt = readString(k); // comment - if (i != 2) { - ostringstream oss; - oss << "DVI format version " << i << " not supported"; - throw DVIException(oss.str()); - } - // 1 dviunit * num/den == multiples of 0.0000001m - // 1 dviunit * _scaleFactor: length of 1 dviunit in TeX points * _mag/1000 - _scaleFactor = num/25400000.0*7227.0/den*_mag/1000.0; - if (_actions) - _actions->preamble(cmt); -} - - -/** Reads and executes DVI postamble command. */ -void DVIReader::cmdPost (int) { - _prevBop = readUnsigned(4); // pointer to previous bop - UInt32 num = readUnsigned(4); - UInt32 den = readUnsigned(4); - _mag = readUnsigned(4); - _pageHeight = readUnsigned(4); // height of tallest page in dvi units - _pageWidth = readUnsigned(4); // width of widest page in dvi units - readUnsigned(2); // max. stack depth - _totalPages = readUnsigned(2); // total number of pages - // 1 dviunit * num/den == multiples of 0.0000001m - // 1 dviunit * _scaleFactor: length of 1 dviunit in TeX points * _mag/1000 - _scaleFactor = num/25400000.0*7227.0/den*_mag/1000.0; - _pageHeight *= _scaleFactor; // to pt units - _pageWidth *= _scaleFactor; - _inPostamble = true; - if (_actions) - _actions->postamble(); -} - - -/** Reads and executes DVI postpost command. */ -void DVIReader::cmdPostPost (int) { - _inPostamble = false; - readUnsigned(4); // pointer to begin of postamble - UInt32 i = readUnsigned(1); // identification byte (should be 2) - if (i == 2) - while (readUnsigned(1) == 223); // skip fill bytes (223), eof bit should be set now - else - throw DVIException("invalid identification value in postpost"); -} - - -/** Reads and executes Begin-Of-Page command. */ -void DVIReader::cmdBop (int) { - Int32 c[10]; - for (int i=0; i < 10; i++) - c[i] = readSigned(4); - readSigned(4); // pointer to peceeding bop (-1 in case of first page) - _currPos.reset(); // set all DVI registers to 0 - while (!_posStack.empty()) - _posStack.pop(); - _currFontNum = 0; - _inPage = true; - _pageLength = 0; - _pagePos = 0; - if (COMPUTE_PAGE_LENGTH) { - // compute number of bytes in current page - int length, param; - CommandHandler handler; - // read all commands until eop is found - while (evalCommand(true, handler, length, param) != 140) { - in().seekg(length, ios_base::cur); - _pageLength += length+1; // parameter length + opcode length (1 byte) - } - ++_pageLength; // add length of eop command (1 byte) - in().seekg(-int(_pageLength), ios_base::cur); // go back to first command following bop - _pageLength += 45; // add length of bop command - } - beginPage(_currPageNum, c); - if (_actions) - _actions->beginPage(_currPageNum, c); -} - - -/** Reads and executes End-Of-Page command. */ -void DVIReader::cmdEop (int) { - if (!_posStack.empty()) - throw DVIException("stack not empty at end of page"); - _inPage = false; - endPage(); - if (_actions) - _actions->endPage(); -} - - -/** Reads and executes push command. */ -void DVIReader::cmdPush (int) { - _posStack.push(_currPos); -} - - -/** Reads and executes pop command (restores pushed position information). */ -void DVIReader::cmdPop (int) { - if (_posStack.empty()) - throw DVIException("stack empty at pop command"); - else { - DVIPosition prevPos = _currPos; - _currPos = _posStack.top(); - _posStack.pop(); - if (_actions) { - if (prevPos.h != _currPos.h) - _actions->moveToX(_currPos.h + _tx); - if (prevPos.v != _currPos.v) - _actions->moveToY(_currPos.v + _ty); - } - } -} - - -/** Helper function that actually sets/puts a charater. It is called by the - * cmdSetChar and cmdPutChar methods. - * @param[in] c character to typeset - * @param[in] moveCursor if true, register h is increased by the character width - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::putChar (UInt32 c, bool moveCursor) { - if (!_inPage) - throw DVIException("set_char or put_char outside of page"); - - FontManager &fm = FontManager::instance(); - Font *font = fm.getFont(_currFontNum); - if (!font) - throw DVIException("no font selected"); - - if (VirtualFont *vf = dynamic_cast(font)) { // is current font a virtual font? - vector *dvi = const_cast*>(vf->getDVI(c)); // get DVI snippet that describes character c - if (dvi) { - DVIPosition pos = _currPos; // save current cursor position - _currPos.x = _currPos.y = _currPos.w = _currPos.z = 0; - int save_fontnum = _currFontNum; // save current font number - fm.enterVF(vf); // new font number context - cmdFontNum0(fm.vfFirstFontNum(vf)); - double save_scale = _scaleFactor; - _scaleFactor = vf->scaledSize()/(1 << 20); - - VectorInputStream vis(*dvi); - istream &is = replaceStream(vis); - try { - executeAll(); // execute DVI fragment - } - catch (const DVIException &e) { - // Message::estream(true) << "invalid dvi in vf: " << e.getMessage() << endl; // @@ - } - replaceStream(is); // restore previous input stream - _scaleFactor = save_scale; // restore previous scale factor - fm.leaveVF(); // restore previous font number context - cmdFontNum0(save_fontnum); // restore previous font number - _currPos = pos; // restore previous cursor position - } - } - else if (_actions) { - _actions->setChar(_currPos.h+_tx, _currPos.v+_ty, c, font); - } - if (moveCursor) - _currPos.h += font->charWidth(c) * font->scaleFactor() * _mag/1000.0; -} - - -/** Reads and executes set_char_x command. Puts a character at the current - * position and advances the cursor. - * @param[in] c character to set - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::cmdSetChar0 (int c) { - putChar(c, true); -} - - -/** Reads and executes setx command. Puts a character at the current - * position and advances the cursor. - * @param[in] len number of parameter bytes (possible values: 1-4) - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::cmdSetChar (int len) { - // According to the dvi specification all character codes are unsigned - // except len == 4. At the moment all char codes are treated as unsigned... - UInt32 c = readUnsigned(len); // if len == 4 c may be signed - putChar(c, true); -} - - -/** Reads and executes putx command. Puts a character at the current - * position but doesn't change the cursor position. - * @param[in] len number of parameter bytes (possible values: 1-4) - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::cmdPutChar (int len) { - // According to the dvi specification all character codes are unsigned - // except len == 4. At the moment all char codes are treated as unsigned... - Int32 c = readUnsigned(len); - putChar(c, false); -} - - -/** Reads and executes set_rule command. Puts a solid rectangle at the current - * position and updates the cursor position. - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::cmdSetRule (int) { - if (_inPage) { - double height = _scaleFactor*readSigned(4); - double width = _scaleFactor*readSigned(4); - if (_actions && height > 0 && width > 0) - _actions->setRule(_currPos.h+_tx, _currPos.v+_ty, height, width); - _currPos.h += width; - if (_actions && (height <= 0 || width <= 0)) - _actions->moveToX(_currPos.h+_tx); - } - else - throw DVIException("set_rule outside of page"); -} - - -/** Reads and executes set_rule command. Puts a solid rectangle at the current - * position but leaves the cursor position unchanged. - * @throw DVIException if method is called ouside a bop/eop pair */ -void DVIReader::cmdPutRule (int) { - if (_inPage) { - double height = _scaleFactor*readSigned(4); - double width = _scaleFactor*readSigned(4); - if (_actions && height > 0 && width > 0) - _actions->setRule(_currPos.h+_tx, _currPos.v+_ty, height, width); - } - else - throw DVIException("put_rule outside of page"); -} - - -void DVIReader::cmdNop (int) {} - -void DVIReader::cmdRight (int len) {_currPos.h += _scaleFactor*readSigned(len); if (_actions) _actions->moveToX(_currPos.h+_tx);} -void DVIReader::cmdDown (int len) {_currPos.v += _scaleFactor*readSigned(len); if (_actions) _actions->moveToY(_currPos.v+_ty);} -void DVIReader::cmdX0 (int) {_currPos.h += _currPos.x; if (_actions) _actions->moveToX(_currPos.h+_tx);} -void DVIReader::cmdY0 (int) {_currPos.v += _currPos.y; if (_actions) _actions->moveToY(_currPos.v+_ty);} -void DVIReader::cmdW0 (int) {_currPos.h += _currPos.w; if (_actions) _actions->moveToX(_currPos.h+_tx);} -void DVIReader::cmdZ0 (int) {_currPos.v += _currPos.z; if (_actions) _actions->moveToY(_currPos.v+_ty);} -void DVIReader::cmdX (int len) {_currPos.x = _scaleFactor*readSigned(len); cmdX0(0);} -void DVIReader::cmdY (int len) {_currPos.y = _scaleFactor*readSigned(len); cmdY0(0);} -void DVIReader::cmdW (int len) {_currPos.w = _scaleFactor*readSigned(len); cmdW0(0);} -void DVIReader::cmdZ (int len) {_currPos.z = _scaleFactor*readSigned(len); cmdZ0(0);} - - -void DVIReader::cmdXXX (int len) { - if (_inPage) { - UInt32 numBytes = readUnsigned(len); - string s = readString(numBytes); - if (_actions) - _actions->special(s); - } - else - throw DVIException("special outside of page"); -} - - -/** Selects a previously defined font by its number. - * @param[in] num font number - * @throw DVIException if font number is undefined */ -void DVIReader::cmdFontNum0 (int num) { - if (Font *font = FontManager::instance().getFont(num)) { - _currFontNum = num; - if (_actions && !dynamic_cast(font)) - _actions->setFont(FontManager::instance().fontID(num), font); // all fonts get a recomputed ID - } - else { - ostringstream oss; - oss << "undefined font number " << num; - throw DVIException(oss.str()); - } -} - - -/** Selects a previously defined font. - * @param[in] len size of font number variable (in bytes) - * @throw DVIException if font number is undefined */ -void DVIReader::cmdFontNum (int len) { - UInt32 num = readUnsigned(len); - cmdFontNum0(num); -} - - -/** Helper function to handle a font definition. - * @param[in] fontnum local font number - * @param[in] name font name - * @param[in] checksum checksum to be compared with TFM checksum - * @param[in] ds design size in TeX point units - * @param[in] ss scaled size in TeX point units */ -void DVIReader::defineFont (UInt32 fontnum, const string &name, UInt32 cs, double ds, double ss) { - FontManager &fm = FontManager::instance(); - int id = fm.registerFont(fontnum, name, cs, ds, ss); - Font *font = fm.getFontById(id); - if (VirtualFont *vf = dynamic_cast(font)) { - // read vf file, register its font and character definitions - fm.enterVF(vf); - ifstream ifs(vf->path(), ios::binary); - VFReader vfReader(ifs); - vfReader.replaceActions(this); - vfReader.executeAll(); - fm.leaveVF(); - } - if (_actions) - _actions->defineFont(id, font); -} - - -/** Defines a new font. - * @param[in] len size of font number variable (in bytes) */ -void DVIReader::cmdFontDef (int len) { - UInt32 fontnum = readUnsigned(len); // font number - UInt32 checksum = readUnsigned(4); // font checksum (to be compared with corresponding TFM checksum) - UInt32 ssize = readUnsigned(4); // scaled size of font in DVI units - UInt32 dsize = readUnsigned(4); // design size of font in DVI units - UInt32 pathlen = readUnsigned(1); // length of font path - UInt32 namelen = readUnsigned(1); // length of font name - string fontpath = readString(pathlen); - string fontname = readString(namelen); - - // process font definitions between bop and eop only, skip those in the postamble - if (_inPage) - defineFont(fontnum, fontname, checksum, dsize*_scaleFactor, ssize*_scaleFactor); -} - - -/** This template method is called by the VFReader after reading a font definition from a VF file. - * @param[in] fontnum local font number - * @param[in] name font name - * @param[in] checksum checksum to be compared with TFM checksum - * @param[in] dsize design size in TeX point units - * @param[in] ssize scaled size in TeX point units */ -void DVIReader::defineVFFont (UInt32 fontnum, string path, string name, UInt32 checksum, double dsize, double ssize) { - VirtualFont *vf = FontManager::instance().getVF(); - defineFont(fontnum, name, checksum, dsize, ssize * vf->scaleFactor()); -} - - -/** This template method is called by the VFReader after reading a character definition from a VF file. - * @param[in] c character number - * @param[in] dvi DVI fragment describing the character */ -void DVIReader::defineVFChar (UInt32 c, vector *dvi) { - FontManager::instance().assignVfChar(c, dvi); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.h deleted file mode 100644 index 1a1163900d6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIReader.h +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************* -** DVIReader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DVIREADER_H -#define DVIREADER_H - -#include -#include -#include -#include -#include "MessageException.h" -#include "StreamReader.h" -#include "VFActions.h" -#include "types.h" - - -struct DVIException : public MessageException -{ - DVIException (const std::string &msg) : MessageException(msg) {} -}; - -struct InvalidDVIFileException : public DVIException -{ - InvalidDVIFileException(const std::string &msg) : DVIException(msg) {} -}; - -struct DVIActions; -struct FileFinder; - -class DVIReader : public StreamReader, protected VFActions -{ - typedef void (DVIReader::*CommandHandler)(int); - - struct DVIPosition - { - double h, v; - double x, w, y, z; - DVIPosition () {reset();} - void reset () {h = v = x = w = y = z = 0.0;} - }; - - public: - DVIReader (std::istream &is, DVIActions *a=0); - - bool executeDocument (); - void executeAll (); - bool executeAllPages (); - void executePreamble (); - void executePostamble (); - bool executePage (unsigned n); - bool executePages (unsigned first, unsigned last); - bool inPostamble () const {return _inPostamble;} - double getXPos () const; - double getYPos () const; - void finishLine () {_prevYPos = std::numeric_limits::min();} - void translateToX (double x) {_tx=x-_currPos.h-_tx;} - void translateToY (double y) {_ty=y-_currPos.v-_ty;} - double getPageWidth () const; - double getPageHeight () const; - int getCurrentFontNumber () const {return _currFontNum;} - unsigned getCurrentPageNumber () const {return _currPageNum;} - unsigned getTotalPages () const {return _totalPages;} - DVIActions* getActions () const {return _actions;} - DVIActions* replaceActions (DVIActions *a); - - protected: - int executeCommand (); - int evalCommand (bool compute_size, CommandHandler &handler, int &length, int ¶m); - void putChar (UInt32 c, bool moveCursor); - void defineFont (UInt32 fontnum, const std::string &name, UInt32 cs, double ds, double ss); - virtual void beginPage (unsigned n, Int32 *c) {} - virtual void endPage () {} - - // VFAction methods - void defineVFFont (UInt32 fontnum, std::string path, std::string name, UInt32 checksum, double dsize, double ssize); - void defineVFChar (UInt32 c, std::vector *dvi); - - // the following methods represent the DVI commands - // they are called by executeCommand and should not be used directly - void cmdSetChar0 (int c); - void cmdSetChar (int len); - void cmdPutChar (int len); - void cmdSetRule (int len); - void cmdPutRule (int len); - void cmdNop (int len); - void cmdBop (int len); - void cmdEop (int len); - void cmdPush (int len); - void cmdPop (int len); - void cmdRight (int len); - void cmdDown (int len); - void cmdX0 (int len); - void cmdY0 (int len); - void cmdW0 (int len); - void cmdZ0 (int len); - void cmdX (int len); - void cmdY (int len); - void cmdW (int len); - void cmdZ (int len); - void cmdFontDef (int len); - void cmdFontNum0 (int n); - void cmdFontNum (int len); - void cmdXXX (int len); - void cmdPre (int len); - void cmdPost (int len); - void cmdPostPost (int len); - - private: - DVIActions *_actions; ///< actions to be performed on various DVI events - bool _inPage; ///< true if between bop and eop - unsigned _totalPages; ///< total number of pages in dvi file - unsigned _currPageNum; ///< current page number - int _currFontNum; ///< current font number - double _scaleFactor; ///< 1 dvi unit = scaleFactor * TeX points - UInt32 _mag; ///< magnification factor * 1000 - bool _inPostamble; ///< true if stream pointer is inside the postamble - Int32 _prevBop; ///< pointer to previous bop - double _pageHeight, _pageWidth; ///< page height and width in TeX points - DVIPosition _currPos; ///< current cursor position - std::stack _posStack; - double _prevYPos; ///< previous vertical cursor position - double _tx, _ty; ///< tranlation of cursor position - size_t _pageLength; ///< number of bytes between current bop end eop - std::streampos _pagePos; ///< distance of current DVI command from bop (in bytes) - - public: - static bool COMPUTE_PAGE_LENGTH; ///< if true, the bop handler computes the number of bytes of the current page -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.cpp deleted file mode 100644 index 24481b670c7..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/************************************************************************* -** DVIToSVG.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifdef HAVE_CONFIG_H - #include "config.h" - #ifdef TARGET_SYSTEM - #define VERSION_STR VERSION " (" TARGET_SYSTEM ")" - #else - #define VERSION_STR VERSION - #endif -#else - #define VERSION_STR "" -#endif - -#include -#include -#include -#include -#include "Calculator.h" -#include "DVIToSVG.h" -#include "DVIToSVGActions.h" -#include "Font.h" -#include "FontManager.h" -#include "FileFinder.h" -#include "GlyphTracerMessages.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "Matrix.h" -#include "Message.h" -#include "PageRanges.h" -#include "PageSize.h" -#include "SVGOutputBase.h" -#include "SVGTree.h" -#include "TFM.h" -#include "XMLDocument.h" -#include "XMLDocTypeNode.h" -#include "XMLNode.h" -#include "XMLString.h" -// -/////////////////////////////////// -// special handlers - -#include "BgColorSpecialHandler.h" -#include "ColorSpecialHandler.h" -#include "DvisvgmSpecialHandler.h" -#include "EmSpecialHandler.h" -#include "NoPsSpecialHandler.h" -#include "PdfSpecialHandler.h" -//#include "HtmlSpecialHandler.h" -#if !defined(DISABLE_GS) - #include "PsSpecialHandler.h" -#endif -#include "TpicSpecialHandler.h" -/////////////////////////////////// - - -using namespace std; - - -/** Returns time stamp of current date/time. */ -static string datetime () { - time_t t; - time(&t); - struct tm *tm = localtime(&t); - char *timestr = asctime(tm); - timestr[24] = 0; // remove newline - return timestr; -} - -class PSHeaderActions : public DVIActions -{ - public : - PSHeaderActions (DVIToSVG &dvisvg) : _dvisvg(dvisvg) {} - - void special (const std::string &s) { - // execute PS headers only - if (!s.empty() && (s[0] == '!' || s.substr(0, 7) == "header=")) - _dvisvg.specialManager().process(s, 0); - } - - BoundingBox& bbox () {return _bbox;} - - private: - DVIToSVG &_dvisvg; - BoundingBox _bbox; -}; - - -/** 'a': trace all glyphs even if some of them are already cached - * 'm': trace missing glyphs, i.e. glyphs not yet cached - * 0 : only trace actually required glyphs */ -char DVIToSVG::TRACE_MODE = 0; - - -DVIToSVG::DVIToSVG (istream &is, SVGOutputBase &out) : DVIReader(is), _out(out) -{ - replaceActions(new DVIToSVGActions(*this, _svg)); -} - - -DVIToSVG::~DVIToSVG () { - delete replaceActions(0); -} - - -/** Starts the conversion process. - * @param[in] first number of first page to convert - * @param[in] last number of last page to convert - * @param[out] pageinfo (number of converted pages, number of total pages) */ -void DVIToSVG::convert (unsigned first, unsigned last, pair *pageinfo) { - if (getTotalPages() == 0) { - executePreamble(); - executePostamble(); // collect scaling information - } - if (first > last) - swap(first, last); - if (first > getTotalPages()) { - ostringstream oss; - oss << "file contains only " << getTotalPages() << " page"; - if (getTotalPages() > 1) - oss << 's'; - throw DVIException(oss.str()); - } - last = min(last, getTotalPages()); - - if (first > 1) { - // ensure loading of PostScript prologues given at the beginning of the first page - // (prologue files are always referenced in first page) - PSHeaderActions headerActions(*this); - DVIActions *save = replaceActions(&headerActions); - executePage(1); - replaceActions(save); - } - for (unsigned i=first; i <= last; ++i) { - executePage(i); - embedFonts(_svg.rootNode()); - _svg.write(_out.getPageStream(getCurrentPageNumber(), getTotalPages())); - string fname = _out.filename(i, getTotalPages()); - Message::mstream(false, Message::MC_PAGE_WRITTEN) << "\npage written to " << (fname.empty() ? "" : fname) << '\n'; - _svg.reset(); - static_cast(getActions())->reset(); - } - if (pageinfo) { - pageinfo->first = last-first+1; - pageinfo->second = getTotalPages(); - } -} - - -/** Convert DVI pages specified by a page range string. - * @param[in] rangestr string describing the pages to convert - * @param[out] pageinfo (number of converted pages, number of total pages) */ -void DVIToSVG::convert (const string &rangestr, pair *pageinfo) { - if (getTotalPages() == 0) { - executePreamble(); - executePostamble(); // collect scaling information - } - PageRanges ranges; - if (!ranges.parse(rangestr, getTotalPages())) - throw MessageException("invalid page range format"); - FORALL(ranges, PageRanges::ConstIterator, it) - convert(it->first, it->second); - if (pageinfo) { - pageinfo->first = ranges.pages(); - pageinfo->second = getTotalPages(); - } -} - - -/** This template method is called by parent class DVIReader before - * executing the BOP actions. - * @param[in] c contains information about the page (page number etc.) */ -void DVIToSVG::beginPage (unsigned n, Int32 *c) { - if (dynamic_cast(getActions())) { - Message::mstream().indent(0); - Message::mstream(false, Message::MC_PAGE_NUMBER) << "processing page " << n << " [" << c[0] << ']'; - Message::mstream().indent(1); - _svg.appendToDoc(new XMLCommentNode(" This file was generated by dvisvgm " VERSION_STR " ")); - _svg.appendToDoc(new XMLCommentNode(" " + datetime() + " ")); - } -} - - -/** This template method is called by parent class DVIReader before - * executing the EOP actions. */ -void DVIToSVG::endPage () { - if (!dynamic_cast(getActions())) - return; - - _specialManager.notifyEndPage(); - // set bounding box and apply page transformations - BoundingBox &bbox = getActions()->bbox(); - if (!_transCmds.empty()) { - Calculator calc; - calc.setVariable("ux", bbox.minX()); - calc.setVariable("uy", bbox.minY()); - calc.setVariable("w", bbox.width()); - calc.setVariable("h", bbox.height()); - calc.setVariable("pt", 1); - calc.setVariable("in", 72.27); - calc.setVariable("cm", 72.27/2.54); - calc.setVariable("mm", 72.27/25.4); - Matrix matrix(_transCmds, calc); - static_cast(getActions())->setPageMatrix(matrix); - if (_bboxString == "min") - bbox.transform(matrix); - } - if (string("dvi none min").find(_bboxString) == string::npos) { - istringstream iss(_bboxString); - StreamInputReader ir(iss); - ir.skipSpace(); - if (isalpha(ir.peek())) { - // set explicitly given page format - PageSize size(_bboxString); - if (size.valid()) { - // convention: DVI position (0,0) equals (1in, 1in) relative - // to the upper left vertex of the page (see DVI specification) - const double border = -72.27; - bbox = BoundingBox(border, border, size.widthInPT()+border, size.heightInPT()+border); - } - } - else { // set/modify bounding box by explicitly given values - try { - bbox.set(_bboxString); - } - catch (const MessageException &e) { - } - } - } - else if (_bboxString == "dvi") { - // center page content - double dx = (getPageWidth()-bbox.width())/2; - double dy = (getPageHeight()-bbox.height())/2; - bbox += BoundingBox(-dx, -dy, dx, dy); - } - if (_bboxString != "none") { - if (bbox.width() == 0) - Message::wstream(false) << "\npage is empty\n"; - else { - _svg.setBBox(bbox); - - Message::mstream(false) << '\n'; - Message::mstream(false, Message::MC_PAGE_SIZE) << "page size: " << bbox.width() << "pt" - " x " << bbox.height() << "pt" - " (" << bbox.width()/72.27*25.4 << "mm" - " x " << bbox.height()/72.27*25.4 << "mm)"; - Message::mstream(false) << '\n'; - } - } -} - - -static void collect_chars (map > &fm) { - typedef const map > UsedCharsMap; - FORALL(fm, UsedCharsMap::const_iterator, it) { - if (it->first->uniqueFont() != it->first) { - FORALL(it->second, set::const_iterator, cit) - fm[it->first->uniqueFont()].insert(*cit); - } - } -} - - -/** Adds the font information to the SVG tree. - * @param[in] svgElement the font nodes are added to this node */ -void DVIToSVG::embedFonts (XMLElementNode *svgElement) { - if (!svgElement) - return; - if (!getActions()) // no dvi actions => no chars written => no fonts to embed - return; - - typedef map > UsedCharsMap; - const DVIToSVGActions *svgActions = static_cast(getActions()); - UsedCharsMap &usedChars = svgActions->getUsedChars(); - - collect_chars(usedChars); - - GlyphTracerMessages messages; - FORALL(usedChars, UsedCharsMap::const_iterator, it) { - const Font *font = it->first; - if (const PhysicalFont *ph_font = dynamic_cast(font)) { - if (TRACE_MODE) - ph_font->traceAllGlyphs(TRACE_MODE == 'a', &messages); - - if (font->path()) // does font file exist? - _svg.append(*ph_font, it->second, &messages); - else - Message::wstream(true) << "can't embed font '" << font->name() << "'\n"; - } - else - Message::wstream(true) << "can't embed font '" << font->name() << "'\n"; - } - _svg.appendFontStyles(svgActions->getUsedFonts()); -} - - -/** Enables or disables processing of specials. If ignorelist == 0, all - * supported special handlers are loaded. To disable selected sets of specials, - * the corresponding prefixes can be given separated by non alpha-numeric characters, - * e.g. "color, ps, em" or "color: ps em" etc. - * A single "*" in the ignore list disables all specials. - * @param[in] ignorelist list of special prefixes to ignore - * @param[in] pswarning if true, shows warning about disabled PS support - * @return the SpecialManager that handles special statements */ -const SpecialManager* DVIToSVG::setProcessSpecials (const char *ignorelist, bool pswarning) { - if (ignorelist && strcmp(ignorelist, "*") == 0) { // ignore all specials? - _specialManager.unregisterHandlers(); - } - else { - // add special handlers - SpecialHandler *handlers[] = { - 0, // placeholder for PsSpecialHandler - new BgColorSpecialHandler, // handles background color special - new ColorSpecialHandler, // handles color specials - new DvisvgmSpecialHandler, // handles raw SVG embeddings - new EmSpecialHandler, // handles emTeX specials - new PdfSpecialHandler, // handles pdf specials -// new HtmlSpecialHandler, // handles hyperref specials - new TpicSpecialHandler, // handles tpic specials - 0 - }; - SpecialHandler **p = handlers; -#if !defined(DISABLE_GS) - if (Ghostscript().available()) - *p = new PsSpecialHandler; - else -#endif - { - *p = new NoPsSpecialHandler; // dummy PS special handler that only prints warning messages - if (pswarning) { -#if defined(DISABLE_GS) - Message::wstream() << "this build of dvisvgm doesn't support the processing of PostScript specials\n"; -#else - Message::wstream() << "processing of PostScript specials is disabled (Ghostscript not found)\n"; -#endif - } - } - _specialManager.unregisterHandlers(); - _specialManager.registerHandlers(p, ignorelist); - } - return &_specialManager; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.h deleted file mode 100644 index 0efc86a8a07..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVG.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************* -** DVIToSVG.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DVITOSVG_H -#define DVITOSVG_H - -#include -#include -#include -#include "DVIReader.h" -#include "SpecialManager.h" -#include "SVGTree.h" - -struct SVGOutputBase; - -class DVIToSVG : public DVIReader -{ - public: - DVIToSVG (std::istream &is, SVGOutputBase &out); - ~DVIToSVG (); - void convert (unsigned firstPage, unsigned lastPage, std::pair *pageinfo=0); - void convert (const std::string &range, std::pair *pageinfo=0); - const SpecialManager* setProcessSpecials (const char *ignorelist=0, bool pswarning=false); - const SpecialManager& specialManager () const {return _specialManager;} - void setPageSize (const std::string &name) {_bboxString = name;} - void setTransformation (const std::string &cmds) {_transCmds = cmds;} - - public: - static char TRACE_MODE; - - protected: - DVIToSVG (const DVIToSVG &); - DVIToSVG operator = (const DVIToSVG &); - void beginPage (unsigned n, Int32 *c); - void endPage (); - void embedFonts (XMLElementNode *svgElement); - - private: - SVGTree _svg; - SVGOutputBase &_out; - std::string _bboxString; - std::string _transCmds; - SpecialManager _specialManager; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.cpp deleted file mode 100644 index 26637ac07b6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/************************************************************************* -** DVIToSVGActions.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "BoundingBox.h" -#include "DVIToSVG.h" -#include "DVIToSVGActions.h" -#include "Font.h" -#include "FontManager.h" -#include "GlyphTracerMessages.h" -#include "SpecialManager.h" -#include "System.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -double DVIToSVGActions::PROGRESSBAR_DELAY=1000; // initial delay in seconds (values >= 1000 disable the progressbar) -bool DVIToSVGActions::EXACT_BBOX = false; - - -DVIToSVGActions::DVIToSVGActions (DVIToSVG &dvisvg, SVGTree &svg) - : _svg(svg), _dvisvg(dvisvg), _pageMatrix(0), _bgcolor(Color::TRANSPARENT), _boxes(0) -{ - _currentFontNum = -1; - _pageCount = 0; -} - - -DVIToSVGActions::~DVIToSVGActions () { - delete _pageMatrix; - delete _boxes; -} - - -void DVIToSVGActions::reset() { - _usedChars.clear(); - _usedFonts.clear(); - _bbox = BoundingBox(); - _currentFontNum = -1; - _bgcolor = Color::TRANSPARENT; -} - - -void DVIToSVGActions::setPageMatrix (const Matrix &matrix) { - delete _pageMatrix; - _pageMatrix = new Matrix(matrix); -} - - -void DVIToSVGActions::moveToX (double x) { - _dvisvg.specialManager().notifyPositionChange(getX(), getY()); - _svg.setX(getX()); // get current horizontal DVI position -} - - -void DVIToSVGActions::moveToY (double y) { - _dvisvg.specialManager().notifyPositionChange(getX(), getY()); - _svg.setY(y); -} - - -/** This method is called when a "set char" command was found in the DVI file. - * It draws a character of the current font. - * @param[in] x horizontal position of left bounding box edge - * @param[in] y vertical position of the character's baseline - * @param[in] c character code relative to the current font - * @param[in] font font to be used */ -void DVIToSVGActions::setChar (double x, double y, unsigned c, const Font *font) { - // If we use SVG fonts there is no need to record all font name/char/size combinations - // because the SVG font mechanism handles this automatically. It's sufficient to - // record font names and chars. The various font sizes can be ignored here. - // For a given font object, Font::uniqueFont() returns the same unique font object for - // all fonts with the same name. - _usedChars[SVGTree::USE_FONTS ? font->uniqueFont() : font].insert(c); - - // However, we record all required fonts - _usedFonts.insert(font); - - _svg.appendChar(c, x, y, *font); - // update bounding box - double wl=0, wr=0, h=0, d=0; // left/right width, height, and depth of character c - static string fontname; - GlyphTracerMessages callback(fontname != font->name(), false); - fontname = font->name(); - BoundingBox charbox; - const PhysicalFont *ph_font = dynamic_cast(font); - if (EXACT_BBOX && ph_font && ph_font->getGlyphBox(c, charbox, &callback)) { - if ((wl = charbox.minX()) > 0) wl=0; - if ((wr = charbox.maxX()) < 0) wr=0; - if ((h = charbox.maxY()) < 0) h=0; - if ((d = -charbox.minY()) < 0) d=0; - } - else { - double s = font->scaleFactor(); - wr = s*(font->charWidth(c) + font->italicCorr(c)); - h = s*font->charHeight(c); - d = s*font->charDepth(c); - } - - BoundingBox bbox(x+wl, y-h, x+wr, y+d); -/* XMLElementNode *rect = new XMLElementNode("rect"); - rect->addAttribute("x", x+wl); - rect->addAttribute("y", y-h); - rect->addAttribute("width", (-wl+wr)); - rect->addAttribute("height", (h+d)); - rect->addAttribute("fill", "none"); - rect->addAttribute("stroke", "red"); - rect->addAttribute("stroke-width", "0.5"); - _svg.appendToPage(rect);*/ - if (!getMatrix().isIdentity()) - bbox.transform(getMatrix()); - embed(bbox); -} - - -/** This method is called when a "set rule" or "put rule" command was found in the - * DVI file. It draws a solid unrotated rectangle. - * @param[in] x horizontal position of left edge - * @param[in] y vertical position of bottom(!) edge - * @param[in] height length of the vertical edges - * @param[in] width length of the horizontal edges */ -void DVIToSVGActions::setRule (double x, double y, double height, double width) { -/* x *= BP; - y *= BP; - height *= BP; - width *= BP; */ - // (x,y) is the lower left corner of the rectangle - XMLElementNode *rect = new XMLElementNode("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().getSVG()); - if (getColor() != Color::BLACK) - rect->addAttribute("fill", _svg.getColor().rgbString()); - _svg.appendToPage(rect); - - // update bounding box - BoundingBox bb(x, y-height, x+width, y); - if (!getMatrix().isIdentity()) - bb.transform(getMatrix()); - embed(bb); -} - - -/** This method is called when a "set font" command was found in the DVI file. The - * font must be previously defined. - * @param[in] num unique number of the font in the DVI file (not necessarily equal to the DVI font number) - * @param[in] font pointer to the font object (always represents a physical font and never a virtual font) */ -void DVIToSVGActions::setFont (int num, const Font *font) { - _currentFontNum = num; - _svg.setFont(num, font); -} - - -/** This method is called when a "special" command was found in the DVI file. - * @param[in] s the special expression */ -void DVIToSVGActions::special (const string &s) { - try { - _dvisvg.specialManager().process(s, this, this); - // @@ output message in case of unsupported specials? - } - catch (const SpecialException &e) { - Message::estream(true) << "error in special '" << s << "': " << e.what() << '\n'; - } -} - - -void DVIToSVGActions::beginSpecial (const char *prefix) { -} - - -void DVIToSVGActions::endSpecial (const char *) { -} - - -/** This method is called when the DVI preamble was read - * @param[in] cmt preamble comment text. */ -void DVIToSVGActions::preamble (const string &cmt) { -} - - -void DVIToSVGActions::postamble () { -} - - -/** This method is called when a "begin of page (bop)" command was found in the DVI file. - * @param[in] c array with 10 components representing \count0 ... \count9. c[0] contains the - * current (printed) page number (may differ from page count) */ -void DVIToSVGActions::beginPage (unsigned n, Int32 *c) { - _svg.newPage(++_pageCount); - _bbox = BoundingBox(); // clear bounding box - if (_boxes) - _boxes->clear(); -} - - -/** This method is called when an "end of page (eop)" command was found in the DVI file. */ -void DVIToSVGActions::endPage () { - _svg.transformPage(_pageMatrix); - if (_bgcolor != Color::TRANSPARENT) { - // create a rectangle filled with the background color - XMLElementNode *r = new XMLElementNode("rect"); - r->addAttribute("x", _bbox.minX()); - r->addAttribute("y", _bbox.minY()); - r->addAttribute("width", _bbox.width()); - r->addAttribute("height", _bbox.height()); - r->addAttribute("fill", _bgcolor.rgbString()); - _svg.prependToPage(r); - } -} - - -void DVIToSVGActions::setBgColor (const Color &color) { - _bgcolor = color; -} - - -void DVIToSVGActions::embed(const BoundingBox& bbox) { - _bbox.embed(bbox); - if (_boxes) { - FORALL(*_boxes, BoxMap::iterator, it) - it->second.embed(bbox); - } -} - - -void DVIToSVGActions::embed(const DPair& p, double r) { - if (r == 0) - _bbox.embed(p); - else - _bbox.embed(p, r); - if (_boxes) - FORALL(*_boxes, BoxMap::iterator, it) - it->second.embed(p, r); -} - - -BoundingBox& DVIToSVGActions::bbox(const string& name, bool reset) { - if (!_boxes) - _boxes = new BoxMap; - BoundingBox &box = (*_boxes)[name]; - if (reset) - box = BoundingBox(); - return box; -} - - -/** This method is called by subprocesses like the PS handler when - * a computation step has finished. Since the total number of steps - * can't be determined in advance, we don't show a percent value but - * a rotating dash. */ -void DVIToSVGActions::progress (const char *id) { - if (PROGRESSBAR_DELAY < 1000) { - static double time=0; - // slow down updating of the progress indicator to prevent flickering - if (System::time() - time > 0.1) { - progress(0, 0, id); - time = System::time(); - } - } -} - - -/** Returns the number of digits of a given integer. */ -static int digits (int n) { - if (n == 0) - return 1; - if (n > 0) - return int(log10(double(n))+1); - return int(log10(double(-n))+2); -} - - -/** Draws a simple progress indicator. - * @param[in] current current iteration step (of 'total' steps) - * @param[in] total total number of iteration steps - * @param[in] id ID of the subprocess providing the information */ -void DVIToSVGActions::progress (size_t current, size_t total, const char *id) { - static double time=0; - static bool draw=false; // show progress indicator? - static const char *prev_id=0; - if (current == 0 && total > 0) { - time = System::time(); - draw = false; - Message::mstream() << '\n'; - } - // don't show the progress indicator before the given time has elapsed - if (!draw && System::time()-time > PROGRESSBAR_DELAY) - draw = true; - if (draw && (System::time() - time > 0.1 || (total > 0 && current == total) || prev_id != id)) { - static int step = -1; // >=0: rotating dash - static size_t prev_current=0, prev_total=1; - const char *tips = "-\\|/"; - if (total == 0) { - current = prev_current; - total = prev_total; - step = (step+1) % 4; - } - else { - prev_current = current; - prev_total = total; - step = -1; - } - // adapt length of progress indicator to terminal width - int cols = Terminal::columns(); - int width = (cols == 0 || cols > 60) ? 50 : 49-60+cols; - double factor = double(current)/double(total); - int length = int(width*factor); - Message::mstream(false, Message::MC_PROGRESS) - << '[' << string(length, '=') - << (factor < 1.0 ? (step < 0 ? ' ' : tips[step]) : '=') - << string(width-length, ' ') - << "] " << string(3-digits(int(100*factor)), ' ') << int(100*factor) - << "%\r"; - // overprint indicator when finished - if (factor == 1.0) - Message::estream().clearline(); - time = System::time(); - prev_id = id; - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.h deleted file mode 100644 index 2e68bb9cb31..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DVIToSVGActions.h +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************* -** DVIToSVGActions.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DVITOSVGACTIONS_H -#define DVITOSVGACTIONS_H - -#include -#include -#include "BoundingBox.h" -#include "DVIActions.h" -#include "Matrix.h" -#include "SpecialActions.h" -#include "SpecialManager.h" -#include "SVGTree.h" -#include "DVIReader.h" - - -class DVIToSVG; -struct FileFinder; -struct Font; -struct XMLNode; - -class DVIToSVGActions : public DVIActions, public SpecialActions, public SpecialManager::Listener -{ - typedef std::map > CharMap; - typedef std::set FontSet; - typedef std::map BoxMap; - - public: - DVIToSVGActions (DVIToSVG &dvisvg, SVGTree &svg); - ~DVIToSVGActions (); - void reset (); - void setChar (double x, double y, unsigned c, const Font *f); - void setRule (double x, double y, double height, double width); - void setBgColor (const Color &color); - void setColor (const Color &color) {_svg.setColor(color);} - void setMatrix (const Matrix &m) {_svg.setMatrix(m);} - const Matrix& getMatrix () const {return _svg.getMatrix();} - Color getColor () const {return _svg.getColor();} - void appendToPage (XMLNode *node) {_svg.appendToPage(node);} - void appendToDefs (XMLNode *node) {_svg.appendToDefs(node);} - void moveToX (double x); - void moveToY (double y); - void setFont (int num, const Font *font); - void special (const std::string &s); - void preamble (const std::string &cmt); - void postamble (); - void beginPage (unsigned n, Int32 *c); - void endPage (); - void beginSpecial (const char *prefix); - void endSpecial (const char *prefix); - void progress (size_t current, size_t total, const char *id=0); - void progress (const char *id); - CharMap& getUsedChars () const {return _usedChars;} - const FontSet& getUsedFonts () const {return _usedFonts;} - void setPageMatrix (const Matrix &tm); - double getX() const {return _dvisvg.getXPos();} - double getY() const {return _dvisvg.getYPos();} - void setX (double x) {_dvisvg.translateToX(x); _svg.setX(x);} - void setY (double y) {_dvisvg.translateToY(y); _svg.setY(y);} - void finishLine () {_dvisvg.finishLine();} - BoundingBox& bbox () {return _bbox;} - BoundingBox& bbox (const std::string &name, bool reset=false); - void embed (const BoundingBox &bbox); - void embed (const DPair &p, double r=0); - - public: - static double PROGRESSBAR_DELAY; ///< progress bar doesn't appear before this time has elapsed (in sec) - static bool EXACT_BBOX; - - private: - SVGTree &_svg; - DVIToSVG &_dvisvg; - BoundingBox _bbox; - int _pageCount; - int _currentFontNum; - mutable CharMap _usedChars; - FontSet _usedFonts; - Matrix *_pageMatrix; // transformation of whole page - Color _bgcolor; - BoxMap *_boxes; -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.cpp deleted file mode 100644 index c13ebe35a38..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************* -** Directory.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "Directory.h" - -using namespace std; - -#ifdef __WIN32__ - #include -#else - #include - #include -#endif - - -Directory::Directory () { -#if __WIN32__ - handle = INVALID_HANDLE_VALUE; -#else - dir = 0; - dirent = 0; -#endif -} - - -Directory::Directory (string dirname) { - open(dirname); -} - -Directory::~Directory () { - close(); -} - - -bool Directory::open (string dname) { - _dirname = dname; -#ifdef __WIN32__ - firstread = true; - if (dname[dname.length()-1] == '/' || dname[dname.length()-1] == '\\') - dname = dname.substr(0, dname.length()-1); - dname += "\\*"; - handle = FindFirstFile(dname.c_str(), &fileData); - return handle != INVALID_HANDLE_VALUE; -#else - dir = opendir(_dirname.c_str()); - return dir; -#endif -} - - -void Directory::close () { -#ifdef __WIN32__ - FindClose(handle); -#else - closedir(dir); -#endif -} - - -/** Reads first/next directory entry. - * @param[in] type type of entry to return (a: file or dir, f: file, d: dir) - * @return name of entry */ -const char* Directory::read (char type) { -#ifdef __WIN32__ - if (handle == INVALID_HANDLE_VALUE) - return 0; - while (firstread || FindNextFile(handle, &fileData)) { - firstread = false; - if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if (type == 'a' || type == 'd') - return fileData.cFileName; - } - else if (type == 'a' || type == 'f') - return fileData.cFileName; - } - FindClose(handle); - handle = INVALID_HANDLE_VALUE; - return 0; -#else - if (!dir) - return 0; - while ((dirent = readdir(dir))) { - string path = string(_dirname) + "/" + dirent->d_name; - struct stat stats; - stat(path.c_str(), &stats); - if (S_ISDIR(stats.st_mode)) { - if (type == 'a' || type == 'd') - return dirent->d_name; - } - else if (type == 'a' || type == 'f') - return dirent->d_name; - } - closedir(dir); - dir = 0; - return 0; -#endif -} - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.h deleted file mode 100644 index 6420bec6d19..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Directory.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************* -** Directory.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DIRECTORY_H -#define DIRECTORY_H - -#include -#ifdef __WIN32__ - #include - #undef max -#else - #include -#endif - -class Directory -{ - public: - Directory (); - Directory (std::string path); - ~Directory (); - bool open (std::string path); - void close (); - const char* read (char type='a'); - - private: - std::string _dirname; -#ifdef __WIN32__ - bool firstread; - HANDLE handle; - WIN32_FIND_DATA fileData; -#else - DIR *dir; - struct dirent *dirent; -#endif -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.cpp deleted file mode 100644 index 11e3c0fc42a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************* -** DvisvgmSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "DvisvgmSpecialHandler.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "SpecialActions.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -/** Replaces constants of the form {?name} by their corresponding value. - * @param[in,out] str text to expand - * @param[in] actions interfcae to the world outside the special handler */ -static void expand_constants (string &str, SpecialActions *actions) { - struct Constant { - const char *name; - string val; - } - constants[] = { - {"x", XMLString(actions->getX())}, - {"y", XMLString(actions->getY())}, - {"color", actions->getColor().rgbString()}, - {"nl", "\n"}, - {0, ""} - }; - bool repl_bbox = true; - while (repl_bbox) { - size_t pos = str.find(string("{?bbox ")); - if (pos == string::npos) - repl_bbox = false; - else { - size_t endpos = pos+7; - while (endpos < str.length() && isalnum(str[endpos])) - ++endpos; - if (str[endpos] == '}') { - BoundingBox &box=actions->bbox(str.substr(pos+7, endpos-pos-7)); - str.replace(pos, endpos-pos+1, box.toSVGViewBox()); - } - else - repl_bbox = false; - } - } - for (const Constant *p=constants; p->name; p++) { - const string pattern = string("{?")+p->name+"}"; - size_t pos = str.find(pattern); - while (pos != string::npos) { - str.replace(pos, strlen(p->name)+3, p->val); - pos = str.find(pattern, pos+p->val.length()); // look for further matches - } - } -} - - -/** Embeds the virtual rectangle (x, y ,w , h) into the current bounding box, - * where (x,y) is the lower left vertex composed of the current DVI position. - * @param[in] w width of the rectangle in TeX point units - * @param[in] h height of the rectangle in TeX point units - * @param[in] d depth of the rectangle in TeX point units */ -static void update_bbox (double w, double h, double d, SpecialActions *actions) { - double x = actions->getX(); - double y = actions->getY(); - actions->embed(BoundingBox(x, y, x+w, y-h)); - actions->embed(BoundingBox(x, y, x+w, y+d)); -} - - -/** Inserts raw text into the SVG tree. - * @param[in,out] in the raw text is read from this input buffer - * @param[in] actions interfcae to the world outside the special handler - * @param[in] group true if the text should be wrapped by a group element */ -static void raw (InputReader &in, SpecialActions *actions, bool group=false) { - string str; - while (!in.eof()) { - int c = in.get(); - if (isprint(c)) - str += char(c); - } - expand_constants(str, actions); - if (!str.empty()) { - XMLNode *node = new XMLTextNode(str); - if (group) { - XMLElementNode *g = new XMLElementNode("g"); - g->addAttribute("x", actions->getX()); - g->addAttribute("y", actions->getY()); - if (actions->getColor() != Color::BLACK) - g->addAttribute("fill", actions->getColor().rgbString()); - g->append(node); - node = g; - } - actions->appendToPage(node); - } -} - - -/** Evaluates the special dvisvgm:bbox. - * variant 1: dvisvgm:bbox [r[el]] [] - * variant 2: dvisvgm:bbox a[bs] - * variant 3: dvisvgm:bbox f[ix] - * variant 4: dvisvgm:bbox n[ew] */ -static void bbox (InputReader &in, SpecialActions *actions) { - in.skipSpace(); - int c = in.peek(); - if (isalpha(c)) { - while (!isspace(in.peek())) // skip trailing characters - in.get(); - if (c == 'n') { - in.skipSpace(); - string name; - while (isalnum(in.peek())) - name += char(in.get()); - in.skipSpace(); - if (!name.empty() && in.eof()) - actions->bbox(name, true); // create new user box - } - else if (c == 'a' || c == 'f') { - double p[4]; - for (int i=0; i < 4; i++) - p[i] = in.getDouble(); - BoundingBox b(p[0], p[1], p[2], p[3]); - if (c == 'a') - actions->embed(b); - else { - actions->bbox() = b; - actions->bbox().lock(); - } - } - } - else - c = 'r'; // no mode specifier => relative box parameters - - if (c == 'r') { - double w = in.getDouble(); - double h = in.getDouble(); - double d = in.getDouble(); - update_bbox(w, h, d, actions); - } -} - - -static void img (InputReader &in, SpecialActions *actions) { - double w = in.getDouble(); - double h = in.getDouble(); - string f = in.getString(); - update_bbox(w, h, 0, actions); - XMLElementNode *img = new XMLElementNode("image"); - img->addAttribute("x", actions->getX()); - img->addAttribute("y", actions->getY()); - img->addAttribute("width", w); - img->addAttribute("height", h); - img->addAttribute("xlink:href", f); - if (actions && !actions->getMatrix().isIdentity()) - img->addAttribute("transform", actions->getMatrix().getSVG()); - actions->appendToPage(img); -} - - -/** Evaluates and executes a dvisvgm special statement. - * @param[in] prefix special prefix read by the SpecialManager - * @param[in] is the special statement is read from this stream - * @param[in,out] in the raw text is read from this input buffer */ -bool DvisvgmSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - if (actions) { - StreamInputBuffer ib(is); - BufferInputReader in(ib); - string cmd = in.getWord(); - if (cmd == "raw") // raw - raw(in, actions); - else if (cmd == "bbox") // bbox [r] or bbox a - bbox(in, actions); - else if (cmd == "img") { // img - img(in, actions); - } - } - return true; -} - - -const char** DvisvgmSpecialHandler::prefixes () const { - static const char *pfx[] = {"dvisvgm:", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.h deleted file mode 100644 index 93e726fe634..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/DvisvgmSpecialHandler.h +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************* -** DvisvgmSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef DVISVGMSPECIALHANDLER_H -#define DVISVGMSPECIALHANDLER_H - -#include "SpecialHandler.h" - -class DvisvgmSpecialHandler : public SpecialHandler -{ - public: - const char* name () const {return "dvisvgm";} - const char* info () const {return "special set for embedding raw SVG snippets";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &in, SpecialActions *actions); -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.cpp deleted file mode 100644 index cbeb5600366..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* -** EPSFile.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "EPSFile.h" -#include "InputBuffer.h" -#include "InputReader.h" - -using namespace std; - - -/** Reads a little-endian 32-bit integer from the given input stream. */ -static UInt32 getUInt32 (istream &is) { - UInt32 value=0; - char buf[4]; - is.read(buf, 4); - for (int i=0; i < 4; i++) - value |= ((buf[i] & 255) << (8*i)); - return value; -} - - -static size_t getline (istream &is, char *line, size_t n) { - char buf[512]; - is.get(buf, min(n, (size_t)512)-1); - n = is.gcount(); - size_t linelen=0; - for (size_t i=0; i < n; i++) - if (isprint(buf[i])) - line[linelen++] = buf[i]; - line[linelen] = 0; - if (is.peek() == '\n') - is.get(); - else - is.ignore(numeric_limits::max(), '\n'); - return linelen; -} - - -EPSFile::EPSFile (const std::string& fname) : _ifs(fname.c_str(), ios::binary), _headerValid(false), _offset(0), _pslength(0) -{ - if (_ifs) { - if (getUInt32(_ifs) != 0xC6D3D0C5) // no binary header present? - _ifs.seekg(0, ios_base::beg); // go back to the first byte - else { - _offset = getUInt32(_ifs); // stream offset where PS part of the file begins - _pslength = getUInt32(_ifs); // length of PS section in bytes - _ifs.seekg(_offset, ios_base::beg); // continue reading at the beginning of the PS section - } - string str; - str += _ifs.get(); - str += _ifs.get(); - _headerValid = (str == "%!"); - _ifs.seekg(0, ios_base::beg); - } -} - - -/** Returns an input stream for the EPS file. The stream pointer is automatically moved - * to the beginning of the ASCII (PostScript) part of the file. */ -istream& EPSFile::istream () const { - _ifs.clear(); - _ifs.seekg(_offset, ios_base::beg); - return _ifs; -} - - -/** Extracts the bounding box information from the DSC header/footer (if present) - * @param[out] the extracted bounding box - * @return true if %%BoundingBox data could be read successfully */ -bool EPSFile::bbox (BoundingBox &box) const { - std::istream &is = EPSFile::istream(); - if (is) { - char buf[64]; - while (is) { - size_t linelen = getline(is, buf, 64); - if (strncmp(buf, "%%BoundingBox:", 14) == 0) { - CharInputBuffer ib(buf, linelen); - BufferInputReader ir(ib); - ir.skip(14); - ir.skipSpace(); - if (!ir.check("(atend)", true)) { - int val[4]; - for (int i=0; i < 4; i++) { - ir.skipSpace(); - ir.parseInt(val[i]); - } - box = BoundingBox(val[0], val[1], val[2], val[3]); - return true; - } - } - } - } - return false; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.h deleted file mode 100644 index 60a4c007d39..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSFile.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* -** EPSFile.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef EPSFILE_H -#define EPSFILE_H - -#include -#include -#include "BoundingBox.h" -#include "types.h" - -class EPSFile -{ - public: - EPSFile (const std::string &fname); - std::istream& istream () const; - bool hasValidHeader () const {return _headerValid;} - bool bbox (BoundingBox &box) const; - UInt32 pslength () const {return _pslength;} - - private: - mutable std::ifstream _ifs; - bool _headerValid; ///< true if file has a valid header - UInt32 _offset; ///< stream offset where ASCII part of the file begins - UInt32 _pslength; ///< length of PS section (in bytes) -}; - -#endif - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.cpp deleted file mode 100644 index 1bf0c81e9b2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* -** EPSToSVG.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "EPSFile.h" -#include "EPSToSVG.h" -#include "Message.h" -#include "MessageException.h" -#include "PsSpecialHandler.h" -#include "SVGOutputBase.h" - -#ifdef HAVE_CONFIG_H - #include "config.h" - #ifdef TARGET_SYSTEM - #define VERSION_STR VERSION " (" TARGET_SYSTEM ")" - #else - #define VERSION_STR VERSION - #endif -#else - #define VERSION_STR "" -#endif - - -using namespace std; - - -void EPSToSVG::convert () { - if (!Ghostscript().available()) - throw MessageException("Ghostscript is required to process the EPS file"); - EPSFile epsfile(_fname); - if (!epsfile.hasValidHeader()) - throw PSException("invalid EPS file"); - - BoundingBox bbox; - epsfile.bbox(bbox); - Message::mstream(false, Message::MC_PAGE_NUMBER) << "processing file " << _fname << '\n'; - Message::mstream().indent(1); - _svg.newPage(1); - // create a psfile special and forward it to the PsSpecialHandler - stringstream ss; - ss << "\"" << _fname << "\" " - "llx=" << bbox.minX() << " " - "lly=" << bbox.minY() << " " - "urx=" << bbox.maxX() << " " - "ury=" << bbox.maxY(); - PsSpecialHandler pshandler; - pshandler.process("psfile=", ss, this); - // output SVG file - _svg.setBBox(_bbox); - _svg.appendToDoc(new XMLCommentNode(" This file was generated by dvisvgm " VERSION_STR " ")); - _svg.write(_out.getPageStream(1, 1)); - string svgfname = _out.filename(1, 1); - Message::mstream(false, Message::MC_PAGE_SIZE) << "graphic size: " << bbox.width() << "pt" - " x " << bbox.height() << "pt" - " (" << bbox.width()/72.27*25.4 << "mm" - " x " << bbox.height()/72.27*25.4 << "mm)\n"; - Message::mstream(false, Message::MC_PAGE_WRITTEN) << "graphic written to " << (svgfname.empty() ? "" : svgfname) << '\n'; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.h deleted file mode 100644 index 92edb5884e0..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EPSToSVG.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* -** EPSToSVG.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef EPSTOSVG_H -#define EPSTOSVG_H - -#include -#include "SpecialActions.h" -#include "SVGTree.h" - -struct SVGOutputBase; - -class EPSToSVG : protected SpecialActions -{ - public: - EPSToSVG (const std::string &fname, SVGOutputBase &out) : _fname(fname), _out(out), _x(0), _y(0) {} - void convert (); - void setTransformation (const Matrix &m); - void setPageSize (const std::string &name); - - protected: - // implement abstract base class SpecialActions - double getX () const {return _x;} - double getY () const {return _y;} - void setX (double x) {_x = x; _svg.setX(x);} - void setY (double y) {_y = y; _svg.setY(y);} - void finishLine () {} - void setColor (const Color &color) {_svg.setColor(color);} - Color getColor () const {return _svg.getColor();} - void setMatrix (const Matrix &m) {_svg.setMatrix(m);} - const Matrix& getMatrix () const {return _svg.getMatrix();} - void setBgColor (const Color &color) {} - void appendToPage (XMLNode *node) {_svg.appendToPage(node);} - void appendToDefs (XMLNode *node) {_svg.appendToDefs(node);} - void embed (const BoundingBox &bbox) {_bbox.embed(bbox);} - void embed (const DPair &p, double r=0) {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);} - BoundingBox& bbox () {return _bbox;} - BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;} - - private: - std::string _fname; ///< name of EPS file - SVGTree _svg; - SVGOutputBase &_out; - double _x, _y; - BoundingBox _bbox; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.cpp deleted file mode 100644 index 3617e188a64..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/************************************************************************* -** EmSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "EmSpecialHandler.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "SpecialActions.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -EmSpecialHandler::EmSpecialHandler () : _linewidth(0.4), _actions(0) { -} - - -/** Computes the "cut vector" that is used to compute the line shape. - * Because each line has a width > 0 the actual shape of the line is a tetragon. - * The 4 vertices can be influenced by the cut parameter c that specifies - * a horizontal, vertical or orthogonal cut of a line end. Depending on c and the - * line's slope a cut vector v can be computed that, relatively to endpoint p, denotes - * the 2 vertices of that line end: v1=p+v and v2=p-v. - * @param[in] c cut direction ('h', 'v' or 'p') - * @param[in] v direction vector of line to be drawn - * @param[in] lw width of line to be drawn - * @return the "cut vector" */ -static DPair cut_vector (char c, const DPair &v, double lw) { - if (c == 'p') - return v.ortho()/v.length() * (lw/2); - DPair cut; - if (c == 'v' && v.x() != 0) { - double slope = v.y()/v.x(); - double h = sqrt(lw*lw*(1+slope*slope)); - cut.y(0.5*h); - } - else if (v.y() != 0) { // c == 'h' - double slope = v.x()/v.y(); - double h = sqrt(lw*lw*(1+slope*slope)); - double sgn = slope < 0 ? 1.0 : -1.0; - cut.x(0.5*h*sgn); - } - return cut; -} - - -/** Creates the SVG element that will a the line. - * @param[in] p1 first endpoint in TeX point units - * @param[in] p2 second endpoint in TeX point units - * @param[in] c1 cut method of first endpoint ('h', 'v' or 'p') - * @param[in] c2 cut method of second endpoint ('h', 'v' or 'p') - * @param[in] lw line width in TeX point units */ -static void create_line (const DPair &p1, const DPair &p2, char c1, char c2, double lw, SpecialActions *actions) { - XMLElementNode *node=0; - DPair dir = p2-p1; - if (dir.x() == 0 || dir.y() == 0 || (c1 == 'p' && c2 == 'p')) { - // draw regular line - node = new XMLElementNode("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().rgbString()); - // update bounding box - actions->embed(p1); - actions->embed(p2); - } - else { - // draw polygon - 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; - node = new XMLElementNode("polygon"); - 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->addAttribute("points", oss.str()); - if (actions->getColor() != Color::BLACK) - node->addAttribute("fill", actions->getColor().rgbString()); - // update bounding box - actions->embed(q11); - actions->embed(q12); - actions->embed(q21); - actions->embed(q22); - } - actions->appendToPage(node); -} - - -static double read_length (InputReader &in) { - struct Unit { - const char *name; - double factor; - } - units[] = { - {"pt", 1.0}, - {"pc", 12.0}, - {"in", 72.27}, - {"bp", 72.27/72}, - {"cm", 72.27/2.54}, - {"mm", 72.27/25.4}, - {"dd", 1238.0/1157}, - {"cc", 1238.0/1157*12}, - {"sp", 1.0/65536}, - {0, 0} - }; - double len = in.getDouble(); - in.skipSpace(); - for (Unit *p=units; p->name; p++) - if (in.check(p->name)) { - len *= p->factor; - break; - } - return len; -} - - -bool EmSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - // em:moveto => move graphic cursor to dvi cursor - // em:lineto => draw line from graphic cursor to dvi cursor, move graphic cursor to dvi cursor - // em:linewidth => set line width to - // em:point [,[,]] => defines point as (,); if and/or is missing, - // the corresponding dvi cursor coordinate is inserted - // and are lengths - // em:line [h|v|p], [h|v|p] [,] => draws line of width from point # to point # - // point number suffixes: - // h: cut line horizontally - // v: cut line vertically - // p: cut line orthogonally to line direction (default) - // if is omitted, the global line width is used - // - // supported length units: pt, pc, in, bp, cm, mm, dd, cc, sp - // default line width: 0.4pt - - if (actions) { - _actions = actions; // save pointer to SpecialActions for later use in endPage - StreamInputBuffer ib(is, 128); - BufferInputReader in(ib); - string cmd = in.getWord(); - if (cmd == "moveto") - _pos = DPair(actions->getX(), actions->getY()); - else if (cmd == "lineto") { - DPair p(actions->getX(), actions->getY()); - create_line(_pos, p, 'p', 'p', _linewidth, actions); - _pos = p; - } - else if (cmd == "linewidth") - _linewidth = read_length(in); - else if (cmd == "point") { - DPair p(actions->getX(), actions->getY()); - int n = in.getInt(); - if (in.getPunct() == ',') { - p.x(in.getDouble()); - if (in.getPunct() == ',') - p.y(in.getDouble()); - } - _points[n] = p; - } - else if (cmd == "line") { - int n1 = in.getInt(); - int c1 = 'p'; - if (isalpha(in.peek())) - c1 = in.get(); - in.getPunct(); - int n2 = in.getInt(); - int c2 = 'p'; - if (isalpha(in.peek())) - c2 = in.get(); - double lw = _linewidth; - if (in.getPunct() == ',') - lw = read_length(in); - map::iterator it1=_points.find(n1); - map::iterator it2=_points.find(n2); - if (it1 != _points.end() && it2 != _points.end()) - create_line(it1->second, it2->second, char(c1), char(c2), lw, actions); - else { - // Line endpoints havn't necessarily to be defined before - // a line definition. If a point wasn't defined yet we push the line - // in a wait list and process the lines at the end of the page. - _lines.push_back(Line(n1, n2, char(c1), char(c2), lw)); - } - } - } - return true; -} - - -/** This method is called at the end of a DVI page. Here we have to draw all pending - * lines that are still in the line list. All line endpoints must be defined until here. */ -void EmSpecialHandler::dviEndPage () { - if (_actions) { - FORALL(_lines, list::iterator, it) { - map::iterator pit1=_points.find(it->p1); - map::iterator pit2=_points.find(it->p2); - if (pit1 != _points.end() && pit2 != _points.end()) - create_line(pit1->second, pit2->second, it->c1, it->c2, it->width, _actions); - // all lines with still undefined points are ignored - } - } - // line and point definitions are local to a page - _lines.clear(); - _points.clear(); -} - - -const char** EmSpecialHandler::prefixes () const { - static const char *pfx[] = {"em:", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.h deleted file mode 100644 index 2a0700ebb9e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/EmSpecialHandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* -** EmSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef EMSPECIALHANDLER_H -#define EMSPECIALHANDLER_H - -#include -#include -#include "Pair.h" -#include "SpecialHandler.h" - - -class EmSpecialHandler : public SpecialHandler -{ - struct Line { - Line (int pp1, int pp2, char cc1, char cc2, double w) : p1(pp1), p2(pp2), c1(cc1), c2(cc2), width(w) {} - int p1, p2; ///< point numbers of line ends - char c1, c2; ///< cut type of line ends (h, v or p) - double width; ///< line width - }; - - public: - EmSpecialHandler (); - const char* name () const {return "em";} - const char* info () const {return "line drawing statements of the emTeX special set";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &in, SpecialActions *actions); - void dviEndPage (); - - protected: - bool isEndPageListener () const {return true;} - - private: - std::map _points; ///< points defined by special em:point - std::list _lines; ///< list of lines with undefined end points - double _linewidth; ///< global line width - DPair _pos; ///< current position of "graphic cursor" - SpecialActions *_actions; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.cpp deleted file mode 100644 index 328b6ea15dd..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/************************************************************************* -** FileFinder.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#undef __cplusplus -#define __cplusplus 1 - -#include -#include -#include -#include -#include "FileFinder.h" -#include "FileSystem.h" -#include "FontMap.h" -#include "Message.h" - -using namespace std; - -#ifdef MIKTEX - #include "MessageException.h" - #include "MiKTeXCom.h" - static MiKTeXCom *miktex=0; -#else - // unfortunately, the kpathsea headers are not C++-ready, - // so we have to wrap it with some ugly code - namespace KPS { - extern "C" { - #include - } - } - using namespace KPS; -#endif - -// --------------------------------------------------- - -static bool _initialized = false; -static bool _mktex_enabled = false; - -// --------------------------------------------------- - -static const char* find_file (const std::string &fname); -static const char* find_mapped_file (std::string fname); -static const char* mktex (const std::string &fname); - - -/** Initializes the file finder. This function must be called before any other - * FileFinder function. - * @param[in] argv0 argv[0] of main() function - * @param[in] progname name of application using the FileFinder - * @param[in] enable_mktexmf if true, tfm and mf file generation is activated */ -void FileFinder::init (const char *argv0, const char *progname, bool enable_mktexmf) { - if (_initialized) - return; - - _mktex_enabled = enable_mktexmf; -#ifdef MIKTEX - miktex = new MiKTeXCom; -#else - kpse_set_program_name(argv0, progname); - // enable tfm and mf generation (actually invoked by calls of kpse_make_tex) - kpse_set_program_enabled(kpse_tfm_format, 1, kpse_src_env); - kpse_set_program_enabled(kpse_mf_format, 1, kpse_src_env); - kpse_make_tex_discard_errors = false; // don't suppress messages of mktexFOO tools -#ifdef TEXLIVEWIN32 - texlive_gs_init(); -#endif -#endif - _initialized = true; -} - - -/** Cleans up the FileFinder. This function must be called before leaving the - * applications main() function. */ -void FileFinder::finish () { -#ifdef MIKTEX - if (miktex) { - delete miktex; - miktex = 0; - } -#endif - _initialized = false; -} - - -/** Returns the version string of the underlying file searching library (kpathsea, MiKTeX) */ -std::string FileFinder::version () { -#ifdef MIKTEX - bool autoinit=false; - try { - if (!_initialized) { - init("", "", false); - autoinit = true; - } - string ret = miktex->getVersion(); - if (autoinit) - finish(); - return ret; - } - catch (MessageException &e) { - if (autoinit) - finish(); - return "not available"; - } -#else - if (const char *v = strrchr(KPSEVERSION, ' ')) - return v+1; -#endif - return "unknown"; -} - - -/** Determines filetype by the filename extension and calls kpse_find_file - * to actually look up the file. - * @param[in] fname name of file to look up - * @return file path on success, 0 otherwise */ -static const char* find_file (const std::string &fname) { - if (!_initialized) - return 0; - - size_t pos = fname.rfind('.'); - if (pos == std::string::npos) - return 0; // no extension => no search - const std::string ext = fname.substr(pos+1); // file extension -#ifdef MIKTEX - return miktex->findFile(fname.c_str()); -#else - static std::string buf; - -#ifdef TEXLIVEWIN32 - if (ext == "exe") { - // lookup exe files in directory where dvisvgm is located - if (const char *path = kpse_var_value("SELFAUTOLOC")) { - buf = std::string(path) + "/" + fname; - return FileSystem::exists(buf.c_str()) ? buf.c_str() : 0; - } - return 0; - } -#endif - - static std::map types; - if (types.empty()) { - types["tfm"] = kpse_tfm_format; - types["pfb"] = kpse_type1_format; - types["vf"] = kpse_vf_format; - types["mf"] = kpse_mf_format; - types["ttc"] = kpse_truetype_format; - types["ttf"] = kpse_truetype_format; - types["map"] = kpse_fontmap_format; - types["sty"] = kpse_tex_format; - types["enc"] = kpse_enc_format; - types["pro"] = kpse_tex_ps_header_format; - types["sfd"] = kpse_sfd_format; - } - std::map::iterator it = types.find(ext.c_str()); - if (it == types.end()) - return 0; - - if (char *path = kpse_find_file(fname.c_str(), it->second, 0)) { - // In the current version of libkpathsea, each call of kpse_find_file produces - // a memory leak since the path buffer is not freed. I don't think we can do - // anything against it here... - buf = path; - std::free(path); - return buf.c_str(); - } - return 0; -#endif -} - - -/** Checks whether the given file is mapped to a different name and if the - * file can be found under this name. - * @param[in] fname name of file to look up - * @param[in] fontmap font mappings - * @return file path on success, 0 otherwise */ -static const char* find_mapped_file (std::string fname) { - size_t pos = fname.rfind('.'); - if (pos == std::string::npos) - return 0; - const std::string ext = fname.substr(pos+1); // file extension - const std::string base = fname.substr(0, pos); - if (const FontMap::Entry *entry = FontMap::instance().lookup(base)) { - const char *path=0; - if (entry->fontname.find('.') != std::string::npos) // does the mapped filename has an extension? - path = find_file(entry->fontname); // look for that file - else { // otherwise, use extension of unmapped file - fname = entry->fontname + "." + ext; - (path = find_file(fname)) || (path = mktex(fname)); - } - return path; - } - return 0; -} - - -/** Runs external mktexFOO tool to create missing tfm or mf file. - * @param[in] fname name of file to build - * @return file path on success, 0 otherwise */ -static const char* mktex (const std::string &fname) { - if (!_initialized) - return 0; - - size_t pos = fname.rfind('.'); - if (!_mktex_enabled || pos == std::string::npos) - return 0; - - std::string ext = fname.substr(pos+1); // file extension - if (ext != "tfm" && ext != "mf") - return 0; - - const char *path = 0; -#ifdef MIKTEX - // maketfm and makemf are located in miktex/bin which is in the search PATH - string toolname = (ext == "tfm" ? "miktex-maketfm" : "miktex-makemf"); - system((toolname+".exe "+fname).c_str()); - path = find_file(fname); -#else - kpse_file_format_type type = (ext == "tfm" ? kpse_tfm_format : kpse_mf_format); - path = kpse_make_tex(type, fname.c_str()); -#endif - return path; -} - - -/** Searches a file in the TeX directory tree. - * If the file doesn't exist, maximal two further steps are applied - * (if "extended" is true): - * - checks whether the filename is mapped to a different name and returns - * the path to that name - * - in case of tfm or mf files: invokes the external mktextfm/mktexmf tool - * to create the missing file - * @param[in] fname name of file to look up - * @param[in] extended if true, use fontmap lookup and mktexFOO calls - * @return path to file on success, 0 otherwise */ -const char* FileFinder::lookup (const std::string &fname, bool extended) { - const char *path; - if ((path = find_file(fname)) || (extended && ((path = find_mapped_file(fname)) || (path = mktex(fname))))) - return path; - return 0; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.h deleted file mode 100644 index f0d8dbba001..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileFinder.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************* -** FileFinder.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef KPSFILEFINDER_H -#define KPSFILEFINDER_H - -#include - -struct FileFinder -{ - static void init (const char *argv0, const char *progname, bool enable_mktexmf); - static void finish (); - static std::string version (); - static const char* lookup (const std::string &fname, bool extended=true); -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.cpp deleted file mode 100644 index 2d7e676772a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/************************************************************************* -** FilePath.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "FilePath.h" -#include "FileSystem.h" -#include "MessageException.h" -#include "macros.h" - -using namespace std; - - -/** Removes redundant slashes from a given path. */ -static string& single_slashes (string &str) { - size_t pos=0; - while ((pos = str.find("//", pos)) != string::npos) - str.replace(pos, 2, "/"); - return str; -} - - -#ifdef __WIN32__ -static char strip_drive_letter (string &path) { - char letter = 0; - if (path.length() >= 2 && path[1] == ':' && isalpha(path[0])) { - letter = tolower(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) + ":").c_str())) { - path.insert(0, FileSystem::getcwd()+"/"); - strip_drive_letter(path); - } - else - throw MessageException("drive " + string(1, target_drive) + ": not accessible"); - } - } - } - return target_drive; -} - - -static void tolower (string &str) { - for (size_t i=0; i < str.length(); ++i) - str[i] = tolower(str[i]); -} -#endif - - -/** Constructs a FilePath object from a given path. Relative paths are - * relative to the current working directory. - * @param[in] path absolute or relative path to a file or directory */ -FilePath::FilePath (const string &path) { - init(path, !FileSystem::isDirectory(path.c_str()), FileSystem::getcwd()); -} - - -/** Constructs a FilePath object. - * @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 - * @param[in] current_dir if 'path' is a relative path expression it will be related to 'current_dir' */ -FilePath::FilePath (const string &path, bool isfile, string current_dir) { - init(path, isfile, current_dir); -} - - -/** Initializes a FilePath object. This method should be called by the constructors only. - * @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 - * @param[in] current_dir if 'path' is a relative path expression it will be related to 'current_dir' */ -void FilePath::init (string path, bool isfile, string current_dir) { - single_slashes(path); - single_slashes(current_dir); -#ifdef __WIN32__ - tolower(path); - path = FileSystem::adaptPathSeperators(path); - _drive = strip_drive_letter(path); -#endif - if (isfile) { - size_t pos = path.rfind('/'); - _fname = path.substr((pos == string::npos) ? 0 : pos+1); - if (pos != string::npos) - path.erase(pos); - else - path.clear(); - } - if (current_dir.empty()) - current_dir = FileSystem::getcwd(); -#ifdef __WIN32__ - tolower(current_dir); - _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 + "/"); - string elem; - FORALL (path, string::const_iterator, it) { - if (*it == '/') { - add(elem); - elem.clear(); - } - else - elem += *it; - } - add(elem); -} - - -/** Adds a location step to the current path. */ -void FilePath::add (const string &dir) { - if (dir == ".." && !_dirs.empty()) - _dirs.pop_back(); - else if (dir.length() > 0 && dir != ".") - _dirs.push_back(dir); -} - - -/** Returns the suffix of the filename. If FilePath represents the - * location of a directory (and not of a file) an empty string - * is returned. */ -string FilePath::suffix () const { - size_t start = 0; - // ignore leading dots - while (start < _fname.length() && _fname[start] == '.') - start++; - string sub = _fname.substr(start); - size_t pos = sub.rfind('.'); - if (pos != string::npos && pos < sub.length()-1) - return sub.substr(pos+1); - return ""; -} - - -/** Changes the suffix of the filename. If FilePath represents the - * location of a directory (and not of a file) nothing happens. - * @param[in] s new suffix */ -void FilePath::suffix (const string &s) { - if (!_fname.empty()) { - string current_suffix = suffix(); - if (!current_suffix.empty()) - _fname.erase(_fname.length()-current_suffix.length()-1); - _fname += "."+s; - } -} - - -/** Returns the filename without suffix. - * Example: FilePath("/a/b/c.def", true) == "c" */ -string FilePath::basename () const { - if (!_fname.empty()) { - size_t len = suffix().length(); - if (len > 0) - len++; // strip dot too - return _fname.substr(0, _fname.length()-len); - } - return ""; -} - - -/** Returns the absolute path string of this FilePath. - * @param[in] with_filename if false, the filename is omitted - * @return the absolute path string */ -string FilePath::absolute (bool with_filename) const { - string path; - FORALL (_dirs, ConstIterator, it) { - path += "/" + *it; - } - 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); -} - - -/** Returns a path string of this FilePath relative to reldir. If we wanted to - * navigate from /a/b/c/d to /a/b/e/f using the shell command "cd", we could do that - * with the relative path argument: "cd ../../e/f". This function returns such a relative - * path. Example: FilePath("/a/b/e/f").relative("/a/b/c/d") => "../../e/f". - * @param[in] reldir absolute path to a directory - * @param[in] with_filename if false, the filename is omitted - * @return the relative path string */ -string FilePath::relative (string reldir, bool with_filename) const { - if (reldir.empty()) - reldir = FileSystem::getcwd(); -#ifdef __WIN32__ - adapt_current_path(reldir, _drive); -#endif - if (reldir[0] != '/') - return absolute(); - FilePath rel(reldir, false); - string path; -#ifdef __WIN32__ - if (rel._drive && _drive && rel._drive != _drive) - path += string(1, _drive) + ":"; -#endif - ConstIterator i = _dirs.begin(); - ConstIterator j = rel._dirs.begin(); - while (i != _dirs.end() && j != rel._dirs.end() && *i == *j) - ++i, ++j; - for (; j != rel._dirs.end(); ++j) - path += "../"; - for (; i != _dirs.end(); ++i) - path += *i + "/"; - if (!path.empty()) - path.erase(path.length()-1, 1); // remove trailing slash - if (with_filename && !_fname.empty()) { - if (!path.empty() && path != "/") - path += "/"; - path += _fname; - } - if (path.empty()) - path = "."; - return single_slashes(path); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.h deleted file mode 100644 index 5bd3fdf98e2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FilePath.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* -** FilePath.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FILEPATH_H -#define FILEPATH_H - -#include -#include - -class FilePath -{ - typedef std::vector Directories; - typedef Directories::iterator Iterator; - typedef Directories::const_iterator ConstIterator; - public: - FilePath (const std::string &path); - FilePath (const std::string &path, bool isfile, std::string current_dir=""); - std::string absolute (bool with_filename=true) const; - std::string relative (std::string reldir="", bool with_filename=true) const; - std::string basename () const; - std::string suffix () const; - void suffix (const std::string &s); - size_t depth () const {return _dirs.size();} - bool isFile () const {return !_fname.empty();} - bool empty () const {return _dirs.empty() && _fname.empty();} - const std::string& filename () const {return _fname;} - void filename (const std::string &fname) {_fname = fname;} - - protected: - void init (std::string path, bool isfile, std::string current_dir); - void add (const std::string &elem); - - private: - Directories _dirs; - std::string _fname; -#ifdef __WIN32__ - char _drive; -#endif -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.cpp deleted file mode 100644 index 67e48595db9..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/************************************************************************* -** FileSystem.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "FileSystem.h" -#include "macros.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - - -using namespace std; - -#ifdef __WIN32__ - #include - #include - const char *FileSystem::DEVNULL = "nul"; - const char FileSystem::PATHSEP = '\\'; - #define unlink _unlink -#else - #include - #include - #include - #include - const char *FileSystem::DEVNULL = "/dev/null"; - const char FileSystem::PATHSEP = '/'; -#endif - - -bool FileSystem::remove (const string &fname) { - return unlink(fname.c_str()) == 0; -} - - -/** Copies a file. - * @param[in] src path of file to copy - * @param[in] dest path of target file - * @param[in] remove_src remove file 'src' if true - * @return true on success */ -bool FileSystem::copy (const string &src, const string &dest, bool remove_src) { - ifstream ifs(src.c_str(), ios::in|ios::binary); - ofstream ofs(dest.c_str(), ios::out|ios::binary); - if (ifs && ofs) { - ofs << ifs.rdbuf(); - if (!ifs.fail() && !ofs.fail() && remove_src) { - ofs.close(); - ifs.close(); - return remove(src); - } - else - return !remove_src; - } - return false; -} - - -bool FileSystem::rename (const string &oldname, const string &newname) { - return ::rename(oldname.c_str(), newname.c_str()) == 0; -} - - -UInt64 FileSystem::filesize (const string &fname) { -#ifdef __WIN32__ - // unfortunately, stat doesn't work properly under Windows - // so we have to use this freaky code - WIN32_FILE_ATTRIBUTE_DATA attr; - GetFileAttributesExA(fname.c_str(), GetFileExInfoStandard, &attr); - return (static_cast(attr.nFileSizeHigh) << (8*sizeof(attr.nFileSizeLow))) | attr.nFileSizeLow; -#else - struct stat attr; - return (stat(fname.c_str(), &attr) == 0) ? attr.st_size : 0; -#endif -} - - -string FileSystem::adaptPathSeperators (string path) { - for (size_t i=0; i < path.length(); i++) - if (path[i] == PATHSEP) - path[i] = '/'; - return path; -} - - -string FileSystem::getcwd () { - char buf[1024]; -#ifdef __WIN32__ - return adaptPathSeperators(_getcwd(buf, 1024)); -#else - return ::getcwd(buf, 1024); -#endif -} - - -/** Changes the work directory. - * @param[in] path to new work directory - * @return true on success */ -bool FileSystem::chdir (const char *dir) { - bool success = false; - if (dir) { -#ifdef __WIN32__ - success = (_chdir(dir) == 0); -#else - success = (chdir(dir) == 0); -#endif - } - return success; -} - - -/** Returns the user's home directory. */ -const char* FileSystem::userdir () { -#ifdef __WIN32__ - const char *drive=getenv("HOMEDRIVE"); - const char *path=getenv("HOMEPATH"); - if (drive && path) { - static string ret = string(drive)+path; - if (!ret.empty()) - return ret.c_str(); - } - return 0; -#else - const char *dir=getenv("HOME"); - if (!dir) { - if (const char *user=getenv("USER")) { - if (struct passwd *pw=getpwnam(user)) - dir = pw->pw_dir; - } - } - return dir; -#endif -} - - -/** Private wrapper function for mkdir: creates a single folder. - * @param[in] dir folder name - * @return true on success */ -static bool s_mkdir (const char *dir) { - bool success = true; - if (!FileSystem::exists(dir)) { -#ifdef __WIN32__ - success = (_mkdir(dir) == 0); -#else - success = (mkdir(dir, 0776) == 0); -#endif - } - return success; -} - - -static bool inline s_rmdir (const char *dir) { -#ifdef __WIN32__ - return (_rmdir(dir) == 0); -#else - return (rmdir(dir) == 0); -#endif -} - - -/** Removes leading and trailing whitespace from a string. */ -static string trim (const string &str) { - int first=0, last=str.length()-1; - while (isspace(str[first])) - first++; - while (isspace(str[last])) - last--; - return str.substr(first, last-first+1); -} - - -/** Creates a new folder relative to the current work directory. If necessary, - * the parent folders are also created. - * @param[in] dir single folder name or path to folder - * @return true if folder(s) could be created */ -bool FileSystem::mkdir (const char *dir) { - bool success = false; - if (dir) { - success = true; - const string dirstr = adaptPathSeperators(trim(dir)); - for (size_t pos=1; success && (pos = dirstr.find('/', pos)) != string::npos; pos++) - success &= s_mkdir(dirstr.substr(0, pos).c_str()); - success &= s_mkdir(dirstr.c_str()); - } - return success; -} - - -/** Removes a directory and its contents. - * @param[in] dirname path to directory - * @return true on success */ -bool FileSystem::rmdir (const char *dirname) { - bool ok = false; - if (dirname && isDirectory(dirname)) { - ok = true; -#ifdef __WIN32__ - string pattern = string(dirname) + "/*"; - WIN32_FIND_DATA data; - HANDLE h = FindFirstFile(pattern.c_str(), &data); - bool ready = (h == INVALID_HANDLE_VALUE); - while (!ready && ok) { - const char *fname = data.cFileName; - string path = string(dirname) + "/" + fname; - if (isDirectory(path.c_str())) { - if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) - ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); - } - else if (isFile(path.c_str())) - ok = remove(path); - else - ok = false; - ready = !FindNextFile(h, &data); - } - FindClose(h); -#else - if (DIR *dir = opendir(dirname)) { - struct dirent *ent; - while ((ent = readdir(dir)) && ok) { - const char *fname = ent->d_name; - string path = string(fname) + "/" + fname; - if (isDirectory(path.c_str())) { - if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) - ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); - } - else if (isFile(path.c_str())) - ok = remove(path); - else - ok = false; - } - closedir(dir); - } -#endif - ok = s_rmdir(dirname); - } - return ok; -} - - -/** Checks if a file or directory exits. */ -bool FileSystem::exists (const char *fname) { - if (!fname) - return false; -#ifdef __WIN32__ - return GetFileAttributes(fname) != INVALID_FILE_ATTRIBUTES; -#else - struct stat attr; - return stat(fname, &attr) == 0; -#endif -} - - -/** Returns true if 'fname' references a directory. */ -bool FileSystem::isDirectory (const char *fname) { - if (!fname) - return false; -#ifdef __WIN32__ - return GetFileAttributes(fname) & FILE_ATTRIBUTE_DIRECTORY; -#else - struct stat attr; - return stat(fname, &attr) == 0 && S_ISDIR(attr.st_mode); -#endif -} - - -/** Returns true if 'fname' references a file. */ -bool FileSystem::isFile (const char *fname) { - if (!fname) - return false; -#ifdef __WIN32__ - ifstream ifs(fname); - return ifs; -#else - struct stat attr; - return stat(fname, &attr) == 0 && S_ISREG(attr.st_mode); -#endif -} - - -int FileSystem::collect (const char *dirname, vector &entries) { - entries.clear(); -#ifdef __WIN32__ - string pattern = string(dirname) + "/*"; - WIN32_FIND_DATA data; - HANDLE h = FindFirstFile(pattern.c_str(), &data); - bool ready = (h == INVALID_HANDLE_VALUE); - while (!ready) { - string fname = data.cFileName; - string path = string(dirname)+"/"+fname; - string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; - if (fname != "." && fname != "..") - entries.push_back(typechar+fname); - ready = !FindNextFile(h, &data); - } - FindClose(h); -#else - if (DIR *dir = opendir(dirname)) { - struct dirent *ent; - while ((ent = readdir(dir))) { - string fname = ent->d_name; - string path = string(dirname)+"/"+fname; - string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; - if (fname != "." && fname != "..") - entries.push_back(typechar+fname); - } - closedir(dir); - } -#endif - return entries.size(); -} - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.h deleted file mode 100644 index c920a5046e6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FileSystem.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************* -** FileSystem.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FILESYSTEM_H -#define FILESYSTEM_H - -#include -#include -#include "types.h" - -struct FileSystem -{ - static bool remove (const std::string &fname); - static bool rename (const std::string &oldname, const std::string &newname); - static bool copy (const std::string &src, const std::string &dest, bool remove_src=false); - static UInt64 filesize (const std::string &fname); - static std::string adaptPathSeperators (std::string path); - static std::string getcwd (); - static bool chdir (const char *dir); - static bool exists (const char *file); - static bool mkdir (const char *dir); - static bool rmdir (const char *fname); - static int collect (const char *dirname, std::vector &entries); - static bool isDirectory (const char *fname); - static bool isFile (const char *fname); - static const char* userdir (); - static const char* DEVNULL; - static const char PATHSEP; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.cpp deleted file mode 100644 index f9ec0737a2d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/************************************************************************* -** Font.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "FileSystem.h" -#include "Font.h" -#include "FontEngine.h" -#include "FileFinder.h" -#include "GFGlyphTracer.h" -#include "Glyph.h" -#include "Message.h" -#include "MetafontWrapper.h" -#include "TFM.h" -#include "VFReader.h" -#include "macros.h" -#include "FileSystem.h" -#include "SignalHandler.h" -#include "Subfont.h" -#include "SVGTree.h" -#include "FontMap.h" - -using namespace std; - - -/** Returns true if 'unicode' is a valid unicode value in XML documents. - * XML version 1.0 doesn't allow various unicode character references - * ( for example). */ -static bool valid_unicode (UInt32 unicode) { - UInt32 ranges[] = { - 0x0000, 0x0020, - 0x007f, 0x0084, - 0x0086, 0x009f, - 0xfdd0, 0xfddf - }; - for (int i=0; i < 4; i++) - if (unicode >= ranges[2*i] && unicode <= ranges[2*i+1]) - return false; - return true; -} - - -UInt32 Font::unicode (UInt32 c) const { - // @@ this should be optimized :-) - return valid_unicode(c) ? c : 0x3400+c; -} - - -/////////////////////////////////////////////////////////////////////////////////////// - - -TFMFont::TFMFont (string name, UInt32 cs, double ds, double ss) - : tfm(0), fontname(name), checksum(cs), dsize(ds), ssize(ss) -{ -} - - -TFMFont::~TFMFont () { - delete tfm; -} - - -/** Returns a font metrics object for the current font. - * @throw FontException if TFM file can't be found */ -const TFM* TFMFont::getTFM () const { - if (!tfm) { - tfm = TFM::createFromFile(fontname.c_str()); - if (!tfm) - throw FontException("can't find "+fontname+".tfm"); - } - return tfm; -} - - -double TFMFont::charWidth (int c) const { - double w = getTFM()->getCharWidth(c); - if (style()) - w *= style()->extend; - return w; -} - - -double TFMFont::italicCorr (int c) const { - double w = getTFM()->getItalicCorr(c); - if (style()) - w *= style()->extend; - return w; -} - - -double TFMFont::charDepth (int c) const {return getTFM()->getCharDepth(c);} -double TFMFont::charHeight (int c) const {return getTFM()->getCharHeight(c);} - - -bool TFMFont::verifyChecksums () const { - if (checksum != 0 && getTFM()->getChecksum() != 0) - return checksum == getTFM()->getChecksum(); - return true; -} - -////////////////////////////////////////////////////////////////////////////// - -// static class variables -bool PhysicalFont::KEEP_TEMP_FILES = false; -const char *PhysicalFont::CACHE_PATH = 0; -double PhysicalFont::METAFONT_MAG = 4; -FontCache PhysicalFont::_cache; - - -Font* PhysicalFont::create (string name, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type) { - return new PhysicalFontImpl(name, 0, checksum, dsize, ssize, type); -} - - -Font* PhysicalFont::create (string name, int fontindex, UInt32 checksum, double dsize, double ssize) { - return new PhysicalFontImpl(name, fontindex, checksum, dsize, ssize, PhysicalFont::TTC); -} - - -const char* PhysicalFont::path () const { - string ext; - switch (type()) { - case PFB: ext = "pfb"; break; - case TTC: ext = "ttc"; break; - case TTF: ext = "ttf"; break; - case MF : ext = "mf"; break; - } - return FileFinder::lookup(name()+"."+ext); -} - - -/** Returns the number of units per EM. The EM square is the virtual area a glyph is designed on. - * All coordinates used to specify portions of the glyph are relative to the origin (0,0) at the - * lower left corner of this square, while the upper right corner is located at (m,m), where m - * is an integer value defined with the font, and returned by this function. */ -int PhysicalFont::unitsPerEm() const { - if (type() == MF) - return 1000; - FontEngine::instance().setFont(*this); - return FontEngine::instance().getUnitsPerEM(); -} - - -int PhysicalFont::hAdvance () const { - if (type() == MF) - return 0; - FontEngine::instance().setFont(*this); - return FontEngine::instance().getHAdvance(); -} - - -double PhysicalFont::hAdvance (int c) const { - if (type() == MF) - return unitsPerEm()*charWidth(c)/designSize(); - FontEngine::instance().setFont(*this); - if (FontEncoding *enc = encoding()) - return FontEngine::instance().getHAdvance(enc->getEntry(c)); - if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) - if (Subfont *sf = map_entry->subfont) - c = sf->decode(c); - return FontEngine::instance().getHAdvance(c); -} - - -string PhysicalFont::glyphName (int c) const { - if (type() == MF) - return ""; - FontEngine::instance().setFont(*this); - if (FontEncoding *enc = encoding()) { - const char *name = enc->getEntry(c); - return name ? name : ""; - } - if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) - if (Subfont *sf = map_entry->subfont) - c = sf->decode(c); - return FontEngine::instance().getGlyphName(c); -} - - -int PhysicalFont::ascent () const { - if (type() == MF) - return 0; - FontEngine::instance().setFont(*this); - return FontEngine::instance().getAscender(); -} - - -int PhysicalFont::descent () const { - if (type() == MF) - return 0; - FontEngine::instance().setFont(*this); - return FontEngine::instance().getDescender(); -} - - -/** Extracts the glyph outlines of a given character. - * @param[in] c character code of requested glyph - * @param[out] glyph path segments of the glyph outline - * @param[in] cb optional callback object for tracer class - * @return true if outline could be computed */ -bool PhysicalFont::getGlyph (int c, GraphicPath &glyph, GFGlyphTracer::Callback *cb) const { - if (type() == MF) { - const Glyph *cached_glyph=0; - if (CACHE_PATH) { - _cache.write(CACHE_PATH); - _cache.read(name().c_str(), CACHE_PATH); - cached_glyph = _cache.getGlyph(c); - } - if (cached_glyph) { - glyph = *cached_glyph; - return true; - } - else { - string gfname; - if (createGF(gfname)) { - try { - GFGlyphTracer tracer(gfname, unitsPerEm()/getTFM()->getDesignSize(), cb); - tracer.setGlyph(glyph); - tracer.executeChar(c); - glyph.closeOpenSubPaths(); - if (CACHE_PATH) - _cache.setGlyph(c, glyph); - return true; - } - catch (GFException &e) { - // @@ print error message - } - } - else { - Message::wstream(true) << "failed creating " << name() << ".gf\n"; - } - } - } - else { // PFB or TTF - bool ok=true; - FontEngine::instance().setFont(*this); - if (FontEncoding *enc = encoding()) { - if (const char *encname = enc->getEntry(c)) - ok = FontEngine::instance().traceOutline(encname, glyph, false); - } - else { - if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) - if (Subfont *sf = map_entry->subfont) - c = sf->decode(c); - ok = FontEngine::instance().traceOutline(c, glyph, false); - } - glyph.closeOpenSubPaths(); - return ok; - } - return false; -} - - -/** Creates a GF file for this font object. - * @param[out] gfname name of GF font file - * @return true on success */ -bool PhysicalFont::createGF (string &gfname) const { - SignalHandler::instance().check(); - gfname = name()+".gf"; - MetafontWrapper mf(name()); - bool ok = mf.make("ljfour", METAFONT_MAG); // call Metafont if necessary - return ok && mf.success() && getTFM(); -} - - -/** Traces all glyphs of the current font and stores them in the cache. If caching is disabled, nothing happens. - * @param[in] includeCached if true, glyphs already cached are traced again - * @param[in] cb optional callback methods called by the tracer - * @return number of glyphs traced */ -int PhysicalFont::traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb) const { - int count = 0; - if (type() == MF && CACHE_PATH) { - if (const TFM *tfm = getTFM()) { - int fchar = tfm->firstChar(); - int lchar = tfm->lastChar(); - string gfname; - Glyph glyph; - if (createGF(gfname)) { - _cache.read(name().c_str(), CACHE_PATH); - GFGlyphTracer tracer(gfname, unitsPerEm()/getTFM()->getDesignSize(), cb); - tracer.setGlyph(glyph); - for (int i=fchar; i <= lchar; i++) { - if (includeCached || !_cache.getGlyph(i)) { - glyph.newpath(); - tracer.executeChar(i); - glyph.closeOpenSubPaths(); - _cache.setGlyph(i, glyph); - ++count; - } - } - _cache.write(CACHE_PATH); - } - } - } - return count; -} - - -/** Computes the exact bounding box of a glyph. - * @param[in] c character code of the glyph - * @param[out] bbox the computed bounding box - * @param[in] optional calback object forwarded to the tracer - * @return true if the box could be computed successfully */ -bool PhysicalFont::getGlyphBox(int c, BoundingBox& bbox, GFGlyphTracer::Callback* cb) const { - Glyph glyph; - if (getGlyph(c, glyph, cb)) { - glyph.computeBBox(bbox); - double s = scaledSize()/unitsPerEm(); - bbox.scale(s, s); - return true; - } - return false; -} - - -Font* VirtualFont::create (string name, UInt32 checksum, double dsize, double ssize) { - return new VirtualFontImpl(name, checksum, dsize, ssize); -} - - -////////////////////////////////////////////////////////////////////////////// - - -PhysicalFontImpl::PhysicalFontImpl (string name, int fontindex, UInt32 cs, double ds, double ss, PhysicalFont::Type type) - : TFMFont(name, cs, ds, ss), _filetype(type), _fontIndex(fontindex), _style(0), _charmap(0) -{ -} - - -PhysicalFontImpl::~PhysicalFontImpl () { - if (CACHE_PATH) - _cache.write(CACHE_PATH); - if (!KEEP_TEMP_FILES) - tidy(); - delete _style; - delete _charmap; -} - - -UInt32 PhysicalFontImpl::unicode (UInt32 c) const { - if (type() == MF) - return Font::unicode(c); - - if (_charmap == 0) { - FontEngine &fe = FontEngine::instance(); - if (fe.setFont(*this)) { - _charmap = new map; - fe.buildTranslationMap(*_charmap); - } - } - typedef map::const_iterator ConstIterator; - ConstIterator it = _charmap->find(c); - if (it != _charmap->end()) - return it->second; - - // No unicode equivalent found in font file. - // Now we should look for a smart alternative but at the moment - // it's sufficient to simply choose a valid unused unicode value... - map reverse_map; - FORALL(*_charmap, ConstIterator, it) - reverse_map[it->second] = it->first; - // can we use charcode itself as unicode replacement? - if (valid_unicode(c) && (reverse_map.empty() || reverse_map.find(c) != reverse_map.end())) - return c; - return 0x3400+c; -} - - -void PhysicalFontImpl::tidy () const { - if (type() == MF) { - const char *ext[] = {"gf", "tfm", "log", 0}; - for (const char **p=ext; *p; ++p) { - if (FileSystem::exists((name()+"."+(*p)).c_str())) - FileSystem::remove(name()+"."+(*p)); - } - } -} - - -void PhysicalFontImpl::setStyle (double bold, double extend, double slant) { - if (_style) { - _style->bold = bold; - _style->extend = extend; - _style->slant = slant; - } - else if (bold != 0 || extend != 1 || slant != 0) - _style = new Style(bold, extend, slant); -} - - -////////////////////////////////////////////////////////////////////////////// - -VirtualFontImpl::VirtualFontImpl (string name, UInt32 cs, double ds, double ss) - : TFMFont(name, cs, ds, ss) -{ -} - - -VirtualFontImpl::~VirtualFontImpl () { - // delete dvi vectors received by VFReaderAction - for (map::iterator i=charDefs.begin(); i != charDefs.end(); ++i) - delete i->second; -} - - -const char* VirtualFontImpl::path () const { - return FileFinder::lookup(name()+".vf"); -} - - -void VirtualFontImpl::assignChar (UInt32 c, DVIVector *dvi) { - if (dvi) { - if (charDefs.find(c) == charDefs.end()) - charDefs[c] = dvi; - else - delete dvi; - } -} - - -const vector* VirtualFontImpl::getDVI (int c) const { - map::const_iterator it = charDefs.find(c); - return (it == charDefs.end() ? 0 : it->second); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.h deleted file mode 100644 index ed3c82f3634..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Font.h +++ /dev/null @@ -1,280 +0,0 @@ -/************************************************************************* -** Font.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONT_H -#define FONT_H - -#include -#include -#include -#include "FontCache.h" -#include "FontEncoding.h" -#include "GFGlyphTracer.h" -#include "Glyph.h" -#include "GraphicPath.h" -#include "MessageException.h" -#include "VFActions.h" -#include "VFReader.h" -#include "types.h" - -class TFM; - - -/** Abstract base for all font classes. */ -struct Font { - struct Style { - Style () : bold(0), extend(0), slant(0) {} - Style (float b, float e, float s) : bold(b), extend(e), slant(s) {} - double bold; ///< stroke width in pt used to draw the glyph outlines - double extend; ///< factor to strech/shrink the glyphs horizontally - double slant; ///< horizontal slanting/skewing value (= tan(phi)) - }; - - virtual ~Font () {} - virtual Font* clone (double ds, double sc) const =0; - virtual const Font* uniqueFont () const =0; - virtual std::string name () const =0; - virtual double designSize () const =0; - virtual double scaledSize () const =0; - virtual double scaleFactor () const {return scaledSize()/designSize();} - virtual double charWidth (int c) const =0; - virtual double charDepth (int c) const =0; - virtual double charHeight (int c) const =0; - virtual double italicCorr (int c) const =0; - virtual const TFM* getTFM () const =0; - virtual const char* path () const =0; - virtual FontEncoding* encoding () const {return FontEncoding::encoding(name());} - virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const =0; - virtual UInt32 unicode (UInt32 c) const; - virtual void tidy () const {} - virtual bool verifyChecksums () const {return true;} - virtual int fontIndex () const {return 0;} - virtual const Style* style () const {return 0;} -}; - - -/** Empty font without any glyphs. Instances of this class are used - * if no physical or virtual font file can be found. - * The metric values returned by the member functions are based on cmr10. */ -struct EmptyFont : public Font -{ - public: - EmptyFont (std::string name) : fontname(name) {} - Font* clone (double ds, double sc) const {return new EmptyFont(*this);} - const Font* uniqueFont () const {return this;} - std::string name () const {return fontname;} - double designSize () const {return 10;} // cmr10 design size in pt - double scaledSize () const {return 10;} // cmr10 scaled size in pt - double charWidth (int c) const {return 9.164;} // width of cmr10's 'M' in pt - double charHeight (int c) const {return 6.833;} // height of cmr10's 'M' in pt - double charDepth (int c) const {return 0;} - double italicCorr (int c) const {return 0;} - const TFM* getTFM () const {return 0;} - const char* path () const {return 0;} - bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const {return false;} - - private: - std::string fontname; -}; - - -/** Interface for all physical fonts. */ -class PhysicalFont : public virtual Font -{ - public: - enum Type {MF, PFB, TTC, TTF}; - static Font* create (std::string name, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type); - static Font* create (std::string name, int fontindex, UInt32 checksum, double dsize, double ssize); - virtual Type type () const =0; - virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const; - virtual bool getGlyphBox (int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb=0) const; - virtual int hAdvance () const; - virtual double hAdvance (int c) const; - std::string glyphName (int c) const; - virtual int unitsPerEm () const; - virtual int ascent () const; - virtual int descent () const; - virtual int traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb=0) const; - const char* path () const; - virtual void setStyle (double bold, double extend, double slant) {} - - protected: - bool createGF (std::string &gfname) const; - - public: - static bool KEEP_TEMP_FILES; - static const char *CACHE_PATH; ///< path to cache directory (0 if caching is disabled) - static double METAFONT_MAG; ///< magnification factor for Metafont calls - - protected: - static FontCache _cache; -}; - - -/** Interface for all virtual fonts. */ -class VirtualFont : public virtual Font -{ - friend class FontManager; - public: - typedef std::vector DVIVector; - - public: - static Font* create (std::string name, UInt32 checksum, double dsize, double ssize); - virtual const DVIVector* getDVI (int c) const =0; - bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const {return false;} - - protected: - virtual void assignChar (UInt32 c, DVIVector *dvi) =0; -}; - - -class TFMFont : public virtual Font -{ - public: - TFMFont (std::string name, UInt32 checksum, double dsize, double ssize); - ~TFMFont (); - const TFM* getTFM () const; - std::string name () const {return fontname;} - double designSize () const {return dsize;} - double scaledSize () const {return ssize;} - double charWidth (int c) const; - double charDepth (int c) const; - double charHeight (int c) const; - double italicCorr (int c) const; - bool verifyChecksums () const; - - private: - mutable TFM *tfm; - std::string fontname; - UInt32 checksum; ///< cheksum to be compared with TFM checksum - double dsize; ///< design size in TeX point units - double ssize; ///< scaled size -}; - - -class PhysicalFontProxy : public PhysicalFont -{ - friend class PhysicalFontImpl; - public: - Font* clone (double ds, double sc) const {return new PhysicalFontProxy(*this, ds, sc);} - const Font* uniqueFont () const {return pf;} - std::string name () const {return pf->name();} - double designSize () const {return dsize;} - double scaledSize () const {return ssize;} - double charWidth (int c) const {return pf->charWidth(c);} - double charDepth (int c) const {return pf->charDepth(c);} - double charHeight (int c) const {return pf->charHeight(c);} - double italicCorr (int c) const {return pf->italicCorr(c);} - const TFM* getTFM () const {return pf->getTFM();} - Type type () const {return pf->type();} - UInt32 unicode (UInt32 c) const {return pf->unicode(c);} - int fontIndex () const {return pf->fontIndex();} - const Style* style () const {return pf->style();} - - protected: - PhysicalFontProxy (const PhysicalFont *font, double ds, double ss) : pf(font), dsize(ds), ssize(ss) {} - PhysicalFontProxy (const PhysicalFontProxy &proxy, double ds, double ss) : pf(proxy.pf), dsize(ds), ssize(ss) {} - - private: - const PhysicalFont *pf; - double dsize; ///< design size in TeX point units - double ssize; ///< scaled size -}; - - -class PhysicalFontImpl : public PhysicalFont, public TFMFont -{ - friend class PhysicalFont; - public: - ~PhysicalFontImpl(); - Font* clone (double ds, double ss) const {return new PhysicalFontProxy(this, ds, ss);} - const Font* uniqueFont () const {return this;} - Type type () const {return _filetype;} - int fontIndex() const {return _fontIndex;} - const Style* style () const {return _style;} - void setStyle (double bold, double extend, double slant); - UInt32 unicode (UInt32 c) const; - void tidy () const; - - protected: - PhysicalFontImpl (std::string name, int fontindex, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type); - - private: - Type _filetype; - int _fontIndex; - Style *_style; - mutable std::map *_charmap; -}; - - -class VirtualFontProxy : public VirtualFont -{ - friend class VirtualFontImpl; - public: - Font* clone (double ds, double ss) const {return new VirtualFontProxy(*this, ds, ss);} - const Font* uniqueFont () const {return vf;} - std::string name () const {return vf->name();} - const DVIVector* getDVI (int c) const {return vf->getDVI(c);} - double designSize () const {return dsize;} - double scaledSize () const {return ssize;} - double charWidth (int c) const {return vf->charWidth(c);} - double charDepth (int c) const {return vf->charDepth(c);} - double charHeight (int c) const {return vf->charHeight(c);} - double italicCorr (int c) const {return vf->italicCorr(c);} - const TFM* getTFM () const {return vf->getTFM();} - const char* path () const {return vf->path();} - - protected: - VirtualFontProxy (const VirtualFont *font, double ds, double ss) : vf(font), dsize(ds), ssize(ss) {} - VirtualFontProxy (const VirtualFontProxy &proxy, double ds, double ss) : vf(proxy.vf), dsize(ds), ssize(ss) {} - void assignChar (UInt32 c, DVIVector *dvi) {delete dvi;} - - private: - const VirtualFont *vf; - double dsize; ///< design size in TeX point units - double ssize; ///< scaled size in TeX point units -}; - - -class VirtualFontImpl : public VirtualFont, public TFMFont -{ - friend class VirtualFont; - public: - ~VirtualFontImpl (); - Font* clone (double ds, double ss) const {return new VirtualFontProxy(this, ds, ss);} - const Font* uniqueFont () const {return this;} - const DVIVector* getDVI (int c) const; - const char* path () const; - - protected: - VirtualFontImpl (std::string name, UInt32 checksum, double dsize, double ssize); - void assignChar (UInt32 c, DVIVector *dvi); - - private: - std::map charDefs; ///< dvi subroutines defining the characters -}; - - -struct FontException : public MessageException -{ - FontException (std::string msg) : MessageException(msg) {} -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.cpp deleted file mode 100644 index a36df9afa82..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/************************************************************************* -** FontCache.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include "CRC32.h" -#include "FileSystem.h" -#include "FontCache.h" -#include "Glyph.h" -#include "Pair.h" -#include "StreamReader.h" -#include "StreamWriter.h" -//#include "gzstream.h" -#include "types.h" - -using namespace std; - -const UInt8 FontCache::VERSION = 5; - - -static Pair32 read_pair (int bytes, StreamReader &sr) { - Int32 x = sr.readSigned(bytes); - Int32 y = sr.readSigned(bytes); - return Pair32(x, y); -} - - -FontCache::FontCache () : _changed(false) -{ -} - - -FontCache::~FontCache () { - clear(); -} - - -/** Removes all data from the cache. This does not affect the cache files. */ -void FontCache::clear () { - _glyphs.clear(); - _fontname.clear(); -} - - -/** Assigns glyph data to a character and adds it to the cache. - * @param[in] c character code - * @param[in] glyph font glyph data */ -void FontCache::setGlyph (int c, const Glyph &glyph) { - _glyphs[c] = glyph; - _changed = true; -} - - -/** Returns the corresponding glyph data of a given character of the current font. - * @param[in] c character code - * @return font glyph data (0 if no matching data was found) */ -const Glyph* FontCache::getGlyph (int c) const { - GlyphMap::const_iterator it = _glyphs.find(c); - return (it != _glyphs.end()) ? &it->second : 0; -} - - -/** Writes the current cache data to a file (only if anything changed after - * the last call of read()). - * @param[in] fontname name of current font - * @param[in] dir directory where the cache file should go - * @return true if writing was successful */ -bool FontCache::write (const char *fontname, const char *dir) const { - if (!_changed) - return true; - - if (fontname && strlen(fontname) > 0) { - if (dir == 0 || strlen(dir) == 0) - dir = FileSystem::getcwd().c_str(); - ostringstream oss; - oss << dir << '/' << fontname << ".fgd"; -// ogzstream ofs(oss.str().c_str(), 9, ios::binary|ios::out); - ofstream ofs(oss.str().c_str(), ios::binary); - return write(fontname, ofs); - } - return false; -} - - -bool FontCache::write (const char* dir) const { - return _fontname.empty() ? false : write(_fontname.c_str(), dir); -} - - -/** Returns the minimal number of bytes needed to store the given value. */ -static int max_int_size (Int32 value) { - Int32 limit = 0x7f; - for (int i=1; i <= 4; i++) { - if ((value < 0 && -value <= limit+1) || (value >= 0 && value <= limit)) - return i; - limit = (limit << 8) | 0xff; - } - return 4; -} - - -/** Returns the minimal number of bytes needed to store the biggest - * pair component of the given vector. */ -static int max_int_size (const Pair *pairs, size_t n) { - int ret=0; - for (size_t i=0; i < n; i++) { - ret = max(ret, max_int_size(pairs[i].x())); - ret = max(ret, max_int_size(pairs[i].y())); - } - return ret; -} - - -/** Writes the current cache data to a stream (only if anything changed after - * the last call of read()). - * @param[in] fontname name of current font - * @param[in] os output stream - * @return true if writing was successful */ -bool FontCache::write (const char *fontname, ostream &os) const { - if (!_changed) - return true; - if (!os) - return false; - - StreamWriter sw(os); - CRC32 crc32; - - struct WriteActions : Glyph::Actions { - WriteActions (StreamWriter &sw, CRC32 &crc32) : _sw(sw), _crc32(crc32) {} - - void draw (char cmd, const Glyph::Point *points, int n) { - int bytes = max_int_size(points, n); - int cmdchar = (bytes << 5) | (cmd - 'A'); - _sw.writeUnsigned(cmdchar, 1, _crc32); - for (int i=0; i < n; i++) { - _sw.writeSigned(points[i].x(), bytes, _crc32); - _sw.writeSigned(points[i].y(), bytes, _crc32); - } - } - StreamWriter &_sw; - CRC32 &_crc32; - } actions(sw, crc32); - - sw.writeUnsigned(VERSION, 1, crc32); - sw.writeUnsigned(0, 4); // space for checksum - sw.writeString(fontname, crc32, true); - sw.writeUnsigned(_glyphs.size(), 4, crc32); - FORALL(_glyphs, GlyphMap::const_iterator, it) { - const Glyph &glyph = it->second; - sw.writeUnsigned(it->first, 4, crc32); - sw.writeUnsigned(glyph.size(), 2, crc32); - glyph.iterate(actions, false); - } - os.seekp(1); - sw.writeUnsigned(crc32.get(), 4); // insert CRC32 checksum - os.seekp(0, ios::end); - return true; -} - - -/** Reads font glyph information from a file. - * @param[in] fontname name of font data to read - * @param[in] dir directory where the cache files are located - * @return true if reading was successful */ -bool FontCache::read (const char *fontname, const char *dir) { - if (_fontname == fontname) - return true; - clear(); - if (fontname && strlen(fontname) > 0) { - if (dir == 0 || strlen(dir) == 0) - dir = FileSystem::getcwd().c_str(); - ostringstream oss; - oss << dir << '/' << fontname << ".fgd"; - ifstream ifs(oss.str().c_str(), ios::binary); -// igzstream ifs(oss.str().c_str(), 9, ios::binary|ios::in); - return read(fontname, ifs); - } - return false; -} - - -/** Reads font glyph information from a stream. - * @param[in] fontname name of font data to read - * @param[in] dir input stream - * @return true if reading was successful */ -bool FontCache::read (const char *fontname, istream &is) { - if (_fontname == fontname) - return true; - clear(); - _fontname = fontname; - if (!is) - return false; - - StreamReader sr(is); - CRC32 crc32; - if (sr.readUnsigned(1, crc32) != VERSION) - return false; - - UInt32 crc32_cmp = sr.readUnsigned(4); - crc32.update(is); - if (crc32.get() != crc32_cmp) - return false; - - is.clear(); - is.seekg(5); // continue reading after checksum - - string fname = sr.readString(); - if (fname != fontname) - return false; - - UInt32 num_glyphs = sr.readUnsigned(4); - while (num_glyphs-- > 0) { - UInt32 c = sr.readUnsigned(4); // character code - UInt16 s = sr.readUnsigned(2); // number of path commands - Glyph &glyph = _glyphs[c]; - while (s-- > 0) { - UInt8 cmdval = sr.readUnsigned(1); - UInt8 cmdchar = (cmdval & 0x1f) + 'A'; - int bytes = cmdval >> 5; - switch (cmdchar) { - case 'C': { - Pair32 p1 = read_pair(bytes, sr); - Pair32 p2 = read_pair(bytes, sr); - Pair32 p3 = read_pair(bytes, sr); - glyph.cubicto(p1, p2, p3); - break; - } - case 'L': - glyph.lineto(read_pair(bytes, sr)); - break; - case 'M': - glyph.moveto(read_pair(bytes, sr)); - break; - case 'Q': { - Pair32 p1 = read_pair(bytes, sr); - Pair32 p2 = read_pair(bytes, sr); - glyph.conicto(p1, p2); - break; - } - case 'Z': - glyph.closepath(); - } - } - } - _changed = false; - return true; -} - - -/** Collects font cache information. - * @param[in] dirname path to font cache directory - * @param[out] infos the collected font information - * @param[out] invalid names of outdated/corrupted cache files - * @return true on success */ -bool FontCache::fontinfo (const char *dirname, vector &infos, vector &invalid) { - infos.clear(); - invalid.clear(); - if (dirname) { - vector fnames; - FileSystem::collect(dirname, fnames); - FORALL(fnames, vector::iterator, it) { - if ((*it)[0] == 'f' && it->length() > 5 && it->substr(it->length()-4) == ".fgd") { - FontInfo info; - string path = string(dirname)+"/"+(it->substr(1)); - ifstream ifs(path.c_str(), ios::binary); - if (fontinfo(ifs, info)) - infos.push_back(info); - else - invalid.push_back(it->substr(1)); - } - } - } - return !infos.empty(); -} - - -/** Collects font cache information of a single font. - * @param[in] is input stream of the cache file - * @param[out] info the collected data - * @return true if data could be read, false if cache file is unavailable, outdated, or corrupted */ -bool FontCache::fontinfo (std::istream &is, FontInfo &info) { - info.name.clear(); - info.numchars = info.numbytes = info.numcmds = 0; - if (is) { - is.clear(); - is.seekg(0); - StreamReader sr(is); - CRC32 crc32; - if ((info.version = sr.readUnsigned(1, crc32)) != VERSION) - return false; - - info.checksum = sr.readUnsigned(4); - crc32.update(is); - if (crc32.get() != info.checksum) - return false; - - is.clear(); - is.seekg(5); // continue reading after checksum - - info.name = sr.readString(); - info.numchars = sr.readUnsigned(4); - for (UInt32 i=0; i < info.numchars; i++) { - sr.readUnsigned(4); // character code - UInt16 s = sr.readUnsigned(2); // number of path commands - while (s-- > 0) { - UInt8 cmdval = sr.readUnsigned(1); - UInt8 cmdchar = (cmdval & 0x1f) + 'A'; - int bytes = cmdval >> 5; - int bc = 0; - switch (cmdchar) { - case 'C': bc = 6*bytes; break; - case 'H': - case 'L': - case 'M': - case 'T': - case 'V': bc = 2*bytes; break; - case 'Q': - case 'S': bc = 4*bytes; break; - case 'Z': break; - default : return false; - } - info.numbytes += bc+1; // command length + command - info.numcmds++; - is.seekg(bc, ios_base::cur); - } - info.numbytes += 6; // number of path commands + char code - } - info.numbytes += 6+info.name.length(); // version + 0-byte + fontname + number of chars - } - return true; -} - - -/** Collects font cache information and write it to a stream. - * @param[in] dirname path to font cache directory - * @param[in] os output is written to this stream - * @param[in] purge if true, outdated and corrupted cache files are removed */ -void FontCache::fontinfo (const char *dirname, ostream &os, bool purge) { - if (dirname) { - vector infos; - vector invalid_files; - if (fontinfo(dirname, infos, invalid_files)) { - os << "cache format version " << infos[0].version << endl; - typedef map SortMap; - SortMap sortmap; - FORALL(infos, vector::iterator, it) - sortmap[it->name] = &(*it); - - FORALL(sortmap, SortMap::iterator, it) { - os << dec << setfill(' ') << left - << setw(10) << left << it->second->name - << setw(5) << right << it->second->numchars << " glyph" << (it->second->numchars == 1 ? ' ':'s') - << setw(10) << right << it->second->numcmds << " cmd" << (it->second->numcmds == 1 ? ' ':'s') - << setw(12) << right << it->second->numbytes << " byte" << (it->second->numbytes == 1 ? ' ':'s') - << setw(6) << "crc:" << setw(8) << hex << right << setfill('0') << it->second->checksum - << endl; - } - } - else - os << "cache is empty\n"; - FORALL(invalid_files, vector::iterator, it) { - string path=string(dirname)+"/"+(*it); - if (FileSystem::remove(path)) - os << "invalid cache file " << (*it) << " removed\n"; - } - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.h deleted file mode 100644 index cf4cbef7ec2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontCache.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************* -** FontCache.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONTCACHE_H -#define FONTCACHE_H - -#include -#include -#include -#include "types.h" -#include "Glyph.h" - -#ifdef VERSION -#undef VERSION -#endif - - -class FontCache -{ - typedef std::map GlyphMap; - - public: - struct FontInfo - { - std::string name; // fontname - UInt16 version; // file format version - UInt32 checksum; // CRC32 checksum of file data - UInt32 numchars; // number of characters - UInt32 numbytes; // number of bytes - UInt32 numcmds; // number of path commands - }; - - public: - FontCache (); - ~FontCache (); - bool read (const char *fontname, const char *dir); - bool read (const char *fontname, std::istream &is); - bool write (const char *dir) const; - bool write (const char *fontname, const char *dir) const; - bool write (const char *fontname, std::ostream &os) const; - const Glyph* getGlyph (int c) const; - void setGlyph (int c, const Glyph &glyph); - void clear (); - const std::string& fontname () const {return _fontname;} - - static bool fontinfo (const char *dirname, std::vector &infos, std::vector &invalid); - static bool fontinfo (std::istream &is, FontInfo &info); - static void fontinfo (const char *dirname, std::ostream &os, bool purge=false); - - private: - static const UInt8 VERSION; - std::string _fontname; - GlyphMap _glyphs; - bool _changed; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.cpp deleted file mode 100644 index c506292362c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/************************************************************************* -** FontEncoding.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "Font.h" -#include "FontEncoding.h" -#include "FontMap.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "FileFinder.h" -#include "Message.h" - -using namespace std; - -static string read_entry (InputReader &in); -static bool valid_name_char (int c); - - -FontEncoding::FontEncoding (const string &encname) : _encname(encname) -{ - read(); -} - - -const char* FontEncoding::path () const { - return FileFinder::lookup(_encname+".enc", false); -} - - -/** Search for suitable enc-file and read its encoding information. - * The file contents must be a valid PostScript vector with 256 entries. */ -void FontEncoding::read () { - if (const char *p = path()) { - ifstream ifs(p); - read(ifs); - } - else - Message::wstream(true) << "encoding file '" << _encname << ".enc' not found\n"; -} - - -/** Read encoding information from stream. */ -void FontEncoding::read (istream &is) { - StreamInputBuffer ib(is, 256); - BufferInputReader in(ib); - _table.resize(256); - - // find beginning of vector - while (!in.eof()) { - in.skipSpace(); - if (in.peek() == '%') - in.skipUntil("\n"); - else - if (in.get() == '[') - break; - } - - // read vector entries - int n=0; - while (!in.eof()) { - in.skipSpace(); - if (in.peek() == '%') - in.skipUntil("\n"); - else if (in.peek() == ']') { - in.get(); - break; - } - else { - string entry = read_entry(in); - if (entry == ".notdef") - entry.clear(); - if (n < 256) - _table[n++] = entry; - } - } - // remove trailing .notdef names - for (n--; n > 0 && _table[n].empty(); n--); - _table.resize(n+1); -} - - -static string read_entry (InputReader &in) { - string entry; - bool accept_slashes=true; - while (!in.eof() && ((in.peek() == '/' && accept_slashes) || valid_name_char(in.peek()))) { - if (in.peek() != '/') - accept_slashes = false; - entry += in.get(); - } - if (entry.length() > 1) { - // strip leading slashes - // According to the PostScript specification, a single slash without further - // following characters is a valid name. - size_t n=0; - while (n < entry.length() && entry[n] == '/') - n++; - entry = entry.substr(n); - } - return entry; -} - - -static bool valid_name_char (int c) { - const char *delimiters = "<>(){}[]/~%"; - return isprint(c) && !isspace(c) && !strchr(delimiters, c); -} - - -/** Returns an entry of the encoding table. - * @param[in] c character code - * @return character name assigned to character code c*/ -const char* FontEncoding::getEntry (int c) const { - if (c >= 0 && (size_t)c < _table.size()) - return !_table[c].empty() ? _table[c].c_str() : 0; - return 0; -} - - -struct EncodingMap : public map -{ - ~EncodingMap () { - for (EncodingMap::iterator it=begin(); it != end(); ++it) - delete it->second; - } -}; - - -/** Returns the encoding of a font. - * @param[in] fontname name of font whose encoding will be returned - * @return pointer to encoding object, or 0 if there is no encoding defined */ -FontEncoding* FontEncoding::encoding (string fontname) { - static EncodingMap encmap; - size_t pos = fontname.rfind('.'); - if (pos != string::npos) - fontname = fontname.substr(0, pos); // strip extension - if (const FontMap::Entry *entry = FontMap::instance().lookup(fontname)) { - EncodingMap::const_iterator it = encmap.find(entry->encname); - if (it != encmap.end()) - return it->second; - if (FileFinder::lookup(entry->encname + ".enc", false)) { - FontEncoding *enc = new FontEncoding(entry->encname); - encmap[entry->encname] = enc; - return enc; - } - } - return 0; -} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.h deleted file mode 100644 index 3170d850256..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEncoding.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************* -** FontEncoding.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONTENCODING_H -#define FONTENCODING_H - -#include -#include -#include -#include -#include "types.h" - - -class FontEncoding -{ - public: - FontEncoding (const std::string &name); - void read (); - void read (std::istream &is); - int size () const {return _table.size();} - std::string name () const {return _encname;} - const char* getEntry (int c) const; - const char* path () const; - static FontEncoding* encoding (std::string fontname); - - private: - std::string _encname; - std::vector _table; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.cpp deleted file mode 100644 index ab53b1bd644..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/************************************************************************* -** FontEngine.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include FT_GLYPH_H -#include FT_OUTLINE_H -#include FT_TRUETYPE_TABLES_H -#include FT_TYPES_H -#include "Font.h" -#include "FontEngine.h" -#include "Message.h" - -using namespace std; - - -/** Converts a floating point value to a 16.16 fixed point value. */ -static inline FT_Fixed to_16dot16 (double val) { - return static_cast(val*65536.0 + 0.5); -} - -/** Converts an integer to a 16.16 fixed point value. */ -static inline FT_Fixed to_16dot16 (int val) { - return static_cast(val) << 16; -} - -/** Converts a floating point value to a 26.6 fixed point value. */ -static inline FT_F26Dot6 to_26dot6 (double val) { - return static_cast(val*64.0 + 0.5); -} - -/** Converts an integer to a 26.6 fixed point value. */ -static inline FT_F26Dot6 to_26dot6 (int val) { - return static_cast(val) << 6; -} - - -/////////////////////////////////////////////////////////////////////////// - - -FontEngine::FontEngine () : _currentFace(0), _currentFont(0) -{ - _currentChar = _currentGlyphIndex = 0; - _horDeviceRes = _vertDeviceRes = 300; - if (FT_Init_FreeType(&_library)) - Message::estream(true) << "FontEngine: error initializing FreeType library\n"; -} - - -FontEngine::~FontEngine () { - if (_currentFace && FT_Done_Face(_currentFace)) - Message::estream(true) << "FontEngine: error removing glyph\n"; - if (FT_Done_FreeType(_library)) - Message::estream(true) << "FontEngine: error removing FreeType library\n"; -} - - -/** Returns the singleton instance of this class. */ -FontEngine& FontEngine::instance () { - static FontEngine engine; - return engine; -} - - -string FontEngine::version () { - FT_Int major, minor, patch; - FT_Library &lib = instance()._library; - FT_Library_Version(lib, &major, &minor, &patch); - ostringstream oss; - oss << major << '.' << minor << '.' << patch; - return oss.str(); -} - - -void FontEngine::setDeviceResolution (int x, int y) { - _horDeviceRes = x; - _vertDeviceRes = y; -} - - -/** Builds a table that maps glyph indexes to char codes. - * @param[in] face font face to be used - * @param[out] reverseMap the resulting map */ -static void build_reverse_map (FT_Face face, map &reverseMap) { - FT_UInt glyphIndex; - UInt32 charcode = FT_Get_First_Char(face, &glyphIndex); - while (glyphIndex) { -// if (reverseMap.find(glyphIndex) == reverseMap.end()) - reverseMap[glyphIndex] = charcode; - charcode = FT_Get_Next_Char(face, charcode, &glyphIndex); - } -} - - -/** Sets the font to be used. - * @param[in] fname path to font file - * @param[in] fontindex index of font in font collection (multi-font files, like TTC) - * @return true on success */ -bool FontEngine::setFont (const string &fname, int fontindex) { - if (FT_New_Face(_library, fname.c_str(), fontindex, &_currentFace)) { - Message::estream(true) << "FontEngine: error reading file " << fname << '\n'; - return false; - } - // look for a custom character map - for (int i=0; i < _currentFace->num_charmaps; i++) { - FT_CharMap charmap = _currentFace->charmaps[i]; - if (charmap->encoding == FT_ENCODING_ADOBE_CUSTOM) { - FT_Set_Charmap(_currentFace, charmap); - break; - } - } - return true; -} - - -bool FontEngine::setFont (const Font &font) { - if (!_currentFont || _currentFont->name() != font.name()) { - _currentFont = &font; - return setFont(font.path(), font.fontIndex()); - } - return true; -} - - -void FontEngine::buildTranslationMap (map &translationMap) const { - FT_CharMap unicodeMap=0, customMap=0; - for (int i=0; i < _currentFace->num_charmaps; i++) { - FT_CharMap charmap = _currentFace->charmaps[i]; - if (charmap->encoding == FT_ENCODING_ADOBE_CUSTOM) - customMap = charmap; - else if (charmap->encoding == FT_ENCODING_UNICODE) - unicodeMap = charmap; - } - if (unicodeMap == 0 || customMap == 0) - return; - - map reverseMap; - build_reverse_map(_currentFace, reverseMap); - - FT_Set_Charmap(_currentFace, unicodeMap); - FT_UInt glyphIndex; - UInt32 charcode = FT_Get_First_Char(_currentFace, &glyphIndex); - while (glyphIndex) { - translationMap[reverseMap[glyphIndex]] = charcode; - charcode = FT_Get_Next_Char(_currentFace, charcode, &glyphIndex); - } - FT_Set_Charmap(_currentFace, customMap); -} - - -const char* FontEngine::getFamilyName () const { - return _currentFace ? _currentFace->family_name : 0; -} - - -const char* FontEngine::getStyleName () const { - return _currentFace ? _currentFace->style_name : 0; -} - - -int FontEngine::getUnitsPerEM () const { - return _currentFace ? _currentFace->units_per_EM : 0; -} - - -int FontEngine::getAscender () const { - return _currentFace ? _currentFace->ascender : 0; -} - - -int FontEngine::getDescender () const { - return _currentFace ? _currentFace->descender : 0; -} - - -int FontEngine::getHAdvance () const { - if (_currentFace) { - TT_OS2 *table = static_cast(FT_Get_Sfnt_Table(_currentFace, ft_sfnt_os2)); - return table ? table->xAvgCharWidth : 0; - } - return 0; -} - - -int FontEngine::getHAdvance (unsigned c) const { - if (_currentFace) { - int index = FT_Get_Char_Index(_currentFace, (FT_ULong)c); - FT_Load_Glyph(_currentFace, index, FT_LOAD_NO_SCALE); - return _currentFace->glyph->metrics.horiAdvance; - } - return 0; -} - - -int FontEngine::getHAdvance (const char *name) const { - if (_currentFace && name) { - int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); - FT_Load_Glyph(_currentFace, index, FT_LOAD_NO_SCALE); - return _currentFace->glyph->metrics.horiAdvance; - } - return 0; -} - - -/** Get first available character of the current font face. */ -int FontEngine::getFirstChar () const { - if (_currentFace) - return _currentChar = FT_Get_First_Char(_currentFace, &_currentGlyphIndex); - return 0; -} - - -/** Get the next available character of the current font face. */ -int FontEngine::getNextChar () const { - if (_currentFace && _currentGlyphIndex) - return _currentChar = FT_Get_Next_Char(_currentFace, _currentChar, &_currentGlyphIndex); - return getFirstChar(); -} - - -/** Returns the glyph name for a given charater code. - * @param[in] c char code - * @return glyph name */ -string FontEngine::getGlyphName (unsigned c) const { - if (_currentFace && FT_HAS_GLYPH_NAMES(_currentFace)) { - char buf[256]; - int index = FT_Get_Char_Index(_currentFace, c); - FT_Get_Glyph_Name(_currentFace, index, buf, 256); - return string(buf); - } - return ""; -} - - -/* Returns the character code for a given glyph name. - * @param name glyph name - * @return char code or 0 if name couldn't be found -int FontEngine::getCharByGlyphName (const char *name) const { - if (_currentFace && FT_HAS_GLYPH_NAMES(_currentFace)) { - int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); - map::const_iterator it = _reverseMap.find(index); - if (it != _reverseMap.end()) - return it->second; - } - return 0; -}*/ - - -vector FontEngine::getPanose () const { - vector panose(10); - if (_currentFace) { - TT_OS2 *table = static_cast(FT_Get_Sfnt_Table(_currentFace, ft_sfnt_os2)); - if (table) - for (int i=0; i < 10; i++) - panose[i] = table->panose[i]; - } - return panose; -} - - -// handle API change in freetype version 2.2.1 -#if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 2 || (FREETYPE_MINOR == 2 && FREETYPE_PATCH >= 1))) - typedef const FT_Vector *FTVectorPtr; -#else - typedef FT_Vector *FTVectorPtr; -#endif - - -// Callback functions used by trace_outline/FT_Outline_Decompose -static int moveto (FTVectorPtr to, void *user) { - Glyph *glyph = static_cast(user); - glyph->moveto(to->x, to->y); - return 0; -} - - -static int lineto (FTVectorPtr to, void *user) { - Glyph *glyph = static_cast(user); - glyph->lineto(to->x, to->y); - return 0; -} - - -static int conicto (FTVectorPtr control, FTVectorPtr to, void *user) { - Glyph *glyph = static_cast(user); - glyph->conicto(control->x, control->y, to->x, to->y); - return 0; -} - - -static int cubicto (FTVectorPtr control1, FTVectorPtr control2, FTVectorPtr to, void *user) { - Glyph *glyph = static_cast(user); - glyph->cubicto(control1->x, control1->y, control2->x, control2->y, to->x, to->y); - return 0; -} - - -/** Traces the outline of a glyph by calling the corresponding "drawing" functions. - * Each glyph is composed of straight lines, quadratic (conic) or cubic B�zier curves. - * This function takes all these outline segments and processes them by calling - * the corresponding functions. The functions must be provided in form of a - * FEGlyphCommands object. - * @param[in] index index of the glyph that will be traced - * @param[in] commands the drawing commands to be executed - * @param[in] scale if true the current pt size will be considered otherwise the plain TrueType units are used. - * @return false on errors */ -static bool trace_outline (FT_Face face, const Font *font, int index, Glyph &glyph, bool scale) { - if (face) { - if (FT_Load_Glyph(face, index, scale ? FT_LOAD_DEFAULT : FT_LOAD_NO_SCALE)) { - Message::estream(true) << "can't load glyph " << int(index) << '\n'; - return false; - } - if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) { - Message::estream(true) << "no outlines found in glyph " << int(index) << '\n'; - return false; - } - FT_Outline outline = face->glyph->outline; - // apply style parameters if set - if (const Font::Style *style = font->style()) { - FT_Matrix matrix = {to_16dot16(style->extend), to_16dot16(style->slant), 0, to_16dot16(1)}; - FT_Outline_Transform(&outline, &matrix); - if (style->bold != 0) - FT_Outline_Embolden(&outline, style->bold/font->scaledSize()*face->units_per_EM); - } - const FT_Outline_Funcs funcs = {moveto, lineto, conicto, cubicto, 0, 0}; - FT_Outline_Decompose(&outline, &funcs, &glyph); - return true; - } - Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; - return false; -} - - -/** Traces the outline of a glyph by calling the corresponding "drawing" functions. - * Each glyph is composed of straight lines, quadratic (conic) or cubic B�zier curves. - * This function takes all these outline segments and processes them by calling - * the corresponding functions. The functions must be provided in form of a - * FEGlyphCommands object. - * @param[in] chr the glyph of this character will be traced - * @param[in] commands the drawing commands to be executed - * @param[in] scale if true the current pt size will be considered otherwise - * the plain TrueType units are used. - * @return false on errors */ -bool FontEngine::traceOutline (UInt16 chr, Glyph &glyph, bool scale) const { - if (_currentFace) { - int index = FT_Get_Char_Index(_currentFace, chr); - return trace_outline(_currentFace, _currentFont, index, glyph, scale); - } - Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; - return false; -} - - -bool FontEngine::traceOutline (const char *name, Glyph &glyph, bool scale) const { - if (_currentFace) { - int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); - return trace_outline(_currentFace, _currentFont, index, glyph, scale); - } - Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; - return false; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.h deleted file mode 100644 index 68652b66523..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontEngine.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************* -** FontEngine.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONTENGINE_H -#define FONTENGINE_H - -#include -#include FT_FREETYPE_H -#include -#include -#include -#include "types.h" -#include "Glyph.h" - -struct Font; - -/** This class provides methods to handle font files and font data. - * It's a wrapper for the Freetype font library. */ -class FontEngine -{ - public: - ~FontEngine (); - static FontEngine& instance (); - static std::string version (); - void setDeviceResolution (int x, int y); - bool setFont (const Font &font); - bool traceOutline (UInt16 chr, Glyph &glyph, bool scale=true) const; - bool traceOutline (const char *name, Glyph &glyph, bool scale) const; - const char* getFamilyName () const; - const char* getStyleName () const; - int getUnitsPerEM () const; - int getAscender () const; - int getDescender () const; - int getHAdvance () const; - int getHAdvance (unsigned int c) const; - int getHAdvance (const char *name) const; - int getFirstChar () const; - int getNextChar () const; - std::vector getPanose () const; - std::string getGlyphName (unsigned int c) const; - int getCharByGlyphName (const char *name) const; - void buildTranslationMap (std::map &translationMap) const; - - protected: - FontEngine (); - bool setFont (const std::string &fname, int fontindex=0); - - private: - int _horDeviceRes, _vertDeviceRes; - mutable unsigned int _currentChar, _currentGlyphIndex; - FT_Face _currentFace; - FT_Library _library; - const Font *_currentFont; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.cpp deleted file mode 100644 index 0481b59a969..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************* -** FontManager.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "Font.h" -#include "FontEncoding.h" -#include "FontManager.h" -#include "FontMap.h" -#include "FileFinder.h" -#include "Message.h" -#include "macros.h" - -using namespace std; - - -FontManager::~FontManager () { - FORALL(_fonts, vector::iterator, i) - delete *i; -} - - -/** Returns the singleton instance */ -FontManager& FontManager::instance () { - static FontManager fm; - return fm; -} - - -/** Returns a unique ID that identifies the font. - * @param[in] n local font number, as used in DVI and VF files - * @return non-negative font ID if font was found, -1 otherwise */ -int FontManager::fontID (int n) const { - if (_vfStack.empty()) { - Num2IdMap::const_iterator it = _num2id.find(n); - return (it == _num2id.end()) ? -1 : it->second; - } - VfNum2IdMap::const_iterator vit = _vfnum2id.find(_vfStack.top()); - if (vit == _vfnum2id.end()) - return -1; - const Num2IdMap &num2id = vit->second; - Num2IdMap::const_iterator it = num2id.find(n); - return (it == num2id.end()) ? -1 : it->second; -} - - -/** Returns a unique ID that identifies the font. Not the font object but the - * font pointer is looked up to get the ID. Thus, two different pointers - * referencing different objects of the same font are mapped to different IDs. - * @param[in] font pointer to font object to be identified - * @return non-negative font ID if font was found, -1 otherwise */ -int FontManager::fontID (const Font *font) const { - for (size_t i=0; i < _fonts.size(); i++) - if (_fonts[i] == font) - return i; - return -1; -} - - -/** Returns a unique ID that identifies the font. - * @param[in] name name of font to be identified, e.g. cmr10 - * @return non-negative font ID if font was found, -1 otherwise */ -int FontManager::fontID (const string &name) const { - map::const_iterator it = _name2id.find(name); - if (it == _name2id.end()) - return -1; - return it->second; -} - - -int FontManager::fontnum (int id) const { - if (id < 0 || size_t(id) > _fonts.size()) - return -1; - if (_vfStack.empty()) { - FORALL(_num2id, Num2IdMap::const_iterator, i) - if (i->second == id) - return i->first; - } - else { - VfNum2IdMap::const_iterator it = _vfnum2id.find(_vfStack.top()); - if (it == _vfnum2id.end()) - return -1; - const Num2IdMap &num2id = it->second; - FORALL(num2id, Num2IdMap::const_iterator, i) - if (i->second == id) - return i->first; - } - return -1; -} - - -int FontManager::vfFirstFontNum (VirtualFont *vf) const { - VfFirstFontMap::const_iterator it = _vfFirstFontMap.find(vf); - return (it == _vfFirstFontMap.end()) ? -1 : (int) it->second; -} - - -/** Returns a previously registered font. - * @param[in] n local font number, as used in DVI and VF files - * @return pointer to font if font was found, 0 otherwise */ -Font* FontManager::getFont (int n) const { - int id = fontID(n); - return (id < 0) ? 0 : _fonts[id]; -} - - -Font* FontManager::getFont (const string &name) const { - int id = fontID(name); - if (id < 0) - return 0; - return _fonts[id]; -} - - -Font* FontManager::getFontById (int id) const { - if (id < 0 || size_t(id) >= _fonts.size()) - return 0; - return _fonts[id]; -} - - -/** Returns the current active virtual font. */ -VirtualFont* FontManager::getVF () const { - return _vfStack.empty() ? 0 : _vfStack.top(); -} - - -static Font* create_font (const string &filename, const string &fontname, int fontindex, UInt32 checksum, double dsize, double ssize) { - string ext; - if (const char *dot = strrchr(filename.c_str(), '.')) - ext = dot+1; - if (!ext.empty() && FileFinder::lookup(filename)) { - if (ext == "pfb") - return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::PFB); - if (ext == "ttf") - return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::TTF); - if (ext == "ttc") - return PhysicalFont::create(fontname, fontindex, checksum, dsize, ssize); - if (ext == "vf") - return VirtualFont::create(fontname, checksum, dsize, ssize); - if (ext == "mf") - return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::MF); - } - return 0; -} - - -/** Registers a new font to be managed by the FontManager. If there is - * already a registered font assigned to number n, nothing happens. - * @param[in] fontnum local font number, as used in DVI and VF files - * @param[in] name TFM fontname given in DVI file, e.g. cmr10 - * @param[in] checksum checksum to be compared with TFM checksum - * @param[in] dsize design size in TeX point units - * @param[in] ssize scaled size in TeX point units - * @return id of registered font */ -int FontManager::registerFont (UInt32 fontnum, string name, UInt32 checksum, double dsize, double ssize) { - int id = fontID(fontnum); - if (id >= 0) - return id; - - Font *newfont = 0; - const int newid = _fonts.size(); // the new font gets this ID - Name2IdMap::iterator it = _name2id.find(name); - if (it != _name2id.end()) { // font with same name already registered? - Font *font = _fonts[it->second]; - newfont = font->clone(dsize, ssize); - } - else { - string filename = name; - int fontindex = 0; - const FontMap::Entry *map_entry = FontMap::instance().lookup(name); - if (map_entry) { - filename = map_entry->fontname; - fontindex = map_entry->fontindex; - } - // try to find font file with the exact given name - if (filename.rfind(".") != string::npos) - newfont = create_font(filename, name, fontindex, checksum, dsize, ssize); - else { - // try various font file formats if the given file has no extension - const char *exts[] = {".pfb", ".ttc", ".ttf", ".vf", ".mf", 0}; - for (const char **p = exts; *p && !newfont; ++p) - newfont = create_font(filename+*p, name, fontindex, checksum, dsize, ssize); - } - if (map_entry) - if (PhysicalFont *pf = dynamic_cast(newfont)) - pf->setStyle(map_entry->bold, map_entry->extend, map_entry->slant); - if (!newfont) { - // create dummy font as a placeholder if the proper font is not available - newfont = new EmptyFont(name); - if (filename.rfind(".") == string::npos) - filename += ".mf"; - // print warning message about missing font file (only once for each filename) - static set missing_fonts; - if (missing_fonts.find(filename) == missing_fonts.end()) { - Message::wstream(true) << "font file '" << filename << "' not found\n"; - missing_fonts.insert(filename); - } - } - else if (!newfont->verifyChecksums()) - Message::wstream(true) << "checksum mismatch in font " << name << '\n'; - _name2id[name] = newid; - } - _fonts.push_back(newfont); - if (_vfStack.empty()) // register font referenced in dvi file? - _num2id[fontnum] = newid; - else { // register font referenced in vf file - VirtualFont *vf = const_cast(_vfStack.top()); - _vfnum2id[vf][fontnum] = newid; - if (_vfFirstFontMap.find(vf) == _vfFirstFontMap.end()) // first fontdef of VF? - _vfFirstFontMap[vf] = fontnum; - } - return newid; -} - - -/** Enters a new virtual font frame. - * This method must be called before processing a VF character. - * @param[in] vf virtual font */ -void FontManager::enterVF (VirtualFont *vf) { - if (vf) - _vfStack.push(vf); -} - - -/** Leaves a previously entered virtual font frame. */ -void FontManager::leaveVF () { - if (!_vfStack.empty()) - _vfStack.pop(); -} - - -/** Assigns a sequence of DVI commands to a char code. - * @param[in] c character code - * @param[in] dvi points to vector with DVI commands */ -void FontManager::assignVfChar (int c, vector *dvi) { - if (!_vfStack.empty() && dvi) - _vfStack.top()->assignChar(c, dvi); -} - - -ostream& FontManager::write (ostream &os, Font *font, int level) { -#if 0 - if (font) { - int id = -1; - for (int i=0; i < fonts.size() && id < 0; i++) - if (fonts[i] == font) - id = i; - - VirtualFont *vf = dynamic_cast(font); - for (int j=0; j < level+1; j++) - os << " "; - os << "id " << id - << " fontnum " << fontnum(id) << " " - << (vf ? "VF" : "PF") << " " - << font->name() - << endl; - - if (vf) { - enterVF(vf); - const Num2IdMap &num2id = vfnum2id.find(vf)->second; - FORALL(num2id, Num2IdMap::const_iterator, i) { - Font *font = fonts[i->second]; - write(os, font, level+1); - } - leaveVF(); - } - } - else { - for (int i=0; i < fonts.size(); i++) - write(os, fonts[i], level); - os << endl; - } -#endif - return os; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.h deleted file mode 100644 index 18966269158..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontManager.h +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************* -** FontManager.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONTMANAGER_H -#define FONTMANAGER_H - -#include -#include -#include -#include -#include -#include -#include "types.h" - - -struct FileFinder; -struct Font; -class TFM; -class VirtualFont; - -/** This class provides methods for easy DVI font handling. - * DVI and VF files use local font numbers to reference fonts. For SVG output - * we need a single list with unique IDs of all physical fonts. Characters of - * virtual fonts are completely replaced by their DVI description so they don't - * appear anywhere in the output. */ -class FontManager -{ - typedef std::map Num2IdMap; - typedef std::map Name2IdMap; - typedef std::map VfNum2IdMap; - typedef std::map VfFirstFontMap; - typedef std::stack VfStack; - - public: - ~FontManager (); - static FontManager& instance (); - int registerFont (UInt32 fontnum, std::string fontname, UInt32 checksum, double dsize, double scale); - Font* getFont (int n) const; - Font* getFont (const std::string &name) const; - Font* getFontById (int id) const; - VirtualFont* getVF () const; - int fontID (int n) const; - int fontID (const Font *font) const; - int fontID (const std::string &name) const; - int fontnum (int id) const; - int vfFirstFontNum (VirtualFont *vf) const; - void enterVF (VirtualFont *vf); - void leaveVF (); - void assignVfChar (int c, std::vector *dvi); - const std::vector& getFonts () const {return _fonts;} - std::ostream& write (std::ostream &os, Font *font=0, int level=0); - - protected: - FontManager () {} - - private: - std::vector _fonts; ///< all registered Fonts - Num2IdMap _num2id; ///< DVI font number -> fontID - Name2IdMap _name2id; ///< fontname -> fontID - VfNum2IdMap _vfnum2id; - VfStack _vfStack; ///< stack of currently processed virtual fonts - VfFirstFontMap _vfFirstFontMap; ///< VF -> local font number of first font defined in VF -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.cpp deleted file mode 100644 index cd349080d14..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/************************************************************************* -** FontMap.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include "Directory.h" -#include "FileFinder.h" -#include "FontManager.h" -#include "FontMap.h" -#include "MapLine.h" -#include "Message.h" -#include "Subfont.h" - -using namespace std; - - -FontMap::~FontMap () { - for (Iterator it=_entries.begin(); it != _entries.end(); ++it) - delete it->second; -} - - -/** Returns the singleton instance. */ -FontMap& FontMap::instance() { - static FontMap fontmap; - return fontmap; -} - - -/** Reads and evaluates a single font map file. - * @param[in] fname name of map file to read - * @param[in] mode selects how to integrate the map file entries into the global map tree - * @return true if file could be opened */ -bool FontMap::read (const string &fname, FontMap::Mode mode) { - ifstream ifs(fname.c_str()); - if (!ifs) - return false; - - int line_number = 1; - while (ifs) { - if (strchr("\n&#%;*", ifs.peek())) // comment line? - ifs.ignore(numeric_limits::max(), '\n'); - else { - try { - MapLine mapline(ifs); - apply(mapline, mode); - } - catch (const MapLineException &e) { - Message::wstream(true) << fname << ", line " << line_number << ": " << e.what() << '\n'; - } - catch (const SubfontException &e) { - Message::wstream(true) << e.filename(); - if (e.lineno() > 0) - Message::wstream(false) << ", line " << e.lineno(); - Message::wstream(false) << e.what() << '\n'; - } - } - line_number++; - } - return true; -} - - -bool FontMap::read (const string &fname, char modechar) { - Mode mode; - switch (modechar) { - case '=': mode = FM_REPLACE; break; - case '-': mode = FM_REMOVE; break; - default : mode = FM_APPEND; - } - return read(fname, mode); -} - - -/** Applies a mapline according to the given mode (append, remove, replace). - * @param[in] mapline the mapline to be applied - * @param[in] mode mode to use - * @return true in case of success */ -bool FontMap::apply (const MapLine& mapline, FontMap::Mode mode) { - switch (mode) { - case FM_APPEND: - return append(mapline); - case FM_REMOVE: - return remove(mapline); - default: - return replace(mapline); - } -} - - -/** Applies a mapline according to the given mode (append, remove, replace). - * @param[in] mapline the mapline to be applied - * @param[in] modechar character that denotes the mode (+, -, or =) - * @return true in case of success */ -bool FontMap::apply (const MapLine& mapline, char modechar) { - Mode mode; - switch (modechar) { - case '=': mode = FM_REPLACE; break; - case '-': mode = FM_REMOVE; break; - default : mode = FM_APPEND; - } - return apply(mapline, mode); -} - - -/** Reads and evaluates a sequence of map files. Each map file is looked up in the local - * directory and the TeX file tree. - * @param[in] fname_seq comma-separated list of map file names - * @return true if at least one of the given map files was found */ -bool FontMap::read (const string &fname_seq) { - bool found = false; - size_t left=0; - while (left < fname_seq.length()) { - const char modechar = fname_seq[left]; - if (strchr("+-=", modechar)) - left++; - string fname; - size_t right = fname_seq.find(',', left); - if (right != string::npos) - fname = fname_seq.substr(left, right-left); - else { - fname = fname_seq.substr(left); - right = fname_seq.length(); - } - if (!fname.empty()) { - if (!read(fname, modechar)) { - if (const char *path = FileFinder::lookup(fname, false)) - found = found || read(path, modechar); - else - Message::wstream(true) << "map file " << fname << " not found\n"; - } - } - left = right+1; - } - return found; -} - - -/** Appends given map line data to the font map if there is no entry for the corresponding - * font in the map yet. - * @param[in] mapline parsed font data - * @return true if data has been appended */ -bool FontMap::append (const MapLine &mapline) { - bool ret = false; - if (!mapline.texname().empty()) { - if (!mapline.fontfname().empty() || !mapline.encname().empty()) { - vector subfonts; - if (mapline.sfd()) - mapline.sfd()->subfonts(subfonts); - else - subfonts.push_back(0); - for (size_t i=0; i < subfonts.size(); i++) { - string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); - Iterator it = _entries.find(fontname); - if (it == _entries.end()) { - _entries[fontname] = new Entry(mapline, subfonts[i]); - ret = true; - } - } - } - } - return ret; -} - - -/** Replaces the map data of the given font. - * If the font is locked (because it's already in use) nothing happens. - * @param[in] mapline parsed font data - * @return true if data has been replaced */ -bool FontMap::replace (const MapLine &mapline) { - if (mapline.texname().empty()) - return false; - if (mapline.fontfname().empty() && mapline.encname().empty()) - return remove(mapline); - - vector subfonts; - if (mapline.sfd()) - mapline.sfd()->subfonts(subfonts); - else - subfonts.push_back(0); - for (size_t i=0; i < subfonts.size(); i++) { - string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); - Iterator it = _entries.find(fontname); - if (it == _entries.end()) - _entries[fontname] = new Entry(mapline, subfonts[i]); - else if (!it->second->locked) - *it->second = Entry(mapline, subfonts[i]); - } - return true; -} - - -/** Removes the map entry of the given font. - * If the font is locked (because it's already in use) nothing happens. - * @param[in] mapline parsed font data - * @return true if entry has been removed */ -bool FontMap::remove (const MapLine &mapline) { - bool ret = false; - if (!mapline.texname().empty()) { - vector subfonts; - if (mapline.sfd()) - mapline.sfd()->subfonts(subfonts); - else - subfonts.push_back(0); - for (size_t i=0; i < subfonts.size(); i++) { - string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); - Iterator it = _entries.find(fontname); - if (it != _entries.end() && !it->second->locked) { - _entries.erase(it); - ret = true; - } - } - } - return ret; -} - - -ostream& FontMap::write (ostream &os) const { - for (ConstIterator it=_entries.begin(); it != _entries.end(); ++it) - os << it->first << " -> " << it->second->fontname << " [" << it->second->encname << "]\n"; - return os; -} - - -/** Reads and evaluates all map files in the given directory. - * @param[in] path to directory containing the map files to be read */ -void FontMap::readdir (const string &dirname) { - Directory dir(dirname); - while (const char *fname = dir.read('f')) { - if (strlen(fname) >= 4 && strcmp(fname+strlen(fname)-4, ".map") == 0) { - string path = dirname + "/" + fname; - read(path.c_str()); - } - } -} - - -/** Returns name of font that is mapped to a given font. - * @param[in] fontname name of font whose mapped name is retrieved - * @returns name of mapped font */ -const FontMap::Entry* FontMap::lookup (const string &fontname) const { - ConstIterator it = _entries.find(fontname); - if (it == _entries.end()) - return 0; - return it->second; -} - - -/** Sets the lock flag for the given font in order to avoid changing the map data of this font. - * @param[in] fontname name of font to be locked */ -void FontMap::lockFont (const string& fontname) { - Iterator it = _entries.find(fontname); - if (it != _entries.end()) - it->second->locked = true; -} - - -/** Removes all (unlocked) entries from the font map. - * @param[in] unlocked_only if true, only unlocked entries are removed */ -void FontMap::clear (bool unlocked_only) { - if (!unlocked_only) - _entries.clear(); - else { - Iterator it=_entries.begin(); - while (it != _entries.end()) { - if (it->second->locked) - ++it; - else { - delete it->second; - _entries.erase(it++); - } - } - } -} - -///////////////////////////////////////////////// - -FontMap::Entry::Entry (const MapLine &mapline, Subfont *sf) - : fontname(mapline.fontfname()), encname(mapline.encname()), subfont(sf), fontindex(mapline.fontindex()), locked(false), - bold(mapline.bold()), slant(mapline.slant()), extend(mapline.extend()) -{ -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.h deleted file mode 100644 index b3c1b85a304..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/FontMap.h +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************* -** FontMap.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef FONTMAP_H -#define FONTMAP_H - -#include -#include -#include - -class MapLine; -class Subfont; - -class FontMap -{ - public: - struct Entry - { - Entry (const MapLine &mapline, Subfont *subfont=0); - std::string fontname; ///< target font name - std::string encname; ///< name of font encoding - Subfont *subfont; - int fontindex; ///< index of font in multi-font file - bool locked; - double bold, slant, extend; - }; - - protected: - typedef std::map::iterator Iterator; - typedef std::map::const_iterator ConstIterator; - - public: - enum Mode {FM_APPEND, FM_REMOVE, FM_REPLACE}; - - ~FontMap (); - static FontMap& instance (); - bool read (const std::string &fname, Mode mode); - bool read (const std::string &fname, char modechar); - bool read (const std::string &fname_seq); - void readdir (const std::string &dirname); - bool apply (const MapLine &mapline, Mode mode); - bool apply (const MapLine &mapline, char modechar); - bool append (const MapLine &mapline); - bool replace (const MapLine &mapline); - bool remove (const MapLine &mapline); - void lockFont (const std::string &fontname); - void clear (bool unlocked_only=false); - std::ostream& write (std::ostream &os) const; - const Entry* lookup(const std::string &fontname) const; - - protected: - FontMap () {} - - private: - std::map _entries; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.cpp deleted file mode 100644 index c40702e595f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************* -** GFGlyphTracer.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "GFGlyphTracer.h" -#include "Pair.h" - -using namespace std; - -GFGlyphTracer::GFGlyphTracer () : GFTracer(_ifs, 0), _glyph(0), _callback(0) -{ -} - -/** Constructs a new glyph tracer. - * @param[in] is GF input stream - * @param[in] upp target units per TeX point */ -GFGlyphTracer::GFGlyphTracer (string &fname, double upp, Callback *cb) - : GFTracer(_ifs, upp), _glyph(0), _callback(cb) -{ - if (_callback) - _callback->setFont(fname); - _ifs.open(fname.c_str(), ios::binary); -} - - -void GFGlyphTracer::reset (string &fname, double upp) { - if (_callback) - _callback->setFont(fname); - if (_ifs.is_open()) - _ifs.close(); - unitsPerPoint(upp); - _ifs.open(fname.c_str(), ios::binary); -} - - -bool GFGlyphTracer::executeChar (UInt8 c) { - if (_glyph) { - if (_callback) - _callback->beginChar(c); - bool ok = GFTracer::executeChar(c); - if (_callback) { - if (ok) - _callback->endChar(c); - else - _callback->emptyChar(c); - return ok; - } - } - return false; -} - - -void GFGlyphTracer::moveTo (double x, double y) { - _glyph->moveto(int(x), int(y)); -} - - -void GFGlyphTracer::lineTo (double x, double y) { - _glyph->lineto(int(x), int(y)); -} - - -void GFGlyphTracer::curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y) { - _glyph->cubicto(int(c1x), int(c1y), int(c2x), int(c2y), int(x), int(y)); -} - - -void GFGlyphTracer::closePath () { - _glyph->closepath(); -} - - -void GFGlyphTracer::endChar (UInt32 c) { - _glyph->newpath(); - GFTracer::endChar(c); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.h deleted file mode 100644 index 379ed1d98c8..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFGlyphTracer.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************* -** GFGlyphTracer.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GFGLYPHTRACER_H -#define GFGLYPHTRACER_H - -#include -#include -#include "GFTracer.h" -#include "Glyph.h" - -class GFGlyphTracer : public GFTracer -{ - public: - struct Callback { - virtual ~Callback () {} - virtual void setFont (const std::string &fontname) {} - virtual void beginChar (UInt8 c) {} - virtual void endChar (UInt8 c) {} - virtual void emptyChar (UInt8 c) {} - }; - - public: - GFGlyphTracer (); - GFGlyphTracer (std::string &fname, double upp, Callback *cb=0); - void reset (std::string &fname, double upp); - void setCallback (Callback *cb) {_callback = cb;} - bool executeChar (UInt8 c); - void moveTo (double x, double y); - void lineTo (double x, double y); - void curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y); - void closePath (); - void endChar (UInt32 c); - void setGlyph (Glyph &glyph) {_glyph = &glyph;} - const Glyph& getGlyph () const {return *_glyph;} - - private: - std::ifstream _ifs; - Glyph *_glyph; - Callback *_callback; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.cpp deleted file mode 100644 index 1bb6c426549..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/************************************************************************* -** GFReader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "GFReader.h" -#include "macros.h" -#include "SignalHandler.h" - -using namespace std; - -struct GFCommand -{ - void (GFReader::*method)(int); - int numBytes; -}; - - -static inline double fix2double (Int32 fix) { - return double(fix)/(1 << 20); -} - - -static inline double scaled2double (Int32 scaled) { - return double(scaled)/(1 << 16); -} - - -GFReader::GFReader (istream &is) : _in(is), _penDown(false) -{ - _minX = _maxX = _minY = _maxY = _x = _y = 0; -} - - -UInt32 GFReader::readUnsigned (int bytes) { - UInt32 ret = 0; - for (int i=bytes-1; i >= 0 && !_in.eof(); i--) { - UInt32 b = _in.get(); - ret |= b << (8*i); - } - return ret; -} - - -Int32 GFReader::readSigned (int bytes) { - Int32 ret = _in.get(); - if (ret & 128) // negative value? - ret |= 0xffffff00; - for (int i=bytes-2; i >= 0 && !_in.eof(); i--) - ret = (ret << 8) | _in.get(); - return ret; -} - - -string GFReader::readString (int bytes) { - vector buf(bytes+1); - if (bytes > 0) - _in.get(&buf[0], bytes+1); // reads 'bytes' bytes (pos. bytes+1 is set to 0) - else - buf[0] = 0; - return &buf[0]; -} - - -/** Reads a single GF command from the current position of the input stream and calls the - * corresponding cmdFOO method. - * @return opcode of the executed command */ -int GFReader::executeCommand () { - SignalHandler::instance().check(); - /* Each cmdFOO command reads the necessary number of bytes from the stream so executeCommand - doesn't need to know the exact GF command format. Some cmdFOO methods are used for multiple - GF commands because they only differ in the size of their parameters. */ - static const GFCommand commands[] = { - {&GFReader::cmdPaint, 1}, {&GFReader::cmdPaint, 2}, {&GFReader::cmdPaint, 3}, // 64-66 - {&GFReader::cmdBoc, 0}, {&GFReader::cmdBoc1, 0}, // 67-68 - {&GFReader::cmdEoc, 0}, // 69 - {&GFReader::cmdSkip, 0}, {&GFReader::cmdSkip, 1}, {&GFReader::cmdSkip, 2},{&GFReader::cmdSkip, 3}, // 70-73 - {&GFReader::cmdXXX, 1}, {&GFReader::cmdXXX, 2}, {&GFReader::cmdXXX, 3}, {&GFReader::cmdXXX, 4}, // 239-242 - {&GFReader::cmdYYY, 0}, // 243 - {&GFReader::cmdNop, 0}, // 244 - {&GFReader::cmdCharLoc, 0}, {&GFReader::cmdCharLoc0, 0}, // 245-246 - {&GFReader::cmdPre, 0}, {&GFReader::cmdPost, 0}, {&GFReader::cmdPostPost, 0} // 247-249 - }; - - int opcode = _in.get(); - if (opcode < 0) // at end of file? - throw GFException("unexpected end of file"); - - if (opcode >= 0 && opcode <= 63) - cmdPaint0(opcode); - else if (opcode >= 74 && opcode <= 238) - cmdNewRow(opcode-74); - else if (opcode >= 250) { - ostringstream oss; - oss << "undefined GF command (opcode " << opcode << ")"; - throw GFException(oss.str()); - } - else { - int offset = opcode <= 73 ? 64 : 239-(73-64+1); - const GFCommand &cmd = commands[opcode-offset]; - if (cmd.method) - (this->*cmd.method)(cmd.numBytes); - } - return opcode; -} - - -bool GFReader::executeChar (UInt8 c) { - _in.clear(); - if (_charInfoMap.empty()) - executePostamble(); // read character info - _in.clear(); - Iterator it = _charInfoMap.find(c); - if (_in && it != _charInfoMap.end()) { - _in.seekg(it->second.location, ios_base::beg); - while (executeCommand() != 69); // execute all commands until eoc is reached - return true; - } - return false; -} - - -bool GFReader::executeAllChars () { - _in.clear(); - if (_charInfoMap.empty()) - executePostamble(); // read character info - _in.clear(); - if (_in) { - _in.seekg(0); - while (executeCommand() != 248); // execute all commands until postamble is reached - return true; - } - return false; -} - - -bool GFReader::executePostamble () { - _in.clear(); - if (!_in) - return false; - _in.seekg(-1, ios_base::end); - while (_in.peek() == 223) // skip fill bytes - _in.seekg(-1, ios_base::cur); - _in.seekg(-4, ios_base::cur); - UInt32 q = readUnsigned(4); // pointer to begin of postamble - _in.seekg(q, ios_base::beg); // now on begin of postamble - while (executeCommand() != 249); // execute all commands until postpost is reached - return true; -} - - -/** Returns the design size of this font int TeX point units. */ -double GFReader::getDesignSize () const { - return fix2double(_designSize); -} - -/** Returns the number of horizontal pixels per point. */ -double GFReader::getHPixelsPerPoint () const { - return scaled2double(_hppp); -} - -/** Returns the number of vertical pixels per point. */ -double GFReader::getVPixelsPerPoint () const { - return scaled2double(_vppp); -} - -/** Returns the width of character c in TeX point units */ -double GFReader::getCharWidth (UInt32 c) const { - ConstIterator it = _charInfoMap.find(c%256); - return it == _charInfoMap.end() ? 0 : it->second.width*getDesignSize()/(1<<24); -} - -/////////////////////// - - -/** Reads the preamble. */ -void GFReader::cmdPre (int) { - UInt32 i = readUnsigned(1); - if (i == 131) { - UInt32 k = readUnsigned(1); - string s = readString(k); - preamble(s); - } - else - throw GFException("invalid identification number in GF preamble"); -} - - -/** Reads the postamble. */ -void GFReader::cmdPost (int) { - readUnsigned(4); // pointer to byte after final eoc - _designSize = readUnsigned(4); // design size of font in points - _checksum = readUnsigned(4); // checksum - _hppp = readUnsigned(4); // horizontal pixels per point (scaled int) - _vppp = readUnsigned(4); // vertical pixels per point (scaled int) - _in.seekg(16, ios_base::cur); // skip x and y bounds - postamble(); -} - - -/** Reads trailing bytes at end of stream. */ -void GFReader::cmdPostPost (int) { - readUnsigned(4); // pointer to begin of postamble - UInt32 i = readUnsigned(1); - if (i == 131) - while (readUnsigned(1) == 223); // skip fill bytes - else - throw GFException("invalid identification number in GF preamble"); -} - - -/** Inverts "paint color" (black to white or vice versa) of n pixels - * and advances the cursor by n. - * @param[in] n number of pixels to be inverted */ -void GFReader::cmdPaint0 (int n) { - if (_penDown) // set pixels? - _bitmap.setBits(_y, _x, n); - _x += n; - _penDown = !_penDown; // inverse pen state -} - - -/** Inverts "paint color" (black to white or vice versa) of n pixels - * and advances the cursor by n. The number n of pixels is read from - * the input stream. - * @param[in] len size of n in bytes */ -void GFReader::cmdPaint (int len) { - UInt32 pixels = readUnsigned(len); - cmdPaint0(pixels); -} - - -/** Beginning of character (generic format). */ -void GFReader::cmdBoc (int) { - _currentChar = readSigned(4); - readSigned(4); // pointer to previous boc with same c mod 256 - _minX = readSigned(4); - _maxX = readSigned(4); - _minY = readSigned(4); - _maxY = readSigned(4); - _x = _minX; - _y = _maxY; - _penDown = false; - _bitmap.resize(_minX, _maxX, _minY, _maxY); - beginChar(_currentChar); -} - - -/** Beginning of character (compact format). */ -void GFReader::cmdBoc1 (int) { - _currentChar = readUnsigned(1); - UInt32 dx = readUnsigned(1); - _maxX = readUnsigned(1); - _minX = _maxX - dx; - UInt32 dy = readUnsigned(1); - _maxY = readUnsigned(1); - _minY = _maxY - dy; - _x = _minX; - _y = _maxY; - _penDown = false; - _bitmap.resize(_minX, _maxX, _minY, _maxY); - beginChar(_currentChar); -} - - -/** End of character. */ -void GFReader::cmdEoc (int) { - endChar(_currentChar); -} - - -/** Moves cursor to the beginning of a following row and sets - * paint color to white. - * @param[in] len if 0: move to next row, otherwise: number of bytes to read. - * The read value denotes the number of rows to be skipped. */ -void GFReader::cmdSkip (int len) { - if (len == 0) - _y--; - else - _y -= readUnsigned(len)+1; - _x = _minX; - _penDown = false; -} - - -/** Moves cursor to pixel number 'col' in the next row and sets - * the paint color to black. - * @param[in] col pixel/column number */ -void GFReader::cmdNewRow (int col) { - _x = _minX + col ; - _y--; - _penDown = true; -} - - -void GFReader::cmdXXX (int len) { - UInt32 n = readUnsigned(len); - string str = readString(n); - special(str); -} - - -void GFReader::cmdYYY (int) { - Int32 y = readSigned(4); - numspecial(y); -} - - -/** Does nothing. */ -void GFReader::cmdNop (int) { -} - - -/** Reads character locator (part of postamble) */ -void GFReader::cmdCharLoc0 (int) { - UInt8 c = readUnsigned(1); // character code mod 256 - UInt8 dm = readUnsigned(1); // - Int32 w = readSigned(4); // (1<<24)*characterWidth/designSize - Int32 p = readSigned(4); // pointer to begin of (last) character data - Int32 dx = 65536*dm; - Int32 dy = 0; - _charInfoMap[c] = CharInfo(dx, dy, w, p); -} - - -/** Reads character locator (part of postamble) */ -void GFReader::cmdCharLoc (int) { - UInt32 c = readUnsigned(1); // character code mod 256 - Int32 dx = readSigned(4); // horizontal escapement (scaled pixel units) - Int32 dy = readSigned(4); // vertical escapement (scaled pixel units) - Int32 w = readSigned(4); // (1<<24)*characterWidth/designSize - Int32 p = readSigned(4); // pointer to begin of (last) character data - _charInfoMap[c] = CharInfo(dx, dy, w, p); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.h deleted file mode 100644 index 0d9a7bb0e32..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFReader.h +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************************* -** GFReader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GFREADER_H -#define GFREADER_H - -#include -#include -#include -#include "Bitmap.h" -#include "MessageException.h" -#include "types.h" - - -class CharInfo; - - -struct GFException : public MessageException -{ - GFException (const std::string &msg) : MessageException(msg) {} -}; - - -class GFReader -{ - struct CharInfo - { - CharInfo () : dx(0), dy(0), width(0), location(0) {} - CharInfo (Int32 dxx, Int32 dyy, Int32 w, UInt32 p) : dx(dxx), dy(dyy), width(w), location(p) {} - - Int32 dx, dy; - Int32 width; // 2^24 * (true width)/(design size) - UInt32 location; - }; - - typedef std::map::iterator Iterator; - typedef std::map::const_iterator ConstIterator; - public: - GFReader (std::istream &is); - virtual ~GFReader () {} - bool executeChar (UInt8 c); - bool executeAllChars (); - bool executePostamble (); - virtual void preamble (const std::string &str) {} - virtual void postamble () {} - virtual void beginChar (UInt32 c) {} - virtual void endChar (UInt32 c) {} - virtual void special (std::string str) {} - virtual void numspecial (Int32 y) {} - const Bitmap& getBitmap () const {return _bitmap;} - double getDesignSize () const; - double getHPixelsPerPoint () const; - double getVPixelsPerPoint () const; - double getCharWidth (UInt32 c) const; - UInt32 getChecksum () const {return _checksum;} - - protected: - Int32 readSigned (int bytes); - UInt32 readUnsigned (int bytes); - std::string readString (int len); - int executeCommand (); - std::istream& getInputStream () const {return _in;} - - void cmdPre (int); - void cmdPost (int); - void cmdPostPost (int); - void cmdPaint0 (int pixels); - void cmdPaint (int len); - void cmdBoc (int); - void cmdBoc1 (int); - void cmdEoc (int); - void cmdSkip (int len); - void cmdNewRow (int col); - void cmdXXX (int len); - void cmdYYY (int); - void cmdNop (int); - void cmdCharLoc0 (int); - void cmdCharLoc (int); - - private: - std::istream &_in; - Int32 _minX, _maxX, _minY, _maxY; - Int32 _x, _y; // current pen location (pixel units) - Int32 _currentChar; - Bitmap _bitmap; // bitmap of current char - FixWord _designSize; // designSize - ScaledInt _hppp, _vppp; // horizontal and vertical pixel per point - UInt32 _checksum; - std::map _charInfoMap; - bool _penDown; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.cpp deleted file mode 100644 index 69a078456a0..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************* -** GFTracer.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "GFTracer.h" -#include "Glyph.h" -#include "Message.h" - -#ifdef __MSVC__ -#include -#else -extern "C" { -#include -} -#endif - -using namespace std; - - -GFTracer::GFTracer (istream &is) - : GFReader(is), _unitsPerPoint(0.0) -{ -} - - -/** Constructs a new GFTracer. - * @param[in] is GF file is read from this stream - * @param[in] upp target units per TeX point */ -GFTracer::GFTracer (istream &is, double upp) - : GFReader(is), _unitsPerPoint(upp) -{ -} - - -void GFTracer::beginChar (UInt32 c) { -} - - -void GFTracer::endChar (UInt32 c) { - const Bitmap &bitmap = getBitmap(); - if (bitmap.empty()) - return; - - // prepare potrace's bitmap structure - vector buffer; - potrace_bitmap_t pobitmap; - pobitmap.w = bitmap.width(); - pobitmap.h = bitmap.height(); - pobitmap.dy = bitmap.copy(buffer); - pobitmap.map = &buffer[0]; - potrace_param_t *param = potrace_param_default(); - potrace_state_t *state = potrace_trace(param, &pobitmap); - potrace_param_free(param); - - if (!state || state->status == POTRACE_STATUS_INCOMPLETE) - Message::wstream(true) << "error while tracing character\n"; - else { - double hsf=1.0, vsf=1.0; // horizontal a d vertical scale factor - if (_unitsPerPoint != 0.0) { - hsf = _unitsPerPoint/getHPixelsPerPoint(); // horizontal scale factor - vsf = _unitsPerPoint/getVPixelsPerPoint(); // vertical scale factor - } - for (potrace_path_t *path = state->plist; path; path = path->next) { - potrace_dpoint_t &p = path->curve.c[path->curve.n-1][2]; // start/end point - moveTo(hsf*(p.x+bitmap.xshift()), vsf*(p.y+bitmap.yshift())); - for (int i=0; i < path->curve.n; i++) { - if (path->curve.tag[i] == POTRACE_CURVETO) { - curveTo(hsf*(path->curve.c[i][0].x+bitmap.xshift()), vsf*(path->curve.c[i][0].y+bitmap.yshift()), - hsf*(path->curve.c[i][1].x+bitmap.xshift()), vsf*(path->curve.c[i][1].y+bitmap.yshift()), - hsf*(path->curve.c[i][2].x+bitmap.xshift()), vsf*(path->curve.c[i][2].y+bitmap.yshift())); - } - else { - lineTo(hsf*(path->curve.c[i][1].x+bitmap.xshift()), vsf*(path->curve.c[i][1].y+bitmap.yshift())); - if (i == path->curve.n-1) - closePath(); - else - lineTo(hsf*(path->curve.c[i][2].x+bitmap.xshift()), vsf*(path->curve.c[i][2].y+bitmap.yshift())); - } - } - } - } - potrace_state_free(state); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.h deleted file mode 100644 index ba15961db65..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GFTracer.h +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************* -** GFTracer.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GFTRACER_H -#define GFTRACER_H - -#include -#include "GFReader.h" - -class GFTracer : public GFReader -{ - public: - GFTracer (std::istream &is); - GFTracer (std::istream &is, double upp); - virtual ~GFTracer () {} - virtual void moveTo (double x, double y) {} - virtual void lineTo (double x, double y) {} - virtual void curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y) {} - virtual void closePath () {} - void beginChar (UInt32 c); - void endChar (UInt32 c); - - protected: - void unitsPerPoint(double upp) {_unitsPerPoint = upp;} - - private: - double _unitsPerPoint; ///< target units per TeX point -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.cpp deleted file mode 100644 index 7da863cbc82..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************************* -** Ghostscript.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "Ghostscript.h" -#if !defined(DISABLE_GS) - -#include -#include -#include - -#if defined(HAVE_LIBGS) - #include -#else - #include "ierrors.h" -#endif - -using namespace std; - -// default name of dynamic/shared Ghostscript library -#if defined(__WIN64__) - #define GS_DL_NAME "gsdll64.dll" -#elif defined(__WIN32__) - #define GS_DL_NAME "gsdll32.dll" -#else - #define GS_DL_NAME "libgs.so" -#endif - - -string Ghostscript::LIBGS_NAME; - - -/** Loads the Ghostscript library but does not create an instance. This - * constructor should only be used to call available() and revision(). */ -Ghostscript::Ghostscript () -#if !defined(HAVE_LIBGS) - : DLLoader(LIBGS_NAME.empty() ? GS_DL_NAME : LIBGS_NAME.c_str()) -#endif -{ - _inst = 0; -} - - -/** Tries to load the shared library and to initialize Ghostscript. - * @param[in] argc number of parameters in array argv - * @param[in] argv parameters passed to Ghostscript - * @param[in] caller this parameter is passed to all callback functions */ -Ghostscript::Ghostscript (int argc, const char **argv, void *caller) -#if !defined(HAVE_LIBGS) - : DLLoader(LIBGS_NAME.empty() ? GS_DL_NAME : LIBGS_NAME.c_str()) -#endif -{ - _inst = 0; - init(argc, argv, caller); -} - - -/** Exits Ghostscript and unloads the dynamic library. */ -Ghostscript::~Ghostscript () { - if (_inst) { - exit(); - delete_instance(); - } -} - - -bool Ghostscript::init (int argc, const char **argv, void *caller) { - if (!_inst) { - int status = new_instance(&_inst, caller); - if (status < 0) - _inst = 0; - else { - init_with_args(argc, (char**)argv); - } - } - return _inst != 0; -} - - -/** Returns true if Ghostscript library was found and can be loaded. */ -bool Ghostscript::available () { -#if defined(HAVE_LIBGS) - return true; -#else - return loaded(); -#endif -} - - -/** 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) { -#if defined(HAVE_LIBGS) - return (gsapi_revision(r, sizeof(gsapi_revision_t)) == 0); -#else - if (PFN_gsapi_revision fn = (PFN_gsapi_revision)loadSymbol("gsapi_revision")) - return (fn(r, sizeof(gsapi_revision_t)) == 0); - return false; -#endif -} - - -/** Returns product name and revision number of the GS library. - * @param[in] revonly if true, only the revision number is returned */ -string Ghostscript::revision (bool revonly) { - gsapi_revision_t r; - if (revision(&r)) { - ostringstream oss; - if (!revonly) - oss << r.product << ' '; - oss << (r.revision/100) << '.' << setfill('0') << setw(2) << (r.revision%100); - return oss.str(); - } - return ""; -} - - -/** Creates a new instance of Ghostscript. This method is called by the constructor and - * should not be used elsewhere. - * @param[out] psinst handle of newly created instance (or 0 on error) - * @param[in] caller pointer forwarded to callback functions */ -int Ghostscript::new_instance (void **psinst, void *caller) { -#if defined(HAVE_LIBGS) - return gsapi_new_instance(psinst, caller); -#else - if (PFN_gsapi_new_instance fn = (PFN_gsapi_new_instance)loadSymbol("gsapi_new_instance")) - return fn(psinst, caller); - *psinst = 0; - return 0; -#endif -} - - -/** Destroys the current instance of Ghostscript. This method is called by the destructor - * and should not be used elsewhere. */ -void Ghostscript::delete_instance () { -#if defined(HAVE_LIBGS) - gsapi_delete_instance(_inst); -#else - if (PFN_gsapi_delete_instance fn = (PFN_gsapi_delete_instance)loadSymbol("gsapi_delete_instance")) - fn(_inst); -#endif -} - - -/** Exits the interpreter. Must be called before destroying the GS instance. */ -int Ghostscript::exit () { -#if defined(HAVE_LIBGS) - return gsapi_exit(_inst); -#else - if (PFN_gsapi_exit fn = (PFN_gsapi_exit)loadSymbol("gsapi_exit")) - return fn(_inst); - return 0; -#endif -} - - -/** Sets the I/O callback functions. - * @param[in] in pointer to stdin handler - * @param[in] out pointer to stdout handler - * @param[in] err pointer to stderr handler */ -int Ghostscript::set_stdio (Stdin in, Stdout out, Stderr err) { -#if defined(HAVE_LIBGS) - return gsapi_set_stdio(_inst, in, out, err); -#else - if (PFN_gsapi_set_stdio fn = (PFN_gsapi_set_stdio)loadSymbol("gsapi_set_stdio")) - return fn(_inst, in, out, err); - return 0; -#endif -} - - -/** Initializes Ghostscript with a set of optional parameters. This - * method is called by the constructor and should not be used elsewhere. - * @param[in] argc number of paramters - * @param[in] argv parameters passed to Ghostscript */ -int Ghostscript::init_with_args (int argc, char **argv) { -#if defined(HAVE_LIBGS) - return gsapi_init_with_args(_inst, argc, argv); -#else - if (PFN_gsapi_init_with_args fn = (PFN_gsapi_init_with_args)loadSymbol("gsapi_init_with_args")) - return fn(_inst, argc, argv); - return 0; -#endif -} - - -/** Tells Ghostscript that several calls of run_string_continue will follow. */ -int Ghostscript::run_string_begin (int user_errors, int *pexit_code) { -#if defined(HAVE_LIBGS) - return gsapi_run_string_begin(_inst, user_errors, pexit_code); -#else - if (PFN_gsapi_run_string_begin fn = (PFN_gsapi_run_string_begin)loadSymbol("gsapi_run_string_begin")) - return fn(_inst, user_errors, pexit_code); - *pexit_code = 0; - return 0; -#endif -} - - -/** Executes a chunk of PostScript commands given by a buffer of characters. The size of - * this buffer must not exceed 64KB. Longer programs can be split into arbitrary smaller chunks - * and passed to Ghostscript by successive calls of run_string_continue. - * @param[in] str buffer containing the PostScript code - * @param[in] length number of characters in buffer - * @param[in] user_errors if non-negative, the default PS error values will be generated, otherwise this value is returned - * @param[out] pexit_code takes the PS error code */ -int Ghostscript::run_string_continue (const char *str, unsigned length, int user_errors, int *pexit_code) { -#if defined(HAVE_LIBGS) - return gsapi_run_string_continue(_inst, str, length, user_errors, pexit_code); -#else - if (PFN_gsapi_run_string_continue fn = (PFN_gsapi_run_string_continue)loadSymbol("gsapi_run_string_continue")) - return fn(_inst, str, length, user_errors, pexit_code); - *pexit_code = 0; - return 0; -#endif -} - - -/** Terminates the successive code feeding. Must be called after the last call of run_string_continue. */ -int Ghostscript::run_string_end (int user_errors, int *pexit_code) { -#if defined(HAVE_LIBGS) - return gsapi_run_string_end(_inst, user_errors, pexit_code); -#else - if (PFN_gsapi_run_string_end fn = (PFN_gsapi_run_string_end)loadSymbol("gsapi_run_string_end")) - return fn(_inst, user_errors, pexit_code); - *pexit_code = 0; - return 0; -#endif -} - - -const char* Ghostscript::error_name (int code) { - if (code < 0) - code = -code; - const char *error_names[] = { ERROR_NAMES }; - if (code == 0 || (size_t)code > sizeof(error_names)/sizeof(error_names[0])) - return 0; -#if defined(HAVE_LIBGS) - // use array defined in libgs to avoid linking the error strings into the binary - return gs_error_names[code-1]; -#elif defined(__WIN32__) - // gs_error_names is private in the Ghostscript DLL so we can't access it here - return error_names[code-1]; -#else - if (const char **error_names = (const char**)loadSymbol("gs_error_names")) - return error_names[code-1]; - return 0; -#endif -} - -#endif // !DISABLE_GS diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.h deleted file mode 100644 index ccfd5b0b0f4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Ghostscript.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************* -** Ghostscript.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GHOSTSCRIPT_H -#define GHOSTSCRIPT_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#if defined(DISABLE_GS) - #include "iapi.h" -#elif defined(HAVE_LIBGS) - #include -#else - #include "DLLoader.h" - #include "iapi.h" -#endif - -#if defined(__WIN32__) && !defined(_Windows) - #define _Windows -#endif - -#if defined(DISABLE_GS) -struct Ghostscript -{ - typedef int (GSDLLCALLPTR Stdin) (void *caller, char *buf, int len); - typedef int (GSDLLCALLPTR Stdout) (void *caller, const char *str, int len); - typedef int (GSDLLCALLPTR Stderr) (void *caller, const char *str, int len); - - Ghostscript () {} - Ghostscript (int argc, const char **argv, void *caller=0) {} - bool available () {return false;} - bool revision (gsapi_revision_t *r) {return false;} - std::string revision (bool revonly=false) {return "";} - int set_stdio (Stdin in, Stdout out, Stderr err) {return 0;} - int run_string_begin (int user_errors, int *pexit_code) {return 0;} - int run_string_continue (const char *str, unsigned int length, int user_errors, int *pexit_code) {return 0;} - int run_string_end (int user_errors, int *pexit_code) {return 0;} - int exit () {return 0;} -}; - -#else - -/** Wrapper class of (a subset of) the Ghostscript API. */ -class Ghostscript -#if !defined(HAVE_LIBGS) -: public DLLoader -#endif -{ - public: - typedef int (GSDLLCALLPTR Stdin) (void *caller, char *buf, int len); - typedef int (GSDLLCALLPTR Stdout) (void *caller, const char *str, int len); - typedef int (GSDLLCALLPTR Stderr) (void *caller, const char *str, int len); - - public: - Ghostscript (); - Ghostscript (int argc, const char **argv, void *caller=0); - ~Ghostscript (); - bool init (int argc, const char **argv, void *caller=0); - bool available (); - bool revision (gsapi_revision_t *r); - std::string revision (bool revonly=false); - int set_stdio (Stdin in, Stdout out, Stderr err); - int run_string_begin (int user_errors, int *pexit_code); - int run_string_continue (const char *str, unsigned int length, int user_errors, int *pexit_code); - int run_string_end (int user_errors, int *pexit_code); - int exit (); - const char* error_name (int code); - - static std::string LIBGS_NAME; - - protected: - Ghostscript (const Ghostscript &gs) {} - int init_with_args (int argc, char **argv); - int new_instance (void **psinst, void *caller); - void delete_instance (); - - private: - void *_inst; ///< Ghostscript handle needed to call the gsapi_foo functions -}; - -#endif // DISABLE_GS - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Glyph.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Glyph.h deleted file mode 100644 index b598dc5002d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Glyph.h +++ /dev/null @@ -1,28 +0,0 @@ -/************************************************************************* -** Glyph.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GLYPH_H -#define GLYPH_H - -#include "GraphicPath.h" - -typedef GraphicPath Glyph; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GlyphTracerMessages.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GlyphTracerMessages.h deleted file mode 100644 index 2b0cedcd8b6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GlyphTracerMessages.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* -** GlyphTracerMessages.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GLYPHTRACERMESSAGES_H -#define GLYPHTRACERMESSAGES_H - -#include -#include "GFGlyphTracer.h" -#include "Message.h" -#include "types.h" - -class GlyphTracerMessages : public GFGlyphTracer::Callback -{ - public: - GlyphTracerMessages (bool sfmsg=true, bool autonl=true) : _sfmsg(sfmsg), _autonl(autonl) {} - - ~GlyphTracerMessages () { - if (_autonl) - Message::mstream() << '\n'; - } - - void endChar (UInt8 c) { - std::ostringstream oss; - oss << '['; - if (isprint(c)) - oss << c; - else - oss << '#' << unsigned(c); - oss << ']'; - Message::mstream(false, Message::MC_TRACING) << oss.str(); - } - - void setFont (const std::string &fname) { - if (_sfmsg && fname != _fname) { - if (!_fname.empty()) - Message::mstream() << '\n'; - Message::mstream(false, Message::MC_STATE) << "tracing glyphs of " << fname.substr(0, fname.length()-3) << '\n'; - _fname = fname; - } - } - - private: - std::string _fname; - bool _sfmsg, _autonl; -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GraphicPath.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GraphicPath.h deleted file mode 100644 index 46a3b0cc335..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/GraphicPath.h +++ /dev/null @@ -1,340 +0,0 @@ -/************************************************************************* -** GraphicPath.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef GRAPHICPATH_H -#define GRAPHICPATH_H - -#include -#include -#include -#include "BoundingBox.h" -#include "Matrix.h" -#include "Pair.h" -#include "XMLString.h" - - -template -class GraphicPath -{ - public: - typedef Pair Point; - - struct Command { - enum Type {MOVETO, LINETO, CONICTO, CUBICTO, CLOSEPATH}; - - Command (Type t) : type(t) {} - - Command (Type t, const Point &p) : type(t) { - params[0] = p; - } - - Command (Type t, const Point &p1, const Point &p2) : type(t) { - params[0] = p1; - params[1] = p2; - } - - Command (Type t, const Point &p1, const Point &p2, const Point &p3) : type(t) { - params[0] = p1; - params[1] = p2; - params[2] = p3; - } - - int numParams () const { - switch (type) { - case CLOSEPATH : return 0; - case MOVETO : - case LINETO : return 1; - case CONICTO : return 2; - case CUBICTO : return 3; - } - return 0; - } - - void transform (const Matrix &matrix) { - for (int i=0; i < numParams(); i++) - params[i] = matrix * params[i]; - } - - Type type; - Point params[3]; - }; - - struct Actions - { - virtual ~Actions () {} - virtual void moveto (const Point &p) {} - virtual void lineto (const Point &p) {} - virtual void hlineto (const T &y) {} - virtual void vlineto (const T &x) {} - virtual void sconicto (const Point &p) {} - virtual void conicto (const Point &p1, const Point &p2) {} - virtual void scubicto (const Point &p1, const Point &p2) {} - virtual void cubicto (const Point &p1, const Point &p2, const Point &p3) {} - virtual void closepath () {} - virtual void draw (char cmd, const Point *points, int n) {} - virtual bool quit () {return false;} - }; - - typedef typename std::vector::iterator Iterator; - typedef typename std::vector::const_iterator ConstIterator; - typedef typename std::vector::const_reverse_iterator ConstRevIterator; - - public: - void newpath () { - _commands.clear(); - } - - /// Returns true if path is empty (there is nothing to draw) - bool empty () const { - return _commands.empty(); - } - - - /// Returns the number of path commands used to describe the path. - size_t size () const { - return _commands.size(); - } - - void moveto (const T &x, const T &y) { - moveto(Point(x, y)); - } - - void moveto (const Point &p) { - // avoid sequences of several MOVETOs; always use latest - if (_commands.empty() || _commands.back().type != Command::MOVETO) - _commands.push_back(Command(Command::MOVETO, p)); - else - _commands.back().params[0] = p; - } - - void lineto (const T &x, const T &y) { - lineto(Point(x, y)); - } - - void lineto (const Point &p) { - _commands.push_back(Command(Command::LINETO, p)); - } - - void conicto (const T &x1, const T &y1, const T &x2, const T &y2) { - conicto(Point(x1, y1), Point(x2, y2)); - } - - void conicto (const Point &p1, const Point &p2) { - _commands.push_back(Command(Command::CONICTO, p1, p2)); - } - - void cubicto (const T &x1, const T &y1, const T &x2, const T &y2, const T &x3, const T &y3) { - cubicto(Point(x1, y1), Point(x2, y2), Point(x3, y3)); - } - - void cubicto (const Point &p1, const Point &p2, const Point &p3) { - _commands.push_back(Command(Command::CUBICTO, p1, p2, p3)); - } - - void closepath () { - _commands.push_back(Command(Command::CLOSEPATH)); - } - - - const std::vector& commands () const { - return _commands; - } - - - /** Detects all open subpaths and closes them by adding a closePath command. - * Most font formats only support closed outline paths so there are no explicit closePath statements - * in the glyph's outline description. All open paths are automatically closed by the renderer. - * This method detects all open paths and adds the missing closePath statement. */ - void closeOpenSubPaths () { - Command *prevCommand = 0; - FORALL(_commands, Iterator, it) { - if (it->type == Command::MOVETO && prevCommand && prevCommand->type != Command::CLOSEPATH) { - prevCommand = &(*it); - it = _commands.insert(it, Command(Command::CLOSEPATH))+1; -// ++it; // skip inserted closePath command in next iteration step - } - else - prevCommand = &(*it); - } - if (!_commands.empty() && _commands.back().type != Command::CLOSEPATH) - closepath(); - } - - - /** Writes the path data as SVG path drawing command to a given output stream. - * @param[in] os output stream used to write the SVG commands to - * @param[in] sx horizontal scale factor - * @param[in] sy vertical scale factor - * @param[in] dx horizontal translation in TeX point units - * @param[in] sy vertical translation in TeX point units */ - void writeSVG (std::ostream &os, double sx=1.0, double sy=1.0, double dx=0.0, double dy=0.0) const { - struct WriteActions : Actions { - WriteActions (std::ostream &os, double sx, double sy, double dx, double dy) - : _os(os), _sx(sx), _sy(sy), _dx(dx), _dy(dy) {} - - void draw (char cmd, const Point *points, int n) { - _os << cmd; - switch (cmd) { - case 'H': _os << XMLString(_sx*points->x()+_dx); break; - case 'V': _os << XMLString(_sy*points->y()+_dy); break; - default : - for (int i=0; i < n; i++) { - if (i > 0) - _os << ' '; - _os << XMLString(_sx*points[i].x()+_dx) << ' ' << XMLString(_sy*points[i].y()+_dy); - } - } - } - std::ostream &_os; - double _sx, _sy, _dx, _dy; - } actions(os, sx, sy, dx, dy); - iterate(actions, true); - } - - - /** Computes the bounding box of the current path. - * @param[out] bbox the computed bounding box */ - void computeBBox (BoundingBox &bbox) const { - struct BBoxActions : Actions { - BBoxActions (BoundingBox &bb) : bbox(bb) {} - void moveto (const Point &p) {bbox.embed(p);} - void lineto (const Point &p) {bbox.embed(p);} - void conicto (const Point &p1, const Point &p2) {bbox.embed(p1); bbox.embed(p2);} - void cubicto (const Point &p1, const Point &p2, const Point &p3) {bbox.embed(p1); bbox.embed(p2); bbox.embed(p3);} - BoundingBox &bbox; - } actions(bbox); - iterate(actions, false); - } - - - /** Checks whether the current path describes a dot/point only (with no extent). - * @param[out] p coordinates of the point if path describes a dot - * @return true if path is a dot/point */ - bool isDot (Point &p) const { - struct DotActions : Actions { - DotActions () : differs(false) {} - void moveto (const Point &p) {point = p;} - void lineto (const Point &p) {differs = (p != point);} - void conicto (const Point &p1, const Point &p2) {differs = (point != p1 || point != p2);} - void cubicto (const Point &p1, const Point &p2, const Point &p3) {differs = (point != p1 || point != p2 || point != p3);} - bool quit () {return differs;} - Point point; - bool differs; - } actions; - iterate(actions, false); - p = actions.point; - return !actions.differs; - } - - - /** Transforms the path according to a given Matrix. - * @param[in] matrix Matrix describing the affine transformation */ - void transform (const Matrix &matrix) { - FORALL(_commands, Iterator, it) - it->transform(matrix); - } - - void iterate (Actions &actions, bool optimize) const; - - private: - std::vector _commands; -}; - - -/** Iterates over all commands defining this path and calls the corresponding template methods. - * In the case of successive bezier curve sequences, control points or tangent slopes are often - * identical so that the path description contains redundant information. SVG provides shorthand - * curve commands that require less parameters. If 'optimize' is true, this method detects such - * command sequences. - * @param[in] actions template methods called by each iteration step - * @param[in] optimize if true, shorthand drawing commands (sconicto, scubicto,...) are considered */ -template -void GraphicPath::iterate (Actions &actions, bool optimize) const { - ConstIterator prev = _commands.end(); // pointer to preceding command - Point fp; // first point of current path - Point cp; // current point - Point pstore[2]; - for (ConstIterator it=_commands.begin(); it != _commands.end() && !actions.quit(); ++it) { - const Point *params = it->params; - switch (it->type) { - case Command::MOVETO: - actions.moveto(params[0]); - actions.draw('M', params, 1); - fp = params[0]; - break; - case Command::LINETO: - if (optimize) { - if (cp.x() == params[0].x()) { - actions.vlineto(params[0].y()); - actions.draw('V', params, 1); - } - else if (cp.y() == params[0].y()) { - actions.hlineto(params[0].x()); - actions.draw('H', params, 1); - } - else { - actions.lineto(params[0]); - actions.draw('L', params, 1); - } - } - else { - actions.lineto(params[0]); - actions.draw('L', params, 1); - } - break; - case Command::CONICTO: - if (optimize && prev != _commands.end() && prev->type == Command::CONICTO && params[0] == pstore[1]*T(2)-pstore[0]) { - actions.sconicto(params[1]); - actions.draw('T', params+1, 1); - } - else { - actions.conicto(params[0], params[1]); - actions.draw('Q', params, 2); - } - pstore[0] = params[0]; // store control point and - pstore[1] = params[1]; // curve endpoint - break; - case Command::CUBICTO: - // is first control point reflection of preceding second control point? - if (optimize && prev != _commands.end() && prev->type == Command::CUBICTO && params[0] == pstore[1]*T(2)-pstore[0]) { - actions.scubicto(params[1], params[2]); - actions.draw('S', params+1, 2); - } - else { - actions.cubicto(params[0], params[1], params[2]); - actions.draw('C', params, 3); - } - pstore[0] = params[1]; // store second control point and - pstore[1] = params[2]; // curve endpoint - break; - case Command::CLOSEPATH: - actions.closepath(); - actions.draw('Z', params, 0); - cp = fp; - } - // update current point - const int np = it->numParams(); - if (np > 0) - cp = it->params[np-1]; - prev = it; - } -} - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.cpp deleted file mode 100644 index ad99305fa3c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************* -** InputBuffer.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "InputBuffer.h" - -using namespace std; - - -StreamInputBuffer::StreamInputBuffer (istream &is, size_t bufsize) - : _is(is), _bufsize(bufsize), _buf1(new UInt8[_bufsize]), _buf2(new UInt8[_bufsize]), _bufptr(_buf1) -{ - _size1 = fillBuffer(_buf1); - _size2 = fillBuffer(_buf2); -} - - -StreamInputBuffer::~StreamInputBuffer () { - delete [] _buf1; - delete [] _buf2; -} - - -int StreamInputBuffer::get () { - if (pos() == _size1) { - if (_size2 == 0) - return -1; - swap(_buf1, _buf2); - _size1 = _size2; - _bufptr = _buf1; - _size2 = fillBuffer(_buf2); - } - UInt8 c = *_bufptr++; - return c; -} - - -/** Returns the next character to be read without skipping it. - * Same as peek(0). */ -int StreamInputBuffer::peek () const { - if (pos() < _size1) - return *_bufptr; - return _size2 > 0 ? *_buf2 : -1; -} - - -/** Returns the n-th next character without skipping it. */ -int StreamInputBuffer::peek (size_t n) const { - if (pos()+n < _size1) - return *(_bufptr+n); - if (pos()+n < _size1+_size2) - return *(_buf2 + pos()+n-_size1); - return -1; -} - - -/** Fills the buffer by reading a sequence of characters from the assigned - * input stream. - * @param[in] buf pointer to character buffer to be filled - * @return number of characters read */ -int StreamInputBuffer::fillBuffer (UInt8 *buf) { - if (_is && !_is.eof()) { - _is.read((char*)buf, _bufsize); - return _is.gcount(); - } - return 0; -} - -/////////////////////////////////////////////// - -SplittedCharInputBuffer::SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2) { - _buf[0] = buf1; - _buf[1] = buf2; - _size[0] = buf1 ? s1 : 0; - _size[1] = buf2 ? s2 : 0; - _index = _size[0] ? 0 : 1; -} - - -int SplittedCharInputBuffer::get () { - if (_size[_index] == 0) - return -1; - int ret = *_buf[_index]++; - _size[_index]--; - if (_index == 0 && _size[0] == 0) - _index++; - return ret; -} - - -int SplittedCharInputBuffer::peek () const { - return _size[_index] ? *_buf[_index] : -1; -} - - -int SplittedCharInputBuffer::peek (size_t n) const { - if (n < _size[_index]) - return _buf[_index][n]; - n -= _size[_index]; - if (_index == 0 && n < _size[1]) - return _buf[1][n]; - return -1; -} - -/////////////////////////////////////////////// - - -int TextStreamInputBuffer::get () { - int c = StreamInputBuffer::get(); - if (c == '\n') { - _line++; - _col = 1; - } - else - _col++; - return c; -} - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.h deleted file mode 100644 index c25df9a1452..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputBuffer.h +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************************* -** InputBuffer.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef INPUTBUFFER_H -#define INPUTBUFFER_H - -#include -#include -#include -#include -#include -#include "types.h" - -struct InputBuffer -{ - virtual ~InputBuffer () {} - virtual int get () =0; - virtual int peek () const =0; - virtual int peek (size_t n) const =0; - virtual bool eof () const =0; - virtual void invalidate () =0; -}; - - -class StreamInputBuffer : public InputBuffer -{ - public: - StreamInputBuffer (std::istream &is, size_t bufsize=1024); - ~StreamInputBuffer (); - int get (); - int peek () const; - int peek (size_t n) const; - bool eof () const {return pos() == _size1 && _size2 == 0;} - void invalidate () {_bufptr = _buf1+_size1; _size2 = 0;} - - protected: - int fillBuffer (UInt8 *buf); - size_t pos () const {return _bufptr-_buf1;} - - private: - std::istream &_is; - const size_t _bufsize; ///< maximal number of bytes each buffer can hold - UInt8 *_buf1; ///< pointer to first buffer - UInt8 *_buf2; ///< pointer to second buffer - size_t _size1; ///< number of bytes in buffer 1 - size_t _size2; ///< number of bytes in buffer 2 - UInt8 *_bufptr; ///< pointer to next byte to read -}; - - -class StringInputBuffer : public InputBuffer -{ - public: - StringInputBuffer (const std::string &str) : _str(str), _pos(0) {} - int get () {return _pos < _str.length() ? _str[_pos++] : -1;} - int peek () const {return _pos < _str.length() ? _str[_pos] : -1;} - int peek (size_t n) const {return _pos+n < _str.length() ? _str[_pos+n] : -1;} - bool eof () const {return _pos >= _str.length();} - void invalidate () {_pos = _str.length();} - - private: - const std::string &_str; - size_t _pos; -}; - - -class CharInputBuffer : public InputBuffer -{ - public: - CharInputBuffer (const char *buf, size_t size) : _pos(buf), _size(buf ? size : 0) {} - - int get () { - if (_size <= 0) - return -1; - else { - _size--; - return *_pos++; - } - } - - - void assign (const char *buf, size_t size) { - _pos = buf; - _size = size; - } - - void assign (const char *buf) {assign(buf, std::strlen(buf));} - int peek () const {return _size > 0 ? *_pos : -1;} - int peek (size_t n) const {return _size >= n ? _pos[n] : -1;} - bool eof () const {return _size <= 0;} - void invalidate () {_size = 0;} - - private: - const char *_pos; - size_t _size; -}; - - -class SplittedCharInputBuffer : public InputBuffer -{ - public: - SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2); - int get (); - int peek () const; - int peek (size_t n) const; - bool eof () const {return _size[_index] == 0;} - void invalidate () {_size[_index] = 0;} - - private: - const char *_buf[2]; - size_t _size[2]; - int _index; -}; - - -class TextStreamInputBuffer : public StreamInputBuffer -{ - public: - TextStreamInputBuffer (std::istream &is) : StreamInputBuffer(is), _line(1), _col(1) {} - int get (); - int line () const {return _line;} - int col () const {return _col;} - - private: - int _line, _col; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.cpp deleted file mode 100644 index 3899a2362b2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/************************************************************************* -** InputReader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "InputReader.h" - -using namespace std; - - -/** Skips n characters. */ -void InputReader::skip (size_t n) { - while (n-- > 0) - get(); -} - - -/** Moves the buffer pointer to the next non-space character. A following call - * of get() returns this character. */ -void InputReader::skipSpace () { - while (isspace(peek())) - get(); -} - - -/** Tries to find a given string and skips all characters preceding that string. - * @param[in] s string to look for (must not be longer than the maximal buffer size) - * @param[in] consume if true, the buffer pointer is moved to the first character following string s - * @return true if s was found */ -bool InputReader::skipUntil (const char *s, bool consume) { - bool found = false; - while (!eof() && !(found = check(s, consume))) - get(); - return found; -} - - -/** Looks for the first occurrence of a given character. - * @param[in] c character to lookup - * @return position of character relative to current location, -1 if character was not found */ -int InputReader::find (char c) const { - int pos = 0; - int cc; - while ((cc = peek(pos)) >= 0 && cc != c) - pos++; - return cc < 0 ? -1 : pos; -} - - -/** Checks if the next characters to be read match a given string. - * @param[in] s string to be matched - * @param[in] consume if true, the characters of the matched string are skipped - * @return true if s matches */ -bool InputReader::check (const char *s, bool consume) { - size_t count = 0; - for (const char *p=s; *p; p++) { - if (peek(count++) != *p) - return false; - } - if (consume) - skip(count); - return true; -} - - -int InputReader::compare (const char *s, bool consume) { - size_t count = 0; - for (const char *p=s; *p; p++) { - int c = peek(count++); - if (c != *p) - return *p < c ? -1 : 1; - } - if (consume) - skip(count); - return 0; -} - - -/** Reads an integer from the buffer. All characters that are part of - * the read integer constant are skipped. If this function returns false, - * the buffer pointer points to the same position as before the function call. - * @param[out] val contains the read integer value on success - * @param[in] accept_sign if false, only positive integers (without sign) are accepted - * @return true if integer could be read */ -bool InputReader::parseInt (int &val, bool accept_sign) { - val = 0; - int fac=1; - char sign; // explicitly given sign - if (accept_sign && ((sign = peek()) == '+' || sign == '-')) { - if (isdigit(peek(1))) { - get(); // skip sign - if (sign == '-') - fac = -1; - } - else - return false; - } - else if (!isdigit(peek())) - return false; - - while (isdigit(peek())) - val = val*10 + (get()-'0'); - val *= fac; - return true; -} - - -bool InputReader::parseUInt (unsigned &val) { - val = 0; - if (!isdigit(peek())) - return false; - while (isdigit(peek())) - val = val*10 + (get()-'0'); - return true; -} - - -bool InputReader::parseInt (int base, int &val) { - if (base < 2 || base > 32) - return false; - - const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; - const char maxdigit = digits[base-1]; - char c; - if (!isalnum(c = tolower(peek())) || c > maxdigit) - return false; - - val = 0; - while (isalnum(c = tolower(peek())) && c <= maxdigit) { - get(); - int digit = c - (c <= '9' ? '0' : 'a'-10); - val = val*base + digit; - } - return true; -} - - -/** Reads a double from the buffer. All characters that are part of - * the read double constant are skipped. If this function returns false, - * the buffer pointer points to the same position as before the function call. - * @param[out] val contains the read double value on success - * @return number details: 0=no number, 'i'=integer, 'f'=floating point number */ -char InputReader::parseDouble (double &val) { - int fac=1; - int int_part=0; - bool is_float = false; - skipSpace(); - char sign = peek(); - if (parseInt(int_part)) { // match [+-]?[0-9]+\.? - if (peek() == '.') { - get(); - is_float = true; - } - if (int_part < 0 || sign == '-') { - fac = -1; - int_part = -int_part; - } - } - else { // match [+-]?\. - char sign; // explicitly given sign - if ((sign = peek()) == '+' || sign == '-') { // match [+-]?\.[0-9] - if (peek(1) != '.' || !isdigit(peek(2))) - return 0; - if (sign == '-') - fac = -1; - skip(2); // skip sign and dot - } - else if (peek() == '.' && isdigit(peek(1))) - get(); - else - return 0; - is_float = true; - } - // parse fractional part - double frac_part=0.0; - for (double u=10; isdigit(peek()); u*=10) - frac_part += (get()-'0')/u; - val = (int_part + frac_part) * fac; - // parse exponent - char c; - if (tolower(peek()) == 'e' && (isdigit(c=peek(1)) || ((c == '+' || c == '-') && isdigit(peek(2))))) { - get(); // skip 'e' - int exp; - parseInt(exp); - val *= pow(10.0, exp); - is_float = true; - } - return is_float ? 'f' : 'i'; -} - - -/** Reads an integer value from the buffer. If no valid integer constant - * could be found at the current position 0 is returned. */ -int InputReader::getInt () { - skipSpace(); - int val; - return parseInt(val) ? val : 0; -} - - -/** Reads an double value from the buffer. If no valid double constant - * could be found at the current position 0 is returned. */ -double InputReader::getDouble () { - skipSpace(); - double val; - return parseDouble(val) ? val : 0.0; -} - - -string InputReader::getWord () { - string ret; - skipSpace(); - while (isalpha(peek())) - ret += get(); - return ret; -} - - -char InputReader::getPunct () { - skipSpace(); - if (ispunct(peek())) - return get(); - return 0; -} - - -/** Reads a string delimited by a given quotation character. - * Before reading the string, all leading whitespace is skipped. Then, the function checks - * for the given quotation character. If it is found, all characters until the second - * appearance of the quotation char are appended to the result. Otherwise, an empty string - * is returned. If the quotation character is 0, the behavior of this function is identical to - * a call of getString(). - * @param[in] quotechar the quotation character bounding the string to be read - * @return the string read */ -string InputReader::getQuotedString (char quotechar) { - if (quotechar == 0) - return getString(); - - string ret; - skipSpace(); - if (peek() == quotechar) { - get(); - while (!eof() && peek() != quotechar) - ret += get(); - get(); - } - return ret; -} - - -/** Reads a string delimited by whitespace and/or invisible characters. - * Before reading the string, all leading whitespace is skipped. Then, the function adds - * all printable characters to the result until a whitespace, an unprintable character, or - * EOF is found. - * @return the string read */ -string InputReader::getString () { - string ret; - skipSpace(); - while (!eof() && !isspace(peek()) && isprint(peek())) - ret += get(); - return ret; -} - - -/** Reads a given number of characters and returns the resulting string. - * @param n number of character to read - * @return the string read */ -string InputReader::getString (size_t n) { - string ret; - while (n-- > 0) - ret += get(); - return ret; -} - - -/*string InputReader::getString (char quotechar) { - string ret; - skipSpace(); - if (quotechar == 0) { - while (!eof() && !isspace(peek()) && isprint(peek())) - ret += get(); - } - else if (peek() == quotechar) { - get(); - while (!eof() && peek() != quotechar) - ret += get(); - get(); - } - return ret; -}*/ - - -int InputReader::parseAttributes (map &attr) { - bool ready=false; - while (!eof() && !ready) { - string key; - skipSpace(); - while (isalnum(peek())) - key += get(); - skipSpace(); - if (peek() == '=') { - get(); - skipSpace(); - string val = getString(); - attr[key] = val; - } - else - ready = true; - } - return attr.size(); -} - -////////////////////////////////////////// - - -int StreamInputReader::peek (size_t n) const { - if (n == 0) - return peek(); - vector chars(n); - _is.read(&chars[0], n); - int ret = peek(); - for (int i=n-1; i >= 0; i--) - _is.putback(chars[i]); - return ret; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.h deleted file mode 100644 index 23a16421567..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/InputReader.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************* -** InputReader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef INPUTREADER_H -#define INPUTREADER_H - -#include -#include -#include -#include "InputBuffer.h" - - -class InputReader -{ - public: - virtual ~InputReader() {} - virtual int get () =0; - virtual int peek () const =0; - virtual int peek (size_t n) const =0; - virtual bool eof () const =0; - virtual bool check (char c) const {return peek() == c;} - virtual bool check (const char *s, bool consume=true); - virtual int compare (const char *s, bool consume=true); - virtual void skip (size_t n); - virtual bool skipUntil (const char *s, bool consume=true); - virtual int find (char c) const; - virtual void skipSpace (); - virtual int getInt (); - virtual bool parseInt (int &val, bool accept_sign=true); - virtual bool parseInt (int base, int &val); - virtual bool parseUInt (unsigned &val); - virtual char parseDouble (double &val); - virtual double getDouble (); - virtual std::string getWord (); - virtual char getPunct (); - virtual std::string getQuotedString (char quotechar); - virtual std::string getString (); - virtual std::string getString (size_t n); - virtual int parseAttributes (std::map &attr); - virtual operator bool () const {return !eof();} -}; - - -class StreamInputReader : public InputReader -{ - public: - StreamInputReader (std::istream &is) : _is(is) {} - int get () {return _is.get();} - int peek () const {return _is.peek();} - int peek (size_t n) const; - bool eof () const {return !_is || _is.eof();} - - private: - std::istream &_is; -}; - - -class BufferInputReader : public InputReader -{ - public: - BufferInputReader (InputBuffer &ib) : _ib(&ib) {} - void assign (InputBuffer &ib) {_ib = &ib;} - int get () {return _ib->get();} - int peek () const {return _ib->peek();} - int peek (size_t n) const {return _ib->peek(n);} - bool eof () const {return _ib->eof();} - - private: - InputBuffer *_ib; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.cpp deleted file mode 100644 index aae20b74e59..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* -** Length.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "InputReader.h" -#include "Length.h" - -#define UNIT(c1,c2) ((c1 << 8)|c2) - -using namespace std; - - -void Length::set (const string &len) { - switch (len.length()) { - case 0: - _pt = 0; - break; - case 1: - if (isdigit(len[0])) - _pt = len[0] - '0'; - else - throw UnitException("invalid length: "+len); - break; - default: - istringstream iss(len); - StreamInputReader ir(iss); - double val; - if (!ir.parseDouble(val)) - throw UnitException("invalid length: "+len); - string unit = ir.getWord(); - set(val, unit); - } -} - - -void Length::set (double val, Unit unit) { - switch (unit) { - case PT: _pt = val; break; - case BP: _pt = val*72.27/72; break; - case IN: _pt = val*72.27; break; - case CM: _pt = val/2.54*72.27; break; - case MM: _pt = val/25.4*72.27; break; - case PC: _pt = val/12*72.27; break; - } -} - - -void Length::set (double val, string unitstr) { - if (unitstr.empty()) - unitstr = "pt"; - else if (unitstr.length() != 2) - throw UnitException("invalid length unit: "+unitstr); - - Unit unit; - switch (UNIT(unitstr[0], unitstr[1])) { - case UNIT('p','t'): unit = PT; break; - case UNIT('b','p'): unit = BP; break; - case UNIT('i','n'): unit = IN; break; - case UNIT('c','m'): unit = CM; break; - case UNIT('m','m'): unit = MM; break; - case UNIT('p','c'): unit = PC; break; - default: - throw UnitException("invalid length unit: "+unitstr); - } - set(val, unit); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.h deleted file mode 100644 index 995ba068cee..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Length.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************* -** Length.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef LENGTH_H -#define LENGTH_H - -#include -#include "MessageException.h" - -#ifdef IN -#undef IN -#endif - -struct UnitException : MessageException -{ - UnitException (const std::string &msg) : MessageException(msg) {} -}; - - -class Length -{ - public: - enum Unit {PT, BP, CM, MM, IN, PC}; - - public: - Length () : _pt(0) {} - Length (double val, Unit unit=PT) {set(val, unit);} - Length (double val, const std::string &unit) {set(val, unit);} - Length (const std::string &len) {set(len);} - void set (double val, Unit unit); - void set (double val, std::string unit); - void set (const std::string &len); - - double pt () const {return _pt;} - double in () const {return _pt/72.27;} - double bp () const {return in()*72;} - double cm () const {return in()*2.54;} - double mm () const {return cm()*10;} - double pc () const {return in()*12;} - - private: - double _pt; // length in TeX point units -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Makefile.am deleted file mode 100644 index dd5fb8c11c3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -:## This file is part of dvisvgm -## Copyright (C) 2005-2013 Martin Gieseking -## -## Process this file with automake. - -bin_PROGRAMS = dvisvgm -noinst_LIBRARIES = libdvisvgm.a - -dvisvgm_SOURCES = gzstream.h \ - dvisvgm.cpp gzstream.cpp - -dvisvgm_LDADD = $(noinst_LIBRARIES) @EXTRA_LIBS@ -dvisvgm_DEPENDENCIES = $(noinst_LIBRARIES) @EXTRA_LIBS@ - -libdvisvgm_a_SOURCES = Bitmap.h BoundingBox.h BgColorSpecialHandler.h Calculator.h CmdLineParserBase.h Color.h CRC32.h \ - ColorSpecialHandler.h CommandLine.h Directory.h DLLoader.h DVIActions.h DVIReader.h DvisvgmSpecialHandler.h DVIToSVG.h \ - DVIToSVGActions.h EmSpecialHandler.h EPSFile.h EPSToSVG.h FileFinder.h FilePath.h FileSystem.h Font.h FontCache.h \ - FontEncoding.h FontEngine.h FontManager.h FontMap.h GFReader.h GFTracer.h GFGlyphTracer.h Ghostscript.h Glyph.h \ - GlyphTracerMessages.h GraphicPath.h InputBuffer.h InputReader.h Length.h macros.h MapLine.h Matrix.h Message.h \ - MessageException.h MetafontWrapper.h NoPsSpecialHandler.h PageRanges.h PageSize.h Pair.h PdfSpecialHandler.h Process.h \ - PSInterpreter.h PSPattern.h PsSpecialHandler.h SignalHandler.h SpecialActions.h SpecialHandler.h SpecialManager.h \ - StreamReader.h StreamWriter.h Subfont.h SVGOutputBase.h SVGTree.h System.h Terminal.h TpicSpecialHandler.h TFM.h types.h \ - VectorStream.h VFActions.h VFReader.h XMLDocTypeNode.h XMLDocument.h XMLNode.h XMLString.h \ - BgColorSpecialHandler.cpp Bitmap.cpp BoundingBox.cpp Calculator.cpp CmdLineParserBase.cpp Color.cpp \ - ColorSpecialHandler.cpp CommandLine.cpp CRC32.cpp Directory.cpp DLLoader.cpp DVIActions.cpp DVIReader.cpp \ - DvisvgmSpecialHandler.cpp DVIToSVG.cpp DVIToSVGActions.cpp EmSpecialHandler.cpp EPSFile.cpp EPSToSVG.cpp FileFinder.cpp \ - FilePath.cpp FileSystem.cpp Font.cpp FontCache.cpp FontEncoding.cpp FontEngine.cpp FontManager.cpp FontMap.cpp \ - GFReader.cpp GFGlyphTracer.cpp GFTracer.cpp Ghostscript.cpp InputBuffer.cpp InputReader.cpp Length.cpp MapLine.cpp \ - Matrix.cpp Message.cpp MetafontWrapper.cpp NoPsSpecialHandler.cpp PageRanges.cpp PageSize.cpp PdfSpecialHandler.cpp \ - Process.cpp psdefs.cpp PSInterpreter.cpp PSPattern.cpp PsSpecialHandler.cpp SignalHandler.cpp SpecialManager.cpp \ - StreamReader.cpp StreamWriter.cpp Subfont.cpp SVGTree.cpp System.cpp Terminal.cpp TFM.cpp TpicSpecialHandler.cpp \ - VFReader.cpp XMLDocument.cpp XMLNode.cpp XMLString.cpp - -EXTRA_DIST = options.xml iapi.h ierrors.h MiKTeXCom.h MiKTeXCom.cpp - -AM_CXXFLAGS = -Wall -Wnon-virtual-dtor - -# the command-line parser is generated from options.xml by opt2cpp -CommandLine.cpp: options.xml - if test -f opt2cpp.xsl; then \ - rm -f $@ $*.h; \ - xsltproc opt2cpp.xsl $<; \ - fi - -# Create a C string definition containing the PostScript routines psdefs.ps needed by class PSInterpreter -$(srcdir)/psdefs.cpp: psdefs.ps - if test -f $<; then \ - ps2c PSInterpreter::PSDEFS $< >$@; \ - fi - -psdefs.ps: ; - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.cpp deleted file mode 100644 index 99dce4f9547..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/************************************************************************* -** MapLine.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "InputBuffer.h" -#include "InputReader.h" -#include "MapLine.h" -#include "Subfont.h" - -using namespace std; - - -/** Constructs a MapLine object by parsing a single mapline from the given stream. */ -MapLine::MapLine (istream &is) - : _sfd(0), _fontindex(0), _slant(0), _bold(0), _extend(1) -{ - char buf[256]; - is.getline(buf, 256); - parse(buf); -} - - -// Some of the following functions have been derived from the dvipdfmx source file fontmap.c: -// http://cvs.ktug.or.kr/viewcvs/dvipdfmx/src/fontmap.c?revision=1.43&view=markup - - -/** Returns true if the given string is in dvips mapline format, and false if it's in dvipdfm format. - @param[in] line string to check */ -bool MapLine::isDVIPSFormat (const char *line) const { - if (strchr(line, '"') || strchr(line, '<')) // these chars are only present in dvips maps - return true; - char prevchar = ' '; - int entry_count=0; - for (const char *p=line; *p; ++p) { - if (isspace(prevchar)) { - if (*p == '-') // options starting with '-' are only present in dvipdfm map files - return false; - if (!isspace(*p)) - entry_count++; - } - prevchar = *p; - } - // tfm_name and ps_name only => dvips map - return entry_count == 2; -} - - -/** Separates main font name and subfont definition name from a given combined name. - * Example: "basename@sfdname@10" => {"basename10", "sfdname"} - * @param[in,out] fontname complete fontname; after separation: main fontname only - * @param[out] sfdname name of subfont definition - * @return true on success */ -static bool split_fontname (string &fontname, string &sfdname) { - size_t pos1; // index of first '@' - if ((pos1 = fontname.find('@')) != string::npos && pos1 > 0) { - size_t pos2; // index of second '@' - if ((pos2 = fontname.find('@', pos1+1)) != string::npos && pos2 > pos1+1) { - sfdname = fontname.substr(pos1+1, pos2-pos1-1); - fontname = fontname.substr(0, pos1) + fontname.substr(pos2+1); - return true; - } - } - return false; -} - - -/** Parses a single mapline and stores the scanned data in member variables. - * The line may either be given in dvips or dvipdfmx mapfile format. - * @param[in] line the mapline */ -void MapLine::parse (const char *line) { - CharInputBuffer ib(line, strlen(line)); - BufferInputReader ir(ib); - _texname = ir.getString(); - string sfdname; - split_fontname(_texname, sfdname); - if (!sfdname.empty()) - _sfd = SubfontDefinition::lookup(sfdname); - if (isDVIPSFormat(line)) - parseDVIPSLine(ir); - else - parseDVIPDFMLine(ir); -} - - -/** Parses a single line in dvips mapfile format. - * @param[in] ir the input stream must be assigned to this reader */ -void MapLine::parseDVIPSLine (InputReader &ir) { - ir.skipSpace(); - if (ir.peek() != '<' && ir.peek() != '"') - _psname = ir.getString(); - ir.skipSpace(); - while (ir.peek() == '<' || ir.peek() == '"') { - if (ir.peek() == '<') { - ir.get(); - if (ir.peek() == '[') - ir.get(); - string name = ir.getString(); - if (name.length() > 4 && name.substr(name.length()-4) == ".enc") - _encname = name.substr(0, name.length()-4); - else - _fontfname = name; - } - else { // ir.peek() == '"' => list of PS font operators - string options = ir.getQuotedString('"'); - StringInputBuffer sib(options); - BufferInputReader sir(sib); - while (!sir.eof()) { - double number; - if (sir.parseDouble(number)) { - // operator with preceding numeric parameter (value opstr) - string opstr = sir.getString(); - if (opstr == "SlantFont") - _slant = number; - else if (opstr == "ExtendFont") - _extend = number; - } - else { - // operator without parameter => skip for now - sir.getString(); - } - } - } - ir.skipSpace(); - } -} - - -static void throw_number_expected (char opt, bool integer_only=false) { - ostringstream oss; - oss << "option -" << opt << ": " << (integer_only ? "integer" : "floating point") << " value expected"; - throw MapLineException(oss.str()); -} - - -/** Parses a single line in dvipdfmx mapfile format. - * @param[in] ir the input stream must be assigned to this reader */ -void MapLine::parseDVIPDFMLine (InputReader &ir) { - ir.skipSpace(); - if (ir.peek() != '-') { - _encname = ir.getString(); - if (_encname == "default" || _encname == "none") - _encname.clear(); - } - ir.skipSpace(); - if (ir.peek() != '-') - _fontfname = ir.getString(); - if (!_fontfname.empty()) { - parseFilenameOptions(_fontfname); - } - ir.skipSpace(); - while (ir.peek() == '-') { - ir.get(); - char option = ir.get(); - if (!isprint(option)) - throw MapLineException("option character expected"); - ir.skipSpace(); - switch (option) { - case 's': // slant - if (!ir.parseDouble(_slant)) - throw_number_expected('s'); - break; - case 'e': // extend - if (!ir.parseDouble(_extend)) - throw_number_expected('e'); - break; - case 'b': // bold - if (!ir.parseDouble(_bold)) - throw_number_expected('b'); - break; - case 'r': //remap (deprecated) - break; - case 'i': // ttc index - if (!ir.parseInt(_fontindex, false)) - throw_number_expected('i', true); - break; - case 'p': // UCS plane - int dummy; - if (!ir.parseInt(dummy, false)) - throw_number_expected('p', true); - break; - case 'u': // to unicode - ir.getString(); - break; - case 'v': // stemV - int stemv; - if (!ir.parseInt(stemv, true)) - throw_number_expected('v', true); - break; - case 'm': // map single chars - ir.skipUntil("-"); - break; - case 'w': // writing mode (horizontal=0, vertical=1) - int vertical; - if (!ir.parseInt(vertical, false)) - throw_number_expected('w', true); - break; - default: - ostringstream oss; - oss << "invalid option: -" << option; - throw MapLineException(oss.str()); - } - ir.skipSpace(); - } -} - - -/** [:INDEX:][!]FONTNAME[/CSI][,VARIANT] */ -void MapLine::parseFilenameOptions (string fname) { - _fontfname = fname; - StringInputBuffer ib(fname); - BufferInputReader ir(ib); - if (ir.peek() == ':' && isdigit(ir.peek(1))) { // index given? - ir.get(); - _fontindex = ir.getInt(); // font index of file with multiple fonts - if (ir.peek() == ':') - ir.get(); - else - _fontindex = 0; - } - if (ir.peek() == '!') // no embedding - ir.get(); - - bool csi_given=false, style_given=false; - int pos; - if ((pos = ir.find('/')) >= 0) { // csi delimiter - csi_given = true; - _fontfname = ir.getString(pos); - } - else if ((pos = ir.find(',')) >= 0) { - style_given = true; - _fontfname = ir.getString(pos); - } - else - _fontfname = ir.getString(); - - if (csi_given) { - if ((pos = ir.find(',')) >= 0) { - style_given = true; - ir.getString(pos); // charcoll - } - else if (ir.eof()) - throw MapLineException("CSI specifier expected"); - else - ir.getString(); // charcoll - } - if (style_given) { - ir.get(); // skip ',' - if (ir.check("BoldItalic")) { - } - else if (ir.check("Bold")) { - } - else if (ir.check("Italic")) { - } - if (!ir.eof()) - throw MapLineException("invalid style given"); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.h deleted file mode 100644 index 87451dc912d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MapLine.h +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* -** MapLine.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MAPLINE_H -#define MAPLINE_H - -#include -#include -#include "MessageException.h" - - -class InputReader; -class SubfontDefinition; - - -struct MapLineException : MessageException -{ - MapLineException (const std::string &msg) : MessageException(msg) {} -}; - - -class MapLine -{ - public: - MapLine (std::istream &is); - const std::string& texname () const {return _texname;} - const std::string& psname () const {return _psname;} - const std::string& fontfname () const {return _fontfname;} - const std::string& encname () const {return _encname;} - int fontindex () const {return _fontindex;} - double bold () const {return _bold;} - double slant () const {return _slant;} - double extend () const {return _extend;} - SubfontDefinition* sfd () const {return _sfd;} - - protected: - void init (); - bool isDVIPSFormat (const char *line) const; - void parse (const char *line); - void parseDVIPSLine (InputReader &ir); - void parseDVIPDFMLine (InputReader &ir); - void parseFilenameOptions (std::string opt); - - private: - std::string _texname; ///< TeX font name - std::string _psname; ///< PS font name - std::string _fontfname; ///< name of fontfile - std::string _encname; ///< name of encoding (without file suffix ".enc") - SubfontDefinition *_sfd; ///< subfont definition to be used - int _fontindex; ///< font index of file with multiple fonts (e.g. ttc files) - double _slant, _bold, _extend; -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.cpp deleted file mode 100644 index 6aba0d04bdd..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/************************************************************************* -** Matrix.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "Calculator.h" -#include "Matrix.h" -#include "XMLString.h" - -using namespace std; - - - -/** Computes the determinant of a given matrix */ -double det (const Matrix &m) { - double sum=0; - for (int i=0; i < 3; ++i) { - sum += m._values[0][i] * m._values[1][(i+1)%3] * m._values[2][(i+2)%3] - - m._values[0][2-i] * m._values[1][(4-i)%3] * m._values[2][(3-i)%3]; - } - return sum; -} - - -/** Computes the determinant of the 2x2 submatrix of m where a given - * row and column were removed. - * @param[in] m base matrix - * @param[in] row row to remove - * @param[in] col column to remove */ -double det (const Matrix &m, int row, int col) { - int c1 = (col+1)%3, c2 = (col+2)%3; - int r1 = (row+1)%3, r2 = (row+2)%3; - if (c1 > c2) - swap(c1, c2); - if (r1 > r2) - swap(r1, r2); - return m._values[r1][c1] * m._values[r2][c2] - - m._values[r1][c2] * m._values[r2][c1]; -} - - -static inline double deg2rad (double deg) { - const double PI = acos(-1.0); - return PI*deg/180.0; -} - - -/** Creates a diagonal matrix ((d,0,0),(0,d,0),(0,0,d)). - * @param[in] d value of diagonal elements */ -Matrix::Matrix (double d) { - for (int i=0; i < 3; i++) - for (int j=0; j < 3; j++) - _values[i][j] = (i==j ? d : 0); -} - - -/** Creates the matrix ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). - * Expects that array v consists of 'size' elements. If size is less than 9, the - * remaining matrix components will be set to those of the identity matrix. - * @param[in] v array containing the matrix components - * @param[in] size size of array v */ -Matrix::Matrix (double v[], unsigned size) { - set(v, size); -} - - -/** Creates the matrix ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). - * If vector v has less than 9 elements, the remaining matrix components will be set to - * those of the identity matrix. - * @param[in] v array containing the matrix components - * @param[in] start use vector components start,...,start+8 */ -Matrix::Matrix (const std::vector &v, int start) { - set(v, start); -} - - -Matrix::Matrix (const string &cmds, Calculator &calc) { - parse(cmds, calc); -} - - -Matrix& Matrix::set (double v[], unsigned size) { - size = min(size, 9u); - for (unsigned i=0; i < size; i++) - _values[i/3][i%3] = v[i]; - for (unsigned i=size; i < 9; i++) - _values[i/3][i%3] = (i%4 ? 0 : 1); - return *this; -} - - -/** Set matrix values ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). - * If vector v has less than 9 elements, the remaining matrix components will be set to - * those of the identity matrix. - * @param[in] v array containing the matrix components - * @param[in] start use vector components start,...,start+8 */ -Matrix& Matrix::set (const vector &v, int start) { - unsigned size = min((unsigned)v.size()-start, 9u); - for (unsigned i=0; i < size; i++) - _values[i/3][i%3] = v[i+start]; - for (unsigned i=size; i < 9; i++) - _values[i/3][i%3] = (i%4 ? 0 : 1); - return *this; -} - - -Matrix& Matrix::translate (double tx, double ty) { - if (tx != 0 || ty != 0) { - TranslationMatrix t(tx, ty); - rmultiply(t); - } - return *this; -} - - -Matrix& Matrix::scale (double sx, double sy) { - if (sx != 1 || sy != 1) { - ScalingMatrix s(sx, sy); - rmultiply(s); - } - return *this; -} - - -/** Multiplies this matrix by ((cos d, -sin d, 0), (sin d, cos d, 0), (0,0,1)) that - * describes an anti-clockwise rotation by d degrees. - * @param[in] deg rotation angle in degrees */ -Matrix& Matrix::rotate (double deg) { - RotationMatrix r(deg); - rmultiply(r); - return *this; -} - - -Matrix& Matrix::xskew (double deg) { - double t = tan(deg2rad(deg)); - if (t != 0) { - double v[] = {1, t}; - Matrix t(v, 2); - rmultiply(t); - } - return *this; -} - - -Matrix& Matrix::yskew (double deg) { - double t = tan(deg2rad(deg)); - if (t != 0) { - double v[] = {1, 0, 0, t}; - Matrix t(v, 4); - rmultiply(t); - } - return *this; -} - - -Matrix& Matrix::flip (bool haxis, double a) { - double s = 1; - if (haxis) // mirror at horizontal axis? - s = -1; - double v[] = {-s, 0, (haxis ? 0 : 2*a), 0, s, (haxis ? 2*a : 0), 0, 0, 1}; - Matrix t(v); - rmultiply(t); - return *this; -} - - -/** Swaps rows and columns of the matrix. */ -Matrix& Matrix::transpose () { - for (int i=0; i < 3; i++) - for (int j=i+1; j < 3; j++) - swap(_values[i][j], _values[j][i]); - return *this; -} - - -/** Multiplies this matrix M with matrix tm (tm is the factor on the left side): M := tm * M */ -Matrix& Matrix::lmultiply (const Matrix &tm) { - Matrix ret; - for (int i=0; i < 3; i++) - for (int j=0; j < 3; j++) - for (int k=0; k < 3; k++) - ret._values[i][j] += _values[i][k] * tm._values[k][j]; - return *this = ret; -} - - -/** Multiplies this matrix M with matrix tm (tm is the factor on the right side): M := M * tm */ -Matrix& Matrix::rmultiply (const Matrix &tm) { - Matrix ret; - for (int i=0; i < 3; i++) - for (int j=0; j < 3; j++) - for (int k=0; k < 3; k++) - ret._values[i][j] += tm._values[i][k] * _values[k][j]; - return *this = ret; -} - - -Matrix& Matrix::invert () { - Matrix ret; - if (double denom = det(*this)) { - for (int i=0; i < 3; ++i) { - for (int j=0; j < 3; ++j) { - ret._values[i][j] = det(*this, i, j)/denom; - if ((i+j)%2 != 0) - ret._values[i][j] *= -1; - } - } - return *this = ret; - } - throw exception(); -} - - -Matrix& Matrix::operator *= (double c) { - for (int i=0; i < 3; i++) - for (int j=0; j < 3; j++) - _values[i][j] *= c; - return *this; -} - - -DPair Matrix::operator * (const DPair &p) const { - double pp[] = {p.x(), p.y(), 1}; - double ret[]= {0, 0}; - for (int i=0; i < 2; i++) - for (int j=0; j < 3; j++) - ret[i] += _values[i][j] * pp[j]; - return DPair(ret[0], ret[1]); -} - - -/** Returns true if this matrix equals. Checks equality by comparing the matrix components. */ -bool Matrix::operator == (const Matrix &m) const { - for (int i=0; i < 2; i++) - for (int j=0; j < 3; j++) - if (_values[i][j] != m._values[i][j]) - return false; - return true; -} - - -/** Returns true if this matrix doesn't equal m. Checks inequality by comparing the matrix components. */ -bool Matrix::operator != (const Matrix &m) const { - for (int i=0; i < 2; i++) - for (int j=0; j < 3; j++) - if (_values[i][j] != m._values[i][j]) - return true; - return false; -} - - -/** Returns true if this matrix is the identity matrix ((1,0,0),(0,1,0),(0,0,1)). */ -bool Matrix::isIdentity() const { - for (int i=0; i < 2; i++) - for (int j=0; j < 3; j++) { - const double &v = _values[i][j]; - if ((i == j && v != 1) || (i != j && v != 0)) - return false; - } - return true; -} - - -/** Checks whether this matrix describes a plain translation (without any other transformations). - * If so, the parameters tx and ty are filled with the translation components. - * @param[out] tx horizontal translation - * @param[out] ty vertical translation - * @return true if matrix describes a pure translation */ -bool Matrix::isTranslation (double &tx, double &ty) const { - tx = _values[0][2]; - ty = _values[1][2]; - for (int i=0; i < 3; i++) - for (int j=0; j < 2; j++) { - const double &v = _values[i][j]; - if ((i == j && v != 1) || (i != j && v != 0)) - return false; - } - return _values[2][2] == 1; -} - - -/** Gets a parameter for the transformation command. - * @param[in] is parameter chars are read from this stream - * @param[in] calc parameters can be arithmetic expressions, so we need a calculator to evaluate them - * @param[in] def default value if parameter is optional - * @param[in] optional true if parameter is optional - * @param[in] leadingComma true if first non-blank must be a comma - * @return value of argument */ -static double getArgument (istream &is, Calculator &calc, double def, bool optional, bool leadingComma) { - while (isspace(is.peek())) - is.get(); - if (!optional && leadingComma && is.peek() != ',') - throw ParserException("',' expected"); - if (is.peek() == ',') { - is.get(); // skip comma - optional = false; // now we expect a parameter - } - string expr; - while (is && !isupper(is.peek()) && is.peek() != ',') - expr += is.get(); - if (expr.length() == 0) { - if (optional) - return def; - else - throw ParserException("parameter expected"); - } - return calc.eval(expr); -} - - -Matrix& Matrix::parse (istream &is, Calculator &calc) { - *this = Matrix(1); - while (is) { - while (isspace(is.peek())) - is.get(); - char cmd = is.get(); - switch (cmd) { - case 'T': { - double tx = getArgument(is, calc, 0, false, false); - double ty = getArgument(is, calc, 0, true, true); - translate(tx, ty); - break; - } - case 'S': { - double sx = getArgument(is, calc, 1, false, false); - double sy = getArgument(is, calc, sx, true, true ); - scale(sx, sy); - break; - } - case 'R': { - double a = getArgument(is, calc, 0, false, false); - double x = getArgument(is, calc, calc.getVariable("ux")+calc.getVariable("w")/2, true, true); - double y = getArgument(is, calc, calc.getVariable("uy")+calc.getVariable("h")/2, true, true); - translate(-x, -y); - rotate(a); - translate(x, y); - break; - } - case 'F': { - char c = is.get(); - if (c != 'H' && c != 'V') - throw ParserException("'H' or 'V' expected"); - double a = getArgument(is, calc, 0, false, false); - flip(c == 'H', a); - break; - } - case 'K': { - char c = is.get(); - if (c != 'X' && c != 'Y') - throw ParserException("transformation command 'K' must be followed by 'X' or 'Y'"); - double a = getArgument(is, calc, 0, false, false); - if (fabs(cos(deg2rad(a))) <= numeric_limits::epsilon()) { - ostringstream oss; - oss << "illegal skewing angle: " << a << " degrees"; - throw ParserException(oss.str()); - } - if (c == 'X') - xskew(a); - else - yskew(a); - break; - } - case 'M': { - double v[9]; - for (int i=0; i < 6; i++) - v[i] = getArgument(is, calc, i%4 ? 0 : 1, i!=0, i!=0); - // third row (0, 0, 1) - v[6] = v[7] = 0; - v[8] = 1; - Matrix tm(v); - rmultiply(tm); - break; - } - default: - ostringstream oss; - oss << "transformation command expected (found '" << cmd << "' instead)"; - throw ParserException(oss.str()); - } - } - return *this; -} - - -Matrix& Matrix::parse (const string &cmds, Calculator &calc) { - istringstream iss; - iss.str(cmds); - return parse(iss, calc); -} - - -/** Returns an SVG matrix expression that can be used in transform attributes. - * ((a,b,c),(d,e,f),(0,0,1)) => matrix(a d b e c f) */ -string Matrix::getSVG () const { - ostringstream oss; - oss << "matrix("; - for (int i=0; i < 3; i++) { - for (int j=0; j < 2; j++) { - if (i > 0 || j > 0) - oss << ' '; - oss << XMLString(_values[j][i]); - } - } - oss << ')'; - return oss.str(); -} - - -ostream& Matrix::write (ostream &os) const { - os << '('; - for (int i=0; i < 3; i++) { - os << '(' << _values[i][0]; - for (int j=1; j < 3; j++) - os << ',' << _values[i][j]; - os << ')'; - if (i < 2) - os << ','; - } - os << ')'; - return os; -} - - -////////////////////////////////////////////////////////////////// - - -TranslationMatrix::TranslationMatrix (double tx, double ty) { - double v[] = {1, 0, tx, 0, 1, ty}; - set(v, 6); -} - - -ScalingMatrix::ScalingMatrix (double sx, double sy) { - double v[] = {sx, 0, 0, 0, sy}; - set(v, 5); -} - - -RotationMatrix::RotationMatrix (double deg) { - double rad = deg2rad(deg); - double c = cos(rad); - double s = sin(rad); - double v[] = {c, -s, 0, s, c}; - set(v, 5); -} - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.h deleted file mode 100644 index d3a52439021..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Matrix.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************* -** Matrix.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MATRIX_H -#define MATRIX_H - -#include -#include -#include -#include "MessageException.h" -#include "Pair.h" - - -struct ParserException : public MessageException -{ - ParserException (const std::string &msg) : MessageException(msg) {} -}; - -class Calculator; - -class Matrix -{ - friend double det (const Matrix &m); - friend double det (const Matrix &m, int row, int col); - - public: - Matrix (const std::string &cmds, Calculator &calc); - Matrix (double d=0); - Matrix (double v[], unsigned size=9); - Matrix (const std::vector &v, int start=0); - Matrix& set (double v[], unsigned size); - Matrix& set (const std::vector &v, int start=0); - double get (int row, int col) const {return _values[row][col];} - Matrix& transpose (); - Matrix& invert (); - Matrix& parse (std::istream &is, Calculator &c); - Matrix& parse (const std::string &cmds, Calculator &c); - Matrix& lmultiply (const Matrix &tm); - Matrix& rmultiply (const Matrix &tm); - Matrix& translate (double tx, double ty); - Matrix& scale (double sx, double sy); - Matrix& rotate (double deg); - Matrix& xskew (double deg); - Matrix& yskew (double deg); - Matrix& flip (bool h, double a); - Matrix& operator *= (double c); - DPair operator * (const DPair &p) const; - bool operator == (const Matrix &m) const; - bool operator != (const Matrix &m) const; - bool isIdentity() const; - bool isTranslation (double &tx, double &ty) const; - std::string getSVG () const; - std::ostream& write (std::ostream &os) const; - - private: - double _values[3][3]; // row x col -}; - - -struct TranslationMatrix : public Matrix -{ - TranslationMatrix (double tx, double ty); -}; - - -struct ScalingMatrix : public Matrix -{ - ScalingMatrix (double sx, double sy); -}; - - -struct RotationMatrix : public Matrix -{ - RotationMatrix (double deg); -}; - - -inline std::ostream& operator << (std::ostream &os, const Matrix &m) { - return m.write(os); -} - - -double det (const Matrix &m); -double det (const Matrix &m, int row, int col); - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.cpp deleted file mode 100644 index 38407ad5f6d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/************************************************************************* -** Message.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include "Message.h" -#include "Terminal.h" - -using namespace std; - -MessageStream::MessageStream () : _os(0), _nl(false), _col(1), _indent(0) { -} - - -MessageStream::MessageStream (std::ostream &os) - : _os(&os), _nl(true), _col(1), _indent(0) -{ - Terminal::init(os); -} - - -MessageStream::~MessageStream () { - if (_os && Message::COLORIZE) - Terminal::finish(*_os); -} - - -void MessageStream::putChar (const char c, ostream &os) { - switch (c) { - case '\r': - os << '\r'; - _nl = true; - _col = 1; - return; - case '\n': - if (!_nl) { - _col = 1; - _nl = true; - os << '\n'; - } - return; - default: - if (_nl) { - os << string(_indent, ' '); - _col += _indent; - } - else { - const int cols = Terminal::columns(); - if (cols > 0 && _col >= cols) { -#ifndef __WIN32__ - // move cursor to next line explicitly (not necessary in Windows/DOS terminal) - os << '\n'; -#endif - os << string(_indent, ' '); - _col = _indent+1; - } - else - _col++; - } - _nl = false; - if (!_nl || c != '\n') - os << c; - } -} - - -MessageStream& MessageStream::operator << (const char *str) { - if (_os && str) { - const char *first = str; - while (*first) { - const char *last = strchr(first, '\n'); - if (!last) - last = first+strlen(first)-1; -#ifndef __WIN32__ - // move cursor to next line explicitly (not necessary in Windows/DOS terminal) - const int cols = Terminal::columns(); - int len = last-first+1; - if (cols > 0 && _col+len > cols && _indent+len <= cols) - putChar('\n', *_os); -#endif - while (first <= last) - putChar(*first++, *_os); - first = last+1; - } - } - return *this; -} - - -MessageStream& MessageStream::operator << (const char &c) { - if (_os) - putChar(c, *_os); - return *this; -} - - -void MessageStream::indent (bool reset) { - if (reset) - _indent = 0; - _indent += 2; -} - - -void MessageStream::outdent (bool all) { - if (all) - _indent = 0; - else if (_indent > 0) - _indent -= 2; -} - - -void MessageStream::clearline () { - if (_os) { - int cols = Terminal::columns(); - *_os << '\r' << string(cols ? cols-1 : 79, ' ') << '\r'; - _nl = true; - _col = 1; - } -} - -static MessageStream nullStream; -static MessageStream messageStream(cerr); - - -////////////////////////////// - -// maximal verbosity -int Message::LEVEL = Message::MESSAGES | Message::WARNINGS | Message::ERRORS; -bool Message::COLORIZE = false; -bool Message::_initialized = false; -Message::Color Message::_classColors[9]; - - -/** Returns the stream for usual messages. */ -MessageStream& Message::mstream (bool prefix, MessageClass mclass) { - init(); - MessageStream *ms = (LEVEL & MESSAGES) ? &messageStream : &nullStream; - if (COLORIZE && ms && ms->os()) { - Terminal::fgcolor(_classColors[mclass].foreground, *ms->os()); - Terminal::bgcolor(_classColors[mclass].background, *ms->os()); - } - if (prefix) - *ms << "\nMESSAGE: "; - return *ms; -} - - -/** Returns the stream for warning messages. */ -MessageStream& Message::wstream (bool prefix) { - init(); - MessageStream *ms = (LEVEL & WARNINGS) ? &messageStream : &nullStream; - if (COLORIZE && ms && ms->os()) { - Terminal::fgcolor(_classColors[MC_WARNING].foreground, *ms->os()); - Terminal::bgcolor(_classColors[MC_WARNING].background, *ms->os()); - } - if (prefix) - *ms << "\nWARNING: "; - return *ms; -} - - -/** Returns the stream for error messages. */ -MessageStream& Message::estream (bool prefix) { - init(); - MessageStream *ms = (LEVEL & ERRORS) ? &messageStream : &nullStream; - if (COLORIZE && ms && ms->os()) { - Terminal::fgcolor(_classColors[MC_ERROR].foreground, *ms->os()); - Terminal::bgcolor(_classColors[MC_ERROR].background, *ms->os()); - } - if (prefix) - *ms << "\nERROR: "; - return *ms; -} - - -static bool colorchar2int (char colorchar, int *val) { - colorchar = tolower(colorchar); - if (colorchar >= '0' && colorchar <= '9') - *val = int(colorchar-'0'); - else if (colorchar >= 'a' && colorchar <= 'f') - *val = int(colorchar-'a'+10); - else if (colorchar == '*') - *val = -1; - else - return false; - return true; -} - - -/** Initializes the Message class. Sets the colors for each message set. - * The colors can be changed via environment variable DVISVGM_COLORS. Its - * value must be a sequence of color entries of the form gg:BF where the - * two-letter ID gg specifies a message set, B the hex digit of the - * background, and F the hex digit of the foreground/text color. - * Color codes: - * - 1: red, 2: green, 4: blue - * - 0-7: dark colors - * - 8-F: light colors - * - *: default color - * Example: num:01 sets page number messages to red on black background */ -void Message::init () { - if (_initialized || !Message::COLORIZE) - return; - - // set default message colors - _classColors[MC_ERROR] = Color(Terminal::RED, true); - _classColors[MC_WARNING] = Color(Terminal::YELLOW); - _classColors[MC_PAGE_NUMBER] = Color(Terminal::BLUE, true); - _classColors[MC_PAGE_SIZE] = Color(Terminal::MAGENTA); - _classColors[MC_PAGE_WRITTEN] = Color(Terminal::GREEN); - _classColors[MC_STATE] = Color(Terminal::CYAN); - _classColors[MC_TRACING] = Color(Terminal::BLUE); - _classColors[MC_PROGRESS] = Color(Terminal::MAGENTA); - - if (const char *color_str = getenv("DVISVGM_COLORS")) { - map classes; - classes["er"] = MC_ERROR; - classes["wn"] = MC_WARNING; - classes["pn"] = MC_PAGE_NUMBER; - classes["ps"] = MC_PAGE_SIZE; - classes["fw"] = MC_PAGE_WRITTEN; - classes["sm"] = MC_STATE; - classes["tr"] = MC_TRACING; - classes["pi"] = MC_PROGRESS; - const char *p=color_str; - - // skip leading whitespace - while (isspace(*p)) - ++p; - - // iterate over color assignments - while (strlen(p) >= 5) { - map::iterator it = classes.find(string(p, 2)); - if (it != classes.end() && p[2] == '=') { - int bgcolor, fgcolor; - if (colorchar2int(p[3], &bgcolor) && colorchar2int(p[4], &fgcolor)) { - _classColors[it->second].background = bgcolor; - _classColors[it->second].foreground = fgcolor; - } - } - p += 5; - - // skip trailing characters in a malformed entry - while (!isspace(*p) && *p != ':' && *p != ';') - ++p; - // skip separation characters - while (isspace(*p) || *p == ':' || *p == ';') - ++p; - } - } - _initialized = true; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.h deleted file mode 100644 index bc4a9ed016c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Message.h +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* -** Message.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MESSAGE_H -#define MESSAGE_H - -#include -#include -#include -#include -#include "Terminal.h" -#include "types.h" - - -class Message; - -class MessageStream -{ - friend class Message; - - public: - MessageStream (); - MessageStream (std::ostream &os); - ~MessageStream (); - - template - MessageStream& operator << (const T &obj) { - std::ostringstream oss; - oss << obj; - (*this) << oss.str(); - return *this; - } - - MessageStream& operator << (const char *str); - MessageStream& operator << (const char &c); - MessageStream& operator << (const std::string &str) {return (*this) << str.c_str();} - - void indent (int level) {_indent = std::max(0, level*2);} - void indent (bool reset=false); - void outdent (bool all=false); - void clearline (); - - protected: - void putChar (const char c, std::ostream &os); - std::ostream* os () {return _os;} - - private: - std::ostream *_os; - bool _nl; ///< true if previous character was a newline - int _col; ///< current terminal column - int _indent; ///< indentation width (number of columns/characters) -}; - - -class Message -{ - struct Color { - Color () : foreground(-1), background(-1) {} - Color (Int8 fgcolor) : foreground(fgcolor), background(-1) {} - Color (Int8 fgcolor, bool light) : foreground(fgcolor + (light ? 8 : 0)), background(-1) {} - Color (Int8 fgcolor, Int8 bgcolor) : foreground(fgcolor), background(bgcolor) {} - Int8 foreground; - Int8 background; - }; - - public: - enum MessageClass { - MC_ERROR, - MC_WARNING, - MC_MESSAGE, - MC_PAGE_NUMBER, - MC_PAGE_SIZE, - MC_PAGE_WRITTEN, - MC_STATE, - MC_TRACING, - MC_PROGRESS, - }; - - public: - static MessageStream& mstream (bool prefix=false, MessageClass mclass=MC_MESSAGE); - static MessageStream& estream (bool prefix=false); - static MessageStream& wstream (bool prefix=false); - - enum {ERRORS=1, WARNINGS=2, MESSAGES=4}; - static int LEVEL; - static bool COLORIZE; - - protected: - static void init (); - - - private: - static Color _classColors[]; - static bool _initialized; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MessageException.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MessageException.h deleted file mode 100644 index e6c4ace019f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MessageException.h +++ /dev/null @@ -1,39 +0,0 @@ -/************************************************************************* -** MessageException.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MESSAGEEXCEPTION_H -#define MESSAGEEXCEPTION_H - -#include -#include - - -class MessageException : public std::exception -{ - public: - MessageException (const std::string &msg) : _message(msg) {} - virtual ~MessageException () throw() {} - const char* what () const throw() {return _message.c_str();} - - private: - std::string _message; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.cpp deleted file mode 100644 index 37e3b68f92f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/************************************************************************* -** MetafontWrapper.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "FileSystem.h" -#include "FileFinder.h" -#include "Message.h" -#include "MetafontWrapper.h" -#include "Process.h" -#include "SignalHandler.h" -#include "macros.h" - -using namespace std; - - -MetafontWrapper::MetafontWrapper (const string &fname) : _fontname(fname) -{ -} - - -/** Calls Metafont and evaluates the logfile. If a gf file was successfully - * generated the dpi value is stripped from the filename - * (e.g. cmr10.600gf => cmr10.gf). This makes life easier... - * @param[in] mode Metafont mode, e.g. "ljfour" - * @param[in] mag magnification factor - * @return true on success */ -bool MetafontWrapper::call (const string &mode, double mag) { - if (!FileFinder::lookup(_fontname+".mf")) - return false; // mf file not available => no need to call the "slow" Metafont - FileSystem::remove(_fontname+".gf"); - -#ifdef __WIN32__ -#ifdef TEXLIVEWIN32 - const char *mfname = "mf-nowin.exe"; -#else - const char *mfname = "mf.exe"; -#endif - const char *cmd = FileFinder::lookup(mfname, false); - if (!cmd) { - Message::estream(true) << "can't run Metafont (" << mfname << " not found)\n"; - return false; - } -#else - const char *cmd = "mf"; -#endif - ostringstream oss; - oss << "\"\\mode=" << mode << ";" - "mag:=" << mag << ";" - "batchmode;" - "input " << _fontname << "\""; - Message::mstream(false, Message::MC_STATE) << "\nrunning Metafont for " << _fontname << '\n'; - Process mf_process(cmd, oss.str().c_str()); - mf_process.run(); - - // try to read Metafont's logfile and get name of created GF file - ifstream ifs((_fontname+".log").c_str()); - if (ifs) { - char buf[128]; - while (ifs) { - ifs.getline(buf, 128); - string line = buf; - if (line.substr(0, 15) == "! Interruption.") - SignalHandler::instance().trigger(true); - if (line.substr(0, 17) == "Output written on") { - size_t pos = line.find("gf ", 18+_fontname.length()); - if (pos != string::npos) { - string gfname = line.substr(18, pos-16); // GF filename found - FileSystem::rename(gfname, _fontname+".gf"); - } - break; - } - } - } - ifstream gf((_fontname+".gf").c_str()); - return gf; -} - - -/** Calls Metafont if output files (tfm and gf) don't already exist. - * @param[in] mode Metafont mode to be used (e.g. 'ljfour') - * @param[in] mag magnification factor - * @return true on success */ -bool MetafontWrapper::make (const string &mode, double mag) { - ifstream tfm((_fontname+".tfm").c_str()); - ifstream gf((_fontname+".gf").c_str()); - if (gf && tfm) // @@ distinguish between gf and tfm - return true; - return call(mode, mag); -} - - -bool MetafontWrapper::success () const { - ifstream tfm((_fontname+".tfm").c_str()); - ifstream gf((_fontname+".gf").c_str()); - return tfm && gf; -} - - -/** Remove all files created by a Metafont call (tfm, gf, log). - * @param[in] keepGF if true, GF files won't be removed */ -void MetafontWrapper::removeOutputFiles (bool keepGF) { - removeOutputFiles(_fontname, keepGF); -} - - -/** Remove all files created by a Metafont call for a given font (tfm, gf, log). - * @param[in] fontname name of font whose temporary files should be removed - * @param[in] keepGF if true, GF files will be kept */ -void MetafontWrapper::removeOutputFiles (const string &fontname, bool keepGF) { - const char *ext[] = {"gf", "tfm", "log", 0}; - for (const char **p = keepGF ? ext+2 : ext; *p; ++p) - FileSystem::remove(fontname + "." + *p); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.h deleted file mode 100644 index 2a69654ff95..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MetafontWrapper.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************* -** MetafontWrapper.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef METAFONTWRAPPER_H -#define METAFONTWRAPPER_H - -#include - - -struct FileFinder; - -class MetafontWrapper -{ - public: - MetafontWrapper (const std::string &fontname); - bool call (const std::string &mode, double mag); - bool make (const std::string &mode, double mag); - bool success () const; - void removeOutputFiles (bool keepGF=false); - static void removeOutputFiles (const std::string &fontname, bool keepGF=false); - - private: - std::string _fontname; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.cpp deleted file mode 100644 index ddf5af52f80..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************* -** MiKTeXCom.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "MessageException.h" -#include "MiKTeXCom.h" -#include "macros.h" - -using namespace std; - - -MiKTeXCom::MiKTeXCom () : _session(0) { - if (FAILED(CoInitialize(0))) - throw MessageException("COM library could not be initialized\n"); -#ifdef _MSC_VER - HRESULT hres = _session.CreateInstance(L"MiKTeX.Session"); -#elif defined(__WIN64__) - HRESULT hres = CoCreateInstance(CLSID_MiKTeXSession2_9, 0, CLSCTX_LOCAL_SERVER, IID_ISession2, (void**)&_session); -#else - HRESULT hres = CoCreateInstance(CLSID_MiKTeXSession2_9, 0, CLSCTX_INPROC_SERVER, IID_ISession2, (void**)&_session); -#endif - if (FAILED(hres)) - throw MessageException("MiKTeX.Session could not be initialized"); -} - - -MiKTeXCom::~MiKTeXCom () { -#ifdef _MSC_VER - _session.Release(); -#else - _session->Release(); -#endif - _session = 0; // avoid automatic calling of Release() after CoUninitialize() - CoUninitialize(); -} - - -string MiKTeXCom::getVersion () { -#ifdef _MSC_VER - MiKTeXSetupInfo info = _session->GetMiKTeXSetupInfo(); -#else - MiKTeXSetupInfo info; - _session->GetMiKTeXSetupInfo(&info); -#endif - _bstr_t version = info.version; - return string(version); -} - - -const char* MiKTeXCom::findFile (const char *fname) { - try { - _bstr_t path; - static string ret; -#ifdef _MSC_VER - HRESULT hres = _session->FindFile(fname, path.GetAddress()); - bool found = (hres != 0); -#else - VARIANT_BOOL found_var; - _session->FindFile(_bstr_t(fname), path.GetAddress(), &found_var); - bool found = (found_var == VARIANT_TRUE); -#endif - if (found) { - ret = _bstr_t(path); - return ret.c_str(); - } - return 0; - } - catch (_com_error &e) { - throw MessageException((const char*)e.Description()); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.h deleted file mode 100644 index 8649cc9f377..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/MiKTeXCom.h +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* -** MiKTeXCom.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MIKTEXCOM_H -#define MIKTEXCOM_H - -#include - -#ifdef _MSC_VER -#import -using namespace MiKTeXSession2_9; -#else -#include "miktex209-session.h" -#endif - - -class MiKTeXCom -{ - public: - MiKTeXCom (); - ~MiKTeXCom (); - std::string getVersion (); - const char* findFile (const char* fname); - - private: -#ifdef _MSC_VER - ISession2Ptr _session; -#else - ISession2 *_session; -#endif -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.cpp deleted file mode 100644 index 31fb41da3c2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************* -** NoPsSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "Message.h" -#include "NoPsSpecialHandler.h" - -using namespace std; - - -bool NoPsSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - _count++; - return true; -} - - -void NoPsSpecialHandler::dviEndPage () { - if (_count > 0) { - string suffix = (_count > 1 ? "s" : ""); - Message::wstream(true) << _count << " PostScript special" << suffix << " ignored. The resulting SVG might look wrong.\n"; - _count = 0; - } -} - - -const char** NoPsSpecialHandler::prefixes () const { - static const char *pfx[] = {"header=", "psfile=", "PSfile=", "ps:", "ps::", "!", "\"", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.h deleted file mode 100644 index a73768ca808..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/NoPsSpecialHandler.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************* -** NoPsSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef NOPSSPECIALHANDLER_H -#define NOPSSPECIALHANDLER_H - -#include "SpecialHandler.h" - -class NoPsSpecialHandler : public SpecialHandler -{ - public: - NoPsSpecialHandler () : _count(0) {} - bool process (const char *prefix, std::istream &is, SpecialActions *actions); - void dviEndPage (); - const char* name () const {return 0;} - const char* info () const {return 0;} - const char** prefixes () const; - - protected: - bool isEndPageListener () const {return true;} - - private: - unsigned _count; // number of PS specials skipped -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.cpp deleted file mode 100644 index f1fad9448d8..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/************************************************************************* -** PSInterpreter.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "FileFinder.h" -#include "InputReader.h" -#include "Message.h" -#include "PSInterpreter.h" -#include "SignalHandler.h" - -using namespace std; - - -const char *PSInterpreter::GSARGS[] = { - "gs", // dummy name - "-q", // be quiet, suppress gs banner - "-dSAFER", // disallow writing of files - "-dNODISPLAY", // we don't need a display device - "-dNOPAUSE", // keep going - "-dWRITESYSTEMDICT", // leave systemdict writable as some operators must be replaced - "-dNOPROMPT", -// "-dNOBIND", -}; - - -/** Constructs a new PSInterpreter object. - * @param[in] actions template methods to be executed after recognizing the corresponding PS operator. */ -PSInterpreter::PSInterpreter (PSActions *actions) - : _mode(PS_NONE), _actions(actions), _bytesToRead(0), _inError(false), _initialized(false) -{ -} - - -void PSInterpreter::init () { - if (!_initialized) { - _gs.init(sizeof(GSARGS)/sizeof(char*), GSARGS, this); - _gs.set_stdio(input, output, error); - _initialized = true; - // Before executing any random PS code redefine some operators and run - // initializing PS code. This cannot be done in the constructor because we - // need the completely initialized PSInterpreter object here. - execute(PSDEFS); - } -} - - -PSActions* PSInterpreter::setActions (PSActions *actions) { - PSActions *old_actions = _actions; - _actions = actions; - return old_actions; -} - - -/** Checks if the given status value returned by Ghostscript indicates an error. - * @param[in] status status value returned by Ghostscript after the execution of a PS snippet - * @throw PSException if the status value indicates a PostScript error */ -void PSInterpreter::checkStatus (int status) { - if (status < 0) { - _mode = PS_QUIT; - if (status < -100) - throw PSException("fatal error"); - if (_errorMessage.empty()) - throw PSException(_gs.error_name(status)); - throw PSException(_errorMessage); - } -} - - -/** Executes a chunk of PostScript code. - * @param[in] str buffer containing the code - * @param[in] len number of characters in buffer - * @param[in] flush If true, a final 'flush' is sent which forces the output buffer to be written immediately. - * @return true if the assigned number of bytes have been read */ -bool PSInterpreter::execute (const char *str, size_t len, bool flush) { - init(); - if (_mode == PS_QUIT) - return false; - - int status=0; - if (_mode == PS_NONE) { - _gs.run_string_begin(0, &status); - _mode = PS_RUNNING; - } - checkStatus(status); - - bool finished=false; - if (_bytesToRead > 0 && len >= _bytesToRead) { - len = _bytesToRead; - finished = true; - } - - // 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) { - SignalHandler::instance().check(); - size_t chunksize = min(len, (size_t)0xffff); - _gs.run_string_continue(p, chunksize, 0, &status); - p += chunksize; - len -= chunksize; - if (_bytesToRead > 0) - _bytesToRead -= chunksize; - if (status == -101) // e_Quit - _mode = PS_QUIT; - else - checkStatus(status); - } - if (flush) { - // force writing contents of output buffer - _gs.run_string_continue("\nflush ", 7, 0, &status); - } - return finished; -} - - -/** Executes a chunk of PostScript code read from a stream. The method returns on EOF. - * @param[in] is the input stream - * @return true if the assigned number of bytes have been read */ -bool PSInterpreter::execute (istream &is) { - char buf[4096]; - bool finished = false; - while (is && !is.eof() && !finished) { - is.read(buf, 4096); - finished = execute(buf, is.gcount(), false); - } - execute("\n", 1); - return finished; -} - - -/** This callback function handles input from stdin to Ghostscript. Currently not needed. - * @param[in] inst pointer to calling instance of PSInterpreter - * @param[in] buf takes the read characters - * @param[in] len size of buffer buf - * @return number of characters read */ -int GSDLLCALL PSInterpreter::input (void *inst, char *buf, int len) { - return 0; -} - - -/** This callback function handles output from Ghostscript to stdout. It looks for - * emitted commands staring with "dvi." and executes them by calling method callActions. - * Ghostscript sends the text in chunks by several calls of this function. - * Unfortunately, the PostScript specification wants error messages also to be sent to stdout - * instead of stderr. Thus, we must collect and concatenate the chunks until an evaluable text - * snippet is completely received. Furthermore, error messages have to be recognized and to be - * filtered out. - * @param[in] inst pointer to calling instance of PSInterpreter - * @param[in] buf contains the characters to be output - * @param[in] len number of characters in buf - * @return number of processed characters (equals 'len') */ -int GSDLLCALL PSInterpreter::output (void *inst, const char *buf, int len) { - PSInterpreter *self = static_cast(inst); - if (self && self->_actions) { - const size_t MAXLEN = 512; // maximal line length (longer lines are of no interest) - const char *end = buf+len-1; // last position of buf - for (const char *first=buf, *last=buf; first <= end; last++, first=last) { - // move first and last to begin and end of the next line, respectively - while (last < end && *last != '\n') - last++; - size_t linelength = last-first+1; - if (linelength > MAXLEN) // skip long lines since they don't contain any relevant information - continue; - - vector &linebuf = self->_linebuf; // just a shorter name... - if ((*last == '\n' || !self->active()) || self->_inError) { - if (linelength + linebuf.size() > 1) { // prefix "dvi." plus final newline - SplittedCharInputBuffer ib(linebuf.empty() ? 0 : &linebuf[0], linebuf.size(), first, linelength); - BufferInputReader in(ib); - if (self->_inError) - self->_errorMessage += string(first, linelength); - else { - in.skipSpace(); - if (in.check("Unrecoverable error: ")) { - self->_errorMessage.clear(); - while (!in.eof()) - self->_errorMessage += in.get(); - self->_inError = true; - } - else if (in.check("dvi.")) - self->callActions(in); - } - } - linebuf.clear(); - } - else { // no line end found => - // save remaining characters and prepend them to the next incoming chunk of characters - if (linebuf.size() + linelength > MAXLEN) - linebuf.clear(); // don't care for long lines - else { - size_t currsize = linebuf.size(); - linebuf.resize(currsize+linelength); - memcpy(&linebuf[currsize], first, linelength); - } - } - } - } - return len; -} - - -/** Converts a vector of strings to a vector of doubles. - * @param[in] str the strings to be converted - * @param[out] d the resulting doubles */ -static void str2double (const vector &str, vector &d) { - for (size_t i=0; i < str.size(); i++) { - istringstream iss(str[i]); - iss >> d[i]; - } -} - - -/** Evaluates a command emitted by Ghostscript and invokes the corresponding - * method of interface class PSActions. - * @param[in] in reader pointing to the next command */ -void PSInterpreter::callActions (InputReader &in) { - // array of currently supported operators (must be ascendingly sorted) - static const struct Operator { - const char *name; // name of operator - int pcount; // number of parameters (< 0 : variable number of parameters) - void (PSActions::*op)(vector &p); // operation handler - } operators [] = { - {"applyscalevals", 3, &PSActions::applyscalevals}, - {"clip", 0, &PSActions::clip}, - {"closepath", 0, &PSActions::closepath}, - {"curveto", 6, &PSActions::curveto}, - {"eoclip", 0, &PSActions::eoclip}, - {"eofill", 0, &PSActions::eofill}, - {"fill", 0, &PSActions::fill}, - {"grestore", 0, &PSActions::grestore}, - {"grestoreall", 0, &PSActions::grestoreall}, - {"gsave", 0, &PSActions::gsave}, - {"initclip", 0, &PSActions::initclip}, - {"lineto", 2, &PSActions::lineto}, - {"makepattern", -1, &PSActions::makepattern}, - {"moveto", 2, &PSActions::moveto}, - {"newpath", 0, &PSActions::newpath}, - {"querypos", 2, &PSActions::querypos}, - {"restore", 1, &PSActions::restore}, - {"rotate", 1, &PSActions::rotate}, - {"save", 1, &PSActions::save}, - {"scale", 2, &PSActions::scale}, - {"setcmykcolor", 4, &PSActions::setcmykcolor}, - {"setdash", -1, &PSActions::setdash}, - {"setgray", 1, &PSActions::setgray}, - {"sethsbcolor", 3, &PSActions::sethsbcolor}, - {"setlinecap", 1, &PSActions::setlinecap}, - {"setlinejoin", 1, &PSActions::setlinejoin}, - {"setlinewidth", 1, &PSActions::setlinewidth}, - {"setmatrix", 6, &PSActions::setmatrix}, - {"setmiterlimit", 1, &PSActions::setmiterlimit}, - {"setopacityalpha", 1, &PSActions::setopacityalpha}, - {"setpattern", -1, &PSActions::setpattern}, - {"setrgbcolor", 3, &PSActions::setrgbcolor}, - {"stroke", 0, &PSActions::stroke}, - {"translate", 2, &PSActions::translate}, - }; - if (_actions) { - in.skipSpace(); - // binary search - int first=0, last=sizeof(operators)/sizeof(Operator)-1; - while (first <= last) { - int mid = first+(last-first)/2; - int cmp = in.compare(operators[mid].name); - if (cmp > 0) - last = mid-1; - else if (cmp < 0) - first = mid+1; - else { - // collect parameters and call handler - vector params; - int pcount = operators[mid].pcount; - if (pcount < 0) { // variable number of parameters? - in.skipSpace(); - while (!in.eof()) { // read all available parameters - params.push_back(in.getString()); - in.skipSpace(); - } - } - else { // fixed number of parameters - for (int i=0; i < pcount; i++) { - in.skipSpace(); - params.push_back(in.getString()); - } - } - vector v(params.size()); - str2double(params, v); - (_actions->*operators[mid].op)(v); - _actions->executed(); - } - } - } -} - - -/** This callback function handles output from Ghostscript to stderr. - * @param[in] inst pointer to calling instance of PSInterpreter - * @param[in] buf contains the characters to be output - * @param[in] len number of chars in buf - * @return number of processed characters */ -int GSDLLCALL PSInterpreter::error (void *inst, const char *buf, int len) { - return len; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.h deleted file mode 100644 index 4e46732a420..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSInterpreter.h +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************* -** PSInterpreter.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PSINTERPRETER_H -#define PSINTERPRETER_H - -#include -#include -#include -#include -#include "Ghostscript.h" -#include "InputReader.h" -#include "MessageException.h" - - -struct PSException : public MessageException -{ - PSException (const std::string &msg) : MessageException(msg) {} -}; - - -/** This interface provides the template methods called by PSInterpreter when executing a PS snippet. - * Each method corresponds to a PostScript operator of the same name. */ -struct PSActions -{ - virtual ~PSActions () {} - virtual void applyscalevals (std::vector &p) =0; - virtual void clip (std::vector &p) =0; - virtual void closepath (std::vector &p) =0; - virtual void curveto (std::vector &p) =0; - virtual void eoclip (std::vector &p) =0; - virtual void eofill (std::vector &p) =0; - virtual void fill (std::vector &p) =0; - virtual void gsave (std::vector &p) =0; - virtual void grestore (std::vector &p) =0; - virtual void grestoreall (std::vector &p) =0; - virtual void initclip (std::vector &p) =0; - virtual void lineto (std::vector &p) =0; - virtual void makepattern (std::vector &p) =0; - virtual void moveto (std::vector &p) =0; - virtual void newpath (std::vector &p) =0; - virtual void querypos (std::vector &p) =0; - virtual void restore (std::vector &p) =0; - virtual void rotate (std::vector &p) =0; - virtual void save (std::vector &p) =0; - virtual void scale (std::vector &p) =0; - virtual void setcmykcolor (std::vector &cmyk) =0; - virtual void setdash (std::vector &p) =0; - virtual void setgray (std::vector &p) =0; - virtual void sethsbcolor (std::vector &hsb) =0; - virtual void setlinecap (std::vector &p) =0; - virtual void setlinejoin (std::vector &p) =0; - virtual void setlinewidth (std::vector &p) =0; - virtual void setmatrix (std::vector &p) =0; - virtual void setmiterlimit (std::vector &p) =0; - virtual void setopacityalpha (std::vector &p) =0; - virtual void setpattern (std::vector &p) =0; - virtual void setrgbcolor (std::vector &rgb) =0; - virtual void stroke (std::vector &p) =0; - virtual void translate (std::vector &p) =0; - virtual void executed () {} // triggered if one of the above PS operators has been executed -}; - - -/** This class provides methods to execute chunks of PostScript code and calls - * several template methods on invocation of selected PS operators (see PSActions). */ -class PSInterpreter -{ - enum Mode {PS_NONE, PS_RUNNING, PS_QUIT}; - - public: - PSInterpreter (PSActions *actions=0); - bool execute (const char *str, size_t len, bool flush=true); - bool execute (const char *str) {return execute(str, std::strlen(str));} - bool execute (const std::string &str) {return execute(str.c_str());} - bool execute (std::istream &is); - bool active () const {return _mode != PS_QUIT;} - void limit (size_t max_bytes) {_bytesToRead = max_bytes;} - PSActions* setActions (PSActions *actions); - - protected: - void init (); - // callback functions - static int GSDLLCALL input (void *inst, char *buf, int len); - static int GSDLLCALL output (void *inst, const char *buf, int len); - static int GSDLLCALL error (void *inst, const char *buf, int len); - - void checkStatus (int status); - void callActions (InputReader &cib); - - private: - Ghostscript _gs; - Mode _mode; ///< current execution mode - PSActions *_actions; ///< actions to be performed - size_t _bytesToRead; ///< if > 0, maximal number of bytes to be processed by following calls of execute() - std::vector _linebuf; - std::string _errorMessage; ///< text of error message - bool _inError; ///< true if scanning error message - bool _initialized; ///< true if PSInterpreter has been completely initialized - static const char *GSARGS[]; ///< parameters passed to Ghostscript - static const char *PSDEFS; ///< initial PostScript definitions -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.cpp deleted file mode 100644 index 52fbf16c589..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* -** PSPattern.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "BoundingBox.h" -#include "PSPattern.h" -#include "SpecialActions.h" -#include "SVGTree.h" -#include "XMLNode.h" - -using namespace std; - - -string PSPattern::svgID () const { - return XMLString("pat")+XMLString(_id); -} - - -/** Appends the definition of this pattern to the "def" section of the SVG tree. */ -void PSPattern::apply (SpecialActions *actions) { - if (XMLElementNode *pattern = createPatternNode()) - actions->appendToDefs(pattern); -} - - -///////////////////////////////////////////////////////////////////////////// - -PSTilingPattern::PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) - : PSPattern(id), _bbox(bbox), _matrix(matrix), _xstep(xstep), _ystep(ystep), _groupNode(0) -{ - const double bp2pt = 72.27/72.0; // factor to convert bp to pt - _bbox.scale(bp2pt, bp2pt); - _xstep *= bp2pt; - _ystep *= bp2pt; - _groupNode = PSTilingPattern::createGroupNode(); -} - - -PSTilingPattern::~PSTilingPattern () { - delete _groupNode; -} - - -/** Creates a new pattern element representing the pattern defined in the PS code. */ -XMLElementNode* PSTilingPattern::createPatternNode () const { - if (!_groupNode) - return 0; - BoundingBox box(_bbox.minX(), _bbox.minY(), _bbox.minX()+_xstep, _bbox.minY()+_ystep); - XMLElementNode *pattern = new XMLElementNode("pattern"); - pattern->addAttribute("id", svgID()); - pattern->addAttribute("x", box.minX()); - pattern->addAttribute("y", box.minY()); - pattern->addAttribute("width", box.width()); - pattern->addAttribute("height", box.height()); - pattern->addAttribute("viewBox", box.toSVGViewBox()); - pattern->addAttribute("patternUnits", "userSpaceOnUse"); - if (!_matrix.isIdentity()) - pattern->addAttribute("patternTransform", _matrix.getSVG()); - if (_xstep < _bbox.width() || _ystep < _bbox.height()) { // overlapping tiles? - // disable clipping at the tile borders => tiles become "transparent" - pattern->addAttribute("overflow", "visible"); - } - if (XMLElementNode *clip=createClipNode()) - pattern->append(clip); - pattern->append(_groupNode); - return pattern; -} - - -/** Creates a new clip element restricting the drawing area to the - * dimensions given in the definition of the pattern. */ -XMLElementNode* PSTilingPattern::createClipNode() const { - XMLElementNode *clip = new XMLElementNode("clipPath"); - clip->addAttribute("id", "pc"+XMLString(psID())); - XMLElementNode *rect = new XMLElementNode("rect"); - rect->addAttribute("x", _bbox.minX()); - rect->addAttribute("y", _bbox.minY()); - rect->addAttribute("width", _bbox.width()); - rect->addAttribute("height", _bbox.height()); - clip->append(rect); - return clip; -} - - -/** Creates a new group element that contains all "drawing" elements that - * define the pattern graphic. */ -XMLElementNode* PSTilingPattern::createGroupNode () const { - // add all succeeding path elements to this group - XMLElementNode *group = new XMLElementNode("g"); - group->addAttribute("clip-path", XMLString("url(#pc")+XMLString(psID())+")"); - return group; -} - - -void PSTilingPattern::apply (SpecialActions *actions) { - PSPattern::apply(actions); - _groupNode = 0; -} - - -///////////////////////////////////////////////////////////////////////////// - -PSColoredTilingPattern::PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) - : PSTilingPattern(id, bbox, matrix, xstep, ystep) -{ -} - - -///////////////////////////////////////////////////////////////////////////// - -PSUncoloredTilingPattern::PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) - : PSTilingPattern(id, bbox, matrix, xstep, ystep), _applied(false) -{ -} - - -PSUncoloredTilingPattern::~PSUncoloredTilingPattern () { - if (_applied) - setGroupNode(0); // prevent deleting the group node in the parent destructor -} - - -/** Returns an SVG id value that identifies this pattern with the current color applied. */ -string PSUncoloredTilingPattern::svgID () const { - ostringstream oss; - oss << PSPattern::svgID() << '-' << hex << _currentColor; - return oss.str(); -} - - -/** Appends the definition of this pattern with the current color applied - * to the "def" section of the SVG tree. */ -void PSUncoloredTilingPattern::apply (SpecialActions* actions) { - set::iterator it=_colors.find(_currentColor); - if (it == _colors.end()) { - if (_applied) - setGroupNode(static_cast(getGroupNode()->clone())); - // assign current color to the pattern graphic - vector colored_elems; - const char *attribs[] = {"fill", "stroke"}; - for (int i=0; i < 2; i++) { - getGroupNode()->findDescendants(0, attribs[i], colored_elems); - for (vector::iterator it=colored_elems.begin(); it != colored_elems.end(); ++it) - if (string((*it)->getAttributeValue(attribs[i])) != "none") - (*it)->addAttribute(attribs[i], _currentColor.rgbString()); - colored_elems.clear(); - } - PSPattern::apply(actions); - _colors.insert(_currentColor); - _applied = true; - } -} - - -XMLElementNode* PSUncoloredTilingPattern::createClipNode() const { - // only the first instance of this patterns get a clip element - if (_colors.empty()) - return PSTilingPattern::createClipNode(); - return 0; -} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.h deleted file mode 100644 index 7e2848dea3b..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PSPattern.h +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************* -** PSPattern.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PSPATTERN_H -#define PSPATTERN_H - -#include -#include -#include "BoundingBox.h" -#include "Color.h" -#include "Matrix.h" - - -struct SpecialActions; -class SVGTree; -class XMLElementNode; - -class PSPattern -{ - public: - virtual ~PSPattern () {} - virtual int psID () const {return _id;} - virtual std::string svgID () const; - virtual void apply (SpecialActions *actions); - - protected: - PSPattern (int id) : _id(id) {} - virtual XMLElementNode* createPatternNode () const =0; - - private: - int _id; ///< PostSCript ID of this pattern -}; - - -class PSTilingPattern : public PSPattern -{ - public: - ~PSTilingPattern (); - virtual XMLElementNode* getContainerNode () {return _groupNode;} - void apply (SpecialActions *actions); - - protected: - PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); - XMLElementNode* createPatternNode () const; - virtual XMLElementNode* createClipNode () const; - virtual XMLElementNode* createGroupNode () const; - virtual XMLElementNode* getGroupNode () const {return _groupNode;} - virtual void setGroupNode (XMLElementNode *node) {_groupNode = node;} - - private: - BoundingBox _bbox; ///< bounding box of the tile graphics - Matrix _matrix; ///< tile transformation - double _xstep, _ystep; ///< horizontal and vertical distance between neighboured tiles - XMLElementNode *_groupNode; ///< group containing the drawing elements -}; - - -class PSColoredTilingPattern : public PSTilingPattern -{ - public: - PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); -}; - - -class PSUncoloredTilingPattern : public PSTilingPattern -{ - public: - PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); - ~PSUncoloredTilingPattern (); - std::string svgID () const; - void setColor (Color color) {_currentColor = color;} - void apply (SpecialActions *actions); - - protected: - XMLElementNode* createClipNode () const; - - private: - std::set _colors; ///< colors this pattern has already been drawn with - Color _currentColor; ///< current color to be applied - bool _applied; ///< has pattern with current group node already been applied to the SVG tree? -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.cpp deleted file mode 100644 index 8a20a35d52b..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************* -** PageRanges.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "InputBuffer.h" -#include "InputReader.h" -#include "PageRanges.h" - -#include "macros.h" - -using namespace std; - - -/** Analyzes a string describing a range sequence. - * Syntax: ([0-9]+(-[0-9]*)?)|(-[0-9]+)(,([0-9]+(-[0-9]*)?)|(-[0-9]+))* - * @param[in] str string to parse - * @param[in] max_page greatest allowed value - * @param[out] ranges the extracted range sequence - * @return true on success; false denotes a syntax error */ -bool PageRanges::parse (string str, int max_page) { - StringInputBuffer ib(str); - BufferInputReader ir(ib); - while (ir) { - int first=1; - int last=max_page; - ir.skipSpace(); - if (!isdigit(ir.peek()) && ir.peek() != '-') - return false; - - if (isdigit(ir.peek())) - first = ir.getInt(); - ir.skipSpace(); - if (ir.peek() == '-') { - while (ir.peek() == '-') - ir.get(); - ir.skipSpace(); - if (isdigit(ir.peek())) - last = ir.getInt(); - } - else - last = first; - ir.skipSpace(); - if (ir.peek() == ',') { - ir.get(); - if (ir.eof()) - return false; - } - else if (!ir.eof()) - return false; - if (first > last) - swap(first, last); - first = max(1, first); - last = max(first, last); - if (max_page > 0) { - first = min(first, max_page); - last = min(last, max_page); - } - insert(first, last); - } - return true; -} - - -/** Adds a page range to the range collection. - * @param[in] first first page of new range - * @param[in] last last page of new range */ -void PageRanges::insert (int first, int last) { - if (first > last) - swap(first, last); - Container::iterator it = _ranges.begin(); - while (it != _ranges.end() && first > it->first+1 && first > it->second+1) - ++it; - if (it == _ranges.end() || last < it->first-1 || first > it->second+1) - it = _ranges.insert(it, Range(first, last)); - else if ((first < it->first && last >= it->first-1) || (first <= it->second+1 && last > it->second)) { - it->first = min(it->first, first); - it->second = max(it->second, last); - } - // merge adjacent ranges - if (it != _ranges.end()) { - Container::iterator l = it; - Container::iterator r = it; - if (l == _ranges.begin()) - l = _ranges.end(); - else - --l; - ++r; - bool l_modified = false; - bool r_modified = false; - if (l != _ranges.end() && l->second >= it->first-1) { - l->first = min(l->first, it->first); - l->second = max(l->second, it->second); - l_modified = true; - } - if (r != _ranges.end() && r->first <= it->second+1) { - r->first = min(r->first, it->first); - r->second = max(r->second, it->second); - r_modified = true; - } - if (l_modified || r_modified) { - _ranges.erase(it); - if (l_modified && r_modified && l->second >= r->first-1) { - l->first = min(l->first, r->first); - l->second = max(l->second, r->second); - _ranges.erase(r); - } - } - } -} - - -/** Returns the number of pages. */ -size_t PageRanges::pages () const { - size_t sum=0; - for (ConstIterator it=_ranges.begin(); it != _ranges.end(); ++it) - sum += it->second - it->first + 1; - return sum; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.h deleted file mode 100644 index 0e5cd58e5ff..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageRanges.h +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************* -** PageRanges.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PAGERANGES_H -#define PAGERANGES_H - -#include -#include -#include - -class PageRanges -{ - public: - typedef std::pair Range; - typedef std::list Container; - typedef Container::iterator Iterator; - typedef Container::const_iterator ConstIterator; - - public: - bool parse (std::string str, int max_page=0); - void insert (int first, int last); - size_t pages () const; - size_t size () const {return _ranges.size();} - const Container& ranges () const {return _ranges;} - ConstIterator begin () const {return _ranges.begin();} - ConstIterator end () const {return _ranges.end();} - - private: - Container _ranges; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.cpp deleted file mode 100644 index 7ff9eb42c0f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************* -** PageSize.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "PageSize.h" - -using namespace std; - -// make sure tolower is a function (and not a macro) -// so that 'transform' can be applied -static int my_tolower (int c) { - return tolower(c); -} - - -/** Computes width and height of ISO/DIN An in millimeters. - * @param[in] n the A level (e.g. n=4 => DIN A4) - * @param[out] width contains the page width when function returns - * @param[out] height contains the page height when function returns */ -static void computeASize (int n, double &width, double &height) { - double sqrt2 = sqrt(2.0); - height = floor(1189.0/pow(sqrt2, n)+0.5); - width = floor(height/sqrt2+0.5); -} - - -/** Computes width and height of ISO/DIN Bn in millimeters. - * @param[in] n the B level (e.g. n=4 => DIN B4) - * @param[out] width contains the page width when function returns - * @param[out] height contains the page height when function returns */ -static void computeBSize (int n, double &width, double &height) { - double w, h; - computeASize(n, width, height); - computeASize(n-1, w, h); - width = floor(sqrt(width * w)+0.5); - height = floor(sqrt(height * h)+0.5); -} - - -/** Computes width and height of ISO/DIN Cn in millimeters. - * @param[in] n the C level (e.g. n=4 => DIN C4) - * @param[out] width contains the page width when function returns - * @param[out] height contains the page height when function returns */ -static void computeCSize (int n, double &width, double &height) { - double w, h; - computeASize(n, width, height); - computeBSize(n, w, h); - width = floor(sqrt(width * w)+0.5); - height = floor(sqrt(height * h)+0.5); -} - - -/** Computes width and height of ISO/DIN Dn in millimeters. - * @param[in] n the D level (e.g. n=4 => DIN D4) - * @param[out] width contains the page width when function returns - * @param[out] height contains the page height when function returns */ -static void computeDSize (int n, double &width, double &height) { - double w, h; - computeASize(n, width, height); - computeBSize(n+1, w, h); - width = floor(sqrt(width * w)+0.5); - height = floor(sqrt(height * h)+0.5); -} - - -/** Constructs a PageSize object of given size. - * @param[in] name specifies the page size, e.g. "A4" or "letter" */ -PageSize::PageSize (string name) : _width(0), _height(0) { - resize(name); -} - - -void PageSize::resize (double w, double h) { - _width = w; - _height = h; -} - -void PageSize::resize (string name) { - if (name.length() < 2) - throw PageSizeException("unknown page format: "+name); - - transform(name.begin(), name.end(), name.begin(), my_tolower); - // extract optional suffix - size_t pos = name.rfind("-"); - bool landscape = false; - if (pos != string::npos) { - string suffix = name.substr(pos); - name = name.substr(0, pos); - if (suffix == "-l" || suffix == "-landscape") - landscape = true; - else if (suffix != "-p" && suffix != "-portrait") - throw PageSizeException("invalid page format suffix: " + suffix); - } - - if (name == "invoice") { - _width = 140; - _height = 216; - } - else if (name == "executive") { - _width = 184; - _height = 267; - } - else if (name == "legal") { - _width = 216; - _height = 356; - } - else if (name == "letter") { - _width = 216; - _height = 279; - } - else if (name == "ledger") { - _width = 279; - _height = 432; - } - else if (isdigit(name[1]) && name.length() < 5) { // limit length of number to prevent arithmetic errors - istringstream iss(name.substr(1)); - int n; - iss >> n; - switch (name[0]) { - case 'a' : computeASize(n, _width, _height); break; - case 'b' : computeBSize(n, _width, _height); break; - case 'c' : computeCSize(n, _width, _height); break; - case 'd' : computeDSize(n, _width, _height); break; - default : throw PageSizeException("invalid page format: "+name); - } - } - if (_width == 0 || _height == 0) - throw PageSizeException("unknown page format: "+name); - if (landscape) - swap(_width, _height); - - const double ptpmm = 72.27/25.4; // TeX points per millimeter (72.27pt = 1in = 25.4mm) - _width *= ptpmm; - _height *= ptpmm; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.h deleted file mode 100644 index bb7a55c7cdc..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PageSize.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************* -** PageSize.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PAGESIZE_H -#define PAGESIZE_H - -#include "MessageException.h" - -struct PageSizeException : public MessageException -{ - PageSizeException (const std::string &msg) : MessageException(msg) {} -}; - -class PageSize -{ - public: - PageSize (double w=0, double h=0) : _width(w), _height(h) {} - PageSize (std::string name); - void resize (std:: string name); - void resize (double w, double h); - double widthInPT () const {return _width;} - double heightInPT () const {return _height;} - double widthInMM () const {return _width*25.4/72.27;} - double heightInMM () const {return _height*25.4/72.27;} - bool valid () const {return _width > 0 && _height > 0;} - - private: - double _width, _height; // in pt -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Pair.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Pair.h deleted file mode 100644 index a3dc5a12af3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Pair.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************* -** Pair.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PAIR_H -#define PAIR_H - -#include -#include -#include "macros.h" -#include "types.h" - -template -class Pair -{ - public: - Pair (T x=0, T y=0) : _x(x), _y(y) {} - Pair operator += (const Pair &p) {_x += p._x; _y += p._y; return *this;} - Pair operator -= (const Pair &p) {_x -= p._x; _y -= p._y; return *this;} - Pair operator *= (T c) {_x *= c; _y *= c; return *this;} - Pair operator /= (T c) {_x /= c; _y /= c; return *this;} - Pair ortho () const {return Pair(-_y, _x);} - double length () const {return std::sqrt(_x*_x + _y*_y);} - bool operator == (const Pair &p) const {return _x == p._x && _y == p._y;} - bool operator != (const Pair &p) const {return _x != p._x || _y != p._y;} - T x () const {return _x;} - T y () const {return _y;} - void x (const T &xx) {_x = xx;} - void y (const T &yy) {_y = yy;} - std::ostream& write (std::ostream &os) const {return os << '(' << _x << ',' << _y << ')';} - - private: - T _x, _y; -}; - - -struct Pair32 : public Pair -{ - Pair32 (Int32 x=0, Int32 y=0) : Pair(x, y) {} - explicit Pair32 (double x, double y) : Pair(Int32(x+0.5), Int32(y+0.5)) {} - Pair32 (const Pair &p) : Pair(p) {} -// operator Pair () {return *this;} -}; - -typedef Pair DPair; - -template -IMPLEMENT_ARITHMETIC_OPERATOR(Pair, +) - -template -IMPLEMENT_ARITHMETIC_OPERATOR(Pair, -) - -template -IMPLEMENT_ARITHMETIC_OPERATOR2(Pair, T, *) - -template -IMPLEMENT_ARITHMETIC_OPERATOR2(Pair, T, /) - -template -IMPLEMENT_OUTPUT_OPERATOR(Pair) - -IMPLEMENT_ARITHMETIC_OPERATOR2(Pair32, Int32, *) -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.cpp deleted file mode 100644 index f3d8464704c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************* -** PdfSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "InputReader.h" -#include "MapLine.h" -#include "PdfSpecialHandler.h" -#include "FontMap.h" -#include "Message.h" - -using namespace std; - - -PdfSpecialHandler::PdfSpecialHandler () : _maplineProcessed(false) -{ -} - - -bool PdfSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - if (!actions) - return true; - StreamInputReader ir(is); - ir.skipSpace(); - string cmd = ir.getWord(); - ir.skipSpace(); - if (cmd == "mapline" || cmd == "mapfile") { - // read mode selector ('+', '-', or '=') - char modechar = '+'; // default mode (append if new, do not replace existing mapping) - if (strchr("=+-", ir.peek())) // leading modifier given? - modechar = ir.get(); - else if (!_maplineProcessed) { // no modifier given? - // remove default map entries if this is the first mapline/mapfile special called - FontMap::instance().clear(); - } - - if (cmd == "mapline") { - try { - MapLine mapline(is); - FontMap::instance().apply(mapline, modechar); - } - catch (const MapLineException &ex) { - Message::wstream(true) << "pdf:mapline: " << ex.what() << '\n'; - } - } - else { // mapfile - string fname = ir.getString(); - if (!FontMap::instance().read(fname, modechar)) - Message::wstream(true) << "can't open map file " << fname << '\n'; - } - _maplineProcessed = true; - } - return true; -} - - -const char** PdfSpecialHandler::prefixes () const { - static const char *pfx[] = {"pdf:", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.h deleted file mode 100644 index 43cdd1045de..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PdfSpecialHandler.h +++ /dev/null @@ -1,39 +0,0 @@ -/************************************************************************* -** PdfSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PDFSPECIALHANDLER_H -#define PDFSPECIALHANDLER_H - -#include "SpecialHandler.h" - -class PdfSpecialHandler : public SpecialHandler -{ - public: - PdfSpecialHandler (); - const char* info () const {return "pdfTeX font map specials";} - const char* name () const {return "pdf";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &is, SpecialActions *actions); - - private: - bool _maplineProcessed; ///< true if a mapline or mapfile special has already been processed -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.cpp deleted file mode 100644 index a76219e9846..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/************************************************************************* -** Process.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifdef __WIN32__ -#include -#else -#include -#include -#include -#include -#endif - -#include -#include "FileSystem.h" -#include "Process.h" -#include "SignalHandler.h" -#include "macros.h" - -using namespace std; - -Process::Process (const string &cmd, const string ¶mstr) - : _cmd(cmd), _paramstr(paramstr) -{ -} - - -#ifndef __WIN32__ -/** Extracts whitespace-sparated parameters from a string. - * @param[in] paramstr the parameter string - * @param[out] params vector holding the extracted parameters */ -static void split_paramstr (string paramstr, vector ¶ms) { - size_t left=0, right=0; // index of first and last character of current parameter - char quote=0; // current quote character, 0=none - const size_t len = paramstr.length(); - while (left <= right && right < len) { - while (left < len && isspace(paramstr[left])) - ++left; - if (left < len && (paramstr[left] == '"' || paramstr[left] == '\'')) - quote = paramstr[left++]; - right = left; - while (right < len && (quote || !isspace(paramstr[right]))) { - if (quote && paramstr[right] == quote) { - quote=0; - break; - } - else - ++right; - } - if (right < len) - paramstr[right]=0; - if (left < len) - params.push_back(¶mstr[left]); - left = ++right; - } -} -#endif - - -/** Runs the process and waits until it's finished. - * @param[in] quiet if true, output to stdout/stderr is suppressed - * @return true if process terminated properly - * @throw SignalException if CTRL-C was pressed during execution */ -bool Process::run (bool quiet) { -#ifdef __WIN32__ - SECURITY_ATTRIBUTES sa; - ZeroMemory(&sa, sizeof(sa)); - sa.nLength = sizeof(sa); - sa.bInheritHandle = true; - - STARTUPINFO si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; - HANDLE devnull = CreateFile("nul", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - si.hStdOutput = quiet ? devnull : GetStdHandle(STD_OUTPUT_HANDLE); - PROCESS_INFORMATION pi; - ZeroMemory(&pi, sizeof(pi)); - - string cmdline = _cmd+" "+_paramstr; - CreateProcess(NULL, (LPSTR)cmdline.c_str(), NULL, NULL, true, 0, NULL, NULL, &si, &pi); - WaitForSingleObject(pi.hProcess, INFINITE); - DWORD exitcode = (DWORD)-1; - GetExitCodeProcess(pi.hProcess, &exitcode); - CloseHandle(devnull); - return exitcode == 0; -#else - pid_t pid = fork(); - if (pid == 0) { // child process - if (quiet) { - int devnull = open(FileSystem::DEVNULL, O_WRONLY); - if (devnull >= 0) { - dup2(devnull, STDOUT_FILENO); - dup2(devnull, STDERR_FILENO); - close(devnull); - } - } - vector params; - params.push_back(_cmd.c_str()); - split_paramstr(_paramstr, params); - params.push_back(0); // trailing NULL marks end - execvp(_cmd.c_str(), const_cast(¶ms[0])); - exit(1); - } - if (pid > 0) { // main process - int status; - for (;;) { - waitpid(pid, &status, WNOHANG); - if (WIFEXITED(status)) // child process exited normally - return WEXITSTATUS(status) == 0; - - try { - SignalHandler::instance().check(); - } - catch (SignalException &e) { // caught ctrl-c - kill(pid, SIGKILL); - throw; - } - } - } - return false; -#endif -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.h deleted file mode 100644 index 973fabf2baf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Process.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************* -** Process.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PROCESS_H -#define PROCESS_H - -#include - -class Process -{ - public: - Process (const std::string &cmd, const std::string ¶mstr); - bool run (bool quiet=true); - - protected: - Process (const Process& orig) {} - - private: - std::string _cmd; - std::string _paramstr; -}; - -#endif - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.cpp deleted file mode 100644 index 91020b9f28c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.cpp +++ /dev/null @@ -1,806 +0,0 @@ -/************************************************************************* -** PsSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "EPSFile.h" -#include "FileFinder.h" -#include "Ghostscript.h" -#include "Message.h" -#include "PSPattern.h" -#include "PsSpecialHandler.h" -#include "SpecialActions.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -static inline double str2double (const string &str) { - double ret; - istringstream iss(str); - iss >> ret; - return ret; -} - - -PsSpecialHandler::PsSpecialHandler () : _psi(this), _actions(0), _initialized(false), _xmlnode(0) -{ -} - - -PsSpecialHandler::~PsSpecialHandler () { - _psi.setActions(0); // ensure no further PS actions are performed - for (map::iterator it=_patterns.begin(); it != _patterns.end(); ++it) - delete it->second; -} - - -/** Initializes the PostScript handler. It's called by the first use of process(). The - * deferred initialization speeds up the conversion of DVI files that doesn't contain - * PS specials. */ -void PsSpecialHandler::initialize (SpecialActions *actions) { - if (!_initialized) { - // initial values of graphics state - _linewidth = 1; - _linecap = _linejoin = 0; - _miterlimit = 4; - _xmlnode = _savenode = 0; - _opacityalpha = 1; // fully opaque - _sx = _sy = _cos = 1.0; - _pattern = 0; - - // execute dvips prologue/header files - const char *headers[] = {"tex.pro", "texps.pro", "special.pro", /*"color.pro",*/ 0}; - for (const char **p=headers; *p; ++p) { - if (const char *path = FileFinder::lookup(*p, false)) { - ifstream ifs(path); - _psi.execute(ifs); - } - else - Message::wstream(true) << "PostScript header file " << *p << " not found\n"; - } - // push dictionary "TeXDict" with dvips definitions on dictionary stack - // and initialize basic dvips PostScript variables - ostringstream oss; - oss << " TeXDict begin 0 0 1000 72 72 () @start " - " 0 0 moveto "; - if (actions) { - float r, g, b; - actions->getColor().getRGB(r, g, b); - oss << r << ' ' << g << ' ' << b << " setrgbcolor "; - } - _psi.execute(oss.str()); - _initialized = true; - } -} - - -/** Move PS graphic position to current DVI location. */ -void PsSpecialHandler::moveToDVIPos () { - if (_actions) { - const double bp=72.0/72.27; // pt -> bp - const double x = _actions->getX()*bp; - const double y = _actions->getY()*bp; - ostringstream oss; - oss << '\n' << x << ' ' << y << " moveto "; - _psi.execute(oss.str()); - _currentpoint = DPair(x, y); - } -} - - -/** Executes a PS snippet and moves the DVI cursor to the current DVI position afterwards. - * It's just a shorthand function as this action sequence is required several times. - * @param[in] psi PS interpreter instance - * @param[in] is stream to read the PS code from - * @param[in] pos current PS graphic position - * @param[in] actions special actions */ -static void exec_and_syncpos (PSInterpreter &psi, istream &is, const DPair &pos, SpecialActions *actions) { - psi.execute(is); - psi.execute("\nquerypos "); // retrieve current PS position (stored in 'pos') - const double pt = 72.27/72.0; // bp -> pt - actions->setX(pos.x()*pt); - actions->setY(pos.y()*pt); -} - - -bool PsSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - if (!_initialized) - initialize(actions); - _actions = actions; - - if (*prefix == '"') { - // read and execute literal PostScript code (isolated by a wrapping save/restore pair) - moveToDVIPos(); - _psi.execute("\n@beginspecial @setspecial "); - _psi.execute(is); - _psi.execute("\n@endspecial "); - } - else if (*prefix == '!') { - // execute literal PostScript header - _psi.execute("\nTeXDict begin @defspecial "); - _psi.execute(is); - _psi.execute("\n@fedspecial end "); - } - else if (strcmp(prefix, "header=") == 0) { - // read and execute PS header files - string fname; - is >> fname; - if (const char *path = FileFinder::lookup(fname, false)) { - ifstream ifs(path); - _psi.execute(ifs); - } - else - Message::estream(true) << "PS header file '" << fname << "' not found"; - } - else if (strcmp(prefix, "psfile=") == 0 || strcmp(prefix, "PSfile=") == 0) { - if (_actions) { - StreamInputReader in(is); - string fname = in.getQuotedString(in.peek() == '"' ? '"' : 0); - map attr; - in.parseAttributes(attr); - psfile(fname, attr); - } - } - else if (strcmp(prefix, "ps::") == 0) { - _actions->finishLine(); // reset DVI position on next DVI command - if (is.peek() == '[') { - // collect characters inside the brackets - string code; - for (int i=0; i < 9 && is.peek() != ']' && !is.eof(); ++i) - code += is.get(); - if (is.peek() == ']') - code += is.get(); - - if (code == "[begin]" || code == "[nobreak]") { - moveToDVIPos(); - exec_and_syncpos(_psi, is, _currentpoint, _actions); - } - else { - // no move to DVI position here - if (code != "[end]") // PS array? - _psi.execute(code); - exec_and_syncpos(_psi, is, _currentpoint, _actions); - } - } - else { // ps:: behaves like ps::[end] - // no move to DVI position here - exec_and_syncpos(_psi, is, _currentpoint, _actions); - } - } - else { // ps: ... - _actions->finishLine(); - moveToDVIPos(); - StreamInputReader in(is); - if (in.check(" plotfile ")) { // ps: plotfile fname - string fname = in.getString(); - ifstream ifs(fname.c_str()); - if (ifs) - _psi.execute(ifs); - else - Message::wstream(true) << "file '" << fname << "' not found in ps: plotfile\n"; - } - else { - // ps: is almost identical to ps::[begin] but does - // a final repositioning to the current DVI location - exec_and_syncpos(_psi, is, _currentpoint, _actions); - moveToDVIPos(); - } - } - return true; -} - - -/** Handles psfile special. - * @param[in] fname EPS file to be included - * @param[in] attr attributes given with \special psfile */ -void PsSpecialHandler::psfile (const string &fname, const map &attr) { - EPSFile epsfile(fname); - istream &is = epsfile.istream(); - if (!is) - Message::wstream(true) << "file '" << fname << "' not found in special 'psfile'\n"; - else { - map::const_iterator it; - const double pt = 72.27/72.0; // bp -> pt - - // bounding box of EPS figure - double llx = (it = attr.find("llx")) != attr.end() ? str2double(it->second)*pt : 0; - double lly = (it = attr.find("lly")) != attr.end() ? str2double(it->second)*pt : 0; - double urx = (it = attr.find("urx")) != attr.end() ? str2double(it->second)*pt : 0; - double ury = (it = attr.find("ury")) != attr.end() ? str2double(it->second)*pt : 0; - - // desired width/height of resulting figure - double rwi = (it = attr.find("rwi")) != attr.end() ? str2double(it->second)/10.0*pt : -1; - double rhi = (it = attr.find("rhi")) != attr.end() ? str2double(it->second)/10.0*pt : -1; - if (rwi == 0 || rhi == 0 || urx-llx == 0 || ury-lly == 0) - return; - - // user transformations (default values chosen according to dvips manual) - double hoffset = (it = attr.find("hoffset")) != attr.end() ? str2double(it->second)*pt : 0; - double voffset = (it = attr.find("voffset")) != attr.end() ? str2double(it->second)*pt : 0; -// double hsize = (it = attr.find("hsize")) != attr.end() ? str2double(it->second) : 612; -// double vsize = (it = attr.find("vsize")) != attr.end() ? str2double(it->second) : 792; - double hscale = (it = attr.find("hscale")) != attr.end() ? str2double(it->second) : 100; - double vscale = (it = attr.find("vscale")) != attr.end() ? str2double(it->second) : 100; - double angle = (it = attr.find("angle")) != attr.end() ? str2double(it->second) : 0; - - Matrix m(1); - m.rotate(angle).scale(hscale/100, vscale/100).translate(hoffset, voffset); - BoundingBox bbox(llx, lly, urx, ury); - bbox.transform(m); - - double sx = rwi/bbox.width(); - double sy = rhi/bbox.height(); - if (sx < 0) sx = sy; - if (sy < 0) sy = sx; - if (sx < 0) sx = sy = 1.0; - - // save current DVI position (in pt units) - const double x = _actions->getX(); - const double y = _actions->getY(); - - // all following drawings are relative to (0,0) - _actions->setX(0); - _actions->setY(0); - moveToDVIPos(); - - _xmlnode = new XMLElementNode("g"); - _psi.execute("\n@beginspecial @setspecial "); // enter \special environment - _psi.limit(epsfile.pslength()); // limit the number of bytes to be processed - _psi.execute(is); // process EPS file - _psi.limit(0); // disable limitation - _psi.execute("\n@endspecial "); // leave special environment - if (!_xmlnode->empty()) { // has anything been drawn? - Matrix m(1); - m.rotate(angle).scale(hscale/100, vscale/100).translate(hoffset, voffset); - m.translate(-llx, lly); - m.scale(sx, sy); // resize image to width "rwi" and height "rhi" - m.translate(x, y); // move image to current DVI position - _xmlnode->addAttribute("transform", m.getSVG()); - _actions->appendToPage(_xmlnode); - } - else - delete _xmlnode; - _xmlnode = 0; - - // restore DVI position - _actions->setX(x); - _actions->setY(y); - moveToDVIPos(); - - // update bounding box - m.scale(sx, -sy); - m.translate(x, y); - bbox = BoundingBox(0, 0, fabs(urx-llx), fabs(ury-lly)); - bbox.transform(m); - _actions->embed(bbox); - } -} - -/////////////////////////////////////////////////////// - -void PsSpecialHandler::gsave (vector &p) { - _clipStack.dup(); -} - - -void PsSpecialHandler::grestore (vector &p) { - _clipStack.pop(); -} - - -void PsSpecialHandler::grestoreall (vector &p) { - _clipStack.pop(-1, true); -} - - -void PsSpecialHandler::save (vector &p) { - _clipStack.dup(static_cast(p[0])); -} - - -void PsSpecialHandler::restore (vector &p) { - _clipStack.pop(static_cast(p[0])); -} - - -void PsSpecialHandler::moveto (vector &p) { - _path.moveto(p[0], p[1]); -} - - -void PsSpecialHandler::lineto (vector &p) { - _path.lineto(p[0], p[1]); -} - - -void PsSpecialHandler::curveto (vector &p) { - _path.cubicto(p[0], p[1], p[2], p[3], p[4], p[5]); -} - - -void PsSpecialHandler::closepath (vector &p) { - _path.closepath(); -} - - -/** Draws the current path recorded by previously executed path commands (moveto, lineto,...). - * @param[in] p not used */ -void PsSpecialHandler::stroke (vector &p) { - if (!_path.empty() && _actions) { - BoundingBox bbox; - if (!_actions->getMatrix().isIdentity()) { - _path.transform(_actions->getMatrix()); - if (!_xmlnode) - bbox.transform(_actions->getMatrix()); - } - - const double pt = 72.27/72.0; // factor to convert bp -> pt - ScalingMatrix scale(pt, pt); - _path.transform(scale); - bbox.transform(scale); - - XMLElementNode *path=0; - Pair 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 = new XMLElementNode("circle"); - path->addAttribute("cx", x); - path->addAttribute("cy", y); - path->addAttribute("r", r); - path->addAttribute("fill", _actions->getColor().rgbString()); - bbox = BoundingBox(x-r, y-r, x+r, y+r); - } - } - else { - // compute bounding box - _path.computeBBox(bbox); - bbox.expand(_linewidth/2); - - ostringstream oss; - _path.writeSVG(oss); - path = new XMLElementNode("path"); - path->addAttribute("d", oss.str()); - path->addAttribute("stroke", _actions->getColor().rgbString()); - 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 (_opacityalpha < 1) - path->addAttribute("stroke-opacity", _opacityalpha); - if (!_dashpattern.empty()) { - ostringstream oss; - for (size_t i=0; i < _dashpattern.size(); i++) { - if (i > 0) - oss << ','; - oss << XMLString(_dashpattern[i]); - } - path->addAttribute("stroke-dasharray", oss.str()); - if (_dashoffset != 0) - path->addAttribute("stroke-dashoffset", _dashoffset); - } - } - if (path && _clipStack.top()) { - // assign clipping path and clip bounding box - path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")"); - BoundingBox clipbox; - _clipStack.top()->computeBBox(clipbox); - bbox.intersect(clipbox); - } - - if (_xmlnode) - _xmlnode->append(path); - else { - _actions->appendToPage(path); - _actions->embed(bbox); - } - _path.newpath(); - } -} - - -/** Draws a closed path filled with the current color. - * @param[in] p not used - * @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */ -void PsSpecialHandler::fill (vector &p, bool evenodd) { - if (!_path.empty() && _actions) { - // compute bounding box - BoundingBox bbox; - _path.computeBBox(bbox); - if (!_actions->getMatrix().isIdentity()) { - _path.transform(_actions->getMatrix()); - if (!_xmlnode) - bbox.transform(_actions->getMatrix()); - } - const double pt = 72.27/72.0; // factor to convert bp -> pt - ScalingMatrix scale(pt, pt); - _path.transform(scale); - bbox.transform(scale); - - ostringstream oss; - _path.writeSVG(oss); - XMLElementNode *path = new XMLElementNode("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().rgbString()); - if (_clipStack.top()) { - // assign clipping path and clip bounding box - path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")"); - BoundingBox clipbox; - _clipStack.top()->computeBBox(clipbox); - bbox.intersect(clipbox); - } - if (evenodd) // SVG default fill rule is "nonzero" algorithm - path->addAttribute("fill-rule", "evenodd"); - if (_opacityalpha < 1) - path->addAttribute("fill-opacity", _opacityalpha); - if (_xmlnode) - _xmlnode->append(path); - else { - _actions->appendToPage(path); - _actions->embed(bbox); - } - _path.newpath(); - } -} - - -/** Creates a Matrix object out of a given sequence of 6 double values. - * The given values must be arranged in PostScript matrix order. - * @param[in] v vector containing the matrix values - * @param[in] startindex vector index of first component - * @param[out] matrix the generated matrix */ -static void create_matrix (vector &v, int startindex, Matrix &matrix) { - // Ensure vector p has 6 elements. If necessary, add missing ones - // using corresponding values of the identity matrix. - if (v.size()-startindex < 6) { - v.resize(6+startindex); - for (int i=v.size()-startindex; i < 6; ++i) - v[i+startindex] = (i%3 ? 0 : 1); - } - // PS matrix [a b c d e f] equals ((a,b,0),(c,d,0),(e,f,1)). - // Since PS uses left multiplications, we must transpose and reorder - // the matrix to ((a,c,e),(b,d,f),(0,0,1)). This is done by the - // following swaps. - swap(v[startindex+1], v[startindex+2]); // => (a, c, b, d, e, f) - swap(v[startindex+2], v[startindex+4]); // => (a, c, e, d, b, f) - swap(v[startindex+3], v[startindex+4]); // => (a, c, e, b, d, f) - matrix.set(v, startindex); -} - - -/** Starts the definition of a new fill pattern. This operator - * expects 9 parameters for tiling patterns (see PS reference 4.9.2): - * @param[in] p the 9 values defining a tiling pattern (see PS reference 4.9.2): - * 0: pattern type (0:none, 1:tiling, 2:shading) - * 1: pattern ID - * 2-5: lower left and upper right coordinates of pattern box - * 6: horizontal distance of adjacent tiles - * 7: vertical distance of adjacent tiles - * 8: paint type (1: colored pattern, 2: uncolored pattern) - * 9-14: pattern matrix */ -void PsSpecialHandler::makepattern (vector &p) { - int pattern_type = static_cast(p[0]); - int id = static_cast(p[1]); - switch (pattern_type) { - case 0: - // pattern definition completed - if (_savenode) { - _xmlnode = _savenode; - _savenode = 0; - } - break; - case 1: { // tiling pattern - BoundingBox bbox(p[2], p[3], p[4], p[5]); - const double &xstep=p[6], &ystep=p[7]; // horizontal and vertical distance of adjacent tiles - int paint_type = static_cast(p[8]); - - Matrix matrix; // transformation matrix given together with pattern definition - create_matrix(p, 9, matrix); - matrix.rmultiply(_actions->getMatrix()); - - PSTilingPattern *pattern=0; - if (paint_type == 1) - pattern = new PSColoredTilingPattern(id, bbox, matrix, xstep, ystep); - else - pattern = new PSUncoloredTilingPattern(id, bbox, matrix, xstep, ystep); - _patterns[id] = pattern; - _savenode = _xmlnode; - _xmlnode = pattern->getContainerNode(); // insert the following SVG elements into this node - break; - } - case 2: { - // define a shading pattern - } - } -} - - -/** Selects a previously defined fill pattern. - * 0: pattern ID - * 1-3: (optional) RGB values for uncolored tiling patterns - * further parameters depend on the pattern type */ -void PsSpecialHandler::setpattern (vector &p) { - int pattern_id = p[0]; - Color color; - if (p.size() == 4) - color.set((float)p[1], (float)p[2], (float)p[3]); - map::iterator it = _patterns.find(pattern_id); - if (it == _patterns.end()) - _pattern = 0; - else { - if (PSUncoloredTilingPattern *pattern = dynamic_cast(it->second)) - pattern->setColor(color); - it->second->apply(_actions); - if (PSTilingPattern *pattern = dynamic_cast(it->second)) - _pattern = pattern; - else - _pattern = 0; - } -} - - -/** Clears the current clipping path. - * @param[in] p not used */ -void PsSpecialHandler::initclip (vector &p) { - _clipStack.push(); // push empty path -} - - -/** Assigns a new clipping path. - * @param[in] p not used - * @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */ -void PsSpecialHandler::clip (vector &p, bool evenodd) { - // when this method is called, _path contains the clipping path - if (!_path.empty() && _actions) { - if (!_actions->getMatrix().isIdentity()) - _path.transform(_actions->getMatrix()); - - const double pt = 72.27/72.0; // factor to convert bp -> pt - ScalingMatrix scale(pt, pt); - _path.transform(scale); - - - int oldID = _clipStack.topID(); - _clipStack.replace(_path); - int newID = _clipStack.topID(); - - ostringstream oss; - _path.writeSVG(oss); - XMLElementNode *path = new XMLElementNode("path"); - path->addAttribute("d", oss.str()); - if (evenodd) - path->addAttribute("clip-rule", "evenodd"); - - XMLElementNode *clip = new XMLElementNode("clipPath"); - clip->addAttribute("id", XMLString("clip")+XMLString(newID)); - if (oldID) - clip->addAttribute("clip-path", XMLString("url(#clip")+XMLString(oldID)+")"); - - clip->append(path); - _actions->appendToDefs(clip); - } -} - - -/** Clears current path */ -void PsSpecialHandler::newpath (vector &p) { - _path.newpath(); -} - - -void PsSpecialHandler::setmatrix (vector &p) { - if (_actions) { - Matrix m; - create_matrix(p, 0, m); - _actions->setMatrix(m); - } -} - - -// In contrast to SVG, PostScript transformations are applied in -// reverse order (M' = T*M). Thus, the transformation matrices must be -// left-multiplied in the following methods scale(), translate() and rotate(). - - -void PsSpecialHandler::scale (vector &p) { - if (_actions) { - Matrix m = _actions->getMatrix(); - ScalingMatrix s(p[0], p[1]); - m.lmultiply(s); - _actions->setMatrix(m); - } -} - - -void PsSpecialHandler::translate (vector &p) { - if (_actions) { - Matrix m = _actions->getMatrix(); - TranslationMatrix t(p[0], p[1]); - m.lmultiply(t); - _actions->setMatrix(m); - } -} - - -void PsSpecialHandler::rotate (vector &p) { - if (_actions) { - Matrix m = _actions->getMatrix(); - RotationMatrix r(p[0]); - m.lmultiply(r); - _actions->setMatrix(m); - } -} - - -void PsSpecialHandler::setgray (vector &p) { - _pattern = 0; - if (_actions) { - Color c; - c.setGray((float)p[0]); - _actions->setColor(c); - } -} - - -void PsSpecialHandler::setrgbcolor (vector &p) { - _pattern= 0; - if (_actions) - _actions->setColor(Color((float)p[0], (float)p[1], (float)p[2])); -} - - -void PsSpecialHandler::setcmykcolor (vector &p) { - _pattern = 0; - if (_actions) { - Color c; - c.setCMYK((float)p[0], (float)p[1], (float)p[2], (float)p[3]); - _actions->setColor(c); - } -} - - -void PsSpecialHandler::sethsbcolor (vector &p) { - _pattern = 0; - if (_actions) { - Color c; - c.setHSB((float)p[0], (float)p[1], (float)p[2]); - _actions->setColor(c); - } -} - - -/** Sets the dash parameters used for stroking. - * @param[in] p dash pattern array m1,...,mn plus trailing dash offset */ -void PsSpecialHandler::setdash (vector &p) { - _dashpattern.clear(); - for (size_t i=0; i < p.size()-1; i++) - _dashpattern.push_back(scale(p[i])); - _dashoffset = scale(p.back()); -} - - -/** This method is called by the PSInterpreter if an PS operator has been executed. */ -void PsSpecialHandler::executed () { - if (_actions) - _actions->progress("ps"); -} - -//////////////////////////////////////////// - -void PsSpecialHandler::ClippingStack::push () { - if (!_stack.empty()) - _stack.push(Entry(0, -1)); -} - - -void PsSpecialHandler::ClippingStack::push (const Path &path, int saveID) { - if (path.empty()) - _stack.push(Entry(0, saveID)); - else { - _paths.push_back(path); - _stack.push(Entry(_paths.size(), saveID)); - } -} - - -/** Pops a single or several elements from the clipping stack. - * The method distingushes between the following cases: - * 1) saveID < 0 and grestoreall == false: - * pop top element if it was pushed by gsave (its saveID is < 0 as well) - * 2) saveID < 0 and grestoreall == true - * repeat popping until stack is empty or the top element was pushed - * by save (its saveID is >= 0) - * 3) saveID >= 0: - * pop all elements until the saveID of the top element equals parameter saveID */ -void PsSpecialHandler::ClippingStack::pop (int saveID, bool grestoreall) { - if (!_stack.empty()) { - if (saveID < 0) { // grestore? - if (_stack.top().saveID < 0) // pushed by 'gsave'? - _stack.pop(); - // pop all further elements pushed by 'gsave' if grestoreall == true - while (grestoreall && !_stack.empty() && _stack.top().saveID < 0) - _stack.pop(); - } - else { - // pop elements pushed by 'gsave' - while (!_stack.empty() && _stack.top().saveID != saveID) - _stack.pop(); - // pop element pushed by 'save' - if (!_stack.empty()) - _stack.pop(); - } - } -} - - -/** Returns a pointer to the path on top of the stack, or 0 if the stack is empty. */ -PsSpecialHandler::Path* PsSpecialHandler::ClippingStack::top () { - return (!_stack.empty() && _stack.top().pathID) - ? &_paths[_stack.top().pathID-1] - : 0; -} - - -/** Pops all elements from the stack. */ -void PsSpecialHandler::ClippingStack::clear() { - _paths.clear(); - while (!_stack.empty()) - _stack.pop(); -} - - -/** Replaces the top element by a new one. - * @param[in] path new path to be on top of the stack */ -void PsSpecialHandler::ClippingStack::replace (const Path &path) { - if (_stack.empty()) - push(path, -1); - else { - _paths.push_back(path); - _stack.top().pathID = _paths.size(); - } -} - - -/** Duplicates the top element, i.e. the top element is pushed again. */ -void PsSpecialHandler::ClippingStack::dup (int saveID) { - _stack.push(_stack.empty() ? Entry(0, -1) : _stack.top()); - _stack.top().saveID = saveID; -} - - -const char** PsSpecialHandler::prefixes () const { - static const char *pfx[] = {"header=", "psfile=", "PSfile=", "ps:", "ps::", "!", "\"", 0}; - return pfx; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.h deleted file mode 100644 index afb9b3cfc36..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/PsSpecialHandler.h +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************* -** PsSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef PSSPECIALHANDLER_H -#define PSSPECIALHANDLER_H - -#include -#include -#include -#include -#include "GraphicPath.h" -#include "PSInterpreter.h" -#include "SpecialHandler.h" -#include "PSPattern.h" - - -class PSPattern; -class XMLElementNode; - -class PsSpecialHandler : public SpecialHandler, protected PSActions -{ - typedef GraphicPath Path; - - class ClippingStack - { - public: - void push (); - void push (const Path &path, int saveID=-1); - void replace (const Path &path); - void dup (int saveID=-1); - void pop (int saveID=-1, bool grestore=false); - void clear (); - bool empty () {return _stack.empty();} - Path* top (); - int topID () {return _stack.empty() ? 0 : _stack.top().pathID;} - - private: - struct Entry { - int pathID; ///< index referencing a path of the pool - int saveID; ///< if >=0, path was pushed by 'save', and saveID holds the ID of the - Entry (int pid, int sid) : pathID(pid), saveID(sid) {} - }; - std::vector _paths; ///< pool of all clipping paths - std::stack _stack; - }; - - public: - PsSpecialHandler (); - ~PsSpecialHandler (); - const char* name () const {return "ps";} - const char* info () const {return "dvips PostScript specials";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &is, SpecialActions *actions); - - protected: - void initialize (SpecialActions *actions); - void moveToDVIPos (); - void psfile (const std::string &fname, const std::map &attr); - - /// scale given value by current PS scale factors - double scale (double v) const {return v*(_sx*_cos*_cos + _sy*(1-_cos*_cos));} - - void applyscalevals (std::vector &p) {_sx = p[0]; _sy = p[1]; _cos = p[2];} - void clip (std::vector &p) {clip(p, false);} - void clip (std::vector &p, bool evenodd); - void closepath (std::vector &p); - void curveto (std::vector &p); - void eoclip (std::vector &p) {clip(p, true);} - void eofill (std::vector &p) {fill(p, true);} - void fill (std::vector &p, bool evenodd); - void fill (std::vector &p) {fill(p, false);} - void grestore (std::vector &p); - void grestoreall (std::vector &p); - void gsave (std::vector &p); - void initclip (std::vector &p); - void lineto (std::vector &p); - void makepattern (std::vector &p); - void moveto (std::vector &p); - void newpath (std::vector &p); - void querypos (std::vector &p) {_currentpoint = DPair(p[0], p[1]);} - void restore (std::vector &p); - void rotate (std::vector &p); - void save (std::vector &p); - void scale (std::vector &p); - void setcmykcolor (std::vector &cmyk); - void setdash (std::vector &p); - void setgray (std::vector &p); - void sethsbcolor (std::vector &hsb); - void setlinecap (std::vector &p) {_linecap = UInt8(p[0]);} - void setlinejoin (std::vector &p) {_linejoin = UInt8(p[0]);} - void setlinewidth (std::vector &p) {_linewidth = p[0] ? scale(p[0])*1.00375 : 0.5;} - void setmatrix (std::vector &p); - void setmiterlimit (std::vector &p) {_miterlimit = p[0]*1.00375;} - void setopacityalpha (std::vector &p){_opacityalpha = p[0];} - void setpattern (std::vector &p); - void setrgbcolor (std::vector &rgb); - void stroke (std::vector &p); - void translate (std::vector &p); - void executed (); - - private: - PSInterpreter _psi; - SpecialActions *_actions; - bool _initialized; - XMLElementNode *_xmlnode; ///< if != 0, created SVG elements are appended to this node - XMLElementNode *_savenode; ///< pointer to temporaryly store _xmlnode - Path _path; - DPair _currentpoint; ///< current PS position in bp units - double _sx, _sy; ///< horizontal and vertical scale factors retrieved by operator "applyscalevals" - double _cos; ///< cosine of angle between (1,0) and transform(1,0) - double _linewidth; ///< current linewidth - double _miterlimit; ///< current miter limit - double _opacityalpha; ///< opacity level (0=fully transparent, ..., 1=opaque) - UInt8 _linecap : 2; ///< current line cap (0=butt, 1=round, 2=projecting square) - UInt8 _linejoin : 2; ///< current line join (0=miter, 1=round, 2=bevel) - double _dashoffset; ///< current dash offset - std::vector _dashpattern; - ClippingStack _clipStack; - std::map _patterns; - PSTilingPattern *_pattern; ///< current pattern -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGOutputBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGOutputBase.h deleted file mode 100644 index f53815c0a28..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGOutputBase.h +++ /dev/null @@ -1,33 +0,0 @@ -/************************************************************************* -** SVGOutputBase.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SVGOUTPUTBASE_H -#define SVGOUTPUTBASE_H - -#include -#include - -struct SVGOutputBase { - virtual ~SVGOutputBase () {} - virtual std::ostream& getPageStream (int page, int numPages) const =0; - virtual std::string filename (int page, int numPages) const =0; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.cpp deleted file mode 100644 index d37dba6dc7f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/************************************************************************* -** SVGTree.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "BoundingBox.h" -#include "DVIToSVG.h" -#include "Font.h" -#include "FontManager.h" -#include "SVGTree.h" -#include "XMLDocument.h" -#include "XMLDocTypeNode.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - - -// static class variables -bool SVGTree::CREATE_STYLE=true; -bool SVGTree::USE_FONTS=true; -bool SVGTree::CREATE_USE_ELEMENTS=false; - - -SVGTree::SVGTree () : _font(0), _color(Color::BLACK), _matrix(1) { - _xchanged = _ychanged = false; - _fontnum = 0; - reset(); -} - - -/** Clears the SVG tree and initializes the root element. */ -void SVGTree::reset () { - _doc.clear(); - _root = new XMLElementNode("svg"); - _root->addAttribute("version", "1.1"); - _root->addAttribute("xmlns", "http://www.w3.org/2000/svg"); - _root->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); - _doc.setRootNode(_root); - _doc.append(new XMLDocTypeNode("svg", "PUBLIC", - "\"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"")); - _page = _text = _span = _defs = 0; -} - - -/** Sets the bounding box of the document. - * @param[in] bbox bounding box in TeX point units */ -void SVGTree::setBBox (const BoundingBox &bbox) { - double bp = 72.0/72.27; // pt -> bp - ScalingMatrix scale(bp, bp); - BoundingBox scaled_box = bbox; - scaled_box.transform(scale); - _root->addAttribute("width", XMLString(scaled_box.width())+"pt"); - _root->addAttribute("height", XMLString(scaled_box.height())+"pt"); - _root->addAttribute("viewBox", scaled_box.toSVGViewBox()); -} - - -/** Starts a new page. - * @param[in] pageno number of new page */ -void SVGTree::newPage (int pageno) { - _page = new XMLElementNode("g"); - if (pageno >= 0) - _page->addAttribute("id", string("page")+XMLString(pageno)); - _root->append(_page); - _text = _span = 0; -} - - -void SVGTree::appendToDefs (XMLNode *node) { - if (!_defs) { - _defs = new XMLElementNode("defs"); - _root->prepend(_defs); - } - _defs->append(node); -} - - -/** Appends a single charater to the current text node. If necessary, and depending on output mode - * and further output states, new XML elements (text, tspan, g, ...) are created. - * @param[in] c character to be added - * @param[in] x x coordinate - * @param[in] y y coordinate - * @param[in] font font to be used */ -void SVGTree::appendChar (int c, double x, double y, const Font &font) { - XMLElementNode *node=_span; - if (USE_FONTS) { - // changes of fonts and transformations require a new text element - if (!_text || _font.changed() || _matrix.changed()) { - newTextNode(x, y); - node = _text; - _color.changed(true); - } - if (_xchanged || _ychanged || (_color.changed() && _color.get() != Color::BLACK)) { - // if drawing position was explicitly changed, create a new tspan element - _span = new XMLElementNode("tspan"); - if (_xchanged) { - _span->addAttribute("x", x); - _xchanged = false; - } - if (_ychanged) { - _span->addAttribute("y", y); - _ychanged = false; - } - if (_color.get() != Color::BLACK) { - _span->addAttribute("fill", _color.get().rgbString()); - _color.changed(false); - } - _text->append(_span); - node = _span; - } - if (!node) { - if (!_text) - newTextNode(x, y); - node = _text; - } - node->append(XMLString(font.unicode(c), false)); - } - else { - if (_color.changed() || _matrix.changed()) { - bool set_color = (_color.changed() && _color.get() != Color::BLACK); - bool set_matrix = (_matrix.changed() && !_matrix.get().isIdentity()); - if (set_color || set_matrix) { - _span = new XMLElementNode("g"); - if (_color.get() != Color::BLACK) - _span->addAttribute("fill", _color.get().rgbString()); - if (!_matrix.get().isIdentity()) - _span->addAttribute("transform", _matrix.get().getSVG()); - _page->append(_span); - node = _span; - _color.changed(false); - _matrix.changed(false); - } - else if (_color.get() == Color::BLACK && _matrix.get().isIdentity()) - node = _span = 0; - } - - if (!node) - node = _page; - if (CREATE_USE_ELEMENTS) { - ostringstream oss; - oss << "#g" << FontManager::instance().fontID(_font) << '-' << c; - XMLElementNode *use = new XMLElementNode("use"); - use->addAttribute("x", XMLString(x)); - use->addAttribute("y", XMLString(y)); - use->addAttribute("xlink:href", oss.str()); - node->append(use); - } - else { - Glyph glyph; - const PhysicalFont *font = dynamic_cast(_font.get()); - if (font && font->getGlyph(c, glyph)) { - double sx = font->scaledSize()/font->unitsPerEm(); - double sy = -sx; - ostringstream oss; - glyph.writeSVG(oss, sx, sy, x, y); - XMLElementNode *glyph_node = new XMLElementNode("path"); - glyph_node->addAttribute("d", oss.str()); - node->append(glyph_node); - } - } - } -} - - -/** Creates a new text element. This is a helper function used by appendChar(). - * @param[in] x current x coordinate - * @param[in] y current y coordinate */ -void SVGTree::newTextNode (double x, double y) { - _text = new XMLElementNode("text"); - _span = 0; // no tspan in text element yet - if (USE_FONTS) { - const Font *font = _font.get(); - if (CREATE_STYLE || !font) - _text->addAttribute("class", string("f")+XMLString(_fontnum)); - else { - _text->addAttribute("font-family", font->name()); - _text->addAttribute("font-size", font->scaledSize()); - } - } - _text->addAttribute("x", x); - _text->addAttribute("y", y); - if (!_matrix.get().isIdentity()) - _text->addAttribute("transform", _matrix.get().getSVG()); - _page->append(_text); - _font.changed(false); - _matrix.changed(false); - _xchanged = false; - _ychanged = false; -} - - -void SVGTree::setFont (int num, const Font *font) { - _font.set(font); - _fontnum = num; -} - - -void SVGTree::transformPage (const Matrix *usermatrix) { - double bp = 72.0/72.27; // pt -> bp - ScalingMatrix matrix(bp, bp); - if (usermatrix) - matrix.rmultiply(*usermatrix); - if (!matrix.isIdentity()) - _page->addAttribute("transform", matrix.getSVG()); -} - - -/** Creates an SVG element for a single glyph. - * @param[in] c character number - * @param[in] font font to extract the glyph from - * @return pointer to element node if glyph exists, 0 otherwise */ -static XMLElementNode* createGlyphNode (int c, const PhysicalFont &font, GFGlyphTracer::Callback *cb) { - Glyph glyph; - if (!font.getGlyph(c, glyph, cb) || (!SVGTree::USE_FONTS && !SVGTree::CREATE_USE_ELEMENTS)) - return 0; - - double sx=1.0, sy=1.0; - double upem = font.unitsPerEm(); - XMLElementNode *glyph_node=0; - if (SVGTree::USE_FONTS) { - glyph_node = new XMLElementNode("glyph"); - glyph_node->addAttribute("unicode", XMLString(font.unicode(c), false)); - glyph_node->addAttribute("horiz-adv-x", XMLString(font.hAdvance(c))); - string name = font.glyphName(c); - if (!name.empty()) - glyph_node->addAttribute("glyph-name", name); - } - else { - ostringstream oss; - oss << 'g' << FontManager::instance().fontID(&font) << '-' << c; - glyph_node = new XMLElementNode("path"); - glyph_node->addAttribute("id", oss.str()); - sx = font.scaledSize()/upem; - sy = -sx; - } - ostringstream oss; - glyph.writeSVG(oss, sx, sy); - glyph_node->addAttribute("d", oss.str()); - return glyph_node; -} - - -void SVGTree::appendFontStyles (const set &fonts) { - if (CREATE_STYLE && USE_FONTS && !fonts.empty() && _defs) { - XMLElementNode *styleNode = new XMLElementNode("style"); - styleNode->addAttribute("type", "text/css"); - _root->insertAfter(styleNode, _defs); - typedef map SortMap; - SortMap sortmap; - FORALL(fonts, set::const_iterator, it) - if (!dynamic_cast(*it)) // skip virtual fonts - sortmap[FontManager::instance().fontID(*it)] = *it; - ostringstream style; - // add font style definitions in ascending order - FORALL(sortmap, SortMap::const_iterator, it) { - style << "text.f" << it->first << ' ' - << "{font-family:" << it->second->name() - << ";font-size:" << it->second->scaledSize() << "}\n"; - } - XMLCDataNode *cdata = new XMLCDataNode(style.str()); - styleNode->append(cdata); - } -} - - -/** Appends glyph definitions of a given font to the defs section of the SVG tree. - * @param[in] font font to be appended - * @param[in] chars codes of the characters whose glyph outlines should be appended */ -void SVGTree::append (const PhysicalFont &font, const set &chars, GFGlyphTracer::Callback *cb) { - if (chars.empty()) - return; - - if (USE_FONTS) { - XMLElementNode *fontNode = new XMLElementNode("font"); - string fontname = font.name(); - fontNode->addAttribute("id", fontname); - fontNode->addAttribute("horiz-adv-x", XMLString(font.hAdvance())); - appendToDefs(fontNode); - - XMLElementNode *faceNode = new XMLElementNode("font-face"); - faceNode->addAttribute("font-family", fontname); - faceNode->addAttribute("units-per-em", XMLString(font.unitsPerEm())); - if (font.type() != PhysicalFont::MF) { - faceNode->addAttribute("ascent", XMLString(font.ascent())); - faceNode->addAttribute("descent", XMLString(font.descent())); - } - fontNode->append(faceNode); - - // add required missing-glyph element - XMLElementNode *missing = new XMLElementNode("missing-glyph"); - missing->addAttribute("d", ""); - fontNode->append(missing); - FORALL(chars, set::const_iterator, i) - fontNode->append(createGlyphNode(*i, font, cb)); - } - else if (CREATE_USE_ELEMENTS && &font != font.uniqueFont()) { - // If the same character is used in various sizes we don't want to embed the complete (lengthy) path - // description multiple times because they would only differ by a scale factor. Thus it's better to - // reference the already embedded path together with a transformation attribute and let the SVG renderer - // scale the glyph properly. This is only necessary if we don't want to use font but path elements. - FORALL(chars, set::const_iterator, it) { - ostringstream oss; - XMLElementNode *use = new XMLElementNode("use"); - oss << 'g' << FontManager::instance().fontID(&font) << '-' << *it; - use->addAttribute("id", oss.str()); - oss.str(""); - oss << "#g" << FontManager::instance().fontID(font.uniqueFont()) << '-' << *it; - use->addAttribute("xlink:href", oss.str()); - double scale = font.scaledSize()/font.uniqueFont()->scaledSize(); - if (scale != 1.0) { - oss.str(""); - oss << "scale(" << scale << ')'; - use->addAttribute("transform", oss.str()); - } - appendToDefs(use); - } - } - else { - FORALL(chars, set::const_iterator, i) - appendToDefs(createGlyphNode(*i, font, cb)); - } -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.h deleted file mode 100644 index c81dbd6d62f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SVGTree.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************* -** SVGTree.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SVGTREE_H -#define SVGTREE_H - -#include -#include -#include "Color.h" -#include "GFGlyphTracer.h" -#include "Matrix.h" -#include "XMLDocument.h" -#include "XMLNode.h" - -class BoundingBox; -class Color; -struct Font; -class Matrix; -class PhysicalFont; - -class SVGTree -{ - template - class Property { - public: - Property (const T &v) : _value(v), _changed(false) {} - - void set (const T &v) { - if (v != _value) { - _value = v; - _changed = true; - } - } - - const T& get () const {return _value;} - operator const T& () {return _value;} - bool changed () const {return _changed;} - void changed (bool c) {_changed = c;} - - private: - T _value; - bool _changed; - }; - - public: - SVGTree (); - void reset (); - void write (std::ostream &os) const {_doc.write(os);} - void newPage (int pageno); - void appendToDefs (XMLNode *node); - void appendToPage (XMLNode *node) {_page->append(node);} - void prependToPage (XMLNode *node){_page->prepend(node);} - void appendToDoc (XMLNode *node) {_doc.append(node);} - void appendToRoot (XMLNode *node) {_root->append(node);} - void appendChar (int c, double x, double y, const Font &font); - void appendFontStyles (const std::set &fonts); - void append (const PhysicalFont &font, const std::set &chars, GFGlyphTracer::Callback *cb=0); - void setBBox (const BoundingBox &bbox); - void setFont (int id, const Font *font); - void setX (double x) {_xchanged = true;} - void setY (double y) {_ychanged = true;} - void setMatrix (const Matrix &m) {_matrix.set(m);} - void setColor (const Color &c) {_color.set(c);} - void transformPage (const Matrix *m); - const Color& getColor () const {return _color.get();} - const Matrix& getMatrix () const {return _matrix.get();} - XMLElementNode* rootNode () const {return _root;} - - public: - static bool USE_FONTS; ///< if true, create font references and don't draw paths directly - static bool CREATE_STYLE; ///< should and class attributes be used to reference fonts? - static bool CREATE_USE_ELEMENTS; ///< allow generation of elements? - - protected: - void newTextNode (double x, double y); - - private: - XMLDocument _doc; - XMLElementNode *_root, *_page, *_text, *_span, *_defs; - bool _xchanged, _ychanged; - Property _font; - Property _color; - Property _matrix; - int _fontnum; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.cpp deleted file mode 100644 index ffcd66165e0..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************* -** SignalHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "SignalHandler.h" - -using namespace std; - -bool SignalHandler::_break = false; - - -SignalHandler::~SignalHandler() { - stop(); -} - - -/** Returns the singleton handler object. */ -SignalHandler& SignalHandler::instance() { - static SignalHandler handler; - return handler; -} - - -/** Starts listening to CTRL-C signals. - * @return true if handler was activated. */ -bool SignalHandler::start () { - if (!_active) { - _break = false; - if (signal(SIGINT, SignalHandler::callback) != SIG_ERR) { - _active = true; - return true; - } - } - return false; -} - - -/** Stops listening for CTRL-C signals. */ -void SignalHandler::stop () { - if (_active) { - signal(SIGINT, SIG_DFL); - _active = false; - } -} - - -/** Checks for incoming signals and throws an exception if CTRL-C was caught. - * @throw SignalException */ -void SignalHandler::check() { - if (_break) - throw SignalException(); -} - - -void SignalHandler::trigger (bool notify) { - _break = true; - if (notify) - check(); -} - - -/** This function is called on CTRL-C signals. */ -void SignalHandler::callback (int) { - _break = true; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.h deleted file mode 100644 index e7473f567d8..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SignalHandler.h +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************* -** SignalHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SIGNALHANDLER_H -#define SIGNALHANDLER_H - -#include - -struct SignalException : public std::exception { -}; - - -class SignalHandler -{ - public: - ~SignalHandler (); - static SignalHandler& instance (); - bool start (); - void stop (); - void check (); - void trigger (bool notify); - bool active () const {return _active;} - - protected: - SignalHandler () : _active(false) {} - static void callback (int signal); - - private: - bool _active; ///< true if listening for signals - static bool _break; ///< true if signal has been caught -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialActions.h deleted file mode 100644 index 3d99d9b17c0..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialActions.h +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************* -** SpecialActions.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SPECIALACTIONS_H -#define SPECIALACTIONS_H - -#include -#include "BoundingBox.h" -#include "Color.h" -#include "Matrix.h" - -struct XMLNode; - -struct SpecialActions -{ - virtual ~SpecialActions () {} - virtual double getX() const =0; - virtual double getY() const =0; - virtual void setX(double x) =0; - virtual void setY(double y) =0; - virtual void finishLine () =0; - virtual void setColor (const Color &color) =0; - virtual Color getColor () const =0; - virtual void setMatrix (const Matrix &m) =0; - virtual const Matrix& getMatrix () const =0; - virtual void setBgColor (const Color &color) =0; - virtual void appendToPage (XMLNode *node) =0; - virtual void appendToDefs (XMLNode *node) =0; - virtual BoundingBox& bbox () =0; - virtual BoundingBox& bbox (const std::string &name, bool reset=false) =0; - virtual void embed (const BoundingBox &bbox) =0; - virtual void embed (const DPair &p, double r=0) =0; - virtual void progress (const char *id) {} -}; - - -class SpecialEmptyActions : public SpecialActions -{ - public: - double getX() const {return 0;} - double getY() const {return 0;} - void setX(double x) {} - void setY(double y) {} - void finishLine () {} - void setColor (const Color &color) {} - void setBgColor (const Color &color) {} - Color getColor () const {return 0;} - void setMatrix (const Matrix &m) {} - const Matrix& getMatrix () const {return _matrix;} - void appendToPage (XMLNode *node) {} - void appendToDefs (XMLNode *node) {} - BoundingBox& bbox () {return _bbox;} - BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;} - void embed (const BoundingBox &bbox) {} - void embed (const DPair &p, double r=0) {} - - private: - BoundingBox _bbox; - Matrix _matrix; -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialHandler.h deleted file mode 100644 index 7818dbfb108..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialHandler.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* -** SpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SPECIALHANDLER_H -#define SPECIALHANDLER_H - -#include -#include -#include "MessageException.h" - - -struct SpecialActions; -class SpecialManager; - - -struct SpecialException : public MessageException -{ - SpecialException (const std::string &msg) : MessageException(msg) {} -}; - - -class SpecialHandler -{ - friend class SpecialManager; - - public: - virtual ~SpecialHandler () {} - virtual const char** prefixes () const=0; - virtual const char* info () const=0; - virtual const char* name () const=0; - virtual bool process (const char *prefix, std::istream &is, SpecialActions *actions)=0; - virtual void dviMovedTo (double x, double y) {} - virtual void dviEndPage () {} - - protected: - virtual bool isEndPageListener () const {return false;} - virtual bool isPositionListener () const {return false;} -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.cpp deleted file mode 100644 index 11c697be46d..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************* -** SpecialManager.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "SpecialActions.h" -#include "SpecialManager.h" -#include "macros.h" - -using namespace std; - - -SpecialManager::~SpecialManager () { - unregisterHandlers(); -} - - -/** Remove all registered handlers. */ -void SpecialManager::unregisterHandlers () { - FORALL(_pool, vector::iterator, it) - delete *it; - _pool.clear(); - _handlers.clear(); - _endPageListeners.clear(); - _positionListeners.clear(); -} - - -/** Registers a single special handler. This method doesn't check if a - * handler of the same class is already registered. - * @param[in] pointer to handler to be registered */ -void SpecialManager::registerHandler (SpecialHandler *handler) { - if (handler) { - // get array of prefixes this handler is responsible for - _pool.push_back(handler); - for (const char **p=handler->prefixes(); *p; ++p) - _handlers[*p] = handler; - if (handler->isEndPageListener()) - _endPageListeners.push_back(handler); - if (handler->isPositionListener()) - _positionListeners.push_back(handler); - } -} - - -/** Registers several special handlers at once. - * If ignorelist == 0, all given handlers are registered. To exclude selected sets of - * specials, the corresponding names can be given separated by non alpha-numeric characters, - * e.g. "color, ps, em" or "color: ps em" etc. - * @param[in] handlers pointer to zero-terminated array of handlers to be registered - * @param[in] ignorelist list of special names to be ignored */ -void SpecialManager::registerHandlers (SpecialHandler **handlers, const char *ignorelist) { - if (handlers) { - string ign = ignorelist ? ignorelist : ""; - FORALL(ign, string::iterator, it) - if (!isalnum(*it)) - *it = '%'; - ign = "%"+ign+"%"; - - for (; *handlers; handlers++) { - if (!(*handlers)->name() || ign.find("%"+string((*handlers)->name())+"%") == string::npos) - registerHandler(*handlers); - else - delete *handlers; - } - } -} - - -/** Looks for an appropriate handler for a given special prefix. - * @param[in] prefix the special prefix, e.g. "color" or "em" - * @return in case of success: pointer to handler, 0 otherwise */ -SpecialHandler* SpecialManager::findHandler (const string &prefix) const { - ConstIterator it = _handlers.find(prefix); - if (it != _handlers.end()) - return it->second; - return 0; -} - - -/** Executes a special command. - * @param[in] special the special expression - * @param[in] actions actions the special handlers can perform - * @param[in] listener object that wants to be notified about the processing state - * @return true if a special handler was found - * @throw SpecialException in case of errors during special processing */ -bool SpecialManager::process (const string &special, SpecialActions *actions, Listener *listener) const { - istringstream iss(special); - string prefix; - int c; - while (isalnum(c=iss.get())) - prefix += c; - if (ispunct(c)) // also add seperation character to identifying prefix - prefix += c; - if (prefix == "ps:" && iss.peek() == ':') - prefix += iss.get(); - if (SpecialHandler *handler = findHandler(prefix)) { - if (listener) - listener->beginSpecial(prefix.c_str()); - bool ret = handler->process(prefix.c_str(), iss, actions); - if (listener) - listener->endSpecial(prefix.c_str()); - return ret; - } - return false; -} - - -void SpecialManager::notifyEndPage () const { - FORALL(_endPageListeners, HandlerPool::const_iterator, it) - (*it)->dviEndPage(); -} - - -void SpecialManager::notifyPositionChange (double x, double y) const { - FORALL(_positionListeners, HandlerPool::const_iterator, it) - (*it)->dviMovedTo(x, y); -} - - -void SpecialManager::writeHandlerInfo (ostream &os) const { - typedef map SortMap; - SortMap m; - FORALL(_handlers, ConstIterator, it) - if (it->second->name()) - m[it->second->name()] = it->second; - FORALL(m, SortMap::iterator, it) { - os << setw(10) << left << it->second->name() << ' '; - if (it->second->info()) - os << it->second->info(); - os << endl; - } -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.h deleted file mode 100644 index 51f9bb08d02..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/SpecialManager.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************* -** SpecialManager.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SPECIALMANAGER_H -#define SPECIALMANAGER_H - -#include -#include -#include -#include -#include "SpecialHandler.h" - -struct SpecialActions; - -class SpecialManager -{ - public: - struct Listener - { - virtual ~Listener () {} - virtual void beginSpecial (const char *prefix)=0; - virtual void endSpecial (const char *prefix)=0; - }; - - private: - typedef std::vector HandlerPool; - typedef std::map HandlerMap; - typedef HandlerMap::iterator Iterator; - typedef HandlerMap::const_iterator ConstIterator; - - public: - SpecialManager () {} - virtual ~SpecialManager (); - void registerHandler (SpecialHandler *handler); - void registerHandlers (SpecialHandler **handlers, const char *ignorelist); - void unregisterHandlers (); - bool process (const std::string &special, SpecialActions *actions, Listener *listener=0) const; - void notifyEndPage () const; - void notifyPositionChange (double x, double y) const; - void writeHandlerInfo (std::ostream &os) const; - - protected: - SpecialManager (const SpecialManager &) {} - void operator = (const SpecialManager &) {} - SpecialHandler* findHandler (const std::string &prefix) const; - - private: - HandlerPool _pool; ///< stores pointers to all handlers - HandlerMap _handlers; ///< pointers to handlers for corresponding prefixes - HandlerPool _endPageListeners; - HandlerPool _positionListeners; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.cpp deleted file mode 100644 index 6e726e4016e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/************************************************************************* -** StreamReader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "CRC32.h" -#include "StreamReader.h" -#include "macros.h" - -using namespace std; - -StreamReader::StreamReader (istream &s) - : _is(&s) -{ -} - - -istream& StreamReader::replaceStream (istream &in) { - istream &ret = *_is; - _is = ∈ - return ret; -} - - -/** Reads an unsigned integer from assigned input stream. - * @param[in] bytes number of bytes to read (max. 4) - * @return read integer */ -UInt32 StreamReader::readUnsigned (int bytes) { - UInt32 ret = 0; - for (bytes--; bytes >= 0 && !_is->eof(); bytes--) { - UInt32 b = _is->get(); - ret |= b << (8*bytes); - } - return ret; -} - - -/** Reads an unsigned integer from assigned input stream and updates the CRC32 checksum. - * @param[in] bytes number of bytes to read (max. 4) - * @param[in,out] crc32 checksum to be updated - * @return read integer */ -UInt32 StreamReader::readUnsigned (int bytes, CRC32 &crc32) { - UInt32 ret = readUnsigned(bytes); - crc32.update(ret, bytes); - return ret; -} - - -/** Reads an signed integer from assigned input stream. - * @param[in] bytes number of bytes to read (max. 4) - * @return read integer */ -Int32 StreamReader::readSigned (int bytes) { - Int32 ret = _is->get(); - if (ret & 128) // negative value? - ret |= 0xffffff00; - for (bytes-=2; bytes >= 0 && !_is->eof(); bytes--) - ret = (ret << 8) | _is->get(); - return ret; -} - - -/** Reads an signed integer from assigned input stream and updates the CRC32 checksum. - * @param[in] bytes number of bytes to read (max. 4) - * @param[in,out] crc32 checksum to be updated - * @return read integer */ -Int32 StreamReader::readSigned (int bytes, CRC32 &crc32) { - Int32 ret = readSigned(bytes); - crc32.update(ret, bytes); - return ret; -} - - -/** Reads a string terminated by a 0-byte. */ -string StreamReader::readString () { - if (!_is) - throw StreamReaderException("no stream assigned"); - string ret; - while (!_is->eof() && _is->peek() > 0) - ret += _is->get(); - _is->get(); // skip 0-byte - return ret; -} - - -/** Reads a string terminated by a 0-byte and updates the CRC32 checksum. - * @param[in,out] crc32 checksum to be updated - * @param[in] finalZero consider final 0-byte in checksum - * @return the string read */ -string StreamReader::readString (CRC32 &crc32, bool finalZero) { - string ret = readString(); - crc32.update((const UInt8*)ret.c_str(), ret.length()); - if (finalZero) - crc32.update(0, 1); - return ret; -} - - -/** Reads a string of a given length. - * @param[in] length number of characters to read - * @return the string read */ -string StreamReader::readString (int length) { - if (!_is) - throw StreamReaderException("no stream assigned"); - char *buf = new char[length+1]; - if (length <= 0) - *buf = 0; - else { - _is->read(buf, length); // reads 'length' bytes - buf[length] = 0; - } - string ret = buf; - delete [] buf; - return ret; -} - - -/** Reads a string of a given length and updates the CRC32 checksum. - * @param[in] length number of characters to read - * @param[in,out] crc32 checksum to be updated - * @return the string read */ -string StreamReader::readString (int length, CRC32 &crc32) { - string ret = readString(length); - crc32.update(ret.c_str()); - return ret; -} - - -vector& StreamReader::readBytes (int n, vector &bytes) { - if (n > 0) - in().read((char*)&bytes[0], n); - return bytes; -} - - -vector& StreamReader::readBytes (int n, vector &bytes, CRC32 &crc32) { - readBytes(n, bytes); - crc32.update(&bytes[0], bytes.size()); - return bytes; -} - - -int StreamReader::readByte (CRC32 &crc32) { - int ret = readByte(); - if (ret >= 0) { - const UInt8 c = UInt8(ret & 0xff); - crc32.update(&c, 1); - } - return ret; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.h deleted file mode 100644 index 341899dd1ec..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamReader.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* -** StreamReader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef STREAMREADER_H -#define STREAMREADER_H - -#include -#include -#include -#include "MessageException.h" -#include "types.h" - -class CRC32; - -class StreamReader -{ - public: - StreamReader (std::istream &s); - virtual ~StreamReader () {} - std::istream& replaceStream (std::istream &s); - UInt32 readUnsigned (int n); - UInt32 readUnsigned (int n, CRC32 &crc32); - Int32 readSigned (int n); - Int32 readSigned (int n, CRC32 &crc32); - std::string readString (); - std::string readString (CRC32 &crc32, bool finalZero=false); - std::string readString (int length); - std::string readString (int length, CRC32 &crc32); - std::vector& readBytes (int n, std::vector &bytes); - std::vector& readBytes (int n, std::vector &bytes, CRC32 &crc32); - int readByte () {return _is->get();} - int readByte (CRC32 &crc32); - - protected: - std::istream& in () {return *_is;} - - private: - std::istream *_is; -}; - - -struct StreamReaderException : public MessageException -{ - StreamReaderException (const std::string &msg) : MessageException(msg) {} -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.cpp deleted file mode 100644 index bdd378f9993..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************* -** StreamWriter.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "CRC32.h" -#include "StreamWriter.h" - -using namespace std; - - -/** Writes an unsigned integer to the output stream. - * @param[in] val the value to write - * @param[in] n number of bytes to be considered */ -void StreamWriter::writeUnsigned (UInt32 val, int n) { - for (n--; n >= 0; n--) - _os.put((val >> (8*n)) & 0xff); -} - - -/** Writes a signed integer to the output stream. - * @param[in] val the value to write - * @param[in] n number of bytes to be considered */ -void StreamWriter::writeSigned (Int32 val, int n) { - writeUnsigned((UInt32)val, n); -} - - -/** Writes a signed integer to the output stream. - * @param[in] val the value to write - * @param[in] finalZero if true, a final 0-byte is appended */ -void StreamWriter::writeString (const string &str, bool finalZero) { - for (size_t i=0; i < str.length(); i++) - _os.put(str[i]); - if (finalZero) - _os.put(0); -} - - -/** Writes an unsigned integer to the output stream. - * @param[in] val the value to write - * @param[in] n number of bytes to be considered - * @param[in,out] crc32 checksum to be updated */ -void StreamWriter::writeUnsigned (UInt32 val, int n, CRC32 &crc32) { - writeUnsigned(val, n); - crc32.update(val, n); -} - - -/** Writes a signed integer to the output stream and updates the CRC32 checksum. - * @param[in] val the value to write - * @param[in] n number of bytes to be considered - * @param[in,out] crc32 checksum to be updated */ -void StreamWriter::writeSigned (Int32 val, int n, CRC32 &crc32) { - writeUnsigned((UInt32)val, n, crc32); -} - - -/** Writes a string to the output stream and updates the CRC32 checksum. - * @param[in] str the string to write - * @param[in,out] crc32 checksum to be updated - * @param[in] finalZero if true, a final 0-byte is appended */ -void StreamWriter::writeString (const std::string &str, CRC32 &crc32, bool finalZero) { - writeString(str, finalZero); - crc32.update((const UInt8*)str.c_str(), str.length() + (finalZero ? 1 : 0)); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.h deleted file mode 100644 index 6217800dae6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/StreamWriter.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* -** StreamWriter.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef STREAMWRITER_H -#define STREAMWRITER_H - -#include -#include "types.h" - - -class CRC32; - -class StreamWriter -{ - public: - StreamWriter (std::ostream &os) : _os(os) {} - virtual ~StreamWriter () {} - void writeUnsigned (UInt32 val, int n); - void writeSigned (Int32 val, int n); - void writeString (const std::string &str, bool finalZero=false); - void writeUnsigned (UInt32 val, int n, CRC32 &crc32); - void writeSigned (Int32 val, int n, CRC32 &crc32); - void writeString (const std::string &str, CRC32 &crc32, bool finalZero=false); - - private: - std::ostream &_os; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.cpp deleted file mode 100644 index aa552d029f6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/************************************************************************* -** Subfont.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "FileFinder.h" -#include "Subfont.h" -#include "Message.h" - -using namespace std; - -// helper functions - -static int skip_mapping_data (istream &is); -static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &pos); - - -/** Constructs a new SubfontDefinition object. - * @param[in] name name of subfont definition - * @param[in] fpath path to corresponding .sfd file*/ -SubfontDefinition::SubfontDefinition (const string &name, const char *fpath) : _sfname(name) { - // read all subfont IDs from the .sfd file but skip the mapping data - ifstream is(fpath); - while (is) { - if (is.peek() == '#') // comment line? - is.ignore(numeric_limits::max(), '\n'); // => skip it - else if (isspace(is.peek())) - is.get(); - else { - string id; - while (is && !isspace(is.peek())) - id += is.get(); - if (!id.empty()) { - pair state = _subfonts.insert(pair(id, (Subfont*)0)); - if (state.second) // id was not present in map already - state.first->second = new Subfont(*this, state.first->first); - skip_mapping_data(is); - } - } - } -} - - -SubfontDefinition::~SubfontDefinition () { - for (Iterator it=_subfonts.begin(); it != _subfonts.end(); ++it) - delete it->second; -} - - -/** Looks for a subfont definition of the given name and returns the corresponding object. - * All objects are only created once for a given name and stored in an internal cache. - * @param[in] name name of subfont definition to lookup - * @return pointer to subfont definition object or 0 if it doesn't exist */ -SubfontDefinition* SubfontDefinition::lookup (const std::string &name) { - typedef map SFDMap; - static SFDMap sfdMap; - SFDMap::iterator it = sfdMap.find(name); - if (it != sfdMap.end()) - return it->second; - SubfontDefinition *sfd=0; - if (const char *path = FileFinder::lookup(name+".sfd", false)) { - sfd = new SubfontDefinition(name, path); - sfdMap[name] = sfd; - } - return sfd; -} - - -/** Returns the full path to the corresponding .sfd file or 0 if it can't be found. */ -const char* SubfontDefinition::path () const { - return FileFinder::lookup(filename(), false); -} - - -/** Returns the subfont with the given ID, or 0 if it doesn't exist. */ -Subfont* SubfontDefinition::subfont (const string &id) const { - ConstIterator it = _subfonts.find(id); - if (it != _subfonts.end()) - return it->second; - return 0; -} - - -/** Returns all subfonts defined in this SFD. */ -int SubfontDefinition::subfonts (vector &sfs) const { - for (ConstIterator it=_subfonts.begin(); it != _subfonts.end(); ++it) - sfs.push_back(it->second); - return sfs.size(); -} - -////////////////////////////////////////////////////////////////////// - -Subfont::~Subfont () { - delete [] _mapping; -} - - -/** Reads the character mappings for a given subfont ID. - * Format of subfont definition (sfd) files: - * sfd ::= (ID entries | '#' '\n')* - * ID ::= - * entries ::= (integer | integer ':' | integer '_' integer)* - * The mapping data for a subfont is given as a sequence of 256 16-bit values where - * value v at position c defines the (global) character code that is assigned to the - * local subfont character c. The sequence v,v+1,v+2,...,v+n can be abbreviated with - * v '_' v+n, e.g. 10_55. In order to continue the sequence at a different position, - * the syntax number ':' can be used. Example: 10: 5 6 7 assigns the values v=5, 6, 7 - * to c=10, 11 and 12, respectively. - * @return true if the data has been read successfully */ -bool Subfont::read () { - if (_mapping) // if there's already a mapping assigned, we're finished here - return true; - if (const char *p = _sfd.path()) { - ifstream is(p); - if (!is) - return false; - - int lineno=1; - while (is) { - if (is.peek() == '#' || is.peek() == '\n') { - is.ignore(numeric_limits::max(), '\n'); // skip comment and empty line - lineno++; - } - else if (isspace(is.peek())) - is.get(); - else { - string id; - while (is && !isspace(is.peek())) - id += is.get(); - if (id != _id) - lineno += skip_mapping_data(is); - else { - // build mapping array - _mapping = new UInt16[256]; - memset(_mapping, 0, 256*sizeof(UInt16)); - int pos=0; - char buf[1024]; - bool complete=false; - while (!complete) { - is.getline(buf, 1024); - complete = scan_line(buf, lineno, _mapping, _sfd.filename() ,pos); - } - return true; - } - } - } - } - return false; -} - - -/** Returns the global character code of the target font for a - * (local) character code of the subfont. - * @param[in] c local character code relative to the subfont - * @return character code of the target font */ -UInt16 Subfont::decode (unsigned char c) { - if (!_mapping && !read()) - return 0; - return _mapping[c]; -} - - -////////////////////////////////////////////////////////////////////// - - -/** Skips the mapping data of a subfont entry. - * @param[in] stream to read from - * @return number of lines skipped */ -static int skip_mapping_data (istream &is) { - char buf[1024]; - bool complete=false; - int lines=0; - while (is && !complete) { - is.getline(buf, 1024); - if (is.gcount() > 1) - lines++; - const char *p = buf+is.gcount()-2; - while (p >= buf && isspace(*p)) - p--; - complete = (p < buf || *p != '\\'); // line doesn't end with backslash - } - return lines; -} - - -/** Scans a single line of mapping data and stores the values in the given array. - * @param[in] line the line of text to be scanned - * @param[in] lineno line number used in exception messages - * @param[in,out] mapping the mapping data - * @param[in,out] offest position/index of next mapping value - * @return true if the line is the last one the current mapping sequence, i.e. the line doesn't end with a backslash */ -static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &offset) { - const char *p=line; - char *q; - for (; *p && isspace(*p); p++); - while (*p) { - if (*p == '\\') { - while (*++p) - if (!isspace(*p)) - throw SubfontException("unexpected backslash in mapping table", fname, lineno); - } - else { - long val1 = strtol(p, &q, 0); // first value of range - long val2; // last value of range - ostringstream oss; // output stream for exception messages - switch (*q) { - case ':': - if (val1 < 0 || val1 > 255) - throw SubfontException(oss << "offset value " << val1 << " out of range (0-255)", fname, lineno); - offset = val1; - val1 = -1; - q++; - break; - case '_': - p = q+1; - val2 = strtol(p, &q, 0); - if (val1 < 0 || val1 > 0xffffL) - throw SubfontException(oss << "table value " << val1 << " out of range", fname, lineno); - if (val2 < 0 || val2 > 0xffffL) - throw SubfontException(oss << "table value " << val2 << " out of range", fname, lineno); - if (p == q || (!isspace(*q) && *q != '\\' && *q)) - throw SubfontException(oss << "unexpected character '" << *q << "'", fname, lineno); - break; - default: - if (p == q || (!isspace(*q) && *q != '\\' && *q)) - throw SubfontException(oss << "unexpected character '" << *q << "'", fname, lineno); - if (val1 < 0 || val1 > 0xffffL) - throw SubfontException("invalid character code", fname, lineno); - val2 = val1; - } - if (val1 >= 0) { - if (val1 > val2 || offset+val2-val1 > 255) - throw SubfontException(oss << "invalid range in mapping table: " << hex << val1 << '_' << val2, fname, lineno); - for (long v=val1; v <= val2; v++) { - if (mapping[offset]) - throw SubfontException(oss << "mapping of character " << offset << " already defined", fname, lineno); - mapping[offset++] = static_cast(v); - } - } - for (p=q; *p && isspace(*p); p++); - } - } - for (p--; p >= line && isspace(*p); p--); - return p < line || *p != '\\'; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.h deleted file mode 100644 index b099bc76897..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Subfont.h +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************* -** Subfont.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SUBFONT_H -#define SUBFONT_H - -#include -#include -#include -#include -#include -#include "MessageException.h" -#include "types.h" - - -class Subfont; - - -/** Represents a collection of subfont mappings as defined in a .sfd file, and - * encapsulates the evaluation of these files. */ -class SubfontDefinition -{ - typedef std::map Subfonts; - typedef Subfonts::iterator Iterator; - typedef Subfonts::const_iterator ConstIterator; - public: - ~SubfontDefinition (); - static SubfontDefinition* lookup (const std::string &name); -// int getIDs (std::vector &ids) const; - const std::string& name() const {return _sfname;} - std::string filename() const {return _sfname+".sfd";} - Subfont* subfont (const std::string &id) const; - int subfonts (std::vector &sfs) const; - const char* path () const; - - protected: - SubfontDefinition (const std::string &name, const char *fpath); - SubfontDefinition (const SubfontDefinition &sfd) {} - - private: - std::string _sfname; ///< name of subfont - Subfonts _subfonts; ///< all subfonts defined in the corresponding .sfd file -}; - - -/** Represents a single subfont mapping defined in a SubfontDefinition (.sfd file). */ -class Subfont -{ - friend class SubfontDefinition; - public: - ~Subfont(); - const std::string& id () const {return _id;} - UInt16 decode (unsigned char c); - - protected: - Subfont (SubfontDefinition &sfd, const std::string &id) : _sfd(sfd), _id(id), _mapping(0) {} - bool read (); - - private: - SubfontDefinition &_sfd; ///< SubfontDefinition where this Subfont belongs to - const std::string &_id; ///< id of this subfont as specified in the .sfd file - UInt16 *_mapping; ///< the character mapping table with 256 entries -}; - - -class SubfontException : public MessageException -{ - public: - SubfontException (const std::string &msg, const std::string &fname, int lineno=0) - : MessageException(msg), _fname(fname), _lineno(lineno) {} - - SubfontException (const std::ostream &oss, const std::string &fname, int lineno=0) - : MessageException(dynamic_cast(oss).str()), _fname(fname), _lineno(lineno) {} - - virtual ~SubfontException () throw() {} - - const char* filename () const {return _fname.c_str();} - int lineno () const {return _lineno;} - - private: - std::string _fname; - int _lineno; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.cpp deleted file mode 100644 index 80c71ec7b4c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************* -** System.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "System.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if defined (HAVE_SYS_TIME_H) -#include -#elif defined (HAVE_SYS_TIMEB_H) -#include -#endif - - -using namespace std; - - -/** Returns timestamp (wall time) in seconds. */ -double System::time () { -#if defined (HAVE_SYS_TIME_H) - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + tv.tv_usec/1000000.0; -#elif defined (HAVE_SYS_TIMEB_H) - struct timeb tb; - ftime(&tb); - return tb.time + tb.millitm/1000.0; -#else - clock_t myclock = clock(); - return double(myclock)/CLOCKS_PER_SEC; -#endif -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.h deleted file mode 100644 index 775d6358dd7..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/System.h +++ /dev/null @@ -1,29 +0,0 @@ -/************************************************************************* -** System.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef SYSTEM_H -#define SYSTEM_H - -namespace System -{ - double time (); -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.cpp deleted file mode 100644 index 093af8cb5e3..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************* -** TFM.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "FileFinder.h" -#include "Message.h" -#include "StreamReader.h" -#include "TFM.h" - -using namespace std; - - -/** Reads a sequence of n TFM words (4 Bytes each). - * @param[in] is reads from this stream - * @param[out] v the read words - * @param[in] n number of words to be read - * @return dynamically allocated array containing the read words - * (must be deleted by the caller) */ -template -static void read_words (StreamReader &sr, vector &v, unsigned n) { - v.clear(); - v.resize(n); - for (unsigned i=0; i < n; i++) - v[i] = sr.readUnsigned(4); -} - - -/** Converts a TFM fix point value to double. */ -static double fix2double (FixWord fix) { - return double(fix)/(1 << 20); -} - - -TFM::TFM () : _checksum(0), _firstChar(0), _lastChar(0), _designSize(0) -{ -} - - -TFM::TFM (istream &is) { - readFromStream(is); -} - - -TFM* TFM::createFromFile (const char *fontname) { - string filename = string(fontname) + ".tfm"; - const char *path = FileFinder::lookup(filename); - ifstream ifs(path, ios_base::binary); - if (ifs) - return new TFM(ifs); - return 0; -} - - -bool TFM::readFromStream (istream &is) { - StreamReader sr(is); - is.seekg(2, ios_base::beg); // skip file size - UInt16 lh = UInt16(sr.readUnsigned(2)); // length of header in 4 byte words - _firstChar= UInt16(sr.readUnsigned(2)); // smalles character code in font - _lastChar = UInt16(sr.readUnsigned(2)); // largest character code in font - UInt16 nw = UInt16(sr.readUnsigned(2)); // number of words in width table - UInt16 nh = UInt16(sr.readUnsigned(2)); // number of words in height table - UInt16 nd = UInt16(sr.readUnsigned(2)); // number of words in depth table - UInt16 ni = UInt16(sr.readUnsigned(2)); // number of words in italic corr. table -// UInt16 nl = UInt16(sr.readUnsigned(2)); // number of words in lig/kern table -// UInt16 nk = UInt16(sr.readUnsigned(2)); // number of words in kern table -// UInt16 ne = UInt16(sr.readUnsigned(2)); // number of words in ext. char table -// UInt16 np = UInt16(sr.readUnsigned(2)); // number of font parameter words - - is.seekg(8, ios_base::cur); // move to header (skip above commented bytes) - _checksum = sr.readUnsigned(4); - _designSize = sr.readUnsigned(4); - is.seekg(24+lh*4, ios_base::beg); // move to char info table - read_words(sr, _charInfoTable, _lastChar-_firstChar+1); - read_words(sr, _widthTable, nw); - read_words(sr, _heightTable, nh); - read_words(sr, _depthTable, nd); - read_words(sr, _italicTable, ni); - return true; -} - - -/** Returns the design size of this font in TeX point units. */ -double TFM::getDesignSize () const { - return fix2double(_designSize); -} - - -// the char info word for each character consists of 4 bytes holding the following information: -// width index w, height index (h), depth index (d), italic correction index (it), -// tag (tg) and a remainder: -// -// byte 1 | byte 2 | byte 3 | byte 4 -// xxxxxxxx | xxxx xxxx | xxxxxx xx | xxxxxxxx -// w | h d | it tg | remainder - -/** Returns the width of char c in TeX point units. */ -double TFM::getCharWidth (int c) const { - if (c < _firstChar || c > _lastChar || unsigned(c-_firstChar) >= _charInfoTable.size()) - return 0; - int index = (_charInfoTable[c-_firstChar] >> 24) & 0xFF; - return fix2double(_widthTable[index]) * fix2double(_designSize); -} - - -/** Returns the height of char c in TeX point units. */ -double TFM::getCharHeight (int c) const { - if (c < _firstChar || c > _lastChar || unsigned(c-_firstChar) >= _charInfoTable.size()) - return 0; - int index = (_charInfoTable[c-_firstChar] >> 20) & 0x0F; - return fix2double(_heightTable[index]) * fix2double(_designSize); -} - - -/** Returns the depth of char c in TeX point units. */ -double TFM::getCharDepth (int c) const { - if (c < _firstChar || c > _lastChar || unsigned(c-_firstChar) >= _charInfoTable.size()) - return 0; - int index = (_charInfoTable[c-_firstChar] >> 16) & 0x0F; - return fix2double(_depthTable[index]) * fix2double(_designSize); -} - - -/** Returns the italic correction of char c in TeX point units. */ -double TFM::getItalicCorr (int c) const { - if (c < _firstChar || c > _lastChar || unsigned(c-_firstChar) >= _charInfoTable.size()) - return 0; - int index = (_charInfoTable[c-_firstChar] >> 10) & 0x3F; - return fix2double(_italicTable[index]) * fix2double(_designSize); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.h deleted file mode 100644 index f2ce472ead4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TFM.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* -** TFM.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef TFM_H -#define TFM_H - -#include -#include -#include "types.h" - -struct FileFinder; - -class TFM -{ - public: - TFM (); - TFM (std::istream &is); - static TFM* createFromFile (const char *fname); - double getDesignSize () const; - double getCharWidth (int c) const; - double getCharHeight (int c) const; - double getCharDepth (int c) const; - double getItalicCorr (int c) const; - UInt32 getChecksum () const {return _checksum;} - UInt16 firstChar () const {return _firstChar;} - UInt16 lastChar () const {return _lastChar;} - - protected: - bool readFromStream (std::istream &is); - - private: - UInt32 _checksum; - UInt16 _firstChar, _lastChar; - FixWord _designSize; ///< design size of the font in TeX points (7227 pt = 254 cm) - std::vector _charInfoTable; - std::vector _widthTable; ///< character widths in design size units - std::vector _heightTable; ///< character height in design size units - std::vector _depthTable; ///< character depth in design size units - std::vector _italicTable; ///< italic corrections in design size units -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.cpp deleted file mode 100644 index b40a68c73d9..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/************************************************************************* -** Terminal.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "Terminal.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_TERMIOS_H -#include -#endif - -#ifdef GWINSZ_IN_SYS_IOCTL -#include -#endif - -#ifdef __WIN32__ -#include -#endif - -#include - - -using namespace std; - - -const int Terminal::RED = 1; -const int Terminal::GREEN = 2; -const int Terminal::BLUE = 4; - -const int Terminal::CYAN = GREEN|BLUE; -const int Terminal::YELLOW = RED|GREEN; -const int Terminal::MAGENTA = RED|BLUE; -const int Terminal::WHITE = RED|GREEN|BLUE; -const int Terminal::DEFAULT = -1; -const int Terminal::BLACK = 0; - -#ifdef __WIN32__ -int Terminal::_defaultColor; -#endif - -int Terminal::_fgcolor = Terminal::DEFAULT; -int Terminal::_bgcolor = Terminal::DEFAULT; - - -/** Initializes the terminal. This method should be called before any of the others. - * @param[in,out] os terminal output stream (currently unused) */ -void Terminal::init (ostream &os) { -#ifdef __WIN32__ - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - if (h != INVALID_HANDLE_VALUE) { - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo(h, &info); - _defaultColor = (info.wAttributes & 0xff); - } -#endif -} - - -/** Finishes the terminal output. Should be called after last terminal action. - * @param[in,out] os terminal output stream */ -void Terminal::finish (ostream &os) { - fgcolor(DEFAULT, os); - bgcolor(DEFAULT, os); -} - - -/** Returns the number of terminal columns (number of characters per row). - * If it's not possible to retrieve information about the terminal size, 0 is returned. */ -int Terminal::columns () { -#if defined(TIOCGWINSZ) - struct winsize ws; - if (ioctl(fileno(stderr), TIOCGWINSZ, &ws) < 0) - return 0; - return ws.ws_col; -#elif defined(__WIN32__) - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &info)) - return 0; - return info.dwSize.X; -#else - return 0; -#endif -} - - -/** Returns the number of terminal rows. - * If it's not possible to retrieve information about the terminal size, 0 is returned. */ -int Terminal::rows () { -#if defined(TIOCGWINSZ) - struct winsize ws; - if (ioctl(fileno(stderr), TIOCGWINSZ, &ws) < 0) - return 0; - return ws.ws_row; -#elif defined(__WIN32__) - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &info)) - return 0; - return info.dwSize.Y; -#else - return 0; -#endif -} - - -/** Sets the foreground color. - * @param[in] color color code - * @param[in] os terminal output stream */ -void Terminal::fgcolor (int color, ostream &os) { - _fgcolor = color; - -#ifdef __WIN32__ - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - if (h != INVALID_HANDLE_VALUE) { - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo(h, &info); - if (_fgcolor == DEFAULT) - color = _defaultColor & 0x0f; - else { - // swap red and blue bits - color = (color & 0x0a) | ((color & 1) << 2) | ((color & 4) >> 2); - } - color = (info.wAttributes & 0xf0) | (color & 0x0f); - SetConsoleTextAttribute(h, (DWORD)color); - } -#else - bool light = false; - if (color != DEFAULT && color > 7) { - light = true; - color %= 8; - } - if (color == DEFAULT) { - os << "\x1B[0m"; - if (_bgcolor != DEFAULT) - bgcolor(_bgcolor, os); - } - else - os << "\x1B[" << (light ? '1': '0') << ';' << (30+(color & 0x07)) << 'm'; -#endif -} - - -/** Sets the background color. - * @param[in] color color code - * @param[in] os terminal output stream */ -void Terminal::bgcolor (int color, ostream &os) { - _bgcolor = color; -#ifdef __WIN32__ - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - if (h != INVALID_HANDLE_VALUE) { - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo(h, &info); - if (_bgcolor == DEFAULT) - color = (_defaultColor & 0xf0) >> 4; - else { - // swap red and blue bits - color = (color & 0x0a) | ((color & 1) << 2) | ((color & 4) >> 2); - } - color = (info.wAttributes & 0x0f) | ((color & 0x0f) << 4); - SetConsoleTextAttribute(h, (DWORD)color); - } -#else - if (color != DEFAULT && color > 7) - color %= 8; - if (color == DEFAULT) { - os << "\x1B[0m"; - if (_fgcolor != DEFAULT) - fgcolor(_fgcolor, os); - } - else - os << "\x1B[" << (40+(color & 0x07)) << 'm'; -#endif -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.h deleted file mode 100644 index 835ae4571e6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/Terminal.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* -** Terminal.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef TERMINAL_H -#define TERMINAL_H - -#include - -class Terminal -{ - public: - static const int DEFAULT; - static const int BLACK; - static const int RED; - static const int GREEN; - static const int BLUE; - static const int CYAN; - static const int YELLOW; - static const int MAGENTA; - static const int WHITE; - - public: - static void init (std::ostream &os); - static void finish (std::ostream &os); - static int columns (); - static int rows (); - static void fgcolor (int color, std::ostream &os); - static void bgcolor (int color, std::ostream &os); - - private: - static int _fgcolor; ///< current foreground color - static int _bgcolor; ///< current background color - -#ifdef __WIN32__ - static int _defaultColor; -#endif -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.cpp deleted file mode 100644 index f61338905e4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/************************************************************************* -** TpicSpecialHandler.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "Color.h" -#include "InputBuffer.h" -#include "InputReader.h" -#include "SpecialActions.h" -#include "TpicSpecialHandler.h" -#include "XMLNode.h" -#include "XMLString.h" -#include "types.h" - -using namespace std; - - -TpicSpecialHandler::TpicSpecialHandler () { - reset(); -} - - -void TpicSpecialHandler::dviEndPage () { - reset(); -} - - -void TpicSpecialHandler::reset () { - _points.clear(); - _penwidth = 1.0; - _fill = -1.0; // no fill -} - - -/** Creates SVG elements that draw lines through the recorded points. - * @param[in] stroke if true, the (out)line is drawn (in black) - * @param[in] fill if true, enclosed area is filled with current color - * @param[in] ddist dash/dot distance of line in TeX point units - * (0:solid line, >0:dashed line, <0:dotted line) */ -void TpicSpecialHandler::drawLines (bool stroke, bool fill, double ddist, SpecialActions *actions) { - if (actions && !_points.empty()) { - XMLElementNode *elem=0; - if (_points.size() == 1) { - const DPair &p = _points.back(); - elem = new XMLElementNode("circle"); - elem->addAttribute("cx", p.x()+actions->getX()); - elem->addAttribute("cy", p.y()+actions->getY()); - elem->addAttribute("r", _penwidth/2.0); - actions->embed(p, _penwidth/2.0); - } - else { - if (_points.size() == 2 || (!fill && _points.front() != _points.back())) { - elem = new XMLElementNode("polyline"); - elem->addAttribute("fill", "none"); - elem->addAttribute("stroke-linecap", "round"); - } - else { - if (_points.front() == _points.back()) - _points.pop_back(); - if (_fill < 0) - _fill = 1; - Color color = actions->getColor(); - color *= _fill; - elem = new XMLElementNode("polygon"); - elem->addAttribute("fill", fill ? color.rgbString() : "none"); - } - ostringstream oss; - FORALL(_points, vector::iterator, it) { - if (it != _points.begin()) - oss << ' '; - double x = it->x()+actions->getX(); - double y = it->y()+actions->getY(); - oss << XMLString(x) << ',' << XMLString(y); - actions->embed(DPair(x, y)); - } - elem->addAttribute("points", oss.str()); - if (stroke) { // draw outline? - elem->addAttribute("stroke", "black"); - elem->addAttribute("stroke-width", XMLString(_penwidth)); - } - } - if (ddist > 0) - elem->addAttribute("stroke-dasharray", XMLString(ddist)); - else if (ddist < 0) - elem->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist)); - actions->appendToPage(elem); - } - reset(); -} - - -/** Stroke a quadratic spline through the midpoints of the lines defined by - * the previously recorded points. The spline starts with a straight line - * from the first point to the mid-point of the first line. The spline ends - * with a straight line from the mid-point of the last line to the last point. - * If ddist=0, the spline is stroked solid. Otherwise ddist denotes the length - * of the dashes and the gaps inbetween. - * @param[in] ddist length of dashes and gaps */ -void TpicSpecialHandler::drawSplines (double ddist, SpecialActions *actions) { - if (actions && !_points.empty()) { - const size_t size = _points.size(); - if (size < 3) - drawLines(true, false, ddist, actions); - else { - double x = actions->getX(); - double y = actions->getY(); - DPair p(x,y); - ostringstream oss; - oss << 'M' << XMLString(x+_points[0].x()) << ',' << XMLString(y+_points[0].y()); - DPair mid = p+_points[0]+(_points[1]-_points[0])/2.0; - oss << 'L' << XMLString(mid.x()) << ',' << XMLString(mid.y()); - actions->embed(p+_points[0]); - for (size_t i=1; i < size-1; i++) { - const DPair p0 = p+_points[i-1]; - const DPair p1 = p+_points[i]; - const DPair p2 = p+_points[i+1]; - mid = p1+(p2-p1)/2.0; - oss << 'Q' << XMLString(p1.x()) << ',' << XMLString(p1.y()) - << ' ' << XMLString(mid.x()) << ',' << XMLString(mid.y()); - actions->embed(mid); - actions->embed((p0+p1*6.0+p2)/8.0, _penwidth); - } - if (_points[0] == _points[size-1]) // closed path? - oss << 'Z'; - else { - oss << 'L' << XMLString(x+_points[size-1].x()) << ',' << XMLString(y+_points[size-1].y()); - actions->embed(p+_points[size-1]); - } - - Color color = actions->getColor(); - color *= _fill; - XMLElementNode *path = new XMLElementNode("path"); - if (_fill >= 0) { - if (_points[0] != _points[size-1]) - oss << 'Z'; - path->addAttribute("fill", color.rgbString()); - } - else - path->addAttribute("fill", "none"); - - path->addAttribute("d", oss.str()); - path->addAttribute("stroke", actions->getColor().rgbString()); - path->addAttribute("stroke-width", XMLString(_penwidth)); - if (ddist > 0) - path->addAttribute("stroke-dasharray", XMLString(ddist)); - else if (ddist < 0) - path->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist)); - actions->appendToPage(path); - } - } - reset(); -} - - -/** Draws an elliptical arc. - * @param[in] cx x-coordinate of arc center - * @param[in] cy y-coordinate of arc center - * @param[in] rx length of horizonal semi-axis - * @param[in] ry length of vertical semi-axis - * @param[in] angle1 starting angle (clockwise) relative to x-axis - * @param[in] angle2 ending angle (clockwise) relative to x-axis */ -void TpicSpecialHandler::drawArc (double cx, double cy, double rx, double ry, double angle1, double angle2, SpecialActions *actions) { - if (actions) { - const double PI2 = 4*asin(1.0); - angle1 *= -1; - angle2 *= -1; - if (fabs(angle1) > PI2) { - int n = (int)(angle1/PI2); - angle1 = angle1 - n*PI2; - angle2 = angle2 - n*PI2; - } - - double x = cx + actions->getX(); - double y = cy + actions->getY(); - XMLElementNode *elem=0; - if (fabs(angle1-angle2) >= PI2) { // closed ellipse? - elem = new XMLElementNode("ellipse"); - elem->addAttribute("cx", XMLString(x)); - elem->addAttribute("cy", XMLString(y)); - elem->addAttribute("rx", XMLString(rx)); - elem->addAttribute("ry", XMLString(ry)); - } - else { - if (angle1 < 0) - angle1 = PI2+angle1; - if (angle2 < 0) - angle2 = PI2+angle2; - elem = new XMLElementNode("path"); - int large_arg = fabs(angle1-angle2) > PI2/2 ? 0 : 1; - int sweep_flag = angle1 > angle2 ? 0 : 1; - if (angle1 > angle2) { - large_arg = 1-large_arg; - sweep_flag = 1-sweep_flag; - } - ostringstream oss; - oss << 'M' << XMLString(x+rx*cos(angle1)) << ',' << XMLString(y+ry*sin(-angle1)) - << 'A' << XMLString(rx) << ',' << XMLString(ry) - << " 0 " - << large_arg << ' ' << sweep_flag << ' ' - << XMLString(x+rx*cos(angle2)) << ',' << XMLString(y-ry*sin(angle2)); - if (_fill >= 0) - oss << 'Z'; - elem->addAttribute("d", oss.str()); - } - elem->addAttribute("stroke-width", _penwidth); - elem->addAttribute("stroke", actions->getColor().rgbString()); - elem->addAttribute("stroke-linecap", "round"); - elem->addAttribute("fill", "none"); - if (_fill >= 0) { - Color color=actions->getColor(); - color *= _fill; - elem->addAttribute("fill", color.rgbString()); - } - else - elem->addAttribute("fill", "none"); - actions->appendToPage(elem); - actions->embed(BoundingBox(cx-rx, cy-ry, cx+rx, cy+ry)); - } - reset(); -} - - -#define cmd_id(c1,c2) ((c1 << 8) | c2) - -bool TpicSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { - if (!prefix || strlen(prefix) != 2) - return false; - - const double PT=0.07227; // factor for milli-inch to TeX points - StreamInputBuffer ib(is); - BufferInputReader in(ib); - switch (cmd_id(prefix[0], prefix[1])) { - case cmd_id('p','n'): // set pen width in milli-inches - _penwidth = in.getDouble()*PT; - break; - case cmd_id('b','k'): // set fill color to black - _fill = 0; - break; - case cmd_id('w','h'): // set fill color to white - _fill = 1; - break; - case cmd_id('s','h'): // set fill color to given gray level - in.skipSpace(); - _fill = in.eof() ? 0.5 : max(0.0, min(1.0, in.getDouble())); - break; - case cmd_id('t','x'): // set fill pattern - break; - case cmd_id('p','a'): { // add point to path - double x=in.getDouble()*PT; - double y=in.getDouble()*PT; - _points.push_back(DPair(x,y)); - break; - } - case cmd_id('f','p'): // draw solid lines through recorded points; close and fill path if fill color was defined - drawLines(true, _fill >= 0, 0, actions); - break; - case cmd_id('i','p'): // don't draw outlines but close the recorded path and fill the resulting polygon - drawLines(false, true, 0, actions); - break; - case cmd_id('d','a'): // as fp but draw dashed lines - drawLines(true, _fill >= 0, in.getDouble()*72.27, actions); - break; - case cmd_id('d','t'): // as fp but draw dotted lines - drawLines(true, _fill >= 0, -in.getDouble()*72.27, actions); - break; - case cmd_id('s','p'): { // draw quadratic splines through recorded points - double ddist = in.getDouble(); - drawSplines(ddist, actions); - break; - } - case cmd_id('a','r'): { // draw elliptical arc - double cx = in.getDouble()*PT; - double cy = in.getDouble()*PT; - double rx = in.getDouble()*PT; - double ry = in.getDouble()*PT; - double a1 = in.getDouble(); - double a2 = in.getDouble(); - drawArc(cx, cy, rx, ry, a1, a2, actions); - break; - } - case cmd_id('i','a'): { // fill elliptical arc - double cx = in.getDouble()*PT; - double cy = in.getDouble()*PT; - double rx = in.getDouble()*PT; - double ry = in.getDouble()*PT; - double a1 = in.getDouble(); - double a2 = in.getDouble(); - if (_fill < 0) - _fill = 1; - drawArc(cx, cy, rx, ry, a1, a2, actions); - if (_fill < 0) - _fill = -1; - break; - } - default: - return false; - } - return true; -} - - -const char** TpicSpecialHandler::prefixes () const { - static const char *pfx[] = {"ar", "bk", "da", "dt", "fp", "ia", "ip", "pa", "pn", "sh", "sp", "tx", "wh", 0}; - return pfx; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.h deleted file mode 100644 index 257843d1115..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/TpicSpecialHandler.h +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* -** TpicSpecialHandler.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef TPICSPECIALHANDLER_H -#define TPICSPECIALHANDLER_H - -#include -#include "Pair.h" -#include "SpecialHandler.h" - -class TpicSpecialHandler : public SpecialHandler -{ - public: - TpicSpecialHandler (); - const char* info () const {return "TPIC specials";} - const char* name () const {return "tpic";} - const char** prefixes () const; - bool process (const char *prefix, std::istream &is, SpecialActions *actions); - void dviEndPage (); - - protected: - bool isEndPageListener () const {return true;} - void reset (); - void drawLines (bool stroke, bool fill, double ddist, SpecialActions *actions); - void drawSplines (double ddist, SpecialActions *actions); - void drawArc (double cx, double cy, double rx, double ry, double angle1, double angle2, SpecialActions *actions); - - private: - double _penwidth; ///< pen width in TeX point units - double _fill; ///< fill intensity [0,1]; if < 0, we don't fill anything - std::vector _points; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFActions.h deleted file mode 100644 index ba25639b337..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFActions.h +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************* -** VFActions.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef VFACTIONS_H -#define VFACTIONS_H - -#include -#include -#include "types.h" - - -struct VFActions -{ - virtual ~VFActions () {} - virtual void preamble (std::string comment, UInt32 checksum, double dsize) {} - virtual void postamble () {} - virtual void defineVFFont (UInt32 fontnum, std::string path, std::string name, UInt32 checksum, double dsize, double ssize) {} - virtual void defineVFChar (UInt32 c, std::vector *dvi) {} -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.cpp deleted file mode 100644 index 5980a63054a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************************* -** VFReader.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "Font.h" -#include "VFActions.h" -#include "VFReader.h" -#include "macros.h" - -using namespace std; - - -/** Converts a TFM fix point value to double. */ -inline static double fix2double (FixWord fix) { - return double(fix)/(1 << 20); -} - - -VFReader::VFReader (istream &is) - : StreamReader(is), _actions(0), _designSize(0) { -} - - -VFReader::~VFReader () { -} - - -VFActions* VFReader::replaceActions (VFActions *a) { - VFActions *ret = _actions; - _actions = a; - return ret; -} - - -/** Reads a single VF command from the current position of the input stream and calls the - * corresponding cmdFOO method. The execution can be influenced by a function of type ApproveOpcode. - * It takes an opcode and returns true if the command is supposed to be executed. - * @param[in] approve function to approve invocation of the action assigned to command - * @return opcode of the executed command */ -int VFReader::executeCommand (ApproveAction approve) { - int opcode = in().get(); - if (!in() || opcode < 0) // at end of file - throw VFException("invalid file"); - - bool approved = !approve || approve(opcode); - VFActions *actions = _actions; - if (!approved) - replaceActions(0); // disable actions - - if (opcode <= 241) // short character definition? - cmdShortChar(opcode); - else if (opcode >= 243 && opcode <= 246) // font definition? - cmdFontDef(opcode-243+1); - else { - switch (opcode) { - case 242: cmdLongChar(); break; // long character definition - case 247: cmdPre(); break; // preamble - case 248: cmdPost(); break; // postamble - default : { // invalid opcode - replaceActions(actions); // reenable actions - ostringstream oss; - oss << "undefined VF command (opcode " << opcode << ')'; - throw VFException(oss.str()); - } - } - } - replaceActions(actions); // reenable actions - return opcode; -} - - -bool VFReader::executeAll () { - in().clear(); // reset all status bits - if (!in()) - return false; - in().seekg(0); // move file pointer to first byte of the input stream - while (!in().eof() && executeCommand() != 248); // stop reading after post (248) - return true; -} - - -/// Returns true if op indicates the preamble or a font definition -static bool is_pre_or_fontdef (int op) {return op > 242;} -static bool is_chardef (int op) {return op < 243;} - - -bool VFReader::executePreambleAndFontDefs () { - in().clear(); - if (!in()) - return false; - in().seekg(0); // move file pointer to first byte of the input stream - while (!in().eof() && executeCommand(is_pre_or_fontdef) > 242); // stop reading after last font definition - return true; -} - - -bool VFReader::executeCharDefs () { - in().clear(); - if (!in()) - return false; - in().seekg(0); - while (!in().eof() && executeCommand(is_chardef) < 243); // stop reading after last char definition - return true; -} - -////////////////////////////////////////////////////////////////////////////// - -/** Reads and executes DVI preamble command. */ -void VFReader::cmdPre () { - UInt32 i = readUnsigned(1); // identification number (should be 2) - UInt32 k = readUnsigned(1); // length of following comment - string cmt = readString(k); // comment - UInt32 cs = readUnsigned(4); // check sum to be compared with TFM cecksum - UInt32 ds = readUnsigned(4); // design size (same as TFM design size) (fix_word) - _designSize = fix2double(ds); - if (i != 202) - throw VFException("invalid identification value in preamble"); - if (_actions) - _actions->preamble(cmt, cs, ds); -} - - -void VFReader::cmdPost () { - while ((readUnsigned(1)) == 248); // skip fill bytes - if (_actions) - _actions->postamble(); -} - - -void VFReader::cmdLongChar () { - UInt32 pl = readUnsigned(4); // packet length (length of DVI subroutine) - if (_actions) { - UInt32 cc = readUnsigned(4); // character code - readUnsigned(4); // character width from corresponding TFM file - vector *dvi = new vector(pl); // DVI subroutine - readBytes(pl, *dvi); - _actions->defineVFChar(cc, dvi); // call template method for user actions - } - else - in().seekg(8+pl, ios::cur); // skip remaining char definition bytes -} - - -/** Reads and executes short_char_x command. - * @param[in] pl packet length (length of DVI subroutine) */ -void VFReader::cmdShortChar (int pl) { - if (_actions) { - UInt32 cc = readUnsigned(1); // character code - readUnsigned(3); // character width from corresponding TFM file - vector *dvi = new vector(pl); // DVI subroutine - readBytes(pl, *dvi); - _actions->defineVFChar(cc, dvi); // call template method for user actions - } - else - in().seekg(4+pl, ios::cur); // skip char definition bytes -} - - -void VFReader::cmdFontDef (int len) { - UInt32 fontnum = readUnsigned(len); // font number - UInt32 checksum = readUnsigned(4); // font checksum (to be compared with corresponding TFM checksum) - UInt32 ssize = readUnsigned(4); // scaled size of font relative to design size (fix_word) - UInt32 dsize = readUnsigned(4); // design size of font (same as TFM design size) (fix_word) - UInt32 pathlen = readUnsigned(1); // length of font path - UInt32 namelen = readUnsigned(1); // length of font name - string fontpath = readString(pathlen); - string fontname = readString(namelen); - if (_actions) { - double ss = fix2double(ssize); - double ds = fix2double(dsize); - _actions->defineVFFont(fontnum, fontpath, fontname, checksum, ds, ss*_designSize); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.h deleted file mode 100644 index 25689dec2c8..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VFReader.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* -** VFReader.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef VFREADER_H -#define VFREADER_H - -#include "MessageException.h" -#include "StreamReader.h" -#include "types.h" - - -struct VFException : public MessageException -{ - VFException (const std::string &msg) : MessageException(msg) {} -}; - - -struct VFActions; - - -class VFReader : public StreamReader -{ - typedef bool (*ApproveAction)(int); - public: - VFReader (std::istream &is); - virtual ~VFReader (); - VFActions* replaceActions (VFActions *a); - bool executeAll (); - bool executePreambleAndFontDefs (); - bool executeCharDefs (); - - protected: - int executeCommand (ApproveAction approve=0); - - // the following methods represent the VF commands - // they are called by executeCommand and should not be used directly - void cmdPre (); - void cmdPost (); - void cmdShortChar (int pl); - void cmdLongChar (); - void cmdFontDef (int len); - - private: - VFActions *_actions; ///< actions to execute when reading a VF command - double _designSize; ///< design size of currently read VF -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VectorStream.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VectorStream.h deleted file mode 100644 index e57dad43ad1..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/VectorStream.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* -** VectorStream.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef VECTORSTREAM_H -#define VECTORSTREAM_H - -#include -#include - - -template -struct VectorStreamBuffer : public std::streambuf -{ - VectorStreamBuffer (std::vector &source) { - setg((char*)&source[0], (char*)&source[0], (char*)&source[0]+source.size()); - } -}; - - -template -class VectorInputStream : public std::istream -{ - public: - VectorInputStream (std::vector &source) : std::istream(&_buf), _buf(source) {} - private: - VectorStreamBuffer _buf; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocTypeNode.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocTypeNode.h deleted file mode 100644 index ad1cd0f3b38..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocTypeNode.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************* -** XMLDocTypeNode.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef XMLDOCTYPENODE_H -#define XMLDOCTYPENODE_H - -#include "XMLNode.h" - -class XMLDocTypeNode : public XMLDeclarationNode -{ - public: - XMLDocTypeNode (const std::string &rootName, const std::string &type, const std::string ¶m) - : XMLDeclarationNode("DOCTYPE", rootName + " " + type + " " + param) {} -}; - - -class XMLEntityNode : public XMLDeclarationNode -{ - public: - XMLEntityNode (const std::string &n, const std::string &v) - : XMLDeclarationNode("ENTITY", n + " " + v) {} -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.cpp deleted file mode 100644 index 5b6e3b1354f..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************* -** XMLDocument.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "macros.h" -#include "XMLDocument.h" - -using namespace std; - -XMLDocument::XMLDocument (XMLElementNode *root) - : _rootElement(root), _emitted(false) -{ -} - - -XMLDocument::~XMLDocument () { - clear(); -} - - -void XMLDocument::clear () { - delete _rootElement; - _rootElement = 0; - FORALL(_nodes, list::iterator, i) - delete *i; - _nodes.clear(); -} - - -void XMLDocument::append (XMLNode *node) { - if (!node) - return; - XMLElementNode *newRoot = dynamic_cast(node); - if (newRoot) { // there can only be one root element node in the document - delete _rootElement; // so if there is already one... - _rootElement = newRoot; // ...we replace it - } - else - _nodes.push_back(node); -} - - -void XMLDocument::setRootNode (XMLElementNode *root) { - delete _rootElement; - _rootElement = root; -} - - -ostream& XMLDocument::write (ostream &os) const { - if (_rootElement) { // no root element => no output - os << "\n"; - FORALL(_nodes, list::const_iterator, i) - (*i)->write(os); - _rootElement->write(os); - } - return os; -} - -/** Writes a part of the XML document to the given output stream and removes - * the completely written nodes. The output stops when a stop node is reached - * (this node won't be printed at all). If a node was only partly emitted, i.e. - * its child was the stop node, a further call of emit will continue the output. - * @param[in] os stream to which the output is written - * @param[in] stopElement node where emitting stops (if 0 the whole tree will be emitted) - * @return true if node was completely emitted */ -bool XMLDocument::emit (ostream& os, XMLNode *stopNode) { - if (_rootElement) { // no root element => no output - if (!_emitted) { - os << "\n"; - _emitted = true; - } - FORALL(_nodes, list::iterator, i) { - if ((*i)->emit(os, stopNode)) { - list::iterator it = i++; // prevent i from being invalidated... - _nodes.erase(it); // ... by erase - --i; // @@ what happens if i points to first child? - } - else - return false; - } - return _rootElement->emit(os, stopNode); - } - return true; -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.h deleted file mode 100644 index 31cf9dea303..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLDocument.h +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************* -** XMLDocument.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef XMLDOCUMENT_H -#define XMLDOCUMENT_H - -#include "XMLNode.h" - -class XMLDocument -{ - public: - XMLDocument (XMLElementNode *root=0); - ~XMLDocument (); - void clear (); - void append (XMLNode *node); - void setRootNode (XMLElementNode *root); - const XMLElementNode* getRootElement () const {return _rootElement;} - std::ostream& write (std::ostream &os) const; - bool emit (std::ostream& os, XMLNode *stopNode); - - private: - std::list _nodes; - XMLElementNode *_rootElement; - bool _emitted; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.cpp deleted file mode 100644 index d69b4a9b049..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/************************************************************************* -** XMLNode.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "macros.h" -#include "XMLNode.h" -#include "XMLString.h" - -using namespace std; - -bool XMLNode::emit (ostream &os, XMLNode *stopNode) { - if (this == stopNode) - return false; - write(os); - return true; -} - - -XMLElementNode::XMLElementNode (const string &n) : _name(n), _emitted(false) { -} - - -XMLElementNode::XMLElementNode (const XMLElementNode &node) - : _name(node._name), _attributes(node._attributes), _emitted(false) -{ - FORALL(node._children, ChildList::const_iterator, it) - _children.push_back((*it)->clone()); -} - - -XMLElementNode::~XMLElementNode () { - FORALL(_children, ChildList::iterator, i) - delete *i; -} - - -void XMLElementNode::addAttribute (const string &name, const string &value) { - _attributes[name] = value; -} - - -void XMLElementNode::addAttribute (const string &name, double value) { - _attributes[name] = XMLString(value); -} - - -void XMLElementNode::append (XMLNode *child) { - if (!child) - return; - XMLTextNode *textNode1 = dynamic_cast(child); - if (!textNode1 || _children.empty()) - _children.push_back(child); - else { - if (XMLTextNode *textNode2 = dynamic_cast(_children.back())) - textNode2->append(textNode1); // merge two consecutive text nodes - else - _children.push_back(child); - } -} - - -void XMLElementNode::append (const string &str) { - if (_children.empty() || !dynamic_cast(_children.back())) - _children.push_back(new XMLTextNode(str)); - else - static_cast(_children.back())->append(str); -} - - -void XMLElementNode::prepend (XMLNode *child) { - if (!child) - return; - XMLTextNode *textNode1 = dynamic_cast(child); - if (!textNode1 || _children.empty()) - _children.push_front(child); - else { - if (XMLTextNode *textNode2 = dynamic_cast(_children.back())) - textNode2->prepend(textNode1); // merge two consecutive text nodes - else - _children.push_front(child); - } -} - - -/** Inserts a new child node before a given child node already present. The latter - * will be the following sibling of the node to be inserted. If there's no such - * node present, nothing is inserted. - * @param[in] child node to be inserted - * @param[in] sibling following sibling of 'child' - * @return true on success */ -bool XMLElementNode::insertBefore (XMLNode *child, XMLNode *sibling) { - ChildList::iterator it = _children.begin(); - while (it != _children.end() && *it != sibling) - ++it; - if (it != _children.end()) { - _children.insert(it, child); - return true; - } - return false; -} - - -/** Inserts a new child node after a given child node already present. The latter - * will be the preceding sibling of the node to be inserted. If there's no such - * node present, nothing is inserted. - * @param[in] child node to be inserted - * @param[in] sibling preceding sibling of 'child' - * @return true on success */ -bool XMLElementNode::insertAfter (XMLNode *child, XMLNode *sibling) { - ChildList::iterator it = _children.begin(); - while (it != _children.end() && *it != sibling) - ++it; - if (it != _children.end()) { - _children.insert(++it, child); - return true; - } - return false; -} - - -/** Finds all descendant elements of a given name and given attribute. - * @param[in] name name of elements to find - * @param[in] attr_name name of attribute to find - * @param[out] descendants all elements found - * @return true if at least one element was found */ -bool XMLElementNode::findDescendants (const char *name, const char *attr_name, vector &descendants) { - FORALL(_children, ChildList::iterator, it) { - if (XMLElementNode *elem = dynamic_cast(*it)) { - if ((!name || elem->getName() == name) && (!attr_name || elem->hasAttribute(attr_name))) - descendants.push_back(elem); - elem->findDescendants(name, attr_name, descendants); - } - } - return !descendants.empty(); -} - - -ostream& XMLElementNode::write (ostream &os) const { - os << '<' << _name; - FORALL(_attributes, AttribMap::const_iterator, i) - os << ' ' << i->first << "='" << i->second << '\''; - if (_children.empty()) - os << "/>\n"; - else { - os << '>'; - if (dynamic_cast(_children.front())) - os << '\n'; - FORALL(_children, ChildList::const_iterator, i) - (*i)->write(os); - os << "\n"; - } - return os; -} - - -/** Writes a part of the XML tree to the given output stream and removes - * the completely written nodes. The output stops when a stop node is reached - * (this node won't be printed at all). If a node was only partly emitted, i.e. - * its child was the stop node, a further call of emit will continue the output. - * @param[in] os stream to which the output is sent to - * @param[in] stopElement node where emitting stops (if 0 the whole tree will be emitted) - * @return true if node was emitted completely */ -bool XMLElementNode::emit (ostream &os, XMLNode *stopNode) { - if (this == stopNode) - return false; - - if (!_emitted) { - os << '<' << _name; - FORALL(_attributes, AttribMap::iterator, i) - os << ' ' << i->first << "='" << i->second << '\''; - if (_children.empty()) - os << "/>\n"; - else { - os << '>'; - if (dynamic_cast(_children.front())) - os << '\n'; - } - - _emitted = true; - } - if (!_children.empty()) { - FORALL(_children, ChildList::iterator, i) { - if ((*i)->emit(os, stopNode)) { - ChildList::iterator it = i++; // prevent i from being invalidated... - _children.erase(it); // ... by erase - --i; // @@ what happens if i points to first child? - } - else - return false; - } - os << "\n"; - } - return true; -} - - -/** Returns true if this element has an attribute of given name. */ -bool XMLElementNode::hasAttribute (const string &name) const { - return _attributes.find(name) != _attributes.end(); -} - - -/** Returns the value of an attribute. - * @param[in] name name of attribute - * @return attribute value or 0 if attribute doesn't exist */ -const char* XMLElementNode::getAttributeValue(const std::string& name) const { - AttribMap::const_iterator it = _attributes.find(name); - if (it != _attributes.end()) - return it->second.c_str(); - return 0; -} - - -////////////////////// - -void XMLTextNode::append (XMLNode *node) { - if (XMLTextNode *tn = dynamic_cast(node)) - append(tn); - else - delete node; -} - - -void XMLTextNode::append (XMLTextNode *node) { - if (node) - _text += node->_text; - delete node; -} - - -void XMLTextNode::append (const string &str) { - _text += str; -} - - -void XMLTextNode::prepend (XMLNode *node) { - if (XMLTextNode *tn = dynamic_cast(node)) - prepend(tn); - else - delete node; -} - - -////////////////////// - -XMLDeclarationNode::XMLDeclarationNode (const string &n, const string &p) - : _name(n), _params(p), _emitted(false) -{ -} - - -XMLDeclarationNode::XMLDeclarationNode (const XMLDeclarationNode &node) - : _name(node._name), _params(node._params), _emitted(false) -{ - FORALL(node._children, list::const_iterator, it) - _children.push_back(new XMLDeclarationNode(**it)); -} - - -XMLDeclarationNode::~XMLDeclarationNode () { - FORALL(_children, list::iterator, i) - delete *i; -} - - -/** Appends another declaration node to this one. - * @param[in] child child to append, must be of type XMLDeclarationNode */ -void XMLDeclarationNode::append (XMLNode *child) { - if (XMLDeclarationNode *decl_node = dynamic_cast(child)) - _children.push_back(decl_node); - else - delete child; -} - - -ostream& XMLDeclarationNode::write (ostream &os) const { - os << "\n"; - else { - os << "[\n"; - FORALL(_children, list::const_iterator, i) - (*i)->write(os); - os << "]>\n"; - } - return os; -} - - -bool XMLDeclarationNode::emit (ostream &os, XMLNode *stopNode) { - if (this == stopNode) - return false; - - if (!_emitted) { - os << "\n"; - else - os << "[\n"; - _emitted = true; - } - if (!_children.empty()) { - FORALL(_children, list::iterator, i) { - if ((*i)->emit(os, stopNode)) { - list::iterator it = i++; // prevent i from being invalidated... - _children.erase(it); // ... by erase - --i; // @@ what happens if i points to first child? - } - else - return false; - } - os << "]>\n"; - } - return true; - -} - -////////////////////// - -ostream& XMLCDataNode::write (ostream &os) const { - os << "\n"; - return os; -} - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.h deleted file mode 100644 index 324bea068aa..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLNode.h +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* -** XMLNode.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef XMLNODE_H -#define XMLNODE_H - -#include -#include -#include -#include - -#include "SpecialActions.h" - - -struct XMLNode -{ - virtual ~XMLNode () {} - virtual XMLNode* clone () const =0; - virtual std::ostream& write (std::ostream &os) const =0; - virtual bool emit (std::ostream &os, XMLNode *stopElement); - virtual void append (XMLNode *child) {} - virtual void prepend (XMLNode *child) {} -}; - - -class XMLElementNode : public XMLNode -{ - typedef std::map AttribMap; - typedef std::list ChildList; - public: - XMLElementNode (const std::string &name); - XMLElementNode (const XMLElementNode &node); - ~XMLElementNode (); - XMLNode* clone () const {return new XMLElementNode(*this);} - void addAttribute (const std::string &name, const std::string &value); - void addAttribute (const std::string &name, double value); - void append (XMLNode *child); - void append (const std::string &str); - void prepend (XMLNode *child); - bool insertAfter (XMLNode *child, XMLNode *sibling); - bool insertBefore (XMLNode *child, XMLNode *sibling); - bool hasAttribute (const std::string &name) const; - const char* getAttributeValue (const std::string &name) const; - bool findDescendants (const char *name, const char *attr_name, std::vector &descendants); - std::ostream& write (std::ostream &os) const; - bool emit (std::ostream &os, XMLNode *stopElement); - bool empty () const {return _children.empty();} - const std::list& children () const {return _children;} - const std::string& getName () const {return _name;} - - private: - std::string _name; // element name (...) - AttribMap _attributes; - ChildList _children; // child nodes - bool _emitted; // true if node has been (partly) emitted -}; - - -class XMLTextNode : public XMLNode -{ - public: - XMLTextNode (const std::string &str) : _text(str) {} - XMLNode* clone () const {return new XMLTextNode(*this);} - void append (XMLNode *node); - void append (XMLTextNode *node); - void append (const std::string &str); - void prepend (XMLNode *child); - std::ostream& write (std::ostream &os) const {return os << _text;} - - private: - std::string _text; -}; - - -class XMLCommentNode : public XMLNode -{ - public: - XMLCommentNode (const std::string &str) : _text(str) {} - XMLNode* clone () const {return new XMLCommentNode(*this);} - std::ostream& write (std::ostream &os) const {return os << "\n";} - - private: - std::string _text; -}; - - -class XMLDeclarationNode : public XMLNode -{ - public: - XMLDeclarationNode (const std::string &n, const std::string &p); - XMLDeclarationNode (const XMLDeclarationNode &node); - ~XMLDeclarationNode (); - XMLNode* clone () const {return new XMLDeclarationNode(*this);} - void append (XMLNode *child); - std::ostream& write (std::ostream &os) const; - bool emit (std::ostream &os, XMLNode *stopElement); - - private: - std::string _name; - std::string _params; - std::list _children; - bool _emitted; -}; - - -class XMLCDataNode : public XMLNode -{ - public: - XMLCDataNode (const std::string &d) : _data(d) {} - XMLNode* clone () const {return new XMLCDataNode(*this);} - std::ostream& write (std::ostream &os) const; - - private: - std::string _data; -}; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.cpp deleted file mode 100644 index 326eaf89bdf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* -** XMLString.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "macros.h" -#include "XMLString.h" - -using namespace std; - -int XMLString::DECIMAL_PLACES = 0; - -static string translate (unsigned c) { - switch (c) { - case '<' : return "<"; - case '&' : return "&"; - case '"' : return """; - case '\'': return "'"; - } - ostringstream oss; - if (c >= 32 && c <= 126) - oss << char(c); - else - oss <<"&#" << unsigned(c) << ';'; - return oss.str(); -} - - -#if 0 -/** Returns the number of pre-decimal places of a given floating point value. */ -static int predecimal_places (double x) { - int n = abs(static_cast(x)); - int ret = (n == 0 ? 0 : 1); - while (n >= 10) { - ret++; - n /= 10; - } - return ret; -} -#endif - - -/** Rounds a floating point value to a given number of decimal places. - * @param[in] x number to round - * @param[in] n number of decimal places (must be between 1 and 6) - * @return rounded value */ -static inline double round (double x, long n) { - const long pow10[] = {10L, 100L, 1000L, 10000L, 100000L, 1000000L}; - n--; - return floor(x*pow10[n]+0.5)/pow10[n]; -} - - -XMLString::XMLString (const string &str, bool plain) { - if (plain) - *this = str; - else { - FORALL(str, string::const_iterator, i) - *this += translate(*i); - } -} - - -XMLString::XMLString (const char *str, bool plain) { - if (str) { - if (plain) - *this = str; - else { - while (*str) - *this += translate(*str++); - } - } -} - - -XMLString::XMLString (int n, bool cast) { - if (cast) { - stringstream ss; - ss << n; - ss >> *this; - } - else - *this += translate(n); -} - - -XMLString::XMLString (double x) { - stringstream ss; - if (DECIMAL_PLACES > 0) - x = round(x, DECIMAL_PLACES); - ss << x; - ss >> *this; -} - - -/* -ostream& XMLString::write (ostream &os) const { - const string *self = static_cast(this); - FORALL(*self, string::const_iterator, i) { - unsigned char c = *i; - switch (c) { - case '<' : os << "<"; break; - case '&' : os << "&"; break; - case '"' : os << """; break; - case '\'': os << "'"; break; - default : - if (c >= 32 && c <= 126) - os << c; - else - os << "&#" << int(c) << ';'; - } - } - return os; -} -*/ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.h deleted file mode 100644 index b1496b4a503..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/XMLString.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************* -** XMLString.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef XMLSTRING_H -#define XMLSTRING_H - -#include - - -class XMLString : public std::string -{ - public: - XMLString () : std::string() {} - XMLString (const char *str, bool plain=false); - XMLString (const std::string &str, bool plain=false); - XMLString (int n, bool cast=true); - XMLString (double x); - - static int DECIMAL_PLACES; ///< number of decimal places applied to floating point values (0-6) -}; - - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/dvisvgm.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/dvisvgm.cpp deleted file mode 100644 index f275ee65e52..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/dvisvgm.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************************* -** dvisvgm.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "gzstream.h" -#include "CommandLine.h" -#include "DVIToSVG.h" -#include "DVIToSVGActions.h" -#include "EPSToSVG.h" -#include "FilePath.h" -#include "FileSystem.h" -#include "Font.h" -#include "FontCache.h" -#include "FontEngine.h" -#include "FontMap.h" -#include "Ghostscript.h" -#include "InputReader.h" -#include "Message.h" -#include "FileFinder.h" -#include "PageSize.h" -#include "SignalHandler.h" -#include "SpecialManager.h" -#include "SVGOutputBase.h" -#include "System.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#include "PSInterpreter.h" -#endif -#ifndef TARGET_SYSTEM -#define TARGET_SYSTEM "" -#endif - -#ifdef __MSVC__ -#include -#else -extern "C" { -#include -} -#endif - -using namespace std; - -class SVGOutput : public SVGOutputBase -{ - public: - SVGOutput (const char *base=0, string pattern="", int zip_level=0) - : _path(base ? base : ""), - _pattern(pattern), - _stdout(base == 0), - _zipLevel(zip_level), - _page(-1), - _os(0) {} - - - ~SVGOutput () { - delete _os; - } - - - /** Returns an output stream for the given page. - * @param[in] page number of current page - * @param[in] numPages total number of pages in the DVI file - * @return output stream for the given page */ - ostream& getPageStream (int page, int numPages) const { - string fname = filename(page, numPages); - if (fname.empty()) { - delete _os; - _os = 0; - return cout; - } - if (page == _page) - return *_os; - - _page = page; - delete _os; - - if (_zipLevel > 0) - _os = new ogzstream(fname.c_str(), _zipLevel); - else - _os = new ofstream(fname.c_str()); - if (!_os || !*_os) { - delete _os; - _os = 0; - throw MessageException("can't open file "+fname+" for writing"); - } - return *_os; - } - - - /** Returns the name of the SVG file containing the given page. - * @param[in] page number of page */ - string filename (int page, int numPages) const { - if (_stdout) - return ""; - string fname = _pattern; - if (fname.empty()) - fname = numPages > 1 ? "%f-%p" : "%f"; - else if (numPages > 1 && fname.find("%p") == string::npos) - fname += FileSystem::isDirectory(fname.c_str()) ? "/%f-%p" : "-%p"; - - // replace pattern variables by their actual values - // %f: basename of the DVI file - // %p: current page number - ostringstream oss; - oss << setfill('0') << setw(max(2, int(1+log10((double)numPages)))) << page; - size_t pos=0; - while ((pos = fname.find('%', pos)) != string::npos && pos < fname.length()-1) { - switch (fname[pos+1]) { - case 'f': fname.replace(pos, 2, _path.basename()); pos += _path.basename().length(); break; - case 'p': fname.replace(pos, 2, oss.str()); pos += oss.str().length(); break; - default : ++pos; - } - } - FilePath outpath(fname, true); - if (outpath.suffix().empty()) - outpath.suffix(_zipLevel > 0 ? "svgz" : "svg"); - string apath = outpath.absolute(); - string rpath = outpath.relative(); - return apath.length() < rpath.length() ? apath : rpath; - } - - private: - FilePath _path; - string _pattern; - bool _stdout; - int _zipLevel; - mutable int _page; // number of current page being written - mutable ostream *_os; -}; - -//////////////////////////////////////////////////////////////////////////////// - -static void show_help (const CommandLine &cmd) { - cout << PACKAGE_STRING "\n\n"; - cmd.help(cmd.help_arg()); - cout << "\nCopyright (C) 2005-2013 Martin Gieseking \n\n"; -} - - -static string remove_path (string fname) { - fname = FileSystem::adaptPathSeperators(fname); - size_t slashpos = fname.rfind('/'); - if (slashpos == string::npos) - return fname; - return fname.substr(slashpos+1); -} - - -static string ensure_suffix (string fname, const string &suffix) { - size_t dotpos = remove_path(fname).rfind('.'); - if (dotpos == string::npos) - fname += "."+suffix; - return fname; -} - - -static string get_transformation_string (const CommandLine &args) { - ostringstream oss; - if (args.rotate_given()) - oss << 'R' << args.rotate_arg() << ",w/2,h/2"; - if (args.translate_given()) - oss << 'T' << args.translate_arg(); - if (args.scale_given()) - oss << 'S' << args.scale_arg(); - if (args.transform_given()) - oss << args.transform_arg(); - return oss.str(); -} - - -static void set_libgs (CommandLine &args) { -#if !defined(DISABLE_GS) && !defined(HAVE_LIBGS) - if (args.libgs_given()) - Ghostscript::LIBGS_NAME = args.libgs_arg(); - else if (getenv("LIBGS")) - Ghostscript::LIBGS_NAME = getenv("LIBGS"); -#endif -} - - -static bool set_cache_dir (const CommandLine &args) { - if (args.cache_given() && !args.cache_arg().empty()) { - if (args.cache_arg() == "none") - PhysicalFont::CACHE_PATH = 0; - else if (FileSystem::exists(args.cache_arg().c_str())) - PhysicalFont::CACHE_PATH = args.cache_arg().c_str(); - else - Message::wstream(true) << "cache directory '" << args.cache_arg() << "' does not exist (caching disabled)\n"; - } - else { - if (const char *userdir = FileSystem::userdir()) { - static string path = userdir; - path += "/.dvisvgm"; - path = FileSystem::adaptPathSeperators(path); - const string cachepath = path+"/cache"; - if (!FileSystem::exists(cachepath.c_str())) { - if (!FileSystem::exists(path.c_str())) - FileSystem::mkdir(cachepath.c_str()); - else { - FileSystem::mkdir(cachepath.c_str()); - // move existing cache files from former location to new one - vector files; - FileSystem::collect(path.c_str(), files); - FORALL(files, vector::iterator, it) { - if (it->at(0) == 'f' && it->length() > 4 && it->substr(it->length()-4, 4) == ".fgd") { - const char *fname = it->c_str()+1; - FileSystem::copy(path+"/"+fname, cachepath+"/"+fname, true); - } - } - } - } - path = cachepath; - PhysicalFont::CACHE_PATH = path.c_str(); - } - if (args.cache_given() && args.cache_arg().empty()) { - cout << "cache directory: " << (PhysicalFont::CACHE_PATH ? PhysicalFont::CACHE_PATH : "(none)") << '\n'; - FontCache::fontinfo(PhysicalFont::CACHE_PATH, cout, true); - return false; - } - } - return true; -} - - -static bool check_bbox (const string &bboxstr) { - const char *formats[] = {"none", "min", "dvi", 0}; - for (const char **p=formats; *p; ++p) - if (bboxstr == *p) - return true; - if (isalpha(bboxstr[0])) { - try { - PageSize size(bboxstr); - return true; - } - catch (const PageSizeException &e) { - Message::estream(true) << "invalid bounding box format '" << bboxstr << "'\n"; - return false; - } - } - try { - BoundingBox bbox; - bbox.set(bboxstr); - return true; - } - catch (const MessageException &e) { - Message::estream(true) << e.what() << '\n'; - return false; - } -} - - -static void print_version (bool extended) { - ostringstream oss; - oss << PACKAGE_STRING; - if (extended) { - if (strlen(TARGET_SYSTEM) > 0) - oss << " (" TARGET_SYSTEM ")"; - oss << "\n" << string(oss.str().length()-1, '-') << "\n" - "freetype: " << FontEngine::version() << "\n"; - - string gsver; - Ghostscript gs; - gsver = gs.revision(true); - if (!gsver.empty()) - oss << "Ghostscript: " << gsver + "\n"; - oss << -#ifdef MIKTEX - "MiKTeX: " << FileFinder::version() << "\n" -#else - "kpathsea: " << FileFinder::version() << "\n" -#endif - "potrace: " << (strchr(potrace_version(), ' ') ? strchr(potrace_version(), ' ')+1 : "unknown") << "\n" - "zlib: " << zlibVersion(); - } - cout << oss.str() << endl; -} - - -static void init_fontmap (const CommandLine &args) { - const char *mapseq = args.fontmap_given() ? args.fontmap_arg().c_str() : 0; - bool additional = mapseq && strchr("+-=", *mapseq); - if (!mapseq || additional) { - const char *mapfiles[] = {"ps2pk.map", "dvipdfm.map", "psfonts.map", 0}; - bool found = false; - for (const char **p=mapfiles; *p && !found; p++) - found = FontMap::instance().read(*p); - if (!found) - Message::wstream(true) << "none of the default map files could be found"; - } - if (mapseq) - FontMap::instance().read(mapseq); -} - - -int main (int argc, char *argv[]) { - CommandLine args; - args.parse(argc, argv); - if (args.error()) - return 1; - - Message::COLORIZE = args.color_given(); - - set_libgs(args); - if (args.version_given()) { - print_version(args.version_arg()); - return 0; - } - if (args.list_specials_given()) { - SVGOutput out; - DVIToSVG dvisvg(cin, out); - if (const SpecialManager *sm = dvisvg.setProcessSpecials()) - sm->writeHandlerInfo(cout); - return 0; - } - - if (!set_cache_dir(args)) - return 0; - - if (argc == 1 || args.help_given()) { - show_help(args); - return 0; - } - - if (argc > 1 && args.numFiles() < 1) { - Message::estream(true) << "no input file given\n"; - return 1; - } - - if (args.stdout_given() && args.zip_given()) { - Message::estream(true) << "writing SVGZ files to stdout is not supported\n"; - return 1; - } - - if (!check_bbox(args.bbox_arg())) - return 1; - - if (args.progress_given()) { - DVIReader::COMPUTE_PAGE_LENGTH = args.progress_given(); - DVIToSVGActions::PROGRESSBAR_DELAY = args.progress_arg(); - } - SVGTree::CREATE_STYLE = !args.no_styles_given(); - SVGTree::USE_FONTS = !args.no_fonts_given(); - SVGTree::CREATE_USE_ELEMENTS = args.no_fonts_arg() < 1; - DVIToSVGActions::EXACT_BBOX = args.exact_given(); - DVIToSVG::TRACE_MODE = args.trace_all_given() ? (args.trace_all_arg() ? 'a' : 'm') : 0; - Message::LEVEL = args.verbosity_arg(); - PhysicalFont::KEEP_TEMP_FILES = args.keep_given(); - PhysicalFont::METAFONT_MAG = args.mag_arg(); - XMLString::DECIMAL_PLACES = max(0, min(6, args.precision_arg())); - - double start_time = System::time(); - string inputfile = ensure_suffix(args.file(0), args.eps_given() ? "eps" : "dvi"); - ifstream ifs(inputfile.c_str(), ios_base::binary|ios_base::in); - if (!ifs) { - Message::estream(true) << "can't open file '" << inputfile << "' for reading\n"; - return 0; - } - try { - FileFinder::init(argv[0], "dvisvgm", !args.no_mktexmf_given()); - SVGOutput out(args.stdout_given() ? 0 : inputfile.c_str(), args.output_arg(), args.zip_given() ? args.zip_arg() : 0); - SignalHandler::instance().start(); - if (args.eps_given()) { - EPSToSVG eps2svg(inputfile, out); - eps2svg.convert(); - Message::mstream().indent(0); - Message::mstream(false, Message::MC_PAGE_NUMBER) - << "file converted in " << (System::time()-start_time) << " seconds\n"; - } - else { - DVIToSVG dvi2svg(ifs, out); - const char *ignore_specials = args.no_specials_given() ? (args.no_specials_arg().empty() ? "*" : args.no_specials_arg().c_str()) : 0; - dvi2svg.setProcessSpecials(ignore_specials, true); - dvi2svg.setTransformation(get_transformation_string(args)); - dvi2svg.setPageSize(args.bbox_arg()); - - init_fontmap(args); - pair pageinfo; - dvi2svg.convert(args.page_arg(), &pageinfo); - Message::mstream().indent(0); - Message::mstream(false, Message::MC_PAGE_NUMBER) << "\n" << pageinfo.first << " of " << pageinfo.second << " page"; - if (pageinfo.second > 1) - Message::mstream(false, Message::MC_PAGE_NUMBER) << 's'; - Message::mstream(false, Message::MC_PAGE_NUMBER) << " converted in " << (System::time()-start_time) << " seconds\n"; - } - } - catch (DVIException &e) { - Message::estream() << "\nDVI error: " << e.what() << '\n'; - } - catch (PSException &e) { - Message::estream() << "\nPostScript error: " << e.what() << '\n'; - } - catch (SignalException &e) { - Message::wstream(true) << "execution interrupted by user\n"; - } - catch (MessageException &e) { - Message::estream(true) << e.what() << '\n'; - } - FileFinder::finish(); - return 0; -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.cpp deleted file mode 100644 index 2893c299891..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// ============================================================================ -// gzstream, C++ iostream classes wrapping the zlib compression library. -// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// ============================================================================ -// -// File : gzstream.C -// Revision : $Revision: 1.3 $ -// Revision_date : $Date: 2006/01/05 16:22:35 $ -// Author(s) : Deepak Bandyopadhyay, Lutz Kettner -// -// Standard streambuf implementation following Nicolai Josuttis, "The -// Standard C++ Library". -// ============================================================================ - -#include "gzstream.h" -#include -#include // for memcpy - -#ifdef GZSTREAM_NAMESPACE -namespace GZSTREAM_NAMESPACE { -#endif - -const int gzstreambuf::bufferSize = 47+256; // size of data buff - -// ---------------------------------------------------------------------------- -// Internal classes to implement gzstream. See header file for user classes. -// ---------------------------------------------------------------------------- - -// -------------------------------------- -// class gzstreambuf: -// -------------------------------------- - -gzstreambuf* gzstreambuf::open(const char* name, int compression_level, int open_mode) { - if ( is_open()) - return (gzstreambuf*)0; - mode = open_mode; - // no append nor read/write mode - if ((mode & std::ios::ate) || (mode & std::ios::app) - || ((mode & std::ios::in) && (mode & std::ios::out))) - return (gzstreambuf*)0; - if (compression_level < 1) - compression_level = 1; - else if (compression_level > 9) - compression_level = 9; - char fmode[10]; - char* fmodeptr = fmode; - if ( mode & std::ios::in) - *fmodeptr++ = 'r'; - else if ( mode & std::ios::out) - *fmodeptr++ = 'w'; - *fmodeptr++ = 'b'; - *fmodeptr++ = '0'+compression_level; - *fmodeptr = '\0'; - file = gzopen( name, fmode); - if (file == 0) - return (gzstreambuf*)0; - opened = 1; - return this; -} - -gzstreambuf * gzstreambuf::close() { - if ( is_open()) { - sync(); - opened = 0; - if ( gzclose( file) == Z_OK) - return this; - } - return (gzstreambuf*)0; -} - -int gzstreambuf::underflow() { // used for input buffer only - if ( gptr() && ( gptr() < egptr())) - return * reinterpret_cast( gptr()); - - if ( ! (mode & std::ios::in) || ! opened) - return EOF; - // Josuttis' implementation of inbuf - int n_putback = gptr() - eback(); - if ( n_putback > 4) - n_putback = 4; - memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback); - - int num = gzread( file, buffer+4, bufferSize-4); - if (num <= 0) // ERROR or EOF - return EOF; - - // reset buffer pointers - setg( buffer + (4 - n_putback), // beginning of putback area - buffer + 4, // read position - buffer + 4 + num); // end of buffer - - // return next character - return * reinterpret_cast( gptr()); -} - -int gzstreambuf::flush_buffer() { - // Separate the writing of the buffer from overflow() and - // sync() operation. - int w = pptr() - pbase(); - if ( gzwrite( file, pbase(), w) != w) - return EOF; - pbump( -w); - return w; -} - -int gzstreambuf::overflow( int c) { // used for output buffer only - if ( ! ( mode & std::ios::out) || ! opened) - return EOF; - if (c != EOF) { - *pptr() = c; - pbump(1); - } - if ( flush_buffer() == EOF) - return EOF; - return c; -} - -int gzstreambuf::sync() { - // Changed to use flush_buffer() instead of overflow( EOF) - // which caused improper behavior with std::endl and flush(), - // bug reported by Vincent Ricard. - if ( pptr() && pptr() > pbase()) { - if ( flush_buffer() == EOF) - return -1; - } - return 0; -} - -// -------------------------------------- -// class gzstreambase: -// -------------------------------------- - -gzstreambase::gzstreambase( const char* name, int compression_level, int mode) { - init( &buf); - open( name, compression_level, mode); -} - -gzstreambase::~gzstreambase() { - buf.close(); -} - -void gzstreambase::open( const char* name, int compression_level, int open_mode) { - if ( ! buf.open( name, compression_level, open_mode)) - clear( rdstate() | std::ios::badbit); -} - -void gzstreambase::close() { - if ( buf.is_open()) - if ( ! buf.close()) - clear( rdstate() | std::ios::badbit); -} - -#ifdef GZSTREAM_NAMESPACE -} // namespace GZSTREAM_NAMESPACE -#endif - -// ============================================================================ -// EOF // diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.h deleted file mode 100644 index 60f38c4fac7..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/gzstream.h +++ /dev/null @@ -1,121 +0,0 @@ -// ============================================================================ -// gzstream, C++ iostream classes wrapping the zlib compression library. -// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// ============================================================================ -// -// File : gzstream.h -// Revision : $Revision: 1.3 $ -// Revision_date : $Date: 2006/01/05 16:22:35 $ -// Author(s) : Deepak Bandyopadhyay, Lutz Kettner -// -// Standard streambuf implementation following Nicolai Josuttis, "The -// Standard C++ Library". -// ============================================================================ - -#ifndef GZSTREAM_H -#define GZSTREAM_H 1 - -// standard C++ with new header file names and std:: namespace -#include -#include -#include - -#ifdef GZSTREAM_NAMESPACE -namespace GZSTREAM_NAMESPACE { -#endif - -// ---------------------------------------------------------------------------- -// Internal classes to implement gzstream. See below for user classes. -// ---------------------------------------------------------------------------- - -class gzstreambuf : public std::streambuf { -private: - static const int bufferSize; // size of data buff - // totals 512 bytes under g++ for igzstream at the end. - - gzFile file; // file handle for compressed file - char buffer[47+256]; // data buffer - char opened; // open/close state of stream - int mode; // I/O mode - - int flush_buffer(); -public: - gzstreambuf() : opened(0) { - setp( buffer, buffer + (bufferSize-1)); - setg( buffer + 4, // beginning of putback area - buffer + 4, // read position - buffer + 4); // end position - // ASSERT: both input & output capabilities will not be used together - } - int is_open() { return opened; } - gzstreambuf* open(const char* name, int compression_level, int open_mode); - gzstreambuf* close(); - ~gzstreambuf() { close(); } - - virtual int overflow( int c = EOF); - virtual int underflow(); - virtual int sync(); -}; - -class gzstreambase : virtual public std::ios { -protected: - gzstreambuf buf; -public: - gzstreambase() { init(&buf); } - gzstreambase( const char* name, int compression_level, int open_mode); - ~gzstreambase(); - void open( const char* name, int compression_level, int open_mode); - void close(); - gzstreambuf* rdbuf() { return &buf; } -}; - -// ---------------------------------------------------------------------------- -// User classes. Use igzstream and ogzstream analogously to ifstream and -// ofstream respectively. They read and write files based on the gz* -// function interface of the zlib. Files are compatible with gzip compression. -// ---------------------------------------------------------------------------- - -class igzstream : public gzstreambase, public std::istream { -public: - igzstream() : std::istream( &buf) {} - igzstream( const char* name, int compression_level, int open_mode = std::ios::in) - : gzstreambase(name, compression_level, open_mode), std::istream( &buf) {} - gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } - void open( const char* name, int compression_level, int open_mode = std::ios::in) { - gzstreambase::open( name, compression_level, open_mode); - } -}; - -class ogzstream : public gzstreambase, public std::ostream { -public: - ogzstream() : std::ostream( &buf) {} - ogzstream( const char* name, int compression_level, int mode = std::ios::out) - : gzstreambase(name, compression_level, mode), std::ostream( &buf) {} - gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } - void open( const char* name, int compression_level, int open_mode = std::ios::out) { - gzstreambase::open(name, compression_level, open_mode); - } -}; - -#ifdef GZSTREAM_NAMESPACE -} // namespace GZSTREAM_NAMESPACE -#endif - -#endif // GZSTREAM_H -// ============================================================================ -// EOF // - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/iapi.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/iapi.h deleted file mode 100644 index 8e29d938d03..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/iapi.h +++ /dev/null @@ -1,300 +0,0 @@ -/* Copyright (C) 2001-2006 Artifex Software, Inc. - All Rights Reserved. - - This software is provided AS-IS with no warranty, either express or - implied. - - This software is distributed under license and may not be copied, modified - or distributed except as expressly authorized under the terms of that - license. Refer to licensing information at http://www.artifex.com/ - or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, - San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. -*/ - -/* $Id: iapi.h 9043 2008-08-28 22:48:19Z giles $ */ - -/* - * Public API for Ghostscript interpreter - * for use both as DLL and for static linking. - * - * Should work for Windows, OS/2, Linux, Mac. - * - * DLL exported functions should be as similar as possible to imain.c - * You will need to include "ierrors.h". - * - * Current problems: - * 1. Ghostscript does not support multiple instances. - * 2. Global variables in gs_main_instance_default() - * and gsapi_instance_counter - */ - -/* Exported functions may need different prefix - * GSDLLEXPORT marks functions as exported - * GSDLLAPI is the calling convention used on functions exported - * by Ghostscript - * GSDLLCALL is used on callback functions called by Ghostscript - * When you include this header file in the caller, you may - * need to change the definitions by defining these - * before including this header file. - * Make sure you get the calling convention correct, otherwise your - * program will crash either during callbacks or soon after returning - * due to stack corruption. - */ - -#ifndef iapi_INCLUDED -# define iapi_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WINDOWS_) || defined(__WINDOWS__) -# ifndef _Windows -# define _Windows -# endif -#endif - -#ifdef _Windows -# ifndef GSDLLEXPORT -# define GSDLLEXPORT __declspec(dllexport) -# endif -# ifndef GSDLLAPI -# define GSDLLAPI __stdcall -# endif -# ifndef GSDLLCALL -# define GSDLLCALL __stdcall -# endif -#endif /* _Windows */ - -#if defined(OS2) && defined(__IBMC__) -# ifndef GSDLLAPI -# define GSDLLAPI _System -# endif -# ifndef GSDLLCALL -# define GSDLLCALL _System -# endif -#endif /* OS2 && __IBMC */ - -#ifdef __MACOS__ -# pragma export on -#endif - -#ifndef GSDLLEXPORT -# define GSDLLEXPORT -#endif -#ifndef GSDLLAPI -# define GSDLLAPI -#endif -#ifndef GSDLLCALL -# define GSDLLCALL -#endif - -#if defined(__IBMC__) -# define GSDLLAPIPTR * GSDLLAPI -# define GSDLLCALLPTR * GSDLLCALL -#else -# define GSDLLAPIPTR GSDLLAPI * -# define GSDLLCALLPTR GSDLLCALL * -#endif - -#ifndef display_callback_DEFINED -# define display_callback_DEFINED -typedef struct display_callback_s display_callback; -#endif - -typedef struct gsapi_revision_s { - const char *product; - const char *copyright; - long revision; - long revisiondate; -} gsapi_revision_t; - - -/* Get version numbers and strings. - * This is safe to call at any time. - * You should call this first to make sure that the correct version - * of the Ghostscript is being used. - * pr is a pointer to a revision structure. - * len is the size of this structure in bytes. - * Returns 0 if OK, or if len too small (additional parameters - * have been added to the structure) it will return the required - * size of the structure. - */ -GSDLLEXPORT int GSDLLAPI -gsapi_revision(gsapi_revision_t *pr, int len); - -/* - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * Ghostscript supports only one instance. - * The current implementation uses a global static instance - * counter to make sure that only a single instance is used. - * If you try to create two instances, the second attempt - * will return < 0 and set pinstance to NULL. - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ -/* Create a new instance of Ghostscript. - * This instance is passed to most other API functions. - * The caller_handle will be provided to callback functions. - */ - -GSDLLEXPORT int GSDLLAPI -gsapi_new_instance(void **pinstance, void *caller_handle); - -/* - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * Ghostscript supports only one instance. - * The current implementation uses a global static instance - * counter to make sure that only a single instance is used. - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ -/* Destroy an instance of Ghostscript - * Before you call this, Ghostscript must have finished. - * If Ghostscript has been initialised, you must call gsapi_exit() - * before gsapi_delete_instance. - */ -GSDLLEXPORT void GSDLLAPI -gsapi_delete_instance(void *instance); - -/* Set the callback functions for stdio - * The stdin callback function should return the number of - * characters read, 0 for EOF, or -1 for error. - * The stdout and stderr callback functions should return - * the number of characters written. - * If a callback address is NULL, the real stdio will be used. - */ -GSDLLEXPORT int GSDLLAPI -gsapi_set_stdio(void *instance, - int (GSDLLCALLPTR stdin_fn)(void *caller_handle, char *buf, int len), - int (GSDLLCALLPTR stdout_fn)(void *caller_handle, const char *str, int len), - int (GSDLLCALLPTR stderr_fn)(void *caller_handle, const char *str, int len)); - -/* Set the callback function for polling. - * This is used for handling window events or cooperative - * multitasking. This function will only be called if - * Ghostscript was compiled with CHECK_INTERRUPTS - * as described in gpcheck.h. - * The polling function should return 0 if all is well, - * and negative if it wants ghostscript to abort. - * The polling function must be fast. - */ -GSDLLEXPORT int GSDLLAPI gsapi_set_poll(void *instance, - int (GSDLLCALLPTR poll_fn)(void *caller_handle)); - -/* Set the display device callback structure. - * If the display device is used, this must be called - * after gsapi_new_instance() and before gsapi_init_with_args(). - * See gdevdisp.h for more details. - */ -GSDLLEXPORT int GSDLLAPI gsapi_set_display_callback( - void *instance, display_callback *callback); - - -/* Initialise the interpreter. - * This calls gs_main_init_with_args() in imainarg.c - * 1. If quit or EOF occur during gsapi_init_with_args(), - * the return value will be e_Quit. This is not an error. - * You must call gsapi_exit() and must not call any other - * gsapi_XXX functions. - * 2. If usage info should be displayed, the return value will be e_Info - * which is not an error. Do not call gsapi_exit(). - * 3. Under normal conditions this returns 0. You would then - * call one or more gsapi_run_*() functions and then finish - * with gsapi_exit(). - */ -GSDLLEXPORT int GSDLLAPI gsapi_init_with_args(void *instance, - int argc, char **argv); - -/* - * The gsapi_run_* functions are like gs_main_run_* except - * that the error_object is omitted. - * If these functions return <= -100, either quit or a fatal - * error has occured. You then call gsapi_exit() next. - * The only exception is gsapi_run_string_continue() - * which will return e_NeedInput if all is well. - */ - -GSDLLEXPORT int GSDLLAPI -gsapi_run_string_begin(void *instance, - int user_errors, int *pexit_code); - -GSDLLEXPORT int GSDLLAPI -gsapi_run_string_continue(void *instance, - const char *str, unsigned int length, int user_errors, int *pexit_code); - -GSDLLEXPORT int GSDLLAPI -gsapi_run_string_end(void *instance, - int user_errors, int *pexit_code); - -GSDLLEXPORT int GSDLLAPI -gsapi_run_string_with_length(void *instance, - const char *str, unsigned int length, int user_errors, int *pexit_code); - -GSDLLEXPORT int GSDLLAPI -gsapi_run_string(void *instance, - const char *str, int user_errors, int *pexit_code); - -GSDLLEXPORT int GSDLLAPI -gsapi_run_file(void *instance, - const char *file_name, int user_errors, int *pexit_code); - - -/* Exit the interpreter. - * This must be called on shutdown if gsapi_init_with_args() - * has been called, and just before gsapi_delete_instance(). - */ -GSDLLEXPORT int GSDLLAPI -gsapi_exit(void *instance); - -/* Visual Tracer */ -/* This function is only for debug purpose clients */ -struct vd_trace_interface_s; -GSDLLEXPORT void GSDLLAPI -gsapi_set_visual_tracer(struct vd_trace_interface_s *I); - - -/* function prototypes */ -typedef int (GSDLLAPIPTR PFN_gsapi_revision)( - gsapi_revision_t *pr, int len); -typedef int (GSDLLAPIPTR PFN_gsapi_new_instance)( - void **pinstance, void *caller_handle); -typedef void (GSDLLAPIPTR PFN_gsapi_delete_instance)( - void *instance); -typedef int (GSDLLAPIPTR PFN_gsapi_set_stdio)(void *instance, - int (GSDLLCALLPTR stdin_fn)(void *caller_handle, char *buf, int len), - int (GSDLLCALLPTR stdout_fn)(void *caller_handle, const char *str, int len), - int (GSDLLCALLPTR stderr_fn)(void *caller_handle, const char *str, int len)); -typedef int (GSDLLAPIPTR PFN_gsapi_set_poll)(void *instance, - int(GSDLLCALLPTR poll_fn)(void *caller_handle)); -typedef int (GSDLLAPIPTR PFN_gsapi_set_display_callback)( - void *instance, display_callback *callback); -typedef int (GSDLLAPIPTR PFN_gsapi_init_with_args)( - void *instance, int argc, char **argv); -typedef int (GSDLLAPIPTR PFN_gsapi_run_string_begin)( - void *instance, int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_run_string_continue)( - void *instance, const char *str, unsigned int length, - int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_run_string_end)( - void *instance, int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_run_string_with_length)( - void *instance, const char *str, unsigned int length, - int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_run_string)( - void *instance, const char *str, - int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_run_file)(void *instance, - const char *file_name, int user_errors, int *pexit_code); -typedef int (GSDLLAPIPTR PFN_gsapi_exit)(void *instance); -typedef void (GSDLLAPIPTR PFN_gsapi_set_visual_tracer) - (struct vd_trace_interface_s *I); - - -#ifdef __MACOS__ -#pragma export off -#endif - -#ifdef __cplusplus -} /* extern 'C' protection */ -#endif - -#endif /* iapi_INCLUDED */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ierrors.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ierrors.h deleted file mode 100644 index 3184341177e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/ierrors.h +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (C) 2001-2006 Artifex Software, Inc. - All Rights Reserved. - - This software is provided AS-IS with no warranty, either express or - implied. - - This software is distributed under license and may not be copied, modified - or distributed except as expressly authorized under the terms of that - license. Refer to licensing information at http://www.artifex.com/ - or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, - San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. -*/ - -/* $Id: ierrors.h 8022 2007-06-05 22:23:38Z giles $ */ -/* Definition of error codes */ - -#ifndef ierrors_INCLUDED -# define ierrors_INCLUDED - -/* - * DO NOT USE THIS FILE IN THE GRAPHICS LIBRARY. - * THIS FILE IS PART OF THE POSTSCRIPT INTERPRETER. - * USE gserrors.h IN THE LIBRARY. - */ - -/* - * A procedure that may return an error always returns - * a non-negative value (zero, unless otherwise noted) for success, - * or negative for failure. - * We use ints rather than an enum to avoid a lot of casting. - */ - -/* Define the error name table */ -extern const char *const gs_error_names[]; - - /* ------ PostScript Level 1 errors ------ */ - -#define e_unknownerror (-1) /* unknown error */ -#define e_dictfull (-2) -#define e_dictstackoverflow (-3) -#define e_dictstackunderflow (-4) -#define e_execstackoverflow (-5) -#define e_interrupt (-6) -#define e_invalidaccess (-7) -#define e_invalidexit (-8) -#define e_invalidfileaccess (-9) -#define e_invalidfont (-10) -#define e_invalidrestore (-11) -#define e_ioerror (-12) -#define e_limitcheck (-13) -#define e_nocurrentpoint (-14) -#define e_rangecheck (-15) -#define e_stackoverflow (-16) -#define e_stackunderflow (-17) -#define e_syntaxerror (-18) -#define e_timeout (-19) -#define e_typecheck (-20) -#define e_undefined (-21) -#define e_undefinedfilename (-22) -#define e_undefinedresult (-23) -#define e_unmatchedmark (-24) -#define e_VMerror (-25) /* must be the last Level 1 error */ - -#define LEVEL1_ERROR_NAMES\ - "unknownerror", "dictfull", "dictstackoverflow", "dictstackunderflow",\ - "execstackoverflow", "interrupt", "invalidaccess", "invalidexit",\ - "invalidfileaccess", "invalidfont", "invalidrestore", "ioerror",\ - "limitcheck", "nocurrentpoint", "rangecheck", "stackoverflow",\ - "stackunderflow", "syntaxerror", "timeout", "typecheck", "undefined",\ - "undefinedfilename", "undefinedresult", "unmatchedmark", "VMerror" - - /* ------ Additional Level 2 errors (also in DPS) ------ */ - -#define e_configurationerror (-26) -#define e_undefinedresource (-27) -#define e_unregistered (-28) - -#define LEVEL2_ERROR_NAMES\ - "configurationerror", "undefinedresource", "unregistered" - - /* ------ Additional DPS errors ------ */ - -#define e_invalidcontext (-29) -/* invalidid is for the NeXT DPS extension. */ -#define e_invalidid (-30) - -#define DPS_ERROR_NAMES\ - "invalidcontext", "invalidid" - -#define ERROR_NAMES\ - LEVEL1_ERROR_NAMES, LEVEL2_ERROR_NAMES, DPS_ERROR_NAMES - - /* ------ Pseudo-errors used internally ------ */ - -/* - * Internal code for a fatal error. - * gs_interpret also returns this for a .quit with a positive exit code. - */ -#define e_Fatal (-100) - -/* - * Internal code for the .quit operator. - * The real quit code is an integer on the operand stack. - * gs_interpret returns this only for a .quit with a zero exit code. - */ -#define e_Quit (-101) - -/* - * Internal code for a normal exit from the interpreter. - * Do not use outside of interp.c. - */ -#define e_InterpreterExit (-102) - -/* - * Internal code that indicates that a procedure has been stored in the - * remap_proc of the graphics state, and should be called before retrying - * the current token. This is used for color remapping involving a call - * back into the interpreter -- inelegant, but effective. - */ -#define e_RemapColor (-103) - -/* - * Internal code to indicate we have underflowed the top block - * of the e-stack. - */ -#define e_ExecStackUnderflow (-104) - -/* - * Internal code for the vmreclaim operator with a positive operand. - * We need to handle this as an error because otherwise the interpreter - * won't reload enough of its state when the operator returns. - */ -#define e_VMreclaim (-105) - -/* - * Internal code for requesting more input from run_string. - */ -#define e_NeedInput (-106) - -/* - * Internal code for a normal exit when usage info is displayed. - * This allows Window versions of Ghostscript to pause until - * the message can be read. - */ -#define e_Info (-110) - -/* - * Define which error codes require re-executing the current object. - */ -#define ERROR_IS_INTERRUPT(ecode)\ - ((ecode) == e_interrupt || (ecode) == e_timeout) - -#endif /* ierrors_INCLUDED */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/macros.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/macros.h deleted file mode 100644 index 8935b9babe9..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/macros.h +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************* -** macros.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef MACROS_H -#define MACROS_H - -#define FORALL(container, itertype, itervar) \ - for (itertype itervar=(container).begin(); itervar != (container).end(); ++itervar) - -#define IMPLEMENT_ARITHMETIC_OPERATOR(class, op) \ - inline class operator op (class a, const class &b) { \ - return a op##= b; \ - } - -#define IMPLEMENT_ARITHMETIC_OPERATOR2(class, scalar, op) \ - inline class operator op (class a, scalar b) { \ - return a op##= b; \ - } - -#define IMPLEMENT_OUTPUT_OPERATOR(class) \ - inline std::ostream& operator << (std::ostream &os, class obj) { \ - return obj.write(os); \ - } - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/options.xml b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/options.xml deleted file mode 100644 index 6f4e2875cd2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/options.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - dvisvgm - [options] dvifile - -E [options] epsfile - This program converts DVI files, as created by TeX/LaTeX, to\nthe XML-based scalable vector graphics format SVG. - - -
- - - -
-
- - - - - - - -
-
- - - - -
-
- - - - - - - - -
-
- - - - - - -
-
-
- diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/psdefs.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/psdefs.cpp deleted file mode 100644 index 259105a3529..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/psdefs.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* -** psdefs.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include "PSInterpreter.h" - -const char *PSInterpreter::PSDEFS = -"3 dict dup begin/Install{matrix setmatrix}def/HWResolution[72 72]def/PageSize[10" -"000 10000]def end setpagedevice/@dodraw true store/@patcnt 0 store/@SD systemdic" -"t def/@UD userdict def true setglobal @SD/:save @SD/save get put @SD/:restore @S" -"D/restore get put @SD/:gsave @SD/gsave get put @SD/:grestore @SD/grestore get pu" -"t @SD/:grestoreall @SD/grestoreall get put @SD/:stroke @SD/stroke get put @SD/:f" -"ill @SD/fill get put @SD/:eofill @SD/eofill get put @SD/:clip @SD/clip get put @" -"SD/:eoclip @SD/eoclip get put @SD/:charpath @SD/charpath get put @SD/:show @SD/s" -"how get put @SD/.setopacityalpha known not{@SD/.setopacityalpha{pop}put}if @SD/p" -"rval{dup type/stringtype eq{print}{30 string cvs print}ifelse}put @SD/prseq{-1 1" -"{-1 roll prval( )print}for(\\n)print}put @SD/prcmd{( )exch(\\ndvi.)3{print}repea" -"t prseq}put @SD/cvxall{{cvx}forall}put @SD/defpr{[exch[/copy @SD]cvxall 5 -1 rol" -"l dup 6 1 roll[/get/exec]cvxall 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 1 roll du" -"p length string cvs/prcmd cvx]cvx def}put @SD/querypos{{currentpoint}stopped{$er" -"ror/newerror false put}{2(querypos)prcmd}ifelse}put @SD/applyscalevals{1 0 trans" -"form 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 0 1 trans" -"form 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 1 0 trans" -"form dup mul exch dup dup mul 3 -1 roll add sqrt div 3(applyscalevals)prcmd}def " -"@SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)prcmd}{0(closepath)prcmd}p" -"athforall}put @SD/charpath{/@dodraw false store :charpath/@dodraw true store}put" -" @SD/show{@dodraw{dup :gsave true charpath eofill :grestore :show}if}put @SD/str" -"oke{@dodraw{0(newpath)prcmd prpath 0(stroke)prcmd newpath}{:stroke}ifelse}put @S" -"D/fill{@dodraw{0(newpath)prcmd prpath 0(fill)prcmd newpath}{:fill}ifelse}put @SD" -"/eofill{@dodraw{0(newpath)prcmd prpath 0(eofill)prcmd newpath}{:eofill}ifelse}pu" -"t @SD/clip{:clip 0(newpath)prcmd prpath 0(clip)prcmd}put @SD/eoclip{:eoclip 0(ne" -"wpath)prcmd prpath 0(eoclip)prcmd}put @SD/bop{pop pop}put/@rect{4 -2 roll moveto" -" exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def/@rectcc" -"{4 -2 roll moveto 2 copy 0 lt exch 0 lt xor{dup 0 exch rlineto exch 0 rlineto ne" -"g 0 exch rlineto}{exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto}ifelse cl" -"osepath}bind def @SD/rectclip{newpath dup type/arraytype eq{aload length 4 idiv{" -"@rectcc}repeat}{@rectcc}ifelse clip newpath}put @SD/rectfill{gsave newpath dup t" -"ype/arraytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifelse fill grestor" -"e}put @SD/rectstroke{gsave newpath dup type/arraytype eq{aload length 4 idiv{@re" -"ct}repeat}{@rect}ifelse stroke grestore}put false setglobal @SD readonly pop/ini" -"tclip 0 defpr/sysexec{@SD exch get exec}def/adddot{dup length 1 add string dup 0" -" 46 put dup 3 -1 roll 1 exch putinterval}def/setlinewidth{dup/setlinewidth sysex" -"ec applyscalevals 1(setlinewidth)prcmd}def/setlinecap 1 defpr/setlinejoin 1 defp" -"r/setmiterlimit 1 defpr/setdash{mark 3 1 roll 2 copy/setdash sysexec applyscalev" -"als exch aload length 1 add -1 roll counttomark(setdash)prcmd pop}def/setgstate{" -"currentlinewidth 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentl" -"inejoin 1(setlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd currentrgbco" -"lor 3(setrgbcolor)prcmd 6 array currentmatrix aload pop 6(setmatrix)prcmd curren" -"tdash mark 3 1 roll exch aload length 1 add -1 roll counttomark(setdash)prcmd po" -"p}def/save{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)prcmd" -"}def/restore{:restore setgstate @UD/@saveID known{@UD begin @saveID end}{0}ifels" -"e 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore setgstate 0(grestore)prcm" -"d}def/grestoreall{:grestoreall setstate 0(grestoreall)prcmd}def/rotate{dup type/" -"arraytype ne{dup 1(rotate)prcmd}if/rotate sysexec}def/scale{dup type/arraytype n" -"e{2 copy 2(scale)prcmd}if/scale sysexec}def/translate{dup type/arraytype ne{2 co" -"py 2(translate)prcmd}if/translate sysexec}def/setmatrix{dup/setmatrix sysexec al" -"oad pop 6(setmatrix)prcmd}def/initmatrix{matrix setmatrix}def/concat{matrix curr" -"entmatrix matrix concatmatrix setmatrix}def/makepattern{gsave <>" -" begin dup/XUID[1000000 @patcnt]put mx/makepattern sysexec dup dup begin Pattern" -"Type @patcnt BBox aload pop XStep YStep PaintType mx aload pop 15(makepattern)pr" -"cmd newpath matrix setmatrix PaintProc 0 1(makepattern)prcmd end/@patcnt @patcnt" -" 1 add store end grestore}def/setpattern{begin PatternType 1 eq{PaintType 1 eq{X" -"UID aload pop exch pop 1}{:gsave[currentcolorspace aload length -1 roll pop]setc" -"olorspace/setcolor sysexec XUID aload pop exch pop currentrgbcolor :grestore 4}i" -"felse(setpattern)prcmd}{/setpattern sysexec}ifelse end}def/setcolor{dup type/dic" -"ttype eq{setpattern}{/setcolor sysexec}ifelse}def/setgray 1 defpr/setcmykcolor 4" -" defpr/sethsbcolor 3 defpr/setrgbcolor 3 defpr/.setopacityalpha{dup/.setopacitya" -"lpha sysexec 1(setopacityalpha)prcmd}def "; diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/types.h b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/types.h deleted file mode 100644 index c22d0e1bf47..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/src/types.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* -** types.h ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#ifndef TYPES_H -#define TYPES_H - -namespace internal { - template - class ERROR_inttype_not_available - { - ERROR_inttype_not_available(); - }; - - template - struct select - { - typedef A T; - }; - - template - struct select - { - typedef B T; - }; -} - - -// Retrieves a signed integer type with sizeof(T) == BYTES -template -struct int_t -{ - typedef typename internal::select >::T>::T>::T>::T>::T T; -}; - - -// Retrieves an unsigned integer type with sizeof(T) == BYTES -template -struct int_t -{ - typedef typename internal::select >::T>::T>::T>::T>::T T; -}; - - -// Machine independent definition of sized integer types -typedef int_t<1, true>::T Int8; -typedef int_t<2, true>::T Int16; -typedef int_t<4, true>::T Int32; -typedef int_t<8, true>::T Int64; -typedef int_t<1, false>::T UInt8; -typedef int_t<2, false>::T UInt16; -typedef int_t<4, false>::T UInt32; -typedef int_t<8, false>::T UInt64; - -typedef Int32 FixWord; -typedef UInt32 ScaledInt; - -#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/BoundingBoxTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/BoundingBoxTest.cpp deleted file mode 100644 index 53bf63c3bf4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/BoundingBoxTest.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************* -** BoundingBoxTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "BoundingBox.h" - -TEST(BoundingBoxTest, set) { - BoundingBox bbox; - bbox.set("1pt 2pt 3pt 4pt"); - EXPECT_EQ(bbox.minX(), 1); - EXPECT_EQ(bbox.minY(), 2); - EXPECT_EQ(bbox.maxX(), 3); - EXPECT_EQ(bbox.maxY(), 4); - - bbox.set("4pt 3pt 2pt 1pt"); - EXPECT_EQ(bbox.minX(), 2); - EXPECT_EQ(bbox.minY(), 1); - EXPECT_EQ(bbox.maxX(), 4); - EXPECT_EQ(bbox.maxY(), 3); - - bbox.set("1pt"); - EXPECT_EQ(bbox.minX(), 1); - EXPECT_EQ(bbox.minY(), 0); - EXPECT_EQ(bbox.maxX(), 5); - EXPECT_EQ(bbox.maxY(), 4); - - bbox.set("2pt 3pt"); - EXPECT_EQ(bbox.minX(), -1); - EXPECT_EQ(bbox.minY(), -3); - EXPECT_EQ(bbox.maxX(), 7); - EXPECT_EQ(bbox.maxY(), 7); - - EXPECT_THROW(bbox.set(""), BoundingBoxException); - EXPECT_THROW(bbox.set("1pt 2pt 3pt"), BoundingBoxException); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CRC32Test.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CRC32Test.cpp deleted file mode 100644 index 40bc3415363..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CRC32Test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************* -** CRC32Test.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "CRC32.h" - -using namespace std; - -TEST(CRC32Test, init) { - CRC32 crc; - EXPECT_EQ(crc.get(), 0); - crc.reset(); - EXPECT_EQ(crc.get(), 0); -} - - -TEST(CRC32Test, update_numbers) { - CRC32 crc; - const UInt32 comp[]={0xf8923be6, 0x4dcd2866, 0x4fdbb57a, 0xcb40f3bf, 0xf1a33887, 0x3422c816, 0x3a8b92a4, 0xedafc4ce, 0x4f5d17ec, 0x4a9f2f68}; - for (int i=-5; i < 5; ++i) { - crc.update(i); - EXPECT_EQ(crc.get(), comp[i+5]); - } - crc.reset(); - EXPECT_EQ(crc.get(), 0); - // add 32 bit values - for (int i=0; i < 256; ++i) - crc.update(i); - EXPECT_EQ(crc.get(), 0xd4c2968b); - for (int i=256; i < 10000; ++i) - crc.update(i); - EXPECT_EQ(crc.get(), 0x6de9e841); -} - - -TEST(CRC32Test, update_array) { - CRC32 crc; - UInt8 vals[256]; - // add 8 bit values - for (int i=0; i < 256; ++i) - vals[i] = i; - crc.update(vals, 256); - EXPECT_EQ(crc.get(), 0x29058c73); -} - - -TEST(CRC32Test, update_string) { - CRC32 crc; - crc.update("dvisvgm converts DVI files to SVG."); - EXPECT_EQ(crc.get(), 0x7c4ef359); - crc.update("It is published under the GNU General Public License."); - EXPECT_EQ(crc.get(), 0xa732081b); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CalculatorTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CalculatorTest.cpp deleted file mode 100644 index a4bb24c6215..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CalculatorTest.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************* -** CalculatorTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "Calculator.h" - -TEST(CalculatorTest, eval) { - Calculator calc; - EXPECT_EQ(calc.eval("2+3+4"), 9); - EXPECT_EQ(calc.eval("2*3+4"), 10); - EXPECT_EQ(calc.eval("2+3*4"), 14); - EXPECT_EQ(calc.eval("(2+3)*4"), 20); - EXPECT_EQ(calc.eval("2*(3+4)"), 14); - EXPECT_EQ(calc.eval("-2+3+4"), 5); - EXPECT_EQ(calc.eval("3/2"), 1.5); - EXPECT_EQ(calc.eval("3%2"), 1); -} - - -TEST(CalculatorTest, variables) { - Calculator calc; - calc.setVariable("a", 1); - EXPECT_EQ(calc.getVariable("a"), 1); - - calc.setVariable("a", 2); - EXPECT_EQ(calc.getVariable("a"), 2); - - calc.setVariable("b", 3); - EXPECT_EQ(calc.eval("a+b"), 5); - EXPECT_EQ(calc.eval("2a+2b"), 10); -} - - -TEST(CalculatorTest, exceptions) { - Calculator calc; - ASSERT_THROW(calc.eval("2++3"), CalculatorException); - ASSERT_THROW(calc.eval("c"), CalculatorException); - ASSERT_THROW(calc.eval("1/0"), CalculatorException); - ASSERT_THROW(calc.eval("1%0"), CalculatorException); - ASSERT_THROW(calc.eval("2*(3+4"), CalculatorException); - ASSERT_THROW(calc.eval("2*(3+4))"), CalculatorException); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/ColorSpecialTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/ColorSpecialTest.cpp deleted file mode 100644 index 48d4d57729b..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/ColorSpecialTest.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************* -** ColorSpecialTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "ColorSpecialHandler.h" -#include "SpecialActions.h" - -class ColorSpecialTest : public ::testing::Test -{ - protected: - struct SetColor : SpecialEmptyActions - { - SetColor () : color(0) {} - void setColor (const Color &c) {color = c;} - bool equals (UInt32 c) {return color == c;} - UInt32 color; - }; - ColorSpecialHandler handler; - SetColor actions; -}; - - -TEST_F(ColorSpecialTest, rgb) { - std::istringstream iss("rgb 1 0 1"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0xff00ff)); -} - - -TEST_F(ColorSpecialTest, hsb) { - std::istringstream iss("hsb 1 0.5 1"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0xff8080)); -} - - -TEST_F(ColorSpecialTest, cmyk) { - std::istringstream iss("cmyk 0.1 0.2 0.4 0.6"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0x4c3300)); -} - - -TEST_F(ColorSpecialTest, stack) { - std::istringstream iss("push rgb 1 0 0"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0xff0000)); - iss.clear(); - iss.str("push Blue"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0x0000ff)); - iss.clear(); - iss.str("pop"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0xff0000)); -} - - -TEST_F(ColorSpecialTest, constant) { - std::istringstream iss("RedViolet"); - handler.process(0, iss, &actions); - EXPECT_TRUE(actions.equals(0x9600a8)); -} - - -TEST_F(ColorSpecialTest, errors) { - std::istringstream iss("UnknownColor"); - EXPECT_THROW(handler.process(0, iss, &actions), SpecialException); - iss.clear(); - iss.str("rgb 0 0.3 3.1"); - EXPECT_THROW(handler.process(0, iss, &actions), SpecialException); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CommandLineTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CommandLineTest.cpp deleted file mode 100644 index 7d1e5874b33..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/CommandLineTest.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/************************************************************************* -** CommandLineTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "CommandLine.h" - -TEST(CommandLineTest, noarg_short) { - CommandLine cmd; - const char *args[] = {"progname", "-s", "-n", "-h"}; - char **argv = const_cast(args); - cmd.parse(4, argv, false); - - EXPECT_TRUE(cmd.stdout_given()); - EXPECT_TRUE(cmd.no_fonts_given()); - EXPECT_TRUE(cmd.help_given()); - EXPECT_FALSE(cmd.list_specials_given()); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); -} - - -TEST(CommandLineTest, noarg_long) { - CommandLine cmd; - const char *args[] = {"progname", "--no-fonts", "--stdout", "--help"}; - char **argv = const_cast(args); - cmd.parse(4, argv, false); - - EXPECT_TRUE(cmd.stdout_given()); - EXPECT_TRUE(cmd.no_fonts_given()); - EXPECT_TRUE(cmd.help_given()); - EXPECT_FALSE(cmd.list_specials_given()); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); -} - - -TEST(CommandLineTest, arg_short) { - CommandLine cmd; - const char *args[] = {"progname", "-p5", "-r45", "-omyfile.xyz", "-ayes"}; - char **argv = const_cast(args); - cmd.parse(5, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "5"); - EXPECT_TRUE(cmd.rotate_given()); - EXPECT_EQ(cmd.rotate_arg(), 45); - EXPECT_TRUE(cmd.output_given()); - EXPECT_EQ(cmd.output_arg(), "myfile.xyz"); - EXPECT_FALSE(cmd.bbox_given()); - EXPECT_EQ(cmd.bbox_arg(), "min"); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); - EXPECT_TRUE(cmd.trace_all_given()); - EXPECT_TRUE(cmd.trace_all_arg()); -} - - -TEST(CommandLineTest, arg_combined) { - CommandLine cmd; - const char *args[] = {"progname", "-lse", "-p5", "-omyfile.xyz"}; - char **argv = const_cast(args); - cmd.parse(4, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "5"); - EXPECT_TRUE(cmd.list_specials_given()); - EXPECT_TRUE(cmd.stdout_given()); - EXPECT_TRUE(cmd.exact_given()); - EXPECT_FALSE(cmd.error()); -} - - -TEST(CommandLineTest, arg_separated) { - CommandLine cmd; - const char *args[] = {"progname", "-p", "5", "-r", "45", "myfile.xyz", "-afalse"}; - char **argv = const_cast(args); - cmd.parse(7, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "5"); - EXPECT_TRUE(cmd.rotate_given()); - EXPECT_EQ(cmd.rotate_arg(), 45); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 1); - EXPECT_TRUE(cmd.trace_all_given()); - EXPECT_FALSE(cmd.trace_all_arg()); -} - - -TEST(CommandLineTest, arg_long) { - CommandLine cmd; - const char *args[] = {"progname", "--page=9", "--rotate=-45.5", "--trace-all", "--output=myfile.zyx"}; - char **argv = const_cast(args); - cmd.parse(5, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "9"); - EXPECT_TRUE(cmd.rotate_given()); - EXPECT_EQ(cmd.rotate_arg(), -45.5); - EXPECT_TRUE(cmd.output_given()); - EXPECT_EQ(cmd.output_arg(), "myfile.zyx"); - EXPECT_FALSE(cmd.bbox_given()); - EXPECT_EQ(cmd.bbox_arg(), "min"); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); - EXPECT_TRUE(cmd.trace_all_given()); - EXPECT_FALSE(cmd.trace_all_arg()); -} - - -TEST(CommandLineTest, abbrev_long) { - CommandLine cmd; - const char *args[] = {"progname", "--pa=9", "--rot=-45.5", "--out=myfile.zyx"}; - char **argv = const_cast(args); - cmd.parse(4, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "9"); - EXPECT_TRUE(cmd.rotate_given()); - EXPECT_EQ(cmd.rotate_arg(), -45.5); - EXPECT_TRUE(cmd.output_given()); - EXPECT_EQ(cmd.output_arg(), "myfile.zyx"); - EXPECT_FALSE(cmd.bbox_given()); - EXPECT_EQ(cmd.bbox_arg(), "min"); - EXPECT_FALSE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); -} - - -TEST(CommandLineTest, error) { - CommandLine cmd; - // error on wrong argument type - const char *args1[] = {"progname", "--rotate=x"}; - char **argv = const_cast(args1); - cmd.parse(2, argv, false); - - EXPECT_FALSE(cmd.rotate_given()); - EXPECT_TRUE(cmd.error()); - - // error on missing arguments - const char *args2[] = {"progname", "--page", "--zip"}; - argv = const_cast(args2); - cmd.parse(3, argv, false); - EXPECT_TRUE(cmd.zip_given()); - EXPECT_EQ(cmd.zip_arg(), 9); - EXPECT_FALSE(cmd.page_given()); - EXPECT_FALSE(cmd.rotate_given()); - EXPECT_TRUE(cmd.error()); - EXPECT_EQ(cmd.numFiles(), 0); - - // error on ambiguous abbreviation of long option - const char *args3[] = {"progname", "--no"}; - argv = const_cast(args3); - cmd.parse(2, argv, false); - EXPECT_TRUE(cmd.error()); - - // incorrect boolean value - const char *args4[] = {"progname", "--trace-all=nope"}; - argv = const_cast(args4); - cmd.parse(2, argv, false); - EXPECT_FALSE(cmd.trace_all_given()); - EXPECT_TRUE(cmd.error()); -} - - -TEST(CommandLineTest, file) { - CommandLine cmd; - const char *args1[] = {"progname", "--page=3", "-z5", "myfile1", "-l", "myfile2"}; - char **argv = const_cast(args1); - cmd.parse(6, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "3"); - EXPECT_TRUE(cmd.zip_given()); - EXPECT_EQ(cmd.zip_arg(), 5); - EXPECT_TRUE(cmd.list_specials_given()); - EXPECT_EQ(cmd.numFiles(), 2); - EXPECT_EQ(strcmp(cmd.file(0), "myfile1"), 0); - EXPECT_EQ(strcmp(cmd.file(1), "myfile2"), 0); - EXPECT_FALSE(cmd.error()); -} - - -TEST(CommandLineTest, files_only) { - CommandLine cmd; - const char *args1[] = {"progname", "--page=3", "-z5", "--", "-l", "myfile"}; - char **argv = const_cast(args1); - cmd.parse(6, argv, false); - - EXPECT_TRUE(cmd.page_given()); - EXPECT_EQ(cmd.page_arg(), "3"); - EXPECT_TRUE(cmd.zip_given()); - EXPECT_EQ(cmd.zip_arg(), 5); - EXPECT_EQ(cmd.numFiles(), 2); - EXPECT_EQ(strcmp(cmd.file(0), "-l"), 0); - EXPECT_EQ(strcmp(cmd.file(1), "myfile"), 0); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/DirectoryTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/DirectoryTest.cpp deleted file mode 100644 index 5a503b9bfd7..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/DirectoryTest.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************* -** DirectoryTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "Directory.h" -#include "FileSystem.h" -#include "macros.h" - -#ifndef SRCDIR -#define SRCDIR "." -#endif - - -using namespace std; - -TEST(DirectoryTest, dirs) { - const char *dirs_to_find[] = {"doc", "src", 0}; - set found_dirs; - Directory dir(".."); - while (const char *dname = dir.read('d')) - found_dirs.insert(dname); - for (const char **p=dirs_to_find; *p; ++p) { - EXPECT_TRUE(found_dirs.find(*p) != found_dirs.end()); - } -} - - -TEST(DirectoryTest, file) { - const char *files_to_find[] = { - "Bitmap.cpp", "BoundingBox.cpp", "Calculator.cpp", - "Directory.cpp", "DVIReader.cpp", "DVIToSVG.cpp", "DVIToSVGActions.cpp", - "FileSystem.cpp", "Font.cpp", "FontEngine.cpp", "FontManager.cpp", - "FontMap.cpp", "GFReader.cpp", "GFTracer.cpp", "FileFinder.cpp", "Message.cpp", - "MetafontWrapper.cpp", "PageSize.cpp", "StreamReader.cpp", - "TFM.cpp", "VFReader.cpp", "XMLDocument.cpp", "XMLNode.cpp", "XMLString.cpp", - 0 - }; - set found_files; - Directory dir(string(SRCDIR)+"/../src"); - while (const char *fname = dir.read('f')) - found_files.insert(fname); - for (const char **p=files_to_find; *p; ++p) { - EXPECT_TRUE(found_files.find(*p) != found_files.end()); - } - EXPECT_TRUE(found_files.find("tests") == found_files.end()); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileFinderTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileFinderTest.cpp deleted file mode 100644 index 9286237ad30..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileFinderTest.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************* -** FileFinderTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "FileFinder.h" - -using std::ifstream; - - -class FileFinderTest : public ::testing::Test -{ - protected: - void SetUp () { - FileFinder::init("FileFinderTest", "FileFinderTest", false); - } - - void TearDown () { - FileFinder::finish(); - } -}; - - -TEST_F(FileFinderTest, find_base_file) { - const char *path = FileFinder::lookup("cmr10.tfm"); - EXPECT_TRUE(path); - ifstream ifs(path); - EXPECT_TRUE(ifs); -} - - -TEST_F(FileFinderTest, find_mapped_file) { - // mapped base tfm file => should be resolved by kpathsea - // circle10.tfm is usually mapped to lcircle.tfm - if (const char *path = FileFinder::lookup("circle10.tfm")) { - EXPECT_TRUE(path); - ifstream ifs(path); - EXPECT_TRUE(ifs); - } - - // mapped lm font => should be resolved using dvisvgm's FontMap - // cork-lmr10 is usually mapped to lmr10 - bool have_lmodern = FileFinder::lookup("lmodern.sty"); - if (have_lmodern) { // package lmodern installed? - if (const char *path = FileFinder::lookup("cork-lmr10.pfb")) { - ifstream ifs(path); - EXPECT_TRUE(ifs); - } - } -} - - -TEST_F(FileFinderTest, mktexmf) { - // ensure availability of ec font => call mktexmf if necessary - if (const char *path = FileFinder::lookup("ecrm2000.mf")) { - ifstream ifs(path); - EXPECT_TRUE(ifs); - } -} - - -TEST_F(FileFinderTest, find_unavailable_file) { - const char *path = FileFinder::lookup("not-available.xyz"); - EXPECT_FALSE(path); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FilePathTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FilePathTest.cpp deleted file mode 100644 index 6f1ef7677ab..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FilePathTest.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************* -** FilePathTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "FilePath.h" -#include "FileSystem.h" - -using namespace std; - - -TEST(FilePathTest, dir1) { - FilePath fp("a/b/c/d", false, "/"); - ASSERT_EQ(fp.absolute(), "/a/b/c/d"); - ASSERT_EQ(fp.relative("/"), "a/b/c/d"); - ASSERT_EQ(fp.relative("/a/b"), "c/d"); - ASSERT_EQ(fp.relative("/a/b/c"), "d"); - ASSERT_EQ(fp.relative("/a/b/c/d"), "."); - ASSERT_EQ(fp.relative("/a/b/x"), "../c/d"); - ASSERT_EQ(fp.relative("/a/b/x/y"), "../../c/d"); -} - - -TEST(FilePathTest, dir2) { - FilePath fp("a/b/c/d", false, "/x/y"); - ASSERT_EQ(fp.absolute(), "/x/y/a/b/c/d"); - ASSERT_EQ(fp.relative("/"), "x/y/a/b/c/d"); - ASSERT_EQ(fp.relative("/x/y/a/b"), "c/d"); - ASSERT_EQ(fp.relative("/x/y/a/b/c"), "d"); - ASSERT_EQ(fp.relative("/x/y/a/b/c/d"), "."); - ASSERT_EQ(fp.relative("/x/y/a/b/x"), "../c/d"); - ASSERT_EQ(fp.relative("/x/y/a/b/x/y"), "../../c/d"); -} - - -TEST(FilePathTest, file1) { - FilePath fp("a/b/c/d/f.ext", true, "/"); - ASSERT_EQ(fp.absolute(), "/a/b/c/d/f.ext"); - ASSERT_EQ(fp.relative("/"), "a/b/c/d/f.ext"); - ASSERT_EQ(fp.relative("/a/b"), "c/d/f.ext"); - ASSERT_EQ(fp.relative("/a/b/c"), "d/f.ext"); - ASSERT_EQ(fp.relative("/a/b/c/d"), "f.ext"); - ASSERT_EQ(fp.relative("/a/b/x"), "../c/d/f.ext"); - ASSERT_EQ(fp.relative("/a/b/x/y"), "../../c/d/f.ext"); - ASSERT_EQ(fp.basename(), "f"); - ASSERT_EQ(fp.suffix(), "ext"); - fp.suffix("new"); - ASSERT_EQ(fp.suffix(), "new"); - ASSERT_EQ(fp.relative("/a/b/x/y"), "../../c/d/f.new"); -} - - -TEST(FilePathTest, file2) { - FilePath fp("/f.ext", true, "/"); - ASSERT_EQ(fp.absolute(), "/f.ext"); - ASSERT_EQ(fp.relative("/a/b"), "../../f.ext"); -} - - -#ifdef __WIN32__ -static string tolower (const string &str) { - string ret; - for (string::const_iterator it=str.begin(); it != str.end(); ++it) - ret += tolower(*it); - return ret; -} -#endif - - -TEST(FilePathTest, autodetect) { - FilePath fp1("FilePathTest.cpp"); - ASSERT_TRUE(fp1.isFile()); - ASSERT_FALSE(fp1.empty()); - string cwd = FileSystem::getcwd(); -#ifdef __WIN32__ - ASSERT_EQ(fp1.absolute(), tolower(cwd + "/FilePathTest.cpp")); -#else - ASSERT_EQ(fp1.absolute(), cwd + "/FilePathTest.cpp"); -#endif - - FilePath fp2(""); - ASSERT_FALSE(fp2.isFile()); - ASSERT_FALSE(fp2.empty()); -#ifdef __WIN32__ - ASSERT_EQ(fp2.absolute(), tolower(FileSystem::getcwd())); -#else - ASSERT_EQ(fp2.absolute(), FileSystem::getcwd()); -#endif -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileSystemTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileSystemTest.cpp deleted file mode 100644 index bd7adeef383..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FileSystemTest.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************* -** FileSystemTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "FileSystem.h" - -#ifndef SRCDIR -#define SRCDIR "." -#endif - -using namespace std; - - -TEST(FileSystemTest, exists) { - EXPECT_TRUE(FileSystem::exists(SRCDIR"/FileSystemTest.cpp")); - EXPECT_FALSE(FileSystem::exists(SRCDIR"/FileSystemTest.cxx")); -} - - -TEST(FileSystemTest, filetype) { - EXPECT_TRUE(FileSystem::isFile(SRCDIR"/FileSystemTest.cpp")); - EXPECT_FALSE(FileSystem::isDirectory(SRCDIR"/FileSystemTest.cpp")); - EXPECT_TRUE(FileSystem::isDirectory("../tests")); - EXPECT_FALSE(FileSystem::isFile("../tests")); -} - - -TEST(FileSystemTest, remove) { - const char *tmpfile = "out.tmp"; - ofstream ofs(tmpfile); - ofs << "FileSystemTest::remove\n"; - ofs.close(); - EXPECT_TRUE(FileSystem::exists(tmpfile)); - FileSystem::remove(tmpfile); - EXPECT_FALSE(FileSystem::exists(tmpfile)); -} - - -TEST(FileSystemTest, rename) { - const char *tmpfile1 = "out.tmp"; - const char *tmpfile2 = "out-new.tmp"; - ofstream ofs(tmpfile1); - ofs << "FileSystemTest::remove\n"; - ofs.close(); - EXPECT_TRUE(FileSystem::exists(tmpfile1)); - FileSystem::rename(tmpfile1, tmpfile2); -#ifndef __WIN32__ - EXPECT_FALSE(FileSystem::exists(tmpfile1)); -#endif - EXPECT_TRUE(FileSystem::exists(tmpfile2)); - FileSystem::remove(tmpfile2); - EXPECT_FALSE(FileSystem::exists(tmpfile2)); -} - - -TEST(FileSystemTest, filesize) { - const char *tmpfile = "out.tmp"; - ofstream ofs(tmpfile, ios::binary); - for (int i=0; i < 123; ++i) - ofs.put(i); - ofs.close(); - EXPECT_EQ(FileSystem::filesize(tmpfile), 123); - FileSystem::remove(tmpfile); -} - - -TEST(FileSystemTest, copy) { - const char *tmpfile1 = "out.tmp"; - const char *tmpfile2 = "out-new.tmp"; - ofstream ofs(tmpfile1); - ofs << "FileSystemTest::copy\n"; - ofs.close(); - FileSystem::copy(tmpfile1, tmpfile2); - ifstream ifs1(tmpfile1); - ifstream ifs2(tmpfile2); - EXPECT_TRUE(ifs1 && ifs2); - while (!ifs1.eof()) { - EXPECT_EQ(ifs1.get(), ifs2.get()); - } - EXPECT_TRUE(ifs2.eof()); - FileSystem::remove(tmpfile1); - FileSystem::remove(tmpfile2); -} - - -TEST(FileSystemTest, move) { - const char *tmpfile1 = "out.tmp"; - const char *tmpfile2 = "out-new.tmp"; - ofstream ofs(tmpfile1); - const char *str = "FileSystemTest::copy\n"; - ofs << str; - ofs.close(); - FileSystem::copy(tmpfile1, tmpfile2, true); - ifstream ifs1(tmpfile1); - ifstream ifs2(tmpfile2); - EXPECT_TRUE(!ifs1 && ifs2); - while (*str) { - EXPECT_EQ(*str++, ifs2.get()); - } - ifs2.get(); - EXPECT_TRUE(ifs2.eof()); - FileSystem::remove(tmpfile2); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontManagerTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontManagerTest.cpp deleted file mode 100644 index d7d0fb30f57..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontManagerTest.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************* -** FontManagerTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "Font.h" -#include "FontManager.h" -#include "FileFinder.h" - -class FontManagerTest : public ::testing::Test -{ - protected: - void SetUp () { - FileFinder::init("FontManagerTest", "FontManagerTest", false); - FontManager &fm = FontManager::instance(); - fm.registerFont(10, "cmr10", 1274110073, 10, 10); - fm.registerFont(11, "cmr10", 1274110073, 10, 12); - fm.registerFont( 9, "cmr10", 1274110073, 10, 14); - } -}; - - -TEST_F(FontManagerTest, fontID1) { - FontManager &fm = FontManager::instance(); - EXPECT_EQ(fm.fontID(10), 0); - EXPECT_EQ(fm.fontID(11), 1); - EXPECT_EQ(fm.fontID(9), 2); - EXPECT_EQ(fm.fontID(1), -1); -} - - -TEST_F(FontManagerTest, font_ID2) { - FontManager &fm = FontManager::instance(); - EXPECT_EQ(fm.fontID("cmr10"), 0); -} - - -TEST_F(FontManagerTest, getFont) { - FontManager &fm = FontManager::instance(); - const Font *f1 = fm.getFont(10); - EXPECT_TRUE(f1); - EXPECT_EQ(f1->name(), "cmr10"); - EXPECT_TRUE(dynamic_cast(f1)); - - const Font *f2 = fm.getFont(11); - EXPECT_TRUE(f2); - EXPECT_NE(f1, f2); - EXPECT_EQ(f2->name(), "cmr10"); - EXPECT_TRUE(dynamic_cast(f2)); - EXPECT_EQ(f2->uniqueFont(), f1); -} - - -TEST_F(FontManagerTest, getFontById) { - FontManager &fm = FontManager::instance(); - EXPECT_EQ(fm.getFont(10), fm.getFontById(0)); - EXPECT_EQ(fm.getFont("cmr10"), fm.getFontById(0)); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontMapTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontMapTest.cpp deleted file mode 100644 index a853b829295..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/FontMapTest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************* -** FontMapTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "FontMap.h" - -using std::ifstream; - -TEST(FontMapTest, pdf_map) { - const char *fname = "tests/dvipdfm_test.map"; - ifstream ifs(fname); - if (ifs) { - FontMap &fm = FontMap::instance(); - fm.read(fname); - const FontMap::Entry *entry; - ASSERT_TRUE((entry = fm.lookup("MyriadPro-Bold-8t")) != 0); - EXPECT_EQ(entry->fontname, "MyriadPro-Bold"); - EXPECT_EQ(entry->encname, "my-lf-t1"); - ASSERT_TRUE((entry = fm.lookup("cmbsy8")) != 0); - EXPECT_EQ(entry->fontname, "cmbsy7"); - EXPECT_EQ(entry->encname, ""); - - // entry without mapped name - EXPECT_TRUE(fm.lookup("msam10") == 0); - EXPECT_TRUE(fm.lookup("msbm10") == 0); - EXPECT_TRUE(fm.lookup("msbm10") == 0); - EXPECT_TRUE(fm.lookup("i don't exist") == 0); - } -} - - -TEST(FontMapTest, ps_map) { - const char *fname = "tests/dvips_test.map"; - ifstream ifs(fname); - if (ifs) { - FontMap &fm = FontMap::instance(); - fm.read(fname); - const FontMap::Entry *entry; - ASSERT_TRUE((entry = fm.lookup("MyriadPro-Bold-8t")) != 0); - EXPECT_EQ(entry->fontname, "MyriadPro-Bold"); - EXPECT_EQ(entry->encname, "my-lf-t1"); - ASSERT_TRUE((entry = fm.lookup("cmbsy8")) != 0); - EXPECT_EQ(entry->fontname, "cmbsy7"); - EXPECT_EQ(entry->encname, ""); - - // entry without mapped name - EXPECT_TRUE(fm.lookup("msam10") == 0); - EXPECT_TRUE(fm.lookup("msbm10") == 0); - EXPECT_TRUE(fm.lookup("msbm10") == 0); - EXPECT_TRUE(fm.lookup("i don't exist") == 0); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GFReaderTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GFReaderTest.cpp deleted file mode 100644 index 333eacfb7c4..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GFReaderTest.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/************************************************************************* -** GFReaderTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include -#include "GFReader.h" -#include "macros.h" - -#ifndef SRCDIR -#define SRCDIR "." -#endif - -using namespace std; - - -struct PixelActions : public Bitmap::ForAllData -{ - void pixel (int x, int y, bool set, const Bitmap &bm) { - if (charmap.size() == 0) { - charmap.resize(bm.height()); - for (int i=0; i < bm.height(); i++) - charmap[i] = string(bm.width(), ' '); - } - ASSERT_GE(x, 0); - ASSERT_LT(x, bm.width()); - ASSERT_GE(y, 0); - ASSERT_LT(y, bm.height()); - charmap[y][x] = (set ? '*' : '-'); - } - - vector charmap; -}; - - -const char *letter_a[] = { - "-----------********--------------------", - "--------**************-----------------", - "------*****-------******---------------", - "-----***------------*****--------------", - "----*****------------******------------", - "---*******------------******-----------", - "---********-----------******-----------", - "---********------------******----------", - "---********------------******----------", - "---********-------------******---------", - "----******--------------******---------", - "-----****---------------******---------", - "------------------------******---------", - "------------------------******---------", - "------------------------******---------", - "------------------------******---------", - "-----------------*************---------", - "-------------*****************---------", - "----------*********-----******---------", - "--------*******---------******---------", - "------*******-----------******---------", - "----********------------******---------", - "---*******--------------******---------", - "--********--------------******---------", - "-********---------------******---------", - "-*******----------------******---------", - "-*******----------------******------**-", - "*******-----------------******------**-", - "*******-----------------******------**-", - "*******-----------------******------**-", - "*******----------------*******------**-", - "*******----------------*******------**-", - "********--------------********------**-", - "-*******-------------***-*****------**-", - "-********------------**---*****----**--", - "--********---------****---*****----**--", - "----*******------****------*********---", - "------**************--------*******----", - "---------********------------*****-----", -}; - - -const char *letter_g[] = { - "------------------------------******---", - "------------********--------*********--", - "----------************----****----****-", - "--------*****------*****-***-----*****-", - "-------*****--------*******------*****-", - "------*****----------*****-------*****-", - "-----*****------------*****--------*---", - "----******------------******-----------", - "----******------------******-----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "---******--------------******----------", - "----******------------******-----------", - "----******------------******-----------", - "-----*****------------*****------------", - "------*****----------*****-------------", - "------******--------*****--------------", - "------*******------*****---------------", - "-----***--************-----------------", - "-----**-----********-------------------", - "----***--------------------------------", - "----***--------------------------------", - "----***--------------------------------", - "----***--------------------------------", - "----****-------------------------------", - "----****-------------------------------", - "----******-----------------------------", - "-----*********************-------------", - "-----************************----------", - "------*************************--------", - "-------**************************------", - "------****************************-----", - "----*****----------------**********----", - "---*****--------------------********---", - "--*****-----------------------******---", - "-*****-------------------------*****---", - "-*****-------------------------******--", - "*****---------------------------*****--", - "*****---------------------------*****--", - "*****---------------------------*****--", - "*****---------------------------*****--", - "*****---------------------------*****--", - "******-------------------------******--", - "-*****-------------------------*****---", - "--*****-----------------------*****----", - "--******---------------------******----", - "----*****-------------------*****------", - "-----******---------------******-------", - "-------*******---------*******---------", - "---------*******************-----------", - "-------------***********---------------", -}; - - -const char *letter_M[] = { - "****************-------------------------------------****************-", - "*****************-----------------------------------*****************-", - "*****************-----------------------------------*****************-", - "-------**********-----------------------------------**********--------", - "--------**-*******---------------------------------**-*******---------", - "--------**-*******---------------------------------**-*******---------", - "--------**--*******-------------------------------**--*******---------", - "--------**--*******-------------------------------**--*******---------", - "--------**--*******-------------------------------**--*******---------", - "--------**---*******-----------------------------**---*******---------", - "--------**---*******-----------------------------**---*******---------", - "--------**---*******-----------------------------**---*******---------", - "--------**----*******---------------------------**----*******---------", - "--------**----*******---------------------------**----*******---------", - "--------**-----*******-------------------------**-----*******---------", - "--------**-----*******-------------------------**-----*******---------", - "--------**-----*******-------------------------**-----*******---------", - "--------**------*******-----------------------**------*******---------", - "--------**------*******-----------------------**------*******---------", - "--------**-------*******---------------------**-------*******---------", - "--------**-------*******---------------------**-------*******---------", - "--------**-------*******---------------------**-------*******---------", - "--------**--------*******-------------------**--------*******---------", - "--------**--------*******-------------------**--------*******---------", - "--------**--------*******-------------------**--------*******---------", - "--------**---------*******-----------------**---------*******---------", - "--------**---------*******-----------------**---------*******---------", - "--------**----------*******---------------**----------*******---------", - "--------**----------*******---------------**----------*******---------", - "--------**----------*******---------------**----------*******---------", - "--------**-----------*******-------------**-----------*******---------", - "--------**-----------*******-------------**-----------*******---------", - "--------**------------*******-----------**------------*******---------", - "--------**------------*******-----------**------------*******---------", - "--------**------------*******-----------**------------*******---------", - "--------**-------------*******---------**-------------*******---------", - "--------**-------------*******---------**-------------*******---------", - "--------**-------------*******---------**-------------*******---------", - "--------**--------------*******-------**--------------*******---------", - "--------**--------------*******-------**--------------*******---------", - "--------**---------------*******-----**---------------*******---------", - "--------**---------------*******-----**---------------*******---------", - "--------**---------------*******-----**---------------*******---------", - "--------**----------------*******---**----------------*******---------", - "--------**----------------*******---**----------------*******---------", - "--------**-----------------*******-**-----------------*******---------", - "--------**-----------------*******-**-----------------*******---------", - "--------**-----------------*******-**-----------------*******---------", - "--------**------------------********------------------*******---------", - "--------**------------------********------------------*******---------", - "--------**------------------********------------------*******---------", - "-------****------------------******-------------------*******---------", - "------******-----------------******-------------------*******---------", - "----**********----------------****-------------------*********--------", - "******************------------****------------***********************-", - "******************------------****------------***********************-", - "******************-------------**-------------***********************-", -}; - - -static void check_letter (const char **lettermap, const vector &charmap) { - for (size_t i=0; i < charmap.size(); i++) - ASSERT_EQ(lettermap[i], charmap[charmap.size()-i-1]); -} - - -TEST(GFReaderTest, executeChar) { - string gf = string(SRCDIR)+"/cmr10.600gf"; - ifstream ifs(gf.c_str(), ios::binary); - ASSERT_TRUE(ifs); - GFReader gfReader(ifs); - PixelActions actions; - - gfReader.executeChar('a'); - ASSERT_EQ(gfReader.getBitmap().width(), 39); - ASSERT_EQ(gfReader.getBitmap().height(), 39); - gfReader.getBitmap().forAllPixels(actions); - check_letter(letter_a, actions.charmap); - - actions.charmap.clear(); - gfReader.executeChar('g'); - ASSERT_EQ(gfReader.getBitmap().width(), 39); - ASSERT_EQ(gfReader.getBitmap().height(), 56); - gfReader.getBitmap().forAllPixels(actions); - check_letter(letter_g, actions.charmap); - - actions.charmap.clear(); - gfReader.executeChar('M'); - ASSERT_EQ(gfReader.getBitmap().width(), 70); - ASSERT_EQ(gfReader.getBitmap().height(), 57); - gfReader.getBitmap().forAllPixels(actions); - check_letter(letter_M, actions.charmap); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GraphicPathTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GraphicPathTest.cpp deleted file mode 100644 index 6df695604f2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/GraphicPathTest.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************* -** GraphicPathTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "GraphicPath.h" - -using std::ostringstream; - -TEST(GraphicPathTest, svg) { - GraphicPath path; - path.moveto(0,0); - path.lineto(10,10); - path.cubicto(20,20,30,30,40,40); - path.closepath(); - ostringstream oss; - path.writeSVG(oss); - EXPECT_EQ(oss.str(), "M0 0L10 10C20 20 30 30 40 40Z"); -} - - -TEST(GraphicPathTest, optimize) { - GraphicPath path; - path.moveto(0,0); - path.lineto(10,0); - path.lineto(10,20); - ostringstream oss; - path.writeSVG(oss); - EXPECT_EQ(oss.str(), "M0 0H10V20"); -} - - -TEST(GraphicPathTest, transform) { - GraphicPath path; - path.moveto(0,0); - path.lineto(1,0); - path.lineto(1,1); - path.lineto(0,1); - path.closepath(); - Matrix m(1); - m.scale(2,2); - m.translate(10, 100); - m.rotate(90); - path.transform(m); - ostringstream oss; - path.writeSVG(oss); - EXPECT_EQ(oss.str(), "M-100 10V12H-102V10Z"); -} - - -TEST(GraphicPathTest, closeOpenSubPaths) { - GraphicPath path; - path.moveto(0,0); - path.lineto(1,0); - path.lineto(1,1); - path.lineto(0,1); - path.moveto(10,10); - path.lineto(11,10); - path.lineto(11,11); - path.lineto(10,11); - path.closeOpenSubPaths(); - ostringstream oss; - path.writeSVG(oss); - EXPECT_EQ(oss.str(), "M0 0H1V1H0ZM10 10H11V11H10Z"); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/LengthTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/LengthTest.cpp deleted file mode 100644 index e6c7bbd5dac..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/LengthTest.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************* -** LengthTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "Length.h" - -TEST(LengthTest, set1) { - Length len; - len.set(1, Length::PT); - EXPECT_EQ(len.pt(), 1); - - len.set(72, Length::BP); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.bp(), 72); - EXPECT_EQ(len.in(), 1); - - len.set(1, Length::IN); - EXPECT_EQ(len.pt(), 72.27); - - len.set(12, Length::PC); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.in(), 1); - - len.set(2.54, Length::CM); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.cm(), 2.54); - EXPECT_EQ(len.mm(), 25.4); - - len.set(25.4, Length::MM); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.cm(), 2.54); - EXPECT_EQ(len.mm(), 25.4); -} - - -TEST(LengthTest, set2) { - Length len; - len.set(1, "pt"); - EXPECT_EQ(len.pt(), 1); - - len.set(72, "bp"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.bp(), 72); - EXPECT_EQ(len.in(), 1); - EXPECT_EQ(len.pc(), 12); - - len.set(1, "in"); - EXPECT_EQ(len.pt(), 72.27); - - len.set(12, "pc"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.in(), 1); - EXPECT_EQ(len.pc(), 12); - - len.set(2.54, "cm"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.cm(), 2.54); - EXPECT_EQ(len.mm(), 25.4); - - len.set(10, "mm"); - EXPECT_EQ(len.cm(), 1); - EXPECT_EQ(len.mm(), 10); - - len.set(1, ""); - EXPECT_EQ(len.pt(), 1); - - ASSERT_THROW(len.set(1, "xy"), UnitException); -} - -TEST(LengthTest, set3) { - Length len; - len.set("1pt"); - EXPECT_EQ(len.pt(), 1); - - len.set("72bp"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.bp(), 72); - EXPECT_EQ(len.in(), 1); - EXPECT_EQ(len.pc(), 12); - - len.set("1in"); - EXPECT_EQ(len.pt(), 72.27); - - len.set("12pc"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.in(), 1); - EXPECT_EQ(len.pc(), 12); - - len.set("2.54cm"); - EXPECT_EQ(len.pt(), 72.27); - EXPECT_EQ(len.cm(), 2.54); - EXPECT_EQ(len.mm(), 25.4); - - len.set("10mm"); - EXPECT_EQ(len.cm(), 1); - EXPECT_EQ(len.mm(), 10); - - len.set("1"); - EXPECT_EQ(len.pt(), 1); - - ASSERT_THROW(len.set("1xy"), UnitException); - ASSERT_THROW(len.set("pt"), UnitException); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/Makefile.am deleted file mode 100644 index 3cc15efde22..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/Makefile.am +++ /dev/null @@ -1,155 +0,0 @@ -## This file is part of dvisvgm -## Copyright (C) 2005-2013 Martin Gieseking -## -## Process this file with automake. - -AM_CXXFLAGS = -I$(srcdir)/../src -I$(srcdir)/../../src -Wall -DSRCDIR='"$(srcdir)"' - -TESTS = -check_PROGRAMS = - -TESTS += BoundingBoxTest -check_PROGRAMS += BoundingBoxTest -BoundingBoxTest_SOURCES = BoundingBoxTest.cpp -BoundingBoxTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += CalculatorTest -check_PROGRAMS += CalculatorTest -CalculatorTest_SOURCES = CalculatorTest.cpp -CalculatorTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += ColorSpecialTest -check_PROGRAMS += ColorSpecialTest -ColorSpecialTest_SOURCES = ColorSpecialTest.cpp -ColorSpecialTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += CommandLineTest -check_PROGRAMS += CommandLineTest -CommandLineTest_SOURCES = CommandLineTest.cpp -CommandLineTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += CRC32Test -check_PROGRAMS += CRC32Test -CRC32Test_SOURCES = CRC32Test.cpp -CRC32Test_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += DirectoryTest -check_PROGRAMS += DirectoryTest -DirectoryTest_SOURCES = DirectoryTest.cpp -DirectoryTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += FileFinderTest -check_PROGRAMS += FileFinderTest -FileFinderTest_SOURCES = FileFinderTest.cpp -FileFinderTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += FilePathTest -check_PROGRAMS += FilePathTest -FilePathTest_SOURCES = FilePathTest.cpp -FilePathTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += FileSystemTest -check_PROGRAMS += FileSystemTest -FileSystemTest_SOURCES = FileSystemTest.cpp -FileSystemTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += FontManagerTest -check_PROGRAMS += FontManagerTest -FontManagerTest_SOURCES = FontManagerTest.cpp -FontManagerTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += FontMapTest -check_PROGRAMS += FontMapTest -FontMapTest_SOURCES = FontMapTest.cpp -FontMapTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += GFReaderTest -check_PROGRAMS += GFReaderTest -GFReaderTest_SOURCES = GFReaderTest.cpp -GFReaderTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += GraphicPathTest -check_PROGRAMS += GraphicPathTest -GraphicPathTest_SOURCES = GraphicPathTest.cpp -GraphicPathTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += LengthTest -check_PROGRAMS += LengthTest -LengthTest_SOURCES = LengthTest.cpp -LengthTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += MapLineTest -check_PROGRAMS += MapLineTest -MapLineTest_SOURCES = MapLineTest.cpp -MapLineTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += MatrixTest -check_PROGRAMS += MatrixTest -MatrixTest_SOURCES = MatrixTest.cpp -MatrixTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += MessageExceptionTest -check_PROGRAMS += MessageExceptionTest -MessageExceptionTest_SOURCES = MessageExceptionTest.cpp -MessageExceptionTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += PageRagesTest -check_PROGRAMS += PageRagesTest -PageRagesTest_SOURCES = PageRagesTest.cpp -PageRagesTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += PageSizeTest -check_PROGRAMS += PageSizeTest -PageSizeTest_SOURCES = PageSizeTest.cpp -PageSizeTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += PairTest -check_PROGRAMS += PairTest -PairTest_SOURCES = PairTest.cpp -PairTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += PSInterpreterTest -check_PROGRAMS += PSInterpreterTest -PSInterpreterTest_SOURCES = PSInterpreterTest.cpp -PSInterpreterTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += SplittedCharInputBufferTest -check_PROGRAMS += SplittedCharInputBufferTest -SplittedCharInputBufferTest_SOURCES = SplittedCharInputBufferTest.cpp -SplittedCharInputBufferTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += StreamInputBufferTest -check_PROGRAMS += StreamInputBufferTest -StreamInputBufferTest_SOURCES = StreamInputBufferTest.cpp -StreamInputBufferTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += StreamReaderTest -check_PROGRAMS += StreamReaderTest -StreamReaderTest_SOURCES = StreamReaderTest.cpp -StreamReaderTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += StreamWriterTest -check_PROGRAMS += StreamWriterTest -StreamWriterTest_SOURCES = StreamWriterTest.cpp -StreamWriterTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += SubfontTest -check_PROGRAMS += SubfontTest -SubfontTest_SOURCES = SubfontTest.cpp -SubfontTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += TypesTest -check_PROGRAMS += TypesTest -TypesTest_SOURCES = TypesTest.cpp -TypesTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTS += VectorStreamTest -check_PROGRAMS += VectorStreamTest -VectorStreamTest_SOURCES = VectorStreamTest.cpp -VectorStreamTest_LDADD = ../src/libdvisvgm.a -L../potracelib -lpotrace -lgtest -lgtest_main -lpthread - -TESTDATA = -TESTDATA += frktest.dvi frktest-wf-cmp.svg frktest-nf-cmp.svg -TESTDATA += sample.dvi sample-wf-cmp.svg sample-nf-cmp.svg -EXTRA_DIST = check-conv normalize.xsl cmr10.600gf sample.sfd $(TESTDATA) -TESTS += check-conv diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MapLineTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MapLineTest.cpp deleted file mode 100644 index e03f53c4b21..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MapLineTest.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************* -** MapLineTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2012 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "FileFinder.h" -#include "MapLine.h" -#include "Subfont.h" - -using namespace std; - - -class MapLineTest : public ::testing::Test -{ - protected: - void SetUp () { - FileFinder::init("MapLineTest", "MapLineTest", false); - } - - void TearDown () { - FileFinder::finish(); - } -}; - - -TEST_F(MapLineTest, psline1) { - istringstream iss("texname0 TEXNAME0 name(), "UGBK"); - EXPECT_EQ(mapline.fontindex(), 0); - EXPECT_DOUBLE_EQ(mapline.slant(), 0.123); - EXPECT_DOUBLE_EQ(mapline.extend(), 0.456); - EXPECT_DOUBLE_EQ(mapline.bold(), 1); - } -} - -TEST_F(MapLineTest, pdfline4) { - istringstream iss("gbk@UGBK@ default :1:!simsun.ttc/UCS,Bold -e.345"); - MapLine mapline(iss); - EXPECT_EQ(mapline.texname(), "gbk"); - EXPECT_EQ(mapline.psname(), ""); - EXPECT_EQ(mapline.encname(), ""); // encodings "default" and "none" are replaced with "" - EXPECT_EQ(mapline.fontfname(), "simsun.ttc"); - if (mapline.sfd() != 0) { // if UGBK.sfd is installed do some more checks - EXPECT_EQ(mapline.sfd()->name(), "UGBK"); - EXPECT_EQ(mapline.fontindex(), 1); - EXPECT_DOUBLE_EQ(mapline.slant(), 0); - EXPECT_DOUBLE_EQ(mapline.extend(), 0.345); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MatrixTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MatrixTest.cpp deleted file mode 100644 index f01878900e1..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MatrixTest.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************* -** MatrixTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "Matrix.h" - -using namespace std; - - -TEST(MatrixTest, svg) { - double v1[] = {1,2,3,4,5,6,7,8,9}; - Matrix m1(v1); - ostringstream oss; - m1.write(oss); - EXPECT_EQ(oss.str(), "((1,2,3),(4,5,6),(7,8,9))"); - EXPECT_EQ(m1.getSVG(), "matrix(1 4 2 5 3 6)"); - - double v2[] = {1,2}; - Matrix m2(v2, 2); - oss.str(""); - m2.write(oss); - EXPECT_EQ(oss.str(), "((1,2,0),(0,1,0),(0,0,1))"); - EXPECT_EQ(m2.getSVG(), "matrix(1 0 2 1 0 0)"); -} - - -TEST(MatrixTest, transpose) { - double v[] = {1,2,3,4,5,6,7,8,9}; - Matrix m(v); - m.transpose(); - ostringstream oss; - m.write(oss); - EXPECT_EQ(oss.str(), "((1,4,7),(2,5,8),(3,6,9))"); - EXPECT_EQ(m.getSVG(), "matrix(1 2 4 5 7 8)"); -} - - -TEST(MatrixTest, scale) { - ScalingMatrix m(2,2); - DPair p = m*DPair(3,3); - EXPECT_DOUBLE_EQ(p.x(), 6); - EXPECT_DOUBLE_EQ(p.y(), 6); - - m = ScalingMatrix(-2,-2); - p = m*DPair(3,3); - EXPECT_DOUBLE_EQ(p.x(), -6); - EXPECT_DOUBLE_EQ(p.y(), -6); -} - - -TEST(MatrixTest, rotate) { - RotationMatrix m(90); - DPair p = m*DPair(2,0); - EXPECT_NEAR(p.x(), 0, 0.0000000001); - EXPECT_NEAR(p.y(), 2, 0.0000000001); - - p = m*p; - EXPECT_NEAR(p.x(), -2, 0.0000000001); - EXPECT_NEAR(p.y(), 0, 0.0000000001); -} - - -TEST(MatrixTest, checks) { - Matrix m(1); - EXPECT_TRUE(m.isIdentity()); - double tx, ty; - EXPECT_TRUE(m.isTranslation(tx, ty)); - EXPECT_EQ(tx, 0); - EXPECT_EQ(ty, 0); - m.translate(1,2); - EXPECT_TRUE(m.isTranslation(tx, ty)); - EXPECT_EQ(tx, 1); - EXPECT_EQ(ty, 2); - m.scale(2, 2); - EXPECT_FALSE(m.isTranslation(tx, ty)); -} - - -TEST(MatrixTest, vec) { - vector v; - for (int i=1; i <= 15; ++i) - v.push_back(i); - Matrix m(v); - ostringstream oss; - m.write(oss); - EXPECT_EQ(oss.str(), "((1,2,3),(4,5,6),(7,8,9))"); - oss.str(""); - - m.set(v, 2); - m.write(oss); - EXPECT_EQ(oss.str(), "((3,4,5),(6,7,8),(9,10,11))"); -} - - -TEST(MatrixTest, det) { - Matrix m1(1); - EXPECT_EQ(det(m1), 1); - - double v2[] = {1,2,3, 4,5,6, 7,8,9}; - Matrix m2(v2); - EXPECT_EQ(det(m2), 1*5*9 + 2*6*7 + 3*4*8 - 3*5*7 - 2*4*9 - 1*6*8); - - EXPECT_EQ(det(m2, 0, 0), 5*9-6*8); - EXPECT_EQ(det(m2, 0, 1), 4*9-6*7); - EXPECT_EQ(det(m2, 0, 2), 4*8-5*7); - EXPECT_EQ(det(m2, 1, 0), 2*9-3*8); - - double v3[] = {1,1,1, 2,2,2, 3,3,3}; - Matrix m3(v3); - EXPECT_EQ(det(m2), 0); - m3.transpose(); - EXPECT_EQ(det(m2), 0); -} - - -TEST(MatrixTest, invert) { - Matrix m1(1); - EXPECT_EQ(m1.invert(), m1); - - double v2[] = {1,2,3, 2,3,1, 3,1,2}; - Matrix m2(v2); - EXPECT_EQ(det(m2), -18); - - double v3[] = {5,-1,-7, -1,-7,5, -7,5,-1}; - Matrix m3(v3); - - m3 *= 1.0/det(m2); - m2.invert(); - for (int i=0; i < 3; ++i) - for (int j=0; j < 3; ++j) - EXPECT_DOUBLE_EQ(m2.get(i,j), m3.get(i,j)); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MessageExceptionTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MessageExceptionTest.cpp deleted file mode 100644 index 14d6ed94978..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/MessageExceptionTest.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* -** BoundingBoxTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "MessageException.h" - -using namespace std; - -static void throw_exception (const string &msg) { - throw MessageException(msg); -} - - -TEST(MessageExceptionTest, catch_direct) { - bool caught=false; - try { - throw_exception("test message"); - FAIL(); - } - catch (MessageException &e) { - ASSERT_TRUE(strcmp(e.what(), "test message") == 0); - caught = true; - } - catch (...) { - FAIL(); - } - ASSERT_TRUE(caught); -} - - -TEST(MessageExceptionTest, catch_indirect1) { - bool caught=false; - try { - throw_exception("test message"); - FAIL(); - } - catch (exception &e) { - ASSERT_TRUE(strcmp(e.what(), "test message") == 0); - caught = true; - } - catch (...) { - FAIL(); - } - ASSERT_TRUE(caught); -} - - -TEST(MessageExceptionTest, catch_indirect2) { - bool caught=false; - try { - throw_exception("test message"); - FAIL(); - } - catch (...) { - caught = true; - } - ASSERT_TRUE(caught); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PSInterpreterTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PSInterpreterTest.cpp deleted file mode 100644 index 06a9e7ce0dc..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PSInterpreterTest.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************* -** PSInterpreterTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "PSInterpreter.h" - -#include -#include - -using namespace std; - -class PSTestActions : public PSActions -{ - public: - void applyscalevals (vector &p) {print("applyscalevals", p);} - void clip (vector &p) {print("clip", p);} - void closepath (vector &p) {print("closepath", p);} - void curveto (vector &p) {print("curveto", p);} - void eoclip (vector &p) {print("eoclip", p);} - void eofill (vector &p) {print("eofill", p);} - void fill (vector &p) {print("fill", p);} - void gsave (vector &p) {print("gsave", p);} - void grestore (vector &p) {print("grestore", p);} - void grestoreall(std::vector &p) {print("grestoreall", p);} - void initclip (vector &p) {print("initclip", p);} - void lineto (vector &p) {print("lineto", p);} - void moveto (vector &p) {print("moveto", p);} - void makepattern (vector &p) {print("makepattern", p);} - void setpattern (vector &p) {print("setpattern", p);} - void newpath (vector &p) {print("newpath", p);} - void querypos (vector &p) {print("querypos", p);} - void restore(std::vector &p) {print("restore", p);} - void rotate (vector &p) {print("rotate", p);} - void save(std::vector &p) {print("save", p);} - void scale (vector &p) {print("scale", p);} - void setcmykcolor (vector &p) {print("setcmykcolor", p);} - void setdash (vector &p) {print("setdash", p);} - void setgray (vector &p) {print("setgray", p);} - void sethsbcolor (vector &p) {print("sethsbcolor", p);} - void setlinecap (vector &p) {print("setlinecap", p);} - void setlinejoin (vector &p) {print("setlinejoin", p);} - void setlinewidth (vector &p) {print("setlinewidth", p);} - void setmatrix (vector &p) {print("setmatrix", p);} - void setmiterlimit (vector &p) {print("setmiterlimit", p);} - void setopacityalpha (vector &p) {print("setopacityalpha", p);} - void setrgbcolor (vector &p) {print("setrgbcolor", p);} - void stroke (vector &p) {print("stroke", p);} - void translate (vector &p) {print("translate", p);} - - - string result () const {return _oss.str();} - void clear () {_oss.str("");} - - protected: - void print (const char *op, const vector &p) { - _oss << op; - for (size_t i=0; i < p.size(); ++i) - _oss << ' ' << p[i]; - _oss << ';'; - } - - private: - ostringstream _oss; -}; - - -TEST(PSInterpreterTest, init) { - PSTestActions actions; - PSInterpreter psi(&actions); - ASSERT_TRUE(psi.active()); - ASSERT_EQ(actions.result(), ""); -} - - -TEST(PSInterpreterTest, gsave_grestore) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("gsave "); - ASSERT_EQ(actions.result(), "gsave;"); - actions.clear(); - - psi.execute("grestore "); - ASSERT_EQ(actions.result(), "setlinewidth 1;setlinecap 0;setlinejoin 0;setmiterlimit 10;setrgbcolor 0 0 0;setmatrix 1 0 0 1 0 0;setdash 0;grestore;"); - actions.clear(); - - psi.execute("1 setlinecap 5 setmiterlimit 0 1 0 setrgbcolor gsave 0 setlinecap 10 setmiterlimit "); - ASSERT_EQ(actions.result(), "setlinecap 1;setmiterlimit 5;setrgbcolor 0 1 0;gsave;setlinecap 0;setmiterlimit 10;"); - actions.clear(); - - psi.execute("grestore "); - ASSERT_EQ(actions.result(), "setlinewidth 1;setlinecap 1;setlinejoin 0;setmiterlimit 5;setrgbcolor 0 1 0;setmatrix 1 0 0 1 0 0;setdash 0;grestore;"); -} - - -TEST(PSInterpreterTest, stroke_fill) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("0 0 moveto 10 10 lineto 0 10 lineto closepath stroke "); - ASSERT_EQ(actions.result(), "newpath;moveto 0 0;lineto 10 10;lineto 0 10;closepath;stroke;"); - actions.clear(); - - psi.execute("0 0 moveto 10 10 lineto 0 10 lineto closepath fill "); - ASSERT_EQ(actions.result(), "newpath;moveto 0 0;lineto 10 10;lineto 0 10;closepath;fill;"); -} - - -TEST(PSInterpreterTest, clip) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("initclip "); - ASSERT_EQ(actions.result(), "initclip;"); - actions.clear(); - - psi.execute("0 0 moveto 10 10 lineto 0 10 lineto closepath clip "); - ASSERT_EQ(actions.result(), "newpath;moveto 0 0;lineto 10 10;lineto 0 10;closepath;clip;"); -} - - -TEST(PSInterpreterTest, transform) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("10 10 scale 90 rotate 100 -100 translate "); - ASSERT_EQ(actions.result(), "scale 10 10;rotate 90;translate 100 -100;"); -} - - -TEST(PSInterpreterTest, calculate) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("2 3 add 4 mul 5 div rotate "); - ASSERT_EQ(actions.result(), "rotate 4;"); -} - - -TEST(PSInterpreterTest, setlinewidth) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("10 setlinewidth "); - ASSERT_EQ(actions.result(), "applyscalevals 1 1 1;setlinewidth 10;"); - actions.clear(); - - psi.execute("5 5 scale 10 setlinewidth "); - ASSERT_EQ(actions.result(), "scale 5 5;applyscalevals 5 5 1;setlinewidth 10;"); - actions.clear(); - - psi.execute("90 rotate 10 setlinewidth "); - ASSERT_EQ(actions.result(), "rotate 90;applyscalevals 5 5 0;setlinewidth 10;"); - actions.clear(); - - psi.execute("-30 rotate 10 setlinewidth "); - ASSERT_EQ(actions.result(), "rotate -30;applyscalevals 5 5 0.5;setlinewidth 10;"); -} - - -TEST(PSInterpreterTest, matrix) { - PSTestActions actions; - PSInterpreter psi(&actions); - psi.execute("matrix setmatrix "); - ASSERT_EQ(actions.result(), "setmatrix 1 0 0 1 0 0;"); - actions.clear(); - psi.execute("10 100 translate 30 rotate matrix currentmatrix setmatrix "); - ASSERT_EQ(actions.result(), "translate 10 100;rotate 30;setmatrix 0.866025 0.5 -0.5 0.866025 10 100;"); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageRagesTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageRagesTest.cpp deleted file mode 100644 index ec0da0dfb28..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageRagesTest.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/************************************************************************* -** PageRagesTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "PageRanges.h" - -using namespace std; - -static ostream& operator << (ostream &os, const PageRanges::Range &r) { - return os << '(' << r.first << ',' << r.second << ')'; -} - - -struct Range -{ - int l, r; -}; - - -static bool is_equal (const PageRanges &pr, const Range *r) { - int i=0; - for (PageRanges::ConstIterator it=pr.begin(); it != pr.end(); ++it) { - if (it->first != r[i].l || it->second != r[i].r) - return false; - ++i; - } - return true; -} - - -TEST(PageRangesTest, single) { - PageRanges pr; - ASSERT_TRUE(pr.parse("123")); - ASSERT_FALSE(pr.ranges().empty()); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(123,123)); - ASSERT_EQ(pr.pages(), 1); -} - - -TEST(PageRangesTest, single_range) { - PageRanges pr; - ASSERT_TRUE(pr.parse("3-19")); - ASSERT_FALSE(pr.ranges().empty()); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(3,19)); - ASSERT_EQ(pr.pages(), 17); -} - - -TEST(PageRangesTest, single_range_inv) { - PageRanges pr; - ASSERT_TRUE(pr.parse("19-3")); - ASSERT_FALSE(pr.ranges().empty()); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(3,19)); - ASSERT_EQ(pr.pages(), 17); -} - - -TEST(PageRangesTest, single_range_lopen) { - PageRanges pr; - ASSERT_TRUE(pr.parse("-19")); - ASSERT_FALSE(pr.ranges().empty()); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(1,19)); - ASSERT_EQ(pr.pages(), 19); -} - - -TEST(PageRangesTest, single_range_ropen) { - PageRanges pr; - ASSERT_TRUE(pr.parse("4-", 100)); - ASSERT_FALSE(pr.ranges().empty()); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(4,100)); - ASSERT_EQ(pr.pages(), 97); -} - - -TEST(PageRangesTest, multiple1) { - PageRanges pr; - ASSERT_TRUE(pr.parse("11,6,9,1,75,6,3")); - ASSERT_EQ(pr.size(), 6); - Range cmp[] = {{1,1},{3,3},{6,6},{9,9},{11,11},{75,75}}; - ASSERT_TRUE(is_equal(pr, cmp)); - ASSERT_EQ(pr.pages(), 6); -} - - -TEST(PageRangesTest, multiple2) { - PageRanges pr; - ASSERT_TRUE(pr.parse("2,6,9,1,75,6,3")); - ASSERT_EQ(pr.size(), 4); - Range cmp[] = {{1,3},{6,6},{9,9},{75,75}}; - ASSERT_TRUE(is_equal(pr, cmp)); -} - - -TEST(PageRangesTest, multiple3) { - PageRanges pr; - ASSERT_TRUE(pr.parse("2,6,9-11,1,25-,19-13,6,3", 100)); - ASSERT_EQ(pr.size(), 5); - Range cmp[] = {{1,3},{6,6},{9,11},{13,19},{25,100}}; - ASSERT_TRUE(is_equal(pr, cmp)); -} - - -TEST(PageRangesTest, overlap1) { - PageRanges pr; - ASSERT_TRUE(pr.parse("5-11, 8-15")); - ASSERT_EQ(pr.size(), 1); - Range cmp[] = {{5,15}}; - ASSERT_TRUE(is_equal(pr, cmp)); -} - - -TEST(PageRangesTest, overlap2) { - PageRanges pr; - ASSERT_TRUE(pr.parse("23-30, 5-11, 17-23, 12-19")); - ASSERT_EQ(pr.size(), 1); - Range cmp[] = {{5,30}}; - ASSERT_TRUE(is_equal(pr, cmp)); -} - - -TEST(PageRangesTest, overlap3) { - PageRanges pr; - ASSERT_TRUE(pr.parse("22-30, 5-11, 21-23, 12-19")); - ASSERT_EQ(pr.size(), 2); - Range cmp[] = {{5,19},{21,30}}; - ASSERT_TRUE(is_equal(pr, cmp)); -} - - -TEST(PageRangesTest, overlap4) { - PageRanges pr; - ASSERT_TRUE(pr.parse("-15, 20-, 8, 12-16, 18-19", 100)); - ASSERT_EQ(pr.size(), 2); - Range cmp[] = {{1,16},{18,100}}; - ASSERT_TRUE(is_equal(pr, cmp)); - ASSERT_TRUE(pr.parse("17")); - ASSERT_EQ(pr.size(), 1); - ASSERT_EQ(pr.ranges().front(), PageRanges::Range(1,100)); -} - - -TEST(PageRangesTest, error) { - PageRanges pr; - ASSERT_FALSE(pr.parse("x")); - ASSERT_FALSE(pr.parse("5-x")); - ASSERT_FALSE(pr.parse("5 6")); - ASSERT_FALSE(pr.parse("5,")); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageSizeTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageSizeTest.cpp deleted file mode 100644 index cb0bf778f9a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PageSizeTest.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************* -** PageSizeTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "PageSize.h" - - -class PageSizeTest : public ::testing::Test -{ - protected: - struct PageData - { - const char *id; - double width, height; - }; - - static const PageData pageData[]; - - PageSize ps; -}; - - -const PageSizeTest::PageData PageSizeTest::pageData[] = { - {"A4", 210, 297}, - {"a4", 210, 297}, - {"a4-p", 210, 297}, - {"a4-portrait", 210, 297}, - {"a4-l", 297, 210}, - {"a4-landscape", 297, 210}, - {"a5", 148, 210}, - {"c10", 28, 40}, - {"letter", 216, 279}, - {0, 0, 0} -}; - - -TEST_F(PageSizeTest, resize) { - EXPECT_FALSE(ps.valid()); - - for (const PageData *p = pageData; p && p->id; p++) { - ps.resize(p->id); - EXPECT_DOUBLE_EQ(ps.widthInMM(), p->width); - EXPECT_DOUBLE_EQ(ps.heightInMM(), p->height); - } -} - - -TEST_F(PageSizeTest, exceptions) { - EXPECT_THROW(ps.resize("a"), PageSizeException); - EXPECT_THROW(ps.resize("e4"), PageSizeException); - EXPECT_THROW(ps.resize("a4-unknown"), PageSizeException); -} - - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PairTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PairTest.cpp deleted file mode 100644 index 68157243f43..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/PairTest.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************* -** PairTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "Pair.h" - -using namespace std; - -TEST(PairTest, constructor) { - DPair p(-1.5, 2); - ASSERT_EQ(p.x(), -1.5); - ASSERT_EQ(p.y(), 2); - DPair q = p; - ASSERT_EQ(q.x(), -1.5); - ASSERT_EQ(q.y(), 2); -} - - -TEST(PairTest, setter) { - DPair p(1,2); - ASSERT_EQ(p, DPair(1,2)); - p.x(3); - ASSERT_EQ(p, DPair(3,2)); - p.y(5); - ASSERT_EQ(p, DPair(3,5)); -} - - -TEST(PairTest, length) { - ASSERT_EQ(DPair(0,0).length(), 0); - ASSERT_EQ(DPair(1,0).length(), 1); - ASSERT_EQ(DPair(0,1).length(), 1); - ASSERT_EQ(DPair(-1,0).length(), 1); - ASSERT_EQ(DPair(0,-1).length(), 1); - - // check some Pythagorean triples - for (int i=1; i < 10; ++i) { - for (int j=i+1; j <= 10; ++j) { - int a = j*j-i*i; - int b = 2*i*j; - int c = j*j+i*i; - ASSERT_EQ(DPair(a, b).length(), c); - ASSERT_EQ(DPair(b, a).length(), c); - ASSERT_EQ(DPair(-a, b).length(), c); - ASSERT_EQ(DPair(-b, a).length(), c); - ASSERT_EQ(DPair(-a, -b).length(), c); - } - } -} - - -TEST(PairTest, add) { - ASSERT_EQ(DPair(2,3)+DPair(0,0), DPair(2,3)); - ASSERT_EQ(DPair(2,3)+DPair(4,5), DPair(6,8)); - ASSERT_EQ(DPair(2,3)+DPair(-4,-5), DPair(-2,-2)); -} - - -TEST(PairTest, sub) { - ASSERT_EQ(DPair(2,3)-DPair(0,0), DPair(2,3)); - ASSERT_EQ(DPair(2,3)-DPair(4,5), DPair(-2,-2)); - ASSERT_EQ(DPair(2,3)-DPair(-4,-5), DPair(6,8)); -} - - -TEST(PairTest, mul) { - ASSERT_EQ(DPair(2,3)*0.0, DPair(0,0)); - ASSERT_EQ(DPair(2,3)*1.0, DPair(2,3)); - ASSERT_EQ(DPair(2,3)*2.0, DPair(4,6)); - ASSERT_EQ(DPair(2,3)*(-2.0), DPair(-4,-6)); -} - - -TEST(PairTest, div) { - ASSERT_EQ(DPair(2,3)/1.0, DPair(2,3)); - ASSERT_EQ(DPair(2,3)/2.0, DPair(1,1.5)); - ASSERT_EQ(DPair(2,3)/(-2.0), DPair(-1,-1.5)); -} - - -TEST(PairTest, equality) { - ASSERT_TRUE(DPair(2,3) == DPair(2,3)); - ASSERT_FALSE(DPair(2,3) == DPair(-2,-3)); - ASSERT_TRUE(DPair(2,3)+DPair(4,5) == DPair(6,8)); - ASSERT_FALSE(DPair(2,3)+DPair(4,5) != DPair(6,8)); -} - - -TEST(PairTest, ortho) { - ASSERT_EQ(DPair(0,0).ortho(), DPair(0,0)); - ASSERT_EQ(DPair(1,0).ortho(), DPair(0,1)); - ASSERT_EQ(DPair(0,1).ortho(), DPair(-1,0)); - ASSERT_EQ(DPair(-1,0).ortho(), DPair(0,-1)); - ASSERT_EQ(DPair(0,-1).ortho(), DPair(1,0)); -} - - -TEST(PairTest, write) { - ostringstream oss; - DPair p(3,4); - oss << p; - ASSERT_EQ(oss.str(), "(3,4)"); - p *= 2; - oss.str(""); - oss << p; - ASSERT_EQ(oss.str(), "(6,8)"); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SplittedCharInputBufferTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SplittedCharInputBufferTest.cpp deleted file mode 100644 index ff35f1c265c..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SplittedCharInputBufferTest.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/************************************************************************* -** SplittedCharInputBufferTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "InputBuffer.h" -#include "InputReader.h" - -using std::istringstream; - -TEST(SplittedCharInputBufferTest, get) { - const char *buf1 = "abcdef"; - const char *buf2 = "ghijklmnopqrstuvwxyz"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - bool ok=true; - for (int i=0; !in.eof() && ok; i++) { - EXPECT_LT(i, 26); - EXPECT_EQ(in.get(), 'a'+i); - ok = (i < 26); - } -} - - -TEST(SplittedCharInputBufferTest, peek) { - const char *buf1 = "abcdef"; - const char *buf2 = "ghijklmnopqrstuvwxyz"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - EXPECT_EQ(in.peek(), 'a'); - for (int i=0; i < 26; i++) - EXPECT_EQ(in.peek(i), 'a'+i); - EXPECT_EQ(in.peek(26), -1); -} - - -TEST(SplittedCharInputBufferTest, check) { - const char *buf1 = "abcde"; - const char *buf2 = "fghijklmnopqrstuvwxyz"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - EXPECT_TRUE(in.check("abc", false)); - EXPECT_TRUE(in.check("abc", true)); - EXPECT_TRUE(in.check("def", true)); - EXPECT_TRUE(in.check("ghi", true)); - EXPECT_TRUE(in.check("jkl", true)); - EXPECT_TRUE(in.check("mnopqrst", false)); - EXPECT_TRUE(in.check("mnopqrst", true)); - EXPECT_TRUE(in.check("uvwxyz", true)); - EXPECT_EQ(in.get(), -1); -} - - -TEST(SplittedCharInputBufferTest, skip) { - const char *buf1 = "abcde"; - const char *buf2 = "fghijklmnopqrstuvwxyz"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - in.skip(3); - EXPECT_EQ(in.peek(), 'd'); - in.skipUntil("ijk", false); - EXPECT_EQ(in.peek(), 'i'); - in.skipUntil("ijk", true); - EXPECT_EQ(in.peek(), 'l'); - in.skipUntil("z", true); - EXPECT_TRUE(in.eof()); -} - - -TEST(SplittedCharInputBufferTest, parseInt) { - const char *buf1 = "1234,-"; - const char *buf2 = "5,+6,10.-"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - int n; - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 1234); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, -5); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 6); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 10); - EXPECT_EQ(in.get(), '.'); - - EXPECT_FALSE(in.parseInt(n)); - EXPECT_EQ(in.get(), '-'); -} - - -TEST(SplittedCharInputBufferTest, parseInt_base) { - const char *buf1 = "1234,-5,10,1a"; - const char *buf2 = "bc,1234a"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - int n; - EXPECT_TRUE(in.parseInt(10, n)); - EXPECT_EQ(n, 1234); - EXPECT_EQ(in.get(), ','); - - EXPECT_FALSE(in.parseInt(10, n)); - in.get(); - EXPECT_TRUE(in.parseInt(10, n)); - EXPECT_EQ(n, 5); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(16, n)); - EXPECT_EQ(n, 16); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(16, n)); - EXPECT_EQ(n, 0x1abc); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(8, n)); - EXPECT_EQ(n, 01234); - EXPECT_EQ(in.get(), 'a'); -} - - -TEST(SplittedCharInputBufferTest, parseDouble) { - const char *buf1 = "1234,-5,6.12,-3"; - const char *buf2 = ".1415,-.1,12e2,10.-"; - SplittedCharInputBuffer buffer(buf1, strlen(buf1), buf2, strlen(buf2)); - BufferInputReader in(buffer); - double d; - EXPECT_EQ(in.parseDouble(d), 'i'); - EXPECT_EQ(d, 1234.0); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'i'); - EXPECT_EQ(d, -5.0); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 6.12); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, -3.1415); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, -0.1); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 1200); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 10.0); - EXPECT_EQ(in.peek(), '-'); - - EXPECT_FALSE(in.parseDouble(d)); - EXPECT_EQ(in.get(), '-'); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamInputBufferTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamInputBufferTest.cpp deleted file mode 100644 index 8a1fbd103c2..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamInputBufferTest.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************* -** StreamInputBufferTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include -#include "InputBuffer.h" -#include "InputReader.h" - -using std::istringstream; -using std::map; -using std::string; - -TEST(StreamInputBufferTest, get) { - istringstream iss("abcdefghijklmnopqrstuvwxyz"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - bool ok=true; - for (int i=0; !in.eof() && ok; i++) { - EXPECT_LT(i, 26); - EXPECT_EQ(in.get(), 'a'+i); - ok = (i < 26); - } -} - - -TEST(StreamInputBufferTest, peek) { - istringstream iss("abcdefghijklmnopqrstuvwxyz"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - EXPECT_EQ(in.peek(), 'a'); - for (int i=0; i < 20; i++) - EXPECT_EQ(in.peek(i), 'a'+i); - // we can't look forward more than BUFSIZE characters (10 in this case) - for (int i=21; i < 26; i++) - EXPECT_EQ(in.peek(i), -1); -} - - -TEST(StreamInputBufferTest, check) { - istringstream iss("abcdefghijklmnopqrstuvwxyz"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - EXPECT_TRUE(in.check("abc", false)); - EXPECT_TRUE(in.check("abc", true)); - EXPECT_TRUE(in.check("def", true)); - EXPECT_TRUE(in.check("ghi", true)); - EXPECT_TRUE(in.check("jkl", true)); - EXPECT_TRUE(in.check("mnopqrst", false)); - EXPECT_TRUE(in.check("mnopqrst", true)); - EXPECT_TRUE(in.check("uvwxyz", true)); -} - - -TEST(StreamInputBufferTest, skip) { - istringstream iss("abcdefghijklmnopqrstuvwxyz"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - in.skip(3); - EXPECT_EQ(in.peek(), 'd'); - in.skipUntil("ijk", false); - EXPECT_EQ(in.peek(), 'i'); - in.skipUntil("ijk", true); - EXPECT_EQ(in.peek(), 'l'); - in.skipUntil("z", true); - EXPECT_TRUE(in.eof()); -} - - -TEST(StreamInputBufferTest, parseInt) { - istringstream iss("1234,-5,+6,10.-"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - int n; - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 1234); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, -5); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 6); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(n)); - EXPECT_EQ(n, 10); - EXPECT_EQ(in.get(), '.'); - - EXPECT_FALSE(in.parseInt(n)); - EXPECT_EQ(in.get(), '-'); -} - - -TEST(StreamInputBufferTest, parseInt_base) { - istringstream iss("1234,-5,10,1abc,1234a"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - int n; - EXPECT_TRUE(in.parseInt(10, n)); - EXPECT_EQ(n, 1234); - EXPECT_EQ(in.get(), ','); - - EXPECT_FALSE(in.parseInt(10, n)); - in.get(); - EXPECT_TRUE(in.parseInt(10, n)); - EXPECT_EQ(n, 5); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(16, n)); - EXPECT_EQ(n, 16); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(16, n)); - EXPECT_EQ(n, 0x1abc); - EXPECT_EQ(in.get(), ','); - - EXPECT_TRUE(in.parseInt(8, n)); - EXPECT_EQ(n, 01234); - EXPECT_EQ(in.get(), 'a'); -} - - -TEST(StreamInputBufferTest, parseDouble) { - istringstream iss("1234,-5,6.12,-3.1415,-0.5,-.1,12e2,10.-"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - double d; - EXPECT_EQ(in.parseDouble(d), 'i'); - EXPECT_EQ(d, 1234.0); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'i'); - EXPECT_EQ(d, -5.0); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 6.12); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, -3.1415); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, -0.5); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, -0.1); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 1200); - EXPECT_EQ(in.get(), ','); - - EXPECT_EQ(in.parseDouble(d), 'f'); - EXPECT_EQ(d, 10.0); - EXPECT_EQ(in.peek(), '-'); - - EXPECT_FALSE(in.parseDouble(d)); - EXPECT_EQ(in.get(), '-'); -} - - -TEST(StreamInputBufferTest, attribs) { - istringstream iss("aaa=1 bbb=2 ccc=3 d e"); - StreamInputBuffer buffer(iss, 10); - BufferInputReader in(buffer); - map attr; - int s = in.parseAttributes(attr); - EXPECT_EQ(s, 3); - EXPECT_EQ(attr["aaa"], "1"); - EXPECT_EQ(attr["bbb"], "2"); - EXPECT_EQ(attr["ccc"], "3"); -} - - -TEST(StreamInputBufferTest, invalidate) { - istringstream iss("aaa=1 bbb=2 ccc=3 d e"); - StreamInputBuffer buffer(iss, 10); - EXPECT_EQ(buffer.get(), 'a'); - EXPECT_EQ(buffer.get(), 'a'); - EXPECT_EQ(buffer.get(), 'a'); - EXPECT_EQ(buffer.get(), '='); - buffer.invalidate(); - EXPECT_TRUE(buffer.eof()); -} - - -TEST(StreamInputBufferTest, find) { - istringstream iss("abcd efgh ijklmn abc"); - StreamInputBuffer buffer(iss); - BufferInputReader reader(buffer); - EXPECT_EQ(reader.find('x'), -1); - EXPECT_EQ(reader.find('c'), 2); - EXPECT_EQ(reader.find(' '), 4); -} - - -TEST(StreamInputBufferTest, getString) { - istringstream iss("abcd efgh \"ijklm\"n abcdef 01234"); - StreamInputBuffer buffer(iss); - BufferInputReader reader(buffer); - EXPECT_EQ(reader.getString(), "abcd"); - EXPECT_EQ(reader.getString(), "efgh"); - EXPECT_EQ(reader.getQuotedString('"'), "ijklm"); - EXPECT_EQ(reader.getQuotedString('"'), ""); - EXPECT_EQ(reader.getString(4), "n ab"); - EXPECT_EQ(reader.getQuotedString(0), "cdef"); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamReaderTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamReaderTest.cpp deleted file mode 100644 index ba294a87201..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamReaderTest.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************* -** StreamReaderTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "CRC32.h" -#include "StreamReader.h" - -using namespace std; - -TEST(StreamReaderTest, readString) { - istringstream iss("dvisvgm converts DVI files to SVG."); - StreamReader reader(iss); - string str = reader.readString(iss.str().length()); - EXPECT_EQ(str, iss.str()); -} - - -TEST(StreamReaderTest, readStringCRC) { - istringstream iss("dvisvgm converts DVI files to SVG."); - StreamReader reader(iss); - CRC32 crc; - string str = reader.readString(iss.str().length(), crc); - EXPECT_EQ(str, iss.str()); - EXPECT_EQ(crc.get(), 0x7c4ef359); -} - - -TEST(StreamReaderTest, readUnsigned) { - string str; - str.push_back('\x00'); - str.push_back('\x01'); - str.push_back('\x02'); - str.push_back('\x03'); - istringstream iss(str); - StreamReader reader(iss); - UInt32 val = reader.readUnsigned(4); - EXPECT_EQ(val, 0x00010203); -} - - -TEST(StreamReaderTest, readUnsignedCRC) { - string str; - str.push_back('\x00'); - str.push_back('\x01'); - str.push_back('\x02'); - str.push_back('\x03'); - istringstream iss(str); - StreamReader reader(iss); - CRC32 crc; - UInt32 val = reader.readUnsigned(4, crc); - EXPECT_EQ(val, 0x00010203); - EXPECT_EQ(crc.get(), 0x8bb98613); -} - - -TEST(StreamReaderTest, readSigned) { - string str; - str.push_back('\xff'); - str.push_back('\xee'); - str.push_back('\xdd'); - str.push_back('\xcc'); - istringstream iss(str); - StreamReader reader(iss); - Int32 val = reader.readUnsigned(4); - EXPECT_EQ(val, 0xffeeddcc); -} - - -TEST(StreamReaderTest, readSignedCRC) { - string str; - str.push_back('\xff'); - str.push_back('\xee'); - str.push_back('\xdd'); - str.push_back('\xcc'); - istringstream iss(str); - StreamReader reader(iss); - CRC32 crc; - Int32 val = reader.readUnsigned(4, crc); - EXPECT_EQ(val, 0xffeeddcc); - EXPECT_EQ(crc.get(), 0xfa79118e); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamWriterTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamWriterTest.cpp deleted file mode 100644 index 0e142c205fa..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/StreamWriterTest.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* -** StreamWriterTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include -#include "CRC32.h" -#include "StreamWriter.h" - -using namespace std; - -TEST(StreamWriterTest, writeString) { - ostringstream oss; - StreamWriter writer(oss); - string str = "dvisvgm converts DVI files to SVG."; - writer.writeString(str); - EXPECT_EQ(oss.str(), str); - - oss.str(""); - writer.writeString(str, true); - str.push_back('\0'); - EXPECT_EQ(oss.str(), str); -} - - -TEST(StreamWriterTest, writeStringCRC) { - ostringstream oss; - StreamWriter writer(oss); - CRC32 crc; - string str = "dvisvgm converts DVI files to SVG."; - writer.writeString(str, crc); - EXPECT_EQ(oss.str(), str); - EXPECT_EQ(crc.get(), 0x7C4EF359); - - oss.str(""); - crc.reset(); - writer.writeString(str, crc, true); - str.push_back('\0'); - EXPECT_EQ(oss.str(), str); - EXPECT_EQ(crc.get(), 0xc0c9482e); -} - - -TEST(StreamWriterTest, writeUnsigned) { - ostringstream oss; - StreamWriter writer(oss); - writer.writeUnsigned(0x00010203, 4); - string str; - str.push_back('\x00'); - str.push_back('\x01'); - str.push_back('\x02'); - str.push_back('\x03'); - EXPECT_EQ(oss.str(), str); -} - - -TEST(StreamWriterTest, writeUnsignedCRC) { - ostringstream oss; - StreamWriter writer(oss); - CRC32 crc; - writer.writeUnsigned(0x00010203, 4, crc); - string str; - str.push_back('\x00'); - str.push_back('\x01'); - str.push_back('\x02'); - str.push_back('\x03'); - EXPECT_EQ(oss.str(), str); - EXPECT_EQ(crc.get(), 0x8bb98613); -} - - -TEST(StreamWriterTest, writeSigned) { - ostringstream oss; - StreamWriter writer(oss); - writer.writeUnsigned(0xffeeddcc, 4); - string str; - str.push_back('\xff'); - str.push_back('\xee'); - str.push_back('\xdd'); - str.push_back('\xcc'); - EXPECT_EQ(oss.str(), str); -} - - -TEST(StreamWriterTest, writeSignedCRC) { - ostringstream oss; - StreamWriter writer(oss); - CRC32 crc; - writer.writeUnsigned(0xffeeddcc, 4, crc); - string str; - str.push_back('\xff'); - str.push_back('\xee'); - str.push_back('\xdd'); - str.push_back('\xcc'); - EXPECT_EQ(oss.str(), str); - EXPECT_EQ(crc.get(), 0xfa79118e); -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SubfontTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SubfontTest.cpp deleted file mode 100644 index de93aafcbaf..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/SubfontTest.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************* -** SubfontTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2012 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "FileFinder.h" -#include "Subfont.h" - -using namespace std; - - -class SubfontTest : public ::testing::Test -{ - protected: - void SetUp () { - FileFinder::init("SubfontTest", "SubfontTest", false); - } - - void TearDown () { - FileFinder::finish(); - } -}; - - -TEST_F(SubfontTest, collect_subfonts) { - try { - if (SubfontDefinition *sfd = SubfontDefinition::lookup("sample")) { - vector subfonts; - const char *ids_cmp[] = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "x1"}; - int size = sizeof(ids_cmp)/sizeof(Subfont*); - EXPECT_EQ(sfd->subfonts(subfonts), size); - for (int i=0; i < size; i++) { - EXPECT_EQ(subfonts[i]->id(), ids_cmp[i]); - } - } - } - catch (SubfontException &e) { - FAIL() << e.what(); - } -} - - -TEST_F(SubfontTest, read_table) { - try { - if (SubfontDefinition *sfd = SubfontDefinition::lookup("sample")) { - // check scanning of single value entries - Subfont *subfont = sfd->subfont("02"); - ASSERT_TRUE(subfont != 0); - EXPECT_EQ(subfont->id(), "02"); - EXPECT_EQ(subfont->decode(0), 0xff45); - EXPECT_EQ(subfont->decode(1), 0xff46); - EXPECT_EQ(subfont->decode(2), 0xff47); - EXPECT_EQ(subfont->decode(8), 0xff4d); - EXPECT_EQ(subfont->decode(32), 0x3047); - EXPECT_EQ(subfont->decode(255), 0x03ba); - - // check scanning of ranges - subfont = sfd->subfont("x1"); - ASSERT_TRUE(subfont != 0); - EXPECT_EQ(subfont->id(), "x1"); - EXPECT_EQ(subfont->decode(0), 0x0010); - EXPECT_EQ(subfont->decode(1), 0x0011); - EXPECT_EQ(subfont->decode(2), 0x0012); - EXPECT_EQ(subfont->decode(0x20), 0x0030); - EXPECT_EQ(subfont->decode(0x21), 0x1010); - EXPECT_EQ(subfont->decode(0x41), 0x1030); - EXPECT_EQ(subfont->decode(0x42), 0xe000); - EXPECT_EQ(subfont->decode(0x43), 0); - - //check scanning of offset values - EXPECT_EQ(subfont->decode(0x9f), 0); - EXPECT_EQ(subfont->decode(0xa0), 0x1000); - EXPECT_EQ(subfont->decode(0xa1), 0x2000); - EXPECT_EQ(subfont->decode(0xa2), 0); - } - } - catch (SubfontException &e) { - FAIL() << e.what() << " in line " << e.lineno(); - } -} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/TypesTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/TypesTest.cpp deleted file mode 100644 index 11cb44fc191..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/TypesTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************************* -** TypesTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include "types.h" - -using namespace std; - - -TEST(TypesTest, size_signed) { - ASSERT_EQ(sizeof(Int8), 1); - ASSERT_EQ(sizeof(Int16), 2); - ASSERT_EQ(sizeof(Int32), 4); - ASSERT_EQ(sizeof(Int64), 8); -} - - -TEST(TypesTest, neg_signed) { - ASSERT_LT(Int8(-1), 0); - ASSERT_LT(Int16(-1), 0); - ASSERT_LT(Int32(-1), 0); - ASSERT_LT(Int64(-1), 0); -} - - -TEST(TypesTest, unsigned_types) { - ASSERT_EQ(sizeof(UInt8), 1); - ASSERT_EQ(sizeof(UInt16), 2); - ASSERT_EQ(sizeof(UInt32), 4); - ASSERT_EQ(sizeof(UInt64), 8); -} - - -TEST(TypesTest, neg_unsigned) { - ASSERT_GT(UInt8(-1), 0); - ASSERT_GT(UInt16(-1), 0); - ASSERT_GT(UInt32(-1), 0); - ASSERT_GT(UInt64(-1), 0); -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/VectorStreamTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/VectorStreamTest.cpp deleted file mode 100644 index 2d5d0b0bc3e..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/VectorStreamTest.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************* -** VectorStreamTest.cpp ** -** ** -** This file is part of dvisvgm -- the DVI to SVG converter ** -** Copyright (C) 2005-2013 Martin Gieseking ** -** ** -** 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 . ** -*************************************************************************/ - -#include -#include -#include "VectorStream.h" - -using std::string; -using std::vector; - -TEST(VectorStreamTest, read) { - const char *str = "abcdefghijklm\0nopqrstuvwxyz"; - vector vec(str, str+27); - VectorInputStream vs(vec); - for (unsigned count = 0; vs; count++) { - int c = vs.get(); - if (count < vec.size()) { - EXPECT_EQ(c, str[count]); - } - else { - EXPECT_EQ(c, -1); - } - } -} - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/check-conv b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/check-conv deleted file mode 100755 index 9aeda3a2d74..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/check-conv +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# This file is part of the dvisvgm package and published under the -# terms of the GNU General Public License version 3 or later. -# See file COPYING for further details. -# (C) 2009-2012 Martin Gieseking - - -files=(sample frktest) -state=0 - -BLUE="\E[0;34m" -GREEN="\E[0;32m" -RED="\E[0;31m" -COLOR_OFF="\E[0m" - -if [ \! -e enable-check-conv ]; then - echo -e "${BLUE}conversion checks skipped${COLOR_OFF}" - exit 0 -fi - -for f in ${files[@]}; do - for m in "wf" "nf"; do - infile=${srcdir}/$f - outfile=$f-$m.svg - cmpfile=${srcdir}/$f-$m-cmp.svg - if [ $m = "wf" ]; then - ../src/dvisvgm -v0 -o$outfile $infile - else - ../src/dvisvgm -v0 -n -o$outfile $infile - fi - xsltproc --novalid ${srcdir}/normalize.xsl $outfile | xmllint --format - >tmp1.svg - xsltproc --novalid ${srcdir}/normalize.xsl $cmpfile | xmllint --format - >tmp2.svg - mv tmp1.svg $outfile - - diff $outfile tmp2.svg >$f-$m.diff #>/dev/null - if [ $? -ne 0 ]; then - echo -en "${RED}FAILED $COLOR_OFF" - state=1 - else - echo -en "${GREEN}PASSED $COLOR_OFF" - rm $outfile - fi - echo "converting $f.dvi (mode $m)" - if [ \! -s $f-$m.diff ]; then - rm $f-$m.diff - fi - rm tmp2.svg - done -done -exit $state diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/cmr10.600gf b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/cmr10.600gf deleted file mode 100644 index 6dca421e21c..00000000000 Binary files a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/cmr10.600gf and /dev/null differ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-nf-cmp.svg b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-nf-cmp.svg deleted file mode 100644 index 372662c6b95..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-nf-cmp.svg +++ /dev/null @@ -1,1223 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-wf-cmp.svg b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-wf-cmp.svg deleted file mode 100644 index b8effca34a5..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest-wf-cmp.svg +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Nonummys -id -sem»r -aliena -auditorum -lorem -ipsum -quod -omnia -sunt -»ccatore‘: -Lorem -ipsum -˘lor -s -it -amet -con -se˝etuer -adi- -piscing -elit: -Sed -diam -tem–r -incidunt -ut -laˆre -et -˘lor -magna -aliquam -erat -volu«t -ut -wis -i -enim -ad -minim -ffiniam -qui‘ -no<rud -oblationem -cor–remque -suscipit -laˆri‘ - - D - ie - Orgel - ,der - - Flđgel - ,daŊ - - Fortepiano - unddaŊ - - Clavicord - sind -die -gebrĽuĚliĚĆen -ClavierinĆrumente -zum -Accompagnement. - - -SĚade, -da -die -sĚŹne -Erfindung -deŊ - - HolfeldisĚen -BogenclavierŊ - - noĚniĚt -gemeinnđŃig -geworden -iĆ; -man -kann -dahero -deĄen -besondere -Vorzđge -hierinnen -noĚ -niĚt -genau -beĆimmen. - - -gewi -zu -glauben, -da - -s - -auĚ -bey -der -Begleitung -gut -auŊnehmen -werde. - - V - ondem -ĆattliĚen -Orte -KirĚehrenbaĚ -in -der -FrŁnkisĚen -SĚweiz -f§hrt -ein -einsameŊ -StrŁĚen, -an -der -Ćeil -abƧr- -zenden -Breitseite -der -Ehrenb§rg -vor§ber, -gen -LeutenbaĚ. -In -einer -halben -Stunde - -daŊ -sĚmuĘe -Pfarrdorf -erreiĚt. -S§dŽĆliĚ -deŊselben, -kaum -eine -ViertelĆunde -entfernt, -treĎen -wir -auf -dem -Wege -naĚ -OrtspiŃ -in -einem -SeitentŁlĚen -von -unber§hrter -Na- -tursĚŽnheit -daŊ -uralte, -einsame -KirĚlein -\Sankt -MoriŃ" -mit -seinem -Ćillen -Friedhofe. -In -der -NŁhe -deŊ -KirĚleinŊ -Ćeht -ein -niedrigeŊ, -§ber -eine -Quelle -erbauteŊ -FeldkapellĚen -mit -der -Statue -deŊ -hl. -MauritiuŊ, -dargeĆellt -alŊ -Ritter -in -voller -Wehr. - - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest.dvi b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest.dvi deleted file mode 100644 index 723b08a2964..00000000000 Binary files a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/frktest.dvi and /dev/null differ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/normalize.xsl b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/normalize.xsl deleted file mode 100644 index 5a6ba2f62d6..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/normalize.xsl +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-nf-cmp.svg b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-nf-cmp.svg deleted file mode 100644 index b448e6caa8a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-nf-cmp.svg +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-wf-cmp.svg b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-wf-cmp.svg deleted file mode 100644 index d597c134c9a..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample-wf-cmp.svg +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Colortest: -red, -blue, -magen -ta - - - x - 0 - cos - t - d - t - = - - - k - =0 - ( - - 1) - k - x - 2 - k - +1 - - (2 - k - +1)! - - Fon -t -st -yles: - - bold - - , - emphasized - - , - sansserif - - , - SmallCaps - - , - slanted - - 1 - - diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.dvi b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.dvi deleted file mode 100644 index 87e6236021d..00000000000 Binary files a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.dvi and /dev/null differ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.sfd b/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.sfd deleted file mode 100644 index e7c84c7b5e1..00000000000 --- a/Build/source/texk/dvisvgm/dvisvgm-1.2.2/tests/sample.sfd +++ /dev/null @@ -1,293 +0,0 @@ -00 0x0000_0x00FF -01 0x3000 0x3001 0x3002 0x00B7 0x02C9 0x02C7 0x00A8 0x3003 \ - 0x3005 0x2014 0xFF5E 0x2016 0x2026 0x2018 0x2019 0x201C \ - 0x201D 0x3014 0x3015 0x3008 0x3009 0x300A 0x300B 0x300C \ - 0x300D 0x300E 0x300F 0x3016 0x3017 0x3010 0x3011 0x00B1 \ - 0x00D7 0x00F7 0x2236 0x2227 0x2228 0x2211 0x220F 0x222A \ - 0x2229 0x2208 0x2237 0x221A 0x22A5 0x2225 0x2220 0x2312 \ - 0x2299 0x222B 0x222E 0x2261 0x224C 0x2248 0x223D 0x221D \ - 0x2260 0x226E 0x226F 0x2264 0x2265 0x221E 0x2235 0x2234 \ - 0x2642 0x2640 0x00B0 0x2032 0x2033 0x2103 0xFF04 0x00A4 \ - 0xFFE0 0xFFE1 0x2030 0x00A7 0x2116 0x2606 0x2605 0x25CB \ - 0x25CF 0x25CE 0x25C7 0x25C6 0x25A1 0x25A0 0x25B3 0x25B2 \ - 0x203B 0x2192 0x2190 0x2191 0x2193 0x3013 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x2488 0x2489 \ - 0x248A 0x248B 0x248C 0x248D 0x248E 0x248F 0x2490 0x2491 \ - 0x2492 0x2493 0x2494 0x2495 0x2496 0x2497 0x2498 0x2499 \ - 0x249A 0x249B 0x2474 0x2475 0x2476 0x2477 0x2478 0x2479 \ - 0x247A 0x247B 0x247C 0x247D 0x247E 0x247F 0x2480 0x2481 \ - 0x2482 0x2483 0x2484 0x2485 0x2486 0x2487 0x2460 0x2461 \ - 0x2462 0x2463 0x2464 0x2465 0x2466 0x2467 0x2468 0x2469 \ - 0xFFFE 0xFFFE 0x3220 0x3221 0x3222 0x3223 0x3224 0x3225 \ - 0x3226 0x3227 0x3228 0x3229 0xFFFE 0xFFFE 0x2160 0x2161 \ - 0x2162 0x2163 0x2164 0x2165 0x2166 0x2167 0x2168 0x2169 \ - 0x216A 0x216B 0xFFFE 0xFFFE 0xFF01 0xFF02 0xFF03 0xFFE5 \ - 0xFF05 0xFF06 0xFF07 0xFF08 0xFF09 0xFF0A 0xFF0B 0xFF0C \ - 0xFF0D 0xFF0E 0xFF0F 0xFF10 0xFF11 0xFF12 0xFF13 0xFF14 \ - 0xFF15 0xFF16 0xFF17 0xFF18 0xFF19 0xFF1A 0xFF1B 0xFF1C \ - 0xFF1D 0xFF1E 0xFF1F 0xFF20 0xFF21 0xFF22 0xFF23 0xFF24 \ - 0xFF25 0xFF26 0xFF27 0xFF28 0xFF29 0xFF2A 0xFF2B 0xFF2C \ - 0xFF2D 0xFF2E 0xFF2F 0xFF30 0xFF31 0xFF32 0xFF33 0xFF34 \ - 0xFF35 0xFF36 0xFF37 0xFF38 0xFF39 0xFF3A 0xFF3B 0xFF3C \ - 0xFF3D 0xFF3E 0xFF3F 0xFF40 0xFF41 0xFF42 0xFF43 0xFF44 -02 0xFF45 0xFF46 0xFF47 0xFF48 0xFF49 0xFF4A 0xFF4B 0xFF4C \ - 0xFF4D 0xFF4E 0xFF4F 0xFF50 0xFF51 0xFF52 0xFF53 0xFF54 \ - 0xFF55 0xFF56 0xFF57 0xFF58 0xFF59 0xFF5A 0xFF5B 0xFF5C \ - 0xFF5D 0xFFE3 0x3041 0x3042 0x3043 0x3044 0x3045 0x3046 \ - 0x3047 0x3048 0x3049 0x304A 0x304B 0x304C 0x304D 0x304E \ - 0x304F 0x3050 0x3051 0x3052 0x3053 0x3054 0x3055 0x3056 \ - 0x3057 0x3058 0x3059 0x305A 0x305B 0x305C 0x305D 0x305E \ - 0x305F 0x3060 0x3061 0x3062 0x3063 0x3064 0x3065 0x3066 \ - 0x3067 0x3068 0x3069 0x306A 0x306B 0x306C 0x306D 0x306E \ - 0x306F 0x3070 0x3071 0x3072 0x3073 0x3074 0x3075 0x3076 \ - 0x3077 0x3078 0x3079 0x307A 0x307B 0x307C 0x307D 0x307E \ - 0x307F 0x3080 0x3081 0x3082 0x3083 0x3084 0x3085 0x3086 \ - 0x3087 0x3088 0x3089 0x308A 0x308B 0x308C 0x308D 0x308E \ - 0x308F 0x3090 0x3091 0x3092 0x3093 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0x30A1 0x30A2 0x30A3 0x30A4 0x30A5 0x30A6 0x30A7 0x30A8 \ - 0x30A9 0x30AA 0x30AB 0x30AC 0x30AD 0x30AE 0x30AF 0x30B0 \ - 0x30B1 0x30B2 0x30B3 0x30B4 0x30B5 0x30B6 0x30B7 0x30B8 \ - 0x30B9 0x30BA 0x30BB 0x30BC 0x30BD 0x30BE 0x30BF 0x30C0 \ - 0x30C1 0x30C2 0x30C3 0x30C4 0x30C5 0x30C6 0x30C7 0x30C8 \ - 0x30C9 0x30CA 0x30CB 0x30CC 0x30CD 0x30CE 0x30CF 0x30D0 \ - 0x30D1 0x30D2 0x30D3 0x30D4 0x30D5 0x30D6 0x30D7 0x30D8 \ - 0x30D9 0x30DA 0x30DB 0x30DC 0x30DD 0x30DE 0x30DF 0x30E0 \ - 0x30E1 0x30E2 0x30E3 0x30E4 0x30E5 0x30E6 0x30E7 0x30E8 \ - 0x30E9 0x30EA 0x30EB 0x30EC 0x30ED 0x30EE 0x30EF 0x30F0 \ - 0x30F1 0x30F2 0x30F3 0x30F4 0x30F5 0x30F6 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x0391 0x0392 \ - 0x0393 0x0394 0x0395 0x0396 0x0397 0x0398 0x0399 0x039A \ - 0x039B 0x039C 0x039D 0x039E 0x039F 0x03A0 0x03A1 0x03A3 \ - 0x03A4 0x03A5 0x03A6 0x03A7 0x03A8 0x03A9 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x03B1 0x03B2 \ - 0x03B3 0x03B4 0x03B5 0x03B6 0x03B7 0x03B8 0x03B9 0x03BA -03 0x03BB 0x03BC 0x03BD 0x03BE 0x03BF 0x03C0 0x03C1 0x03C3 \ - 0x03C4 0x03C5 0x03C6 0x03C7 0x03C8 0x03C9 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x0410 0x0411 0x0412 0x0413 \ - 0x0414 0x0415 0x0401 0x0416 0x0417 0x0418 0x0419 0x041A \ - 0x041B 0x041C 0x041D 0x041E 0x041F 0x0420 0x0421 0x0422 \ - 0x0423 0x0424 0x0425 0x0426 0x0427 0x0428 0x0429 0x042A \ - 0x042B 0x042C 0x042D 0x042E 0x042F 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x0430 0x0431 0x0432 0x0433 \ - 0x0434 0x0435 0x0451 0x0436 0x0437 0x0438 0x0439 0x043A \ - 0x043B 0x043C 0x043D 0x043E 0x043F 0x0440 0x0441 0x0442 \ - 0x0443 0x0444 0x0445 0x0446 0x0447 0x0448 0x0449 0x044A \ - 0x044B 0x044C 0x044D 0x044E 0x044F 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0x0101 0x00E1 0x01CE 0x00E0 0x0113 0x00E9 \ - 0x011B 0x00E8 0x012B 0x00ED 0x01D0 0x00EC 0x014D 0x00F3 \ - 0x01D2 0x00F2 0x016B 0x00FA 0x01D4 0x00F9 0x01D6 0x01D8 \ - 0x01DA 0x01DC 0x00FC 0x00EA 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0x3105 0x3106 \ - 0x3107 0x3108 0x3109 0x310A 0x310B 0x310C 0x310D 0x310E \ - 0x310F 0x3110 0x3111 0x3112 0x3113 0x3114 0x3115 0x3116 \ - 0x3117 0x3118 0x3119 0x311A 0x311B 0x311C 0x311D 0x311E \ - 0x311F 0x3120 0x3121 0x3122 0x3123 0x3124 0x3125 0x3126 \ - 0x3127 0x3128 0x3129 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0x2500 0x2501 0x2502 0x2503 0x2504 \ - 0x2505 0x2506 0x2507 0x2508 0x2509 0x250A 0x250B 0x250C -04 0x250D 0x250E 0x250F 0x2510 0x2511 0x2512 0x2513 0x2514 \ - 0x2515 0x2516 0x2517 0x2518 0x2519 0x251A 0x251B 0x251C \ - 0x251D 0x251E 0x251F 0x2520 0x2521 0x2522 0x2523 0x2524 \ - 0x2525 0x2526 0x2527 0x2528 0x2529 0x252A 0x252B 0x252C \ - 0x252D 0x252E 0x252F 0x2530 0x2531 0x2532 0x2533 0x2534 \ - 0x2535 0x2536 0x2537 0x2538 0x2539 0x253A 0x253B 0x253C \ - 0x253D 0x253E 0x253F 0x2540 0x2541 0x2542 0x2543 0x2544 \ - 0x2545 0x2546 0x2547 0x2548 0x2549 0x254A 0x254B 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE -05 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE -06 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE 0xFFFE \ - 0xFFFE 0xFFFE 0x554A 0x963F 0x57C3 0x6328 0x54CE 0x5509 \ - 0x54C0 0x7691 0x764C 0x853C 0x77EE 0x827E 0x788D 0x7231 \ - 0x9698 0x978D 0x6C28 0x5B89 0x4FFA 0x6309 0x6697 0x5CB8 \ - 0x80FA 0x6848 0x80AE 0x6602 0x76CE 0x51F9 0x6556 0x71AC \ - 0x7FF1 0x8884 0x50B2 0x5965 0x61CA 0x6FB3 0x82AD 0x634C \ - 0x6252 0x53ED 0x5427 0x7B06 0x516B 0x75A4 0x5DF4 0x62D4 \ - 0x8DCB 0x9776 0x628A 0x8019 0x575D 0x9738 0x7F62 0x7238 \ - 0x767D 0x67CF 0x767E 0x6446 0x4F70 0x8D25 0x62DC 0x7A17 \ - 0x6591 0x73ED 0x642C 0x6273 0x822C 0x9881 0x677F 0x7248 \ - 0x626E 0x62CC 0x4F34 0x74E3 0x534A 0x529E 0x7ECA 0x90A6 \ - 0x5E2E 0x6886 0x699C 0x8180 0x7ED1 0x68D2 0x78C5 0x868C \ - 0x9551 0x508D 0x8C24 0x82DE 0x80DE 0x5305 0x8912 0x5265 \ - 0x8584 0x96F9 0x4FDD 0x5821 0x9971 0x5B9D 0x62B1 0x62A5 \ - 0x66B4 0x8C79 0x9C8D 0x7206 0x676F 0x7891 0x60B2 0x5351 \ - 0x5317 0x8F88 0x80CC 0x8D1D 0x94A1 0x500D 0x72C8 0x5907 \ - 0x60EB 0x7119 0x88AB 0x5954 0x82EF 0x672C 0x7B28 0x5D29 -07 0x7EF7 0x752D 0x6CF5 0x8E66 0x8FF8 0x903C 0x9F3B 0x6BD4 \ - 0x9119 0x7B14 0x5F7C 0x78A7 0x84D6 0x853D 0x6BD5 0x6BD9 \ - 0x6BD6 0x5E01 0x5E87 0x75F9 0x95ED 0x655D 0x5F0A 0x5FC5 \ - 0x8F9F 0x58C1 0x81C2 0x907F 0x965B 0x97AD 0x8FB9 0x7F16 \ - 0x8D2C 0x6241 0x4FBF 0x53D8 0x535E 0x8FA8 0x8FA9 0x8FAB \ - 0x904D 0x6807 0x5F6A 0x8198 0x8868 0x9CD6 0x618B 0x522B \ - 0x762A 0x5F6C 0x658C 0x6FD2 0x6EE8 0x5BBE 0x6448 0x5175 \ - 0x51B0 0x67C4 0x4E19 0x79C9 0x997C 0x70B3 0x75C5 0x5E76 \ - 0x73BB 0x83E0 0x64AD 0x62E8 0x94B5 0x6CE2 0x535A 0x52C3 \ - 0x640F 0x94C2 0x7B94 0x4F2F 0x5E1B 0x8236 0x8116 0x818A \ - 0x6E24 0x6CCA 0x9A73 0x6355 0x535C 0x54FA 0x8865 0x57E0 \ - 0x4E0D 0x5E03 0x6B65 0x7C3F 0x90E8 0x6016 0x64E6 0x731C \ - 0x88C1 0x6750 0x624D 0x8D22 0x776C 0x8E29 0x91C7 0x5F69 \ - 0x83DC 0x8521 0x9910 0x53C2 0x8695 0x6B8B 0x60ED 0x60E8 \ - 0x707F 0x82CD 0x8231 0x4ED3 0x6CA7 0x85CF 0x64CD 0x7CD9 \ - 0x69FD 0x66F9 0x8349 0x5395 0x7B56 0x4FA7 0x518C 0x6D4B \ - 0x5C42 0x8E6D 0x63D2 0x53C9 0x832C 0x8336 0x67E5 0x78B4 \ - 0x643D 0x5BDF 0x5C94 0x5DEE 0x8BE7 0x62C6 0x67F4 0x8C7A \ - 0x6400 0x63BA 0x8749 0x998B 0x8C17 0x7F20 0x94F2 0x4EA7 \ - 0x9610 0x98A4 0x660C 0x7316 0x573A 0x5C1D 0x5E38 0x957F \ - 0x507F 0x80A0 0x5382 0x655E 0x7545 0x5531 0x5021 0x8D85 \ - 0x6284 0x949E 0x671D 0x5632 0x6F6E 0x5DE2 0x5435 0x7092 \ - 0x8F66 0x626F 0x64A4 0x63A3 0x5F7B 0x6F88 0x90F4 0x81E3 \ - 0x8FB0 0x5C18 0x6668 0x5FF1 0x6C89 0x9648 0x8D81 0x886C \ - 0x6491 0x79F0 0x57CE 0x6A59 0x6210 0x5448 0x4E58 0x7A0B \ - 0x60E9 0x6F84 0x8BDA 0x627F 0x901E 0x9A8B 0x79E4 0x5403 \ - 0x75F4 0x6301 0x5319 0x6C60 0x8FDF 0x5F1B 0x9A70 0x803B \ - 0x9F7F 0x4F88 0x5C3A 0x8D64 0x7FC5 0x65A5 0x70BD 0x5145 \ - 0x51B2 0x866B 0x5D07 0x5BA0 0x62BD 0x916C 0x7574 0x8E0C \ - 0x7A20 0x6101 0x7B79 0x4EC7 0x7EF8 0x7785 0x4E11 0x81ED \ - 0x521D 0x51FA 0x6A71 0x53A8 0x8E87 0x9504 0x96CF 0x6EC1 \ - 0x9664 0x695A 0x7840 0x50A8 0x77D7 0x6410 0x89E6 0x5904 -08 0x63E3 0x5DDD 0x7A7F 0x693D 0x4F20 0x8239 0x5598 0x4E32 \ - 0x75AE 0x7A97 0x5E62 0x5E8A 0x95EF 0x521B 0x5439 0x708A \ - 0x6376 0x9524 0x5782 0x6625 0x693F 0x9187 0x5507 0x6DF3 \ - 0x7EAF 0x8822 0x6233 0x7EF0 0x75B5 0x8328 0x78C1 0x96CC \ - 0x8F9E 0x6148 0x74F7 0x8BCD 0x6B64 0x523A 0x8D50 0x6B21 \ - 0x806A 0x8471 0x56F1 0x5306 0x4ECE 0x4E1B 0x51D1 0x7C97 \ - 0x918B 0x7C07 0x4FC3 0x8E7F 0x7BE1 0x7A9C 0x6467 0x5D14 \ - 0x50AC 0x8106 0x7601 0x7CB9 0x6DEC 0x7FE0 0x6751 0x5B58 \ - 0x5BF8 0x78CB 0x64AE 0x6413 0x63AA 0x632B 0x9519 0x642D \ - 0x8FBE 0x7B54 0x7629 0x6253 0x5927 0x5446 0x6B79 0x50A3 \ - 0x6234 0x5E26 0x6B86 0x4EE3 0x8D37 0x888B 0x5F85 0x902E \ - 0x6020 0x803D 0x62C5 0x4E39 0x5355 0x90F8 0x63B8 0x80C6 \ - 0x65E6 0x6C2E 0x4F46 0x60EE 0x6DE1 0x8BDE 0x5F39 0x86CB \ - 0x5F53 0x6321 0x515A 0x8361 0x6863 0x5200 0x6363 0x8E48 \ - 0x5012 0x5C9B 0x7977 0x5BFC 0x5230 0x7A3B 0x60BC 0x9053 \ - 0x76D7 0x5FB7 0x5F97 0x7684 0x8E6C 0x706F 0x767B 0x7B49 \ - 0x77AA 0x51F3 0x9093 0x5824 0x4F4E 0x6EF4 0x8FEA 0x654C \ - 0x7B1B 0x72C4 0x6DA4 0x7FDF 0x5AE1 0x62B5 0x5E95 0x5730 \ - 0x8482 0x7B2C 0x5E1D 0x5F1F 0x9012 0x7F14 0x98A0 0x6382 \ - 0x6EC7 0x7898 0x70B9 0x5178 0x975B 0x57AB 0x7535 0x4F43 \ - 0x7538 0x5E97 0x60E6 0x5960 0x6DC0 0x6BBF 0x7889 0x53FC \ - 0x96D5 0x51CB 0x5201 0x6389 0x540A 0x9493 0x8C03 0x8DCC \ - 0x7239 0x789F 0x8776 0x8FED 0x8C0D 0x53E0 0x4E01 0x76EF \ - 0x53EE 0x9489 0x9876 0x9F0E 0x952D 0x5B9A 0x8BA2 0x4E22 \ - 0x4E1C 0x51AC 0x8463 0x61C2 0x52A8 0x680B 0x4F97 0x606B \ - 0x51BB 0x6D1E 0x515C 0x6296 0x6597 0x9661 0x8C46 0x9017 \ - 0x75D8 0x90FD 0x7763 0x6BD2 0x728A 0x72EC 0x8BFB 0x5835 \ - 0x7779 0x8D4C 0x675C 0x9540 0x809A 0x5EA6 0x6E21 0x5992 \ - 0x7AEF 0x77ED 0x953B 0x6BB5 0x65AD 0x7F0E 0x5806 0x5151 \ - 0x961F 0x5BF9 0x58A9 0x5428 0x8E72 0x6566 0x987F 0x56E4 \ - 0x949D 0x76FE 0x9041 0x6387 0x54C6 0x591A 0x593A 0x579B \ - 0x8EB2 0x6735 0x8DFA 0x8235 0x5241 0x60F0 0x5815 0x86FE -09 0x5CE8 0x9E45 0x4FC4 0x989D 0x8BB9 0x5A25 0x6076 0x5384 \ - 0x627C 0x904F 0x9102 0x997F 0x6069 0x800C 0x513F 0x8033 \ - 0x5C14 0x9975 0x6D31 0x4E8C 0x8D30 0x53D1 0x7F5A 0x7B4F \ - 0x4F10 0x4E4F 0x9600 0x6CD5 0x73D0 0x85E9 0x5E06 0x756A \ - 0x7FFB 0x6A0A 0x77FE 0x9492 0x7E41 0x51E1 0x70E6 0x53CD \ - 0x8FD4 0x8303 0x8D29 0x72AF 0x996D 0x6CDB 0x574A 0x82B3 \ - 0x65B9 0x80AA 0x623F 0x9632 0x59A8 0x4EFF 0x8BBF 0x7EBA \ - 0x653E 0x83F2 0x975E 0x5561 0x98DE 0x80A5 0x532A 0x8BFD \ - 0x5420 0x80BA 0x5E9F 0x6CB8 0x8D39 0x82AC 0x915A 0x5429 \ - 0x6C1B 0x5206 0x7EB7 0x575F 0x711A 0x6C7E 0x7C89 0x594B \ - 0x4EFD 0x5FFF 0x6124 0x7CAA 0x4E30 0x5C01 0x67AB 0x8702 \ - 0x5CF0 0x950B 0x98CE 0x75AF 0x70FD 0x9022 0x51AF 0x7F1D \ - 0x8BBD 0x5949 0x51E4 0x4F5B 0x5426 0x592B 0x6577 0x80A4 \ - 0x5B75 0x6276 0x62C2 0x8F90 0x5E45 0x6C1F 0x7B26 0x4F0F \ - 0x4FD8 0x670D 0x6D6E 0x6DAA 0x798F 0x88B1 0x5F17 0x752B \ - 0x629A 0x8F85 0x4FEF 0x91DC 0x65A7 0x812F 0x8151 0x5E9C \ - 0x8150 0x8D74 0x526F 0x8986 0x8D4B 0x590D 0x5085 0x4ED8 \ - 0x961C 0x7236 0x8179 0x8D1F 0x5BCC 0x8BA3 0x9644 0x5987 \ - 0x7F1A 0x5490 0x5676 0x560E 0x8BE5 0x6539 0x6982 0x9499 \ - 0x76D6 0x6E89 0x5E72 0x7518 0x6746 0x67D1 0x7AFF 0x809D \ - 0x8D76 0x611F 0x79C6 0x6562 0x8D63 0x5188 0x521A 0x94A2 \ - 0x7F38 0x809B 0x7EB2 0x5C97 0x6E2F 0x6760 0x7BD9 0x768B \ - 0x9AD8 0x818F 0x7F94 0x7CD5 0x641E 0x9550 0x7A3F 0x544A \ - 0x54E5 0x6B4C 0x6401 0x6208 0x9E3D 0x80F3 0x7599 0x5272 \ - 0x9769 0x845B 0x683C 0x86E4 0x9601 0x9694 0x94EC 0x4E2A \ - 0x5404 0x7ED9 0x6839 0x8DDF 0x8015 0x66F4 0x5E9A 0x7FB9 \ - 0x57C2 0x803F 0x6897 0x5DE5 0x653B 0x529F 0x606D 0x9F9A \ - 0x4F9B 0x8EAC 0x516C 0x5BAB 0x5F13 0x5DE9 0x6C5E 0x62F1 \ - 0x8D21 0x5171 0x94A9 0x52FE 0x6C9F 0x82DF 0x72D7 0x57A2 \ - 0x6784 0x8D2D 0x591F 0x8F9C 0x83C7 0x5495 0x7B8D 0x4F30 \ - 0x6CBD 0x5B64 0x59D1 0x9F13 0x53E4 0x86CA 0x9AA8 0x8C37 \ - 0x80A1 0x6545 0x987E 0x56FA 0x96C7 0x522E 0x74DC 0x5250 -x1 0x0010_0x0030 0x1010_0x1030 0xe000 \ - 0xA0: 0x1000 0x2000 - -# eof diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/ChangeLog b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/ChangeLog new file mode 100644 index 00000000000..5b3fadf9abc --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/ChangeLog @@ -0,0 +1,29 @@ +2013-06-16 Peter Breitenlohner + + * patch-01-cpp: New version for kpathsea adapted to C++. + +2013-05-17 Peter Breitenlohner + + * Import release 1.3. + * patch-01-cpp: Adapted. + +2013-04-11 Peter Breitenlohner + + * Import release 1.2.1. + * patch-1-cpp (removed): Renamed ... + * patch-01-cpp (new): ... and adapted. + +2013-04-02 Karl Berry + + * patch-1-cpp (new): Force __cplusplus to be 1, + for sake of g++ 4.7.x and including c-memstr.h and Solaris. + Patch from Apostolos, tlbuild 1 Apr 2013 00:34:43. + +2013-03-02 Peter Breitenlohner + + * Import release 1.2. + +2013-01-29 Peter Breitenlohner + + * Import release 1.1. + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/TL-Changes b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/TL-Changes new file mode 100644 index 00000000000..59930768c30 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/TL-Changes @@ -0,0 +1,15 @@ +Changes applied to the dvisvgm-1.3 tree as obtained from: + http://downloads.sourceforge.net/dvisvgm/dvisvgm-1.3.tar.gz + +Removed: + Makefile.in + aclocal.m4 + config.guess + config.sub + configure + depcomp + install-sh + missing + tests/ + */Makefile.in + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/patch-01-cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/patch-01-cpp new file mode 100644 index 00000000000..2472d5cfaa0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3-PATCHES/patch-01-cpp @@ -0,0 +1,26 @@ +diff -ur dvisvgm-1.3.orig/src/FileFinder.cpp dvisvgm-1.3/src/FileFinder.cpp +--- dvisvgm-1.3.orig/src/FileFinder.cpp 2013-05-13 13:15:57.000000000 +0200 ++++ dvisvgm-1.3/src/FileFinder.cpp 2013-06-16 18:31:08.000000000 +0200 +@@ -27,21 +27,12 @@ + #include "FontMap.h" + #include "Message.h" + +-using namespace std; +- + #ifdef MIKTEX + #include "MessageException.h" + #include "MiKTeXCom.h" + static MiKTeXCom *miktex=0; + #else +- // unfortunately, the kpathsea headers are not C++-ready, +- // so we have to wrap it with some ugly code +- namespace KPS { +- extern "C" { +- #include +- } +- } +- using namespace KPS; ++ #include + #endif + + // --------------------------------------------------- diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/AUTHORS b/Build/source/texk/dvisvgm/dvisvgm-1.3/AUTHORS new file mode 100644 index 00000000000..d9b6468421e --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/AUTHORS @@ -0,0 +1,7 @@ +Martin Gieseking + author of dvisvgm + +Deepak Bandyopadhyay, Lutz Kettner + authors of gzstream library + dvisvgm uses a slightly modified version + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/COPYING b/Build/source/texk/dvisvgm/dvisvgm-1.3/COPYING new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/INSTALL b/Build/source/texk/dvisvgm/dvisvgm-1.3/INSTALL new file mode 100644 index 00000000000..a4b34144dcf --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/INSTALL @@ -0,0 +1,229 @@ +Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/LGPL-2.1.txt b/Build/source/texk/dvisvgm/dvisvgm-1.3/LGPL-2.1.txt new file mode 100644 index 00000000000..602bfc94635 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/LGPL-2.1.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.3/Makefile.am new file mode 100644 index 00000000000..a3462b39cdb --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/Makefile.am @@ -0,0 +1,9 @@ +## This file is part of dvisvgm +## Copyright (C) 2005-2013 Martin Gieseking +## +## Process this file with automake. + +AUTOMAKE_OPTIONS = foreign +EXTRA_DIST = COPYING LGPL-2.1.txt +SUBDIRS = src tests doc + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/NEWS b/Build/source/texk/dvisvgm/dvisvgm-1.3/NEWS new file mode 100644 index 00000000000..b6c0c98060a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/NEWS @@ -0,0 +1,299 @@ +dvisvgm-1.3 (2013-05-13) +- added support for hyperref specials +- added command-line option --linkmarker to select the way how to mark hyperlinked areas +- dvisvgm builds for MiKTeX now try to access the Ghostscript DLL provided by MiKTeX so that + it's no longer necessary to install Ghostscript seperately +- improved the handling of TFM files to avoid failures in case of malformed files +- added evaluation of Japanese Font Metric (JFM) files +- the bundled potrace library has been removed from the source tarball as it's easy to build + the latest releases from the original sources available at http://potrace.sourceforge.net +- several code refactorings + +dvisvgm-1.2.2 (2013-04-26) +- fixed a bug that prevented the lookup of fontmap files +- avoid throwing an exception but print a warning message if MiKTeX is not available +- print a warning message if PostScript specials are found but ignored +- added information about "dvisvgm -E" to the --help text and to the manpage +- various code refactorings and cleanups + +dvisvgm-1.2.1 (2013-04-09) +- updated bundled potrace library to version 1.11 +- avoid building bundled potracelib if system library is present (patch by Alexis Ballier) +- allow background color specials to create white background rectangles +- code refactorings and cleanup + +dvisvgm-1.2 (2013-03-01) +- PostScript handler: added support of tiling patterns +- PostScript handler: added support for EPS files with binary headers/footers +- added option --eps to directly convert EPS files to SVG +- added option --precision to select the number of decimal places used in the generated SVG files +- added an optional argument to --help to choose a display variant +- fixed the text alignment of the --help output +- improved handling of PostScript operator "show" +- choose the correct output location if the input file argument contains path specifiers (Windows only) + +dvisvgm-1.1 (2013-01-22) +- added evaluation of pdf:mapline and pdf:mapfile specials +- added evaluation of subfont file definitions (.sfd files) +- added support for TTC (TrueType collection) fonts +- added evaluation of font style parameters given in a font map definition +- renamed option --map-file to --fontmap +- the new option --fontmap allows multiple mapfile arguments and optional mode specifiers +- if a PostScript error occurs, dvisvgm prints an error message together with the + PS operand stack, as generated by Ghostscript +- if font checksums don't match, dvisvgm prints a warning now +- avoid throwing exceptions if referenced encoding files are not available +- added support for 64bit Windows builds +- removed compilation error when using a C++11 compiler (patch by Peter Breitenlohner) +- some code refactorings and improvements + +dvisvgm-1.0.12 (2012-09-27) +- print a message if the processing of PostScript specials is disabled +- the resulting SVG is now scaled to bp ("big point" units) properly +- added the evaluation of PS operators rectclip, rectfill, and rectstroke +- ignore dvips operator bop if present in a PS special +- fixed processing of special strings that contain newline characters + +dvisvgm-1.0.11 (2012-03-09) +- added Ghostscript to library list printed by --version=yes +- fixed a bug in the number parser that could lead to displaced objects (SF bug #3471097) +- corrected the computation of bounding boxes of DVI rules (lp bug #948713) +- improved code compatibility to make dvisvgm compile with clang++ (patch by Vladimir Lomov) +- fixed formatting issues in the manual page +- updated information about bug reporting (tracker moved to Launchpad) + +dvisvgm-1.0.10 (2011-12-18) +- introduced environment variable DVISVGM_COLORS to allow user-defined message colors +- fixed linking issue concerning libfreetype +- fixed potential clashes of character IDs + +dvisvgm-1.0.9 (2011-10-13) +- fixed segfault occurred in TeX Live Win32 caused by mf.exe being unavailable + (thanks to Akira Kakuto for tracking down the issue) +- updated bundled potrace library to version 1.10 +- some minor code improvements + +dvisvgm-1.0.8 (2011-05-31) +- PS handler: added evaluation of PS operators save, restore, and grestoreall +- PS handler: fixed potential segfault caused by invisible zero-length paths +- fixed computation of current drawing position influenced by PS and DVI actions +- don't stop Metafont conversions on errors any longer in order to convert + buggy MF fonts properly + +dvisvgm-1.0.7 (2011-05-06) +- improved overall handling of PS specials +- fixed broken PS special subset 'ps::' +- fixed scaling of PS line properties (width, dash distance, etc.) +- fixed semantics of TPIC special 'ip' (doesn't draw polygon outlines any longer) + +dvisvgm-1.0.6 (2011-04-21) +- fixed segfault occurred if a (malformed) DVI file calls set_char/put_char + without preceding font definition +- added CTRL-C handler +- MiKTeX support updated to version 2.9 +- some code refactorings + +dvisvgm-1.0.5 (2011-03-01) +- added optional integer argument to option -n to disable generation of elements +- added missing unit to width/height attributes of svg root element (SF bug #3185773) +- added integrity check to font cache files +- updated bundled potrace library to version 1.9 +- fixed a couple of minor issues + +dvisvgm-1.0.4 (2010-12-18) +- added missing line width/dash pattern scaling to PS handler +- fixed scaling issue in PS positioning +- fixed compilation issue related to FreeType 2.4.0 + +dvisvgm-1.0.3 (2010-08-06) +- applied some more portability patches for TeX Live +- fixed a potential memory issue +- fixed a transformation issue regarding special 'psfile' (SF bug #3037372) + +dvisvgm-1.0.2 (2010-06-22) +- applied latest TeX Live portability patches sent by Peter Breitenlohner and Karl Berry +- fixed a potrace name clash occurred on Mac OS X Tiger +- fixed putchar() name clash occurred on Solaris +- fixed a couple of conversion warnings +- updated the test suite + +dvisvgm-1.0.1 (2010-06-11) +- fixed a memory issue in the PS handler that could lead to a segfault (SF bug #3013392) +- fixed a recursion issue in the PS handler +- suppress ANSI color code when terminating + +dvisvgm-1.0 (2010-06-08) +- conversion of multiple pages (must be enabled explicitly, see option --pages) +- added transparency support to the PS handler +- improved conversion results of the PS handler +- added support for computation of local bounding boxes +- optional colorization of dvisvgm messages (option --color) +- improved progress indicator (option --progress) +- a couple of improvements of the build system + +dvisvgm-0.9.1 (2010-04-23) +- CSS style definitions omit unnecessary fonts now +- SVG validity was broken when using font elements +- fixed two memory issues that could lead to segfaults + +dvisvgm-0.9 (2010-03-25) +- added option --exact and corresponding algorithms to compute the exact + bounding boxes of characters +- added option --keep that prevents deleting temporary font files +- extended option --trace-all by an optional boolean argument controlling + the re-tracing of glyphs +- fixed bug in evaluation of embedded PS headers +- several code refactorings + +dvisvgm-0.8.8 (2010-02-02) +- added option --libgs and evaluation of environment variable LIBGS + to overwrite the expected file name of the GS shared library + (only available if dvisvgm isn't linked against libgs and GS support + isn't completely disabled) +- option --bbox can now be used to enlarge the minimal bounding box by + a given amount +- fixed bug in evaluation of option --page +- applied patches sent by Peter Breitenlohner to prepare the integration of + dvisvgm into TeX Live +- some code refactorings + +dvisvgm-0.8.7 (2009-11-09) +- fixed a bounding box issue concerning italic corrections +- PS handler: zero-length paths are now drawn as dots +- PS handler: fixed a path positioning issue +- PS handler: colors set by color specials are now considered properly +- added macro {?nl} to be used with special dvisvgm:raw + +dvisvgm-0.8.6 (2009-10-13) +- renamed command-line option --bbox-format to --bbox +- option --bbox can now be used to set an arbitrary bounding box +- added the two special variants "dvisvgm:bbox abs" and "dvisvgm:bbox fix" +- PS clipping path sequences and intersections are now handled correctly +- fixed a PS bounding box bug +- fixed a couple of PS positioning issues reported by John Bowman +- fixed a bit shift overflow in the font tracer occurred on 64-bit systems + +dvisvgm-0.8.5 (2009-10-01) +- added an optional depth parameter to special dvisvgm:raw +- updated the man page +- added LGPL license text needed for the gzstream wrapper classes + +dvisvgm-0.8.4 (2009-09-17) +- improved the command-line parser to be more POSIX-compliant +- added a simple progress indicator for time-consuming special operations +- option --cache prints more information about the cached fonts +- fixed a clipping bug in the PostScript handler + (thanks to John Bowman for also providing a patch for this issue) +- fixed a bug in computation of the PS bounding box +- fixed a memory bug in the GF tracer module + +dvisvgm-0.8.3 (2009-08-28) +- added basic evaluation of the PostScript "show" operator + (handles PSTricks Type 3 fonts properly now) +- improved checks for Ghostscript and potrace library in configure script +- external Ghostscript and potrace development files are used if available +- PostScript header/prologue files are now loaded regardless of converted page +- replaced command-line option variant --cache=? by --cache + +dvisvgm-0.8.2 (2009-08-24) +- changed license of dvisvgm to GPL version 3 or later +- replaced getopt-based command-line parser by own implementation + in order to simplify future internationalizations +- fixed memory bug in fontmap reader + +dvisvgm-0.8.1 (2009-08-02) +- added evaluation of more psfile parameters +- fixed computation of bounding box in psfile special +- fixed compilation errors and a conversion bug occurred on x64 systems + +dvisvgm-0.8 (2009-07-27) +- experimental evaluation of PostScript specials has been added (requires + a recent version of the Ghostscript shared library libgs.so or gsdll32.dll) +- several code improvements and refactorings +- fixed compilation bug occurred when using GCC 4.4.x + +dvisvgm-0.7.3 (2009-04-24) +- fixed bug in font map reader that could cause a segmentation fault +- fixed bug in creation of shorthand path drawing commands +- fixed bug in TPIC special handler + +dvisvgm-0.7.2 (2009-04-02) +- font caching has been added (speeds up embedding of bitmap fonts) +- added option --trace-all that enables tracing of all glyphs of all + bitmap fonts used in the current DVI file. Even glyphs that are currently + not needed are considered. This avoids multiple calls of Metafont for the + same fonts. In combination with the new caching functionality this can + drastically increase the speed of successive dvisvgm calls. +- if option --no-fonts is used, all glyph sizes are now computed correctly +- use shorthand path commands in SVG fonts if possible + +dvisvgm-0.7.1 (2009-03-09) +- evaluation of a subset of emTeX specials has been added +- specials for embedding of raw SVG snippets have been added +- evaluation of TPIC specials has been added +- added background color support +- added option -n, --no-fonts that replaces fonts by paths + (enables applications w/o SVG font support to render dvisvgm's output properly) +- moved defs to top of SVG file to make Firefox's SVG renderer happy +- fixed bug in color handler + +dvisvgm-0.7 (2009-02-16) +- basic support for evaluation of specials has been added +- evaluation of color specials has been added +- renamed command-line option -S to --no-specials and inverted previous behavior +- selected special sets can be disabled by optional arguments to --no-specials + (currently only color specials) +- added option --no-style (see manpage for further details) +- added optional '+' flag to option --map-file (see manpage for further details) +- fixed \magnificaton bug (dvi magnification factor is now applied properly) +- fixed buggy call of maketfm/makemf in Windows/MiKTeX version +- fixed buggy evaluation of command-line argument -m/--map-file +- several internal code improvements + +dvisvgm-0.6.1 (2009-01-29) +- added support for dvips map files +- removed dependency on dvipdfm's map file (now ps2pk.map, psfonts.map or dvipdfm.map is used by default) +- fixed compilation bug #2535497 +- some internal refactorings + +dvisvgm-0.6 (2009-01-23) +- added support for varying font encodings +- updated MiKTeX support using its COM interface +- fixed incomplete handling of nested virtual fonts +- fixed a font handling bug that could cause segmentation faults +- fixed bug in matrix transformation code +- updated bundled potrace library to version 1.8 + +dvisvgm-0.5 (2007-03-26) +- redesigned and improved font handling +- added support for virtual fonts +- evaluation of dvipdfm's map file to find font files with differing + names (e.g. cork-lmr10 => lmr10) +- automatic invocation of mktexmf etc. in case of missing font files (tfm, mf) +- command-line option -m has been renamed to -M +- added command-line options -m/--map-file and -n/--no-mktexmf +- memory bug in StreamCounter class has been fixed +- added sources of Peter Selinger's potrace library (part of potrace, http://potrace.sourceforge.net) + to simplify the build process + +dvisvgm-0.4.3 (2007-01-03) +- problem with changed freetype API (freetype version >= 2.2.1) has been fixed +- updated MiKTeX support to version 2.5 +- minor code improvements +- some unit tests based on CxxTest (http://cxxtest.sourceforge.net) have been added + +dvisvgm-0.4.2 (2005-09-22) +- added SVG transformation options +- some bugfixes in command line frontend and TFM handling +- code refactorings to improve modularity and extensibility + +dvisvgm-0.4.1 (2005-09-02) +- added option -b to specify the bounding box +- added a manual page + +dvisvgm-0.4 (2005-08-24) +- Added a glyph tracing module that vectorizes Metafont's bitmap output + if no corresponding Type 1 font file is available. + +dvisvgm-0.3 (2005-08-10) +- Initial public release with basic conversion functionality. diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/README b/Build/source/texk/dvisvgm/dvisvgm-1.3/README new file mode 100644 index 00000000000..d9728660268 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/README @@ -0,0 +1,110 @@ +dvisvgm -- A DVI to SVG converter + +DESCRIPTION + + dvisvgm is a utility for TeX/LaTeX users. It converts + DVI files to the XML-based scalable vector graphics format SVG. + + +DEPENDENCIES + + dvisvgm relies on the following free libraries: + * FreeType 2 (http://www.freetype.org) + This library is used to extract glyph outlines + from PFB files. + + * Ghostscript (http://pages.cs.wisc.edu/~ghost) + The PostScript special handler requires the Ghostscript + library libgs.so (Linux) or gsdll32.dll/gsdll64.dll (Windows) + to be installed. If the configure script finds the corresponding + Ghostscript development files on the system, it directly + links against libgs.so. Otherwise, the library is looked up + at runtime and PostScript support is enabled only if libgs.so + could be found. + Due to incompatible changes of the Ghostscript API, dvisvgm + requires Ghostscript 8.31 or later. + + * kpathsea + This library is part of the Web2C package and is + usually installed in conjunction with a TeX distribution. + kpathsea provides functions for searching files in the + large texmf tree. + + * potracelib (http://potrace.sourceforge.net) + Peter Selinger's bitmap tracing library is utilized to + vectorize Metafont's bitmap output. + + * zlib (http://www.zlib.org) + Compressed SVG files are produced by using functions + of this library and the Gzstream wrapper classes + (http://www.cs.unc.edu/Research/compgeom/gzstream) + which are licensed under LGPL version 2.1 (or optionally any + later version) and should be included with this package. + + If you want to build and run the testsuite located in the tests + subdirectory, you also need the googletest libraries + (http://code.google.com/p/googletest). + + +COMPILATION + + Quick installation info: + * type "./configure" + * type "make" + * type "make install" as root (or "sudo make install") + + For generic configuration instructions see the file INSTALL. + + The configure script should recognize all necessary parameters. + If a library is installed but not detected, specify its location + as commandline parameter of configure, e.g. + ./configure --with-freetype=/usr/local/freetype + (all available options can be displayed with ./configure --help) + + The tracer module calls Metafont in case of lacking TFM or PFB files + via a system call. Please ensure that Metafont is installed and + reachable through the search path. + + If you don't like compiling the sources yourself, you can + download pre-compiled executables for Windows and MiKTeX + from sourceforge.net instead (see below). + + +USAGE + Information about the command-line interface and the available options + can be found in the manual page. + + +ADDITIONAL INFORMATION + This package is available from CTAN (dviware/dvisvgm) and can + be downloaded from the project website at sourceforge.net as well: + + http://dvisvgm.sourceforge.net + + Here you can find the sources, pre-compiled binaries and further additional + information about the converter and related topics. + + If you've found a bug, please let me know. You can either send me an + email or preferably use the bug tracker at Launchpad + (see https://launchpad.net/dvisvgm). + + +COPYRIGHT + + Copyright (C) 2005-2013 Martin Gieseking + + 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 . + + See the file COPYING for details. + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/config.h.in b/Build/source/texk/dvisvgm/dvisvgm-1.3/config.h.in new file mode 100644 index 00000000000..b027999e9b3 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/config.h.in @@ -0,0 +1,166 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if the `closedir' function returns void instead of `int'. */ +#undef CLOSEDIR_VOID + +/* Set to 1 if PostScript support should be disabled */ +#undef DISABLE_GS + +/* Define to 1 if `TIOCGWINSZ' requires . */ +#undef GWINSZ_IN_SYS_IOCTL + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `ftime' function. */ +#undef HAVE_FTIME + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `dl' library (-ldl). */ +#undef HAVE_LIBDL + +/* Define to 1 if you have the `gs' library (-lgs). */ +#undef HAVE_LIBGS + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define to 1 if you have the `kpathsea' library (-lkpathsea). */ +#undef HAVE_LIBKPATHSEA + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the `potrace' library (-lpotrace). */ +#undef HAVE_LIBPOTRACE + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_STAT_EMPTY_STRING_BUG + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIMEB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#undef LSTAT_FOLLOWS_SLASHED_SYMLINK + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* The machine triplet of the target system */ +#undef TARGET_SYSTEM + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/config.rpath b/Build/source/texk/dvisvgm/dvisvgm-1.3/config.rpath new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/configure.ac b/Build/source/texk/dvisvgm/dvisvgm-1.3/configure.ac new file mode 100644 index 00000000000..f4ff7d70248 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/configure.ac @@ -0,0 +1,155 @@ +# This file is part of dvisvgm +# Copyright (C) 2005-2013 Martin Gieseking +# +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) +AC_INIT([dvisvgm],[1.3],[martin.gieseking@uos.de]) +DATE="May 2013" +AC_CONFIG_SRCDIR(src) +AC_CONFIG_HEADER(config.h) +AC_CANONICAL_HOST +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE + +AH_TEMPLATE([TARGET_SYSTEM], [The machine triplet of the target system]) +AC_DEFINE_UNQUOTED([TARGET_SYSTEM], ["$target"]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +AC_PROG_RANLIB +AC_LANG(C) + +AC_CHECK_FUNCS([ftime gettimeofday]) +AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) +AC_HEADER_TIOCGWINSZ + +AC_CHECK_HEADER([kpathsea/kpathsea.h], , + [AC_MSG_ERROR([please install the kpathsea development package])]) +AC_CHECK_LIB(kpathsea, kpse_find_file, , + [AC_MSG_ERROR([libkpathsea not found, please install the corresponding package first])]) + +AC_MSG_CHECKING([kpathsea version]) +AC_RUN_IFELSE([AC_LANG_SOURCE([#include + #include + int main() { + FILE *f; + f = fopen("kpseversion", "w"); + if(!f) exit(1); + fprintf(f, "%s\n", KPSEVERSION); + fclose(f); + exit(0); + }])], + [kpseversion=`cat kpseversion|sed 's/kpathsea version //'`], [kpseversion=], [kpseversion=unknown]) +AC_MSG_RESULT("$kpseversion") +rm -f kpseversion +if test -z "$kpseversion"; then + AC_MSG_ERROR([Could not compile a simple kpathsea program -- check your installation]) +fi + + +# Check how to link potracelib +HAVE_LIBPOTRACE=1 +AC_CHECK_HEADER([potracelib.h], + [AC_CHECK_LIB(m, sqrt) # required to pass potrace check + AC_CHECK_LIB(potrace, potrace_trace, , HAVE_LIBPOTRACE=0)], HAVE_LIBPOTRACE=0) + +if test "$HAVE_LIBPOTRACE" -eq 0; then + AC_MSG_ERROR([potrace library not found]) +fi + + +# Check how to link Ghostscript +HAVE_LIBGS=1 +AC_CHECK_HEADER([ghostscript/iapi.h], + AC_CHECK_LIB(gs, gsapi_new_instance, , HAVE_LIBGS=0), HAVE_LIBGS=0) + +if test "$HAVE_LIBGS" -eq 0; then + AC_CHECK_LIB(dl, dlopen, , + [AC_DEFINE(DISABLE_GS, 1, [Set to 1 if PostScript support is to be disabled]) + AC_MSG_WARN(PostScript support disabled)]) +else + # query Ghostscript version + AC_MSG_CHECKING([Ghostscript version]) + AC_RUN_IFELSE([AC_LANG_SOURCE([#include + #include + int main () { + gsapi_revision_t r; + if (gsapi_revision(&r, sizeof(gsapi_revision_t)) == 0) { + FILE *f; + f = fopen("gsversion", "w"); + if (!f) exit(1); + fprintf(f, "%ld\n", r.revision); + fclose(f); + exit(0); + } + }])], + [gsversion=`cat gsversion`], [gsversion=], [gsversion=unknown]) + AC_MSG_RESULT("$gsversion") + rm -f gsversion + if test "$gsversion" -lt 831; then + # current Ghostscript API was introduced in version 8.31 + # older versions are not supported + LIBS=`echo $LIBS | sed "s/-lgs //" $LIBS` + AC_DEFINE(DISABLE_GS, 1, [Set to 1 if PostScript support should be disabled]) + AC_MSG_WARN([Ghostscript version < 8.31 found; PostScript support disabled]) + fi +fi + +# Check for pkg-config +PKG_PROG_PKG_CONFIG + +# Check for libraries. +PKG_CHECK_MODULES([FREETYPE], [freetype2]) +CXXFLAGS="$CXXFLAGS ${FREETYPE_CFLAGS}" +LIBS="$LIBS ${FREETYPE_LIBS}" + +AC_CHECK_LIB(z, gzopen) + +# Check for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS([libintl.h stdlib.h string.h strings.h unistd.h]) + +# Check for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_STRUCT_TM + +# Check for library functions. +AC_FUNC_CLOSEDIR_VOID +AC_FUNC_ERROR_AT_LINE +AC_FUNC_MALLOC +AC_FUNC_STAT +AC_FUNC_VPRINTF +AC_CHECK_FUNCS([memset strcasecmp strtol]) + +# add options for selection of "optional" library locations +# currently these libraries are mandatory; the --with-foo options +# are used to specify the locations explicitely + +AC_ARG_WITH(zlib,[ --with-zlib=DIR location of the zlib library], + [if test "$withval" != no; then + if test "$withval" != yes; then + ZLIB_DIR=$withval + fi + fi]) + +if test "$withval" != no; then + if test -n "$ZLIB_DIR"; then + CPPFLAGS="$CPPFLAGS -I$ZLIB_DIR -I$ZLIB_DIR/include" + LDFLAGS="$LDFLAGS -L$ZLIB_DIR/lib" + fi +fi + +AC_SUBST(DATE) +AC_SUBST(EXTRA_LIBS) +AC_SUBST(AM_CPPFLAGS) +AC_SUBST(AM_LDFLAGS) +AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/dvisvgm.txt doc/Makefile]) +AC_OUTPUT + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/Makefile.am new file mode 100644 index 00000000000..fb5c56ffedf --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/Makefile.am @@ -0,0 +1,39 @@ +## This file is part of dvisvgm +## Copyright (C) 2005-2013 Martin Gieseking +## +## Process this file with automake. + +man_MANS = dvisvgm.1 +EXTRA_DIST = $(man_MANS) + +dvisvgm.1: dvisvgm.txt + if [ `type -p a2x` ]; then \ + a2x -dmanpage -fmanpage -L -a icons -a 'iconsdir=.' $<; \ + rm -f dvisvgm.xml; \ + fi + +dvisvgm.pdf: dvisvgm.1 + echo '[ /Author (Martin Gieseking) /Title (dvisvgm manual page) /Subject (manual page of dvisvgm @VERSION@) /DOCINFO pdfmark' >tmp.ps + man -t ./$< >>tmp.ps + ps2pdf tmp.ps $@ + rm -f tmp.ps + +dvi-pdf: dvisvgm.dvi + dvipdfm $< + rm -f $< + +dvisvgm.dvi: dvisvgm.1 + groff -Tdvi -mandoc ./$< >$@ + +dvisvgm.html: dvisvgm.txt + asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -dmanpage $< + +html: dvisvgm.html +man: dvisvgm.1 +pdf: dvisvgm.pdf + +clean: + rm -f dvisvgm.pdf dvisvgm.html dvisvgm.xml dvisvgm.txt + +distclean-local: + rm -f dvisvgm.pdf dvisvgm.html dvisvgm.xml dvisvgm.txt dvisvgm.1 diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.1 b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.1 new file mode 100644 index 00000000000..193fad44ed2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.1 @@ -0,0 +1,1061 @@ +'\" t +.\" Title: dvisvgm +.\" Author: Martin Gieseking +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 05/13/2013 +.\" Manual: dvisvgm Manual +.\" Source: dvisvgm 1.3 +.\" Language: English +.\" +.TH "DVISVGM" "1" "05/13/2013" "dvisvgm 1\&.3" "dvisvgm Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +dvisvgm \- converts DVI files to the XML\-based SVG format +.SH "SYNOPSIS" +.sp +\fBdvisvgm\fR [ \fIoptions\fR ] \fIfile\fR [\&.dvi] +.sp +\fBdvisvgm\fR \-E [ \fIoptions\fR ] \fIfile\fR [\&.eps] +.SH "DESCRIPTION" +.sp +The command\-line utility \fBdvisvgm\fR converts DVI files, as generated by TeX/LaTeX, to the XML\-based scalable vector graphics format SVG\&. Since the current SVG standard 1\&.1 doesn\(cqt specify multi\-page graphics, dvisvgm creates separate SVG files for each DVI page\&. Because of compatibility reasons, only the first page is converted by default\&. In order to select a different page or arbitrary page sequences, use option \fB\-p\fR which is described below\&. +.sp +dvisvgm should properly convert all pages that are made up of fonts and rules only\&. However, the utility also supports a couple of DVI extensions defined in terms of \fIDVI specials\fR\&. For a more detailed overview, see section \fBsupport of specials\fR below\&. +.sp +As SVG is a vector based graphics format, dvisvgm tries to convert the glyph outlines of all used fonts into scalable path descriptions\&. The fastest way to do that is to extract the path information from PFB (PostScript Type 1) files\&. So, if dvisvgm is able to find a PFB file for a required font, it will read the necessary information from this file\&. +.sp +TeX\(cqs main source for font descriptions is Metafont though, which produces bitmap output\&. That\(cqs why not all obtainable TeX fonts are available in PFB format\&. In these cases, dvisvgm tries to vectorize Metafont\(cqs output (GF fonts) by tracing the glyph bitmaps\&. The results are not as perfect as most (manually optimized) PFB outlines but are nonetheless really nice in most cases\&. +.SH "OPTIONS" +.PP +\fB\-a, \-\-trace\-all\fR=[\fIretrace\fR] +.RS 4 +This option forces dvisvgm to trace not only the actually needed glyphs but all glyphs of all bitmap fonts used in the DVI file\&. Since the tracing results are stored in the font cache, all following DVI conversions (without option +\fB\-\-trace\-all\fR) where these fonts are involved, will be much faster\&. By default, dvisvgm traces only the actually needed glyphs, and adds them to the cache\&. The boolean option +\fIretrace\fR +determines how to handle glyphs already stored in the cache\&. By default, these glyphs are skipped\&. Setting argument +\fIretrace\fR +to +\fIyes\fR +or +\fItrue\fR +forces dvisvgm to trace the corresponding bitmaps again\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +This option only takes affect if font caching is active\&. Thus, +\fB\-\-trace\-all\fR +cannot be combined with option +\fB\-\-cache=none\fR\&. +.sp .5v +.RE +.RE +.PP +\fB\-b, \-\-bbox\fR=\fIfmt\fR +.RS 4 +Sets the bounding box of the generated graphic to the specified format\&. The parameter +\fIfmt\fR +takes either one of the format specifiers listed below, or a sequence of four comma\- or whitespace\-separated length values +\fIx1\fR, +\fIy1\fR, +\fIx2\fR +and +\fIy2\fR\&. The latter define two diagonal corners of the bounding box\&. Each length value consists of a floating point number and an optional length unit (pt, bp, cm, mm, in, or pc)\&. If the unit is omitted, TeX points (pt) are assumed\&. +.sp +It\(cqs also possible to give only one length value +\fIl\fR\&. In this case, the minimal bounding box is computed and enlarged by adding (\-\fIl\fR,\-\fIl\fR) to the upper left and (\fIl\fR,\fIl\fR) to the lower right corner\&. +.sp +Alternatively, the following format specifiers are supported: +.PP +\fBInternational DIN/ISO paper sizes\fR +.RS 4 +A\fIn\fR, B\fIn\fR, C\fIn\fR, D\fIn\fR, where +\fIn\fR +is a non\-negative integer, e\&.g\&. A4 or a4 for DIN/ISO A4 format (210mm \(mu 297mm)\&. +.RE +.PP +\fBNorth American paper sizes\fR +.RS 4 +invoice, executive, legal, letter, ledger +.RE +.PP +\fBSpecial bounding box sizes\fR +.RS 4 +.TS +tab(:); +lt lt +lt lt +lt lt. +T{ +\fBdvi\fR +T}:T{ +page size stored in the DVI file +T} +T{ +\fBmin\fR +T}:T{ +computes the minimal/tightest bounding box +T} +T{ +\fBnone\fR +T}:T{ +no bounding box is assigned +T} +.TE +.sp 1 +.RE +.RE +.PP +\fBPage orientation\fR +.RS 4 +The default page orientation for DIN/ISO and American paper sizes is +\fIportrait\fR, i\&.e\&. +\fIwidth\fR +< +\fIheight\fR\&. Appending +\fB\-landscape\fR +or simply +\fB\-l\fR +to the format string switches to +\fIlandscape\fR +mode (\fIwidth\fR +> +\fIheight\fR)\&. For symmetry reasons you can also explicitly add +\fB\-portrait\fR +or +\fB\-p\fR +to indicate the default portrait format\&. Note that these suffixes are part of the size string and not separate options\&. Thus, they must directly follow the size specifier without additional blanks\&. Furthermore, the orientation suffixes can\(cqt be used with +\fBdvi\fR, +\fBmin\fR, and +\fBnone\fR\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +Option +\fB\-b, \-\-bbox\fR +only affects the bounding box and does not transform the page content\&. Hence, if you choose a landscape format, the page won\(cqt be rotated\&. +.sp .5v +.RE +.RE +.PP +\fB\-C, \-\-cache\fR[=\fIdir\fR] +.RS 4 +To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion information in cache files\&. By default, these files are stored in $HOME/\&.dvisvgm/cache\&. If you prefer a different location, use option +\fB\-\-cache\fR +to overwrite the default\&. Furthermore, it is also possible to disable the font caching mechanism completely with option +\fB\-\-cache=none\fR\&. If argument +\fIdir\fR +is omitted, dvisvgm prints the path of the default cache directory and some information about the stored fonts\&. Additionally, outdated and corrupted cache files are removed\&. +.RE +.PP +\fB\-\-color\fR +.RS 4 +Enables colorization of messages printed during the conversion process\&. The colors can be customized via the environment variable +DVISVGM_COLORS\&. See the ENVIRONMENT section below for further information\&. +.RE +.PP +\fB\-E, \-\-eps\fR +.RS 4 +If this option is given, dvisvgm does not expect a DVI but an EPS input file, and tries to convert it to SVG\&. In order to do so, a single +\fIpsfile\fR +special command is created and forwarded to the PostScript special handler\&. This option is only available if dvisvgm was built with PostScript support enabled, and requires Ghostscript to be available\&. See option +\fB\-\-libgs\fR +for further information\&. +.RE +.PP +\fB\-e, \-\-exact\fR +.RS 4 +If this option is given, dvisvgm computes the precise bounding box of each character\&. By default, the values stored in a font\(cqs TFM file are used to determine a glyph\(cqs extent\&. As these values are intended to realize optimal character placements and are not designed to represent the exact dimensions, they don\(cqt necessarily correspond with the bounds of the visual glyphs\&. Thus, width and/or height of some glyphs may be larger than the respective TFM values\&. As a result, this can lead to clipped characters at the bounds of the SVG graphic\&. With option +\fB\-\-exact\fR, dvisvgm analyzes the actual shape of each character and derives a usually tight bounding box\&. +.RE +.PP +\fB\-m, \-\-fontmap\fR=\fIfilenames\fR +.RS 4 +Loads and evaluates a single or multiple font map files\&. These files are required to resolve font file names and encodings\&. dvisvgm does not provide its own map file but tries to read available ones coming with dvips or dvipdfm\&. If option +\fB\-\-fonrmapm\fR +is not given, dvisvgm looks for the default map files +ps2pk\&.map, +dvipdfm\&.map, and +psfonts\&.map +(in this order)\&. Otherwise, the listed files are used\&. Multiple filenames must be separated by commas without leading and/or trailing whitespace\&. The map files are evaluated in the given order\&. By default, redefined mappings do not replace previous ones\&. However, each filename can be preceded by an optional mode specifier (\fB+\fR, +\fB\-\fR, or +\fB=\fR) to change this behavior: +.PP ++mapfile +.RS 4 +Only those entries in the given map file that don\(cqt redefine a font mapping are applied\&. That\(cqs also the default mode if no mode specifier is given\&. +.RE +.PP +\-mapfile +.RS 4 +Ensures that none of the font mappings defined in the given map file are used, i\&.e\&. previously defined mappings for the specified fonts are removed\&. +.RE +.PP +=mapfile +.RS 4 +All mappings defined in the map file are applied\&. Previously defined settings for the same font are replaced\&. +.sp +If the first filename in the filename sequence is preceded by a mode specifier, dvisvgm loads the default font map (see above) and applies the other map files afterwards\&. Otherwise, none of default map files will be loaded automatically\&. +.sp +Examples: +\fB\-\-fontmap=myfile1\&.map,+myfile2\&.map\fR +loads +myfile1\&.map +followed by +myfile2\&.map +where all redefinitions of +myfile2\&.map +are ignored\&. +\fB\-\-fontmap==myfile1\&.map,\-myfile2\&.map\fR +loads the default map file followed by +myfile1\&.map +and +myfile2\&.map +where all redefinitions of +myfile1\&.map +replace previous entries\&. Afterwards, all definitions for the fonts given in +myfile2\&.map +are removed again\&. +.sp +For further information about the map file formats, see the manuals of dvips and dvipdfm\&. +.RE +.RE +.PP +\fB\-h, \-\-help\fR[=\fImode\fR] +.RS 4 +Prints a short summary of all available command\-line options\&. The optional +\fImode\fR +parameter is an integer value between 0 and 2\&. It selects the display variant of the help text\&. Mode 0 lists all options divided into categories with section headers\&. This is also the default if dvisvgm is called without parameters\&. Mode 1 lists all options ordered by the short option name, while mode 2 sorts the lines by the long option name\&. +.RE +.PP +\fB\-\-keep\fR +.RS 4 +Disables the removal of temporary files as created by Metafont (usually \&.gf, \&.tfm, and \&.log files)\&. +.RE +.PP +\fB\-\-libgs\fR=\fIfilename\fR +.RS 4 +This option is only available if the Ghostscript library is not directly linked to dvisvgm and if PostScript support was not completely disabled during compilation\&. In this case, dvisvgm tries to load the shared GS library dynamically during runtime\&. By default, it expects the library\(cqs name to be libgs\&.so (on Unix\-like systems) or gsdll32\&.dll/gsdll64\&.dll (Windows)\&. Option +\fB\-\-libgs\fR +can be used to give a different name\&. Alternatively, it\(cqs also possible to set the GS library name by the environment variable +LIBGS\&. The latter has less precedence than the command\-line option\&. +.RE +.PP +\fB\-L, \-\-linkmark\fR=\fItype\fR +.RS 4 +Selects the method how to mark hyperlinked areas\&. The +\fItype\fR +argument can take one of the values +\fInone\fR, +\fIbox\fR, and +\fIline\fR, where the latter is the default, i\&.e\&. all links are underlined when dvisvgm is called without option +\fB\-\-linkmark\fR\&. Type +\fIbox\fR +draws a rectangle around the linked area, and +\fInone\fR +tells dvisvgm not to add any visible objects to hyperlinks\&. +.RE +.PP +\fB\-l, \-\-list\-specials\fR +.RS 4 +Prints a list of registered special handlers and exits\&. Each handler processes a set of special statements belonging to the same category\&. In most cases, the categories are identified by the prefix of the special statements\&. It\(cqs usually a leading word separated from the rest of the statement by a colon or a blank, e\&.g\&. +\fIcolor\fR +or +\fIps\fR\&. +.RE +.PP +\fB\-M, \-\-mag\fR=\fIfactor\fR +.RS 4 +Sets the magnification factor applied in conjunction with Metafont calls prior tracing the glyphs\&. The larger this value, the better the tracing results\&. Nevertheless, large magnification values can cause Metafont arithmetic errors due to number overflows\&. So, use this option with care\&. The default setting usually produces nice results\&. +.RE +.PP +\fB\-\-no\-mktexmf\fR +.RS 4 +Suppresses the generation of missing font files\&. If dvisvgm can\(cqt find a font file through the kpathsea lookup mechanism, it calls the external tools mktextfm or mktexmf by\&. This option disables these calls\&. +.RE +.PP +\fB\-n, \-\-no\-fonts\fR[=\fIvariant\fR] +.RS 4 +If this option is given, dvisvgm doesn\(cqt create SVG +\fIfont\fR +elements but uses +\fIpaths\fR +instead\&. The resulting SVG files tends to be larger but concurrently more compatible with most applications that don\(cqt support SVG fonts yet\&. The optional argument +\fIvariant\fR +selects the method how to substitute fonts by paths\&. Variant 0 creates +\fIpath\fR +and +\fIuse\fR +elements\&. Variant 1 creates +\fIpath\fR +elements only\&. Option +\fB\-\-no\-fonts\fR +implies +\fB\-\-no\-styles\fR\&. +.RE +.PP +\fB\-c, \-\-scale\fR=\fIsx\fR[,\fIsy\fR] +.RS 4 +Scales the page content horizontally by +\fIsx\fR +and vertically by +\fIsy\fR\&. This option is equivalent to +\fB\-TS\fR\fIsx\fR,\fIsy\fR\&. +.RE +.PP +\fB\-S, \-\-no\-specials\fR[=\fInames\fR] +.RS 4 +Disable processing of special commands embedded in the DVI file\&. If no further parameter is given, all specials are ignored\&. To selectively disable sets of specials, an optional comma\-separated list of names can be appended to this option\&. A +\fIname\fR +is the unique identifier referencing the intended special handler\&. Option +\fB\-\-list\-specials\fR +lists all currently available handlers and their names\&. All unsupported special statements are silently ignored\&. +.RE +.PP +\fB\-\-no\-styles\fR +.RS 4 +By default, dvisvgm creates CSS styles and class attributes to reference fonts because it\(cqs more compact than repeatedly set the complete font information in each text element\&. However, if you prefer direct font references, the default behavior can be disabled with option +\fB\-\-no\-styles\fR\&. +.RE +.PP +\fB\-o, \-\-output\fR=\fIpattern\fR +.RS 4 +Sets the name pattern of the output file\&. Parameter +\fIpattern\fR +is a string that may contain the variables +\fB%f\fR +and +\fB%p\fR\&. +\fB%f\fR +stands for the base name of the DVI file, i\&.e\&. the DVI filename without suffix, and +\fB%p\fR +is the current page number\&. The default pattern is +\fB%f\-%p\&.svg\fR +if the DVI file consists of more than one page, and +\fB%f\&.svg\fR +otherwise\&. That means, a DVI file +\fIfoo\&.dvi\fR +is converted to +\fIfoo\&.svg\fR +if +\fIfoo\&.dvi\fR +is a single\-page document\&. Otherwise, multiple SVG files +\fIfoo\-01\&.svg\fR, +\fIfoo\-02\&.svg\fR, etc\&. are produced\&. In Windows environments, the percent sign indicates dereferenced environment variables, and must therefore be protected by a second percent sign, e\&.g\&. +\fB\-\-output=%%f\-%%p\fR\&. +.RE +.PP +\fB\-p, \-\-page\fR=\fIranges\fR +.RS 4 +This option sets the pages to be processed\&. Parameter +\fIranges\fR +consists of a comma\-separated list of single page numbers and/or page ranges\&. A page range is a pair of numbers separated by a hyphen, e\&.g\&. 5\-12\&. Thus, a page sequence might look like this: 2\-4,6,9\-12,15\&. It doesn\(cqt matter if a page is given more than once or if page ranges overlap\&. dvisvgm always extracts the page numbers in ascending order and converts them only once\&. In order to stay compatible with previous versions, the default page sequence is 1\&. dvisvgm therefore converts only the first page and not the whole document in case option +\fB\-\-page\fR +is omitted\&. Usually, page ranges consist of two numbers denoting the first and last page to be converted\&. If the conversion is to be started at page 1, or if it should continue up to the last DVI page, the first or second range number can be omitted, respectively\&. Example: +\fB\-\-page=\-10\fR +converts all pages up to page 10, +\fB\-\-page=10\-\fR +converts all pages starting with page 10\&. Please consider that the page values don\(cqt refer to the page numbers printed on the page\&. Instead, the physical page count is expected, where the first page always gets number 1\&. +.RE +.PP +\fB\-d, \-\-precision\fR=\fIdigits\fR +.RS 4 +Specifies the maximal number of decimal places applied to floating\-point attribute values\&. All attribute values written to the generated SVG file(s) are rounded accordingly\&. The parameter +\fIdigits\fR +allows integer values from 0 to 6, where 0 enables the automatic selection of significant decimal places\&. This is also the default value if dvisvgm is called without option +\fB\-\-precision\fR\&. +.RE +.PP +\fB\-P, \-\-progress\fR[=\fIdelay\fR] +.RS 4 +Enables a simple progress indicator shown when time\-consuming operations like PostScript specials are processed\&. The indicator doesn\(cqt appear before the given delay (in seconds) has elapsed\&. The default delay value is 0\&.5 seconds\&. +.RE +.PP +\fB\-r, \-\-rotate\fR=\fIangle\fR +.RS 4 +Rotates the page content clockwise by +\fIangle\fR +degrees around the page center\&. This option is equivalent to +\fB\-TR\fR\fIangle\fR\&. +.RE +.PP +\fB\-s, \-\-stdout\fR +.RS 4 +Don\(cqt write the SVG output to a file but redirect it to +\fBstdout\fR\&. +.RE +.PP +\fB\-T, \-\-transform\fR=\fIcommands\fR +.RS 4 +Applies a sequence of transformations to the SVG content\&. Each transformation is described by a +\fIcommand\fR +beginning with a capital letter followed by a list of comma\-separated parameters\&. Following transformation commands are supported: +.PP +\fBT\fR \fItx\fR[,\fIty\fR] +.RS 4 +Translates (moves) the page in direction of vector (\fItx\fR,\fIty\fR)\&. If +\fIty\fR +is omitted, +\fIty\fR=0 is assumed\&. The expected unit length of +\fItx\fR +and +\fIty\fR +are TeX points (1pt = 1/72\&.27in)\&. However, there are several constants defined to simplify the unit conversion (see below)\&. +.RE +.PP +\fBS\fR \fIsx\fR[,\fIsy\fR] +.RS 4 +Scales the page horizontally by +\fIsx\fR +and vertically by +\fIsy\fR\&. If +\fIsy\fR +is omitted, +\fIsy\fR=\fIsx\fR +is assumed\&. +.RE +.PP +\fBR\fR \fIangle\fR[,\fIx\fR,\fIy\fR] +.RS 4 +Rotates the page clockwise by +\fIangle\fR +degrees around point (\fIx\fR,\fIy\fR)\&. If the optional arguments +\fIx\fR +and +\fIy\fR +are omitted, the page will be rotated around its center depending on the chosen page format\&. When option +\fB\-bnone\fR +is given, the rotation center is origin (0,0)\&. +.RE +.PP +\fBKX\fR \fIangle\fR +.RS 4 +Skews the page along the +\fIx\fR\-axis by +\fIangle\fR +degrees\&. Argument +\fIangle\fR +can take any value except 90+180\fIk\fR, where +\fIk\fR +is an integer\&. +.RE +.PP +\fBKY\fR \fIangle\fR +.RS 4 +Skews the page along the +\fIy\fR\-axis by +\fIangle\fR +degrees\&. Argument +\fIangle\fR +can take any value except 90+180\fIk\fR, where +\fIk\fR +is an integer\&. +.RE +.PP +\fBFH\fR [\fIy\fR] +.RS 4 +Mirrors (flips) the page at the horizontal line through point (0,\fIy\fR)\&. Omitting the optional argument leads to +\fIy\fR=\fIh\fR/2, where +\fIh\fR +denotes the page height (see +\fIpre\-defined constants\fR +below)\&. +.RE +.PP +\fBFV\fR [\fIx\fR] +.RS 4 +Mirrors (flips) the page at the vertical line through point (\fIx\fR,0)\&. Omitting the optional argument leads to +\fIx\fR=\fIw\fR/2, where +\fIw\fR +denotes the page width (see +\fIpre\-defined constants\fR +below)\&. +.RE +.PP +\fBM\fR \fIm1\fR,\&...,\fIm6\fR +.RS 4 +Applies a transformation described by the 3\(mu3 matrix ((\fIm1\fR,\fIm2\fR,\fIm3\fR),(\fIm4\fR,\fIm5\fR,\fIm6\fR),(0,0,1)), where the inner triples denote the rows\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +All transformation commands of option +\fB\-T, \-\-transform\fR +are applied in the order of their appearance\&. Multiple commands can optionally be separated by spaces\&. In this case the whole transformation string has to be enclosed in double quotes\&. All parameters are expressions of floating point type\&. You can either give plain numbers or arithmetic terms combined by the operators +\fB+\fR +(addition), +\fB\-\fR +(subtraction), +\fB*\fR +(multiplication), +\fB/\fR +(division) or +\fB%\fR +(modulo) with common associativity and precedence rules\&. Parentheses may be used as well\&. +.sp +Additionally, some pre\-defined constants are provided: +.TS +tab(:); +lt lt +lt lt +lt lt +lt lt. +T{ +\fBux\fR +T}:T{ +horizontal position of upper left page corner in TeX point units +T} +T{ +\fBuy\fR +T}:T{ +vertical position of upper left page corner in TeX point units +T} +T{ +\fBh\fR +T}:T{ +page height in TeX point units (0 in case of +\fB\-bnone\fR) +T} +T{ +\fBw\fR +T}:T{ +page width in TeX point units (0 in case of +\fB\-bnone\fR) +T} +.TE +.sp 1 +Furthermore, you can use the length constants +\fBpt\fR, +\fBmm\fR, +\fBcm\fR +and +\fBin\fR, e\&.g\&. +2cm +or +1\&.6in\&. Thus, option +\-TT1in,0R45 +moves the page content 1 inch to the right and rotates it by 45 degrees around the page center afterwards\&. +.sp +For single transformations you can also use options +\fB\-c\fR, +\fB\-t\fR +and +\fB\-r\fR\&. Note that the order in which these options are given is not significant, i\&.e\&. you can\(cqt use them to describe transformation sequences\&. They are simply independent shorthand options for common transformations\&. +.sp .5v +.RE +.RE +.RE +.PP +\fB\-t, \-\-translate\fR=\fItx\fR[,\fIty\fR] +.RS 4 +Translates (moves) the page content in direction of vector (\fItx\fR,\fIty\fR)\&. This option is equivalent to +\fB\-TT\fR\fItx\fR,\fIty\fR\&. +.RE +.PP +\fB\-v, \-\-verbosity\fR=\fIlevel\fR +.RS 4 +Controls the type of messages printed during a dvisvgm run: +.TS +tab(:); +lt lt +lt lt +lt lt +lt lt. +T{ +\fB0\fR +T}:T{ +no message output +T} +T{ +\fB1\fR +T}:T{ +error messages only +T} +T{ +\fB2\fR +T}:T{ +warning messages only +T} +T{ +\fB4\fR +T}:T{ +informational messages only +T} +.TE +.sp 1 +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +By adding these values you can combine the categories\&. The default level is 7, i\&.e\&. all messages are printed\&. +.sp .5v +.RE +.RE +.PP +\fB\-V, \-\-version\fR[=\fIextended\fR] +.RS 4 +Prints the version of dvisvgm and exits\&. If the optional argument is set to +\fIyes\fR, the version numbers of the linked libraries are printed as well\&. +.RE +.PP +\fB\-z, \-\-zip\fR[=\fIlevel\fR] +.RS 4 +Creates a compressed SVG file with suffix \&.svgz\&. The optional argument specifies the compression level\&. Valid values are in the range of 1 to 9 (default value is 9)\&. Larger values cause better compression results but take more computation time\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBCaution\fR +.ps -1 +.br +This option cannot be combined with +\fB\-s, \-\-stdout\fR\&. +.sp .5v +.RE +.RE +.SH "SUPPORT OF SPECIALS" +.sp +dvisvgm supports several sets of \fIspecial commands\fR that can be used to enrich DVI files with additional features, like color, graphics or hyperlinks\&. The evaluation of special commands is delegated to various handlers\&. Each handler is responsible for all special statements of the same command set, i\&.e\&. commands beginning with the same prefix\&. To get a list of actually provided special handlers, use option \fB\-\-list\-specials\fR (see above)\&. +.PP +\fBbgcolor\fR +.RS 4 +Special statement for changing the background/page color\&. Since SVG 1\&.1 doesn\(cqt support background colors, dvisvgm inserts a rectangle of the chosen color into the generated SVG document\&. This rectangle always gets the same size as the selected or computed bounding box\&. This background color command is part of the color special set but is handled separately in order to let the user turn it off\&. For an overview of the command syntax, see the documentation of dvips, for instance\&. +.RE +.PP +\fBcolor\fR +.RS 4 +Statements of this command set provide instructions to change the text/paint color\&. For an overview of the exact syntax, see the documentation of dvips, for instance\&. +.RE +.PP +\fBdvisvgm\fR +.RS 4 +dvisvgm offers its own small set of specials\&. The following list gives a brief overview\&. +.PP +\fBdvisvgm:raw\fR \fItext\fR +.RS 4 +Adds an arbitrary sequence of characters to the SVG output\&. dvisvgm does not perform any validation here, thus the user has to ensure that the resulting SVG is still valid\&. Parameter +\fItext\fR +may contain the macros +\fB{?x}\fR, +\fB{?y}\fR, and +\fB{?color}\fR +that are expanded to the current +\fIx\fR +or +\fIy\fR +coordinate and the current color, respectively\&. Also, macro +\fB{?nl}\fR +expands to a newline character\&. +.RE +.PP +\fBdvisvgm:img\fR \fIwidth\fR \fIheight\fR \fIfile\fR +.RS 4 +Creates an image element at the current graphic position referencing the given file\&. JPEG, PNG, and SVG images can be used here\&. However, dvisvgm does not check the file format or the file name suffix\&. The lengths +\fIwidth\fR +and +\fIheight\fR +must be given as plain floating point numbers in TeX point units (1in = 72\&.27pt)\&. +.RE +.PP +\fBdvisvgm:bbox\fR n[ew] \fIname\fR +.RS 4 +Defines or resets a local bounding box called +\fIname\fR\&. The name may consist of letters and digits\&. While processing a DVI page, dvisvgm continuously updates the (global) bounding box of the current page in order to determine the minimal rectangle containing all visible page components (characters, images, drawing elements etc\&.) Additionally to the global bounding box, the user can request an arbitrary number of named local bounding boxes\&. Once defined, these boxes are updated together with the global bounding box starting with the first character that follows the definition\&. Thus, the local boxes can be used to compute the extent of parts of the page\&. This is useful for scenarios where the generated SVG file is post\-processed\&. In conjunction with special dvisvgm:raw, the macro +\fB{?bbox \fR\fB\fIname\fR\fR\fB}\fR +expands to the four values +\fIx\fR, +\fIy\fR, +\fIw\fR, and +\fIh\fR +(separated by spaces) specifying the coordinates of the upper left corner, width, and height of the local box +\fIname\fR\&. If box +\fIname\fR +wasn\(cqt previously defined, all four values equal zero\&. +.RE +.PP +\fBdvisvgm:bbox\fR \fIwidth\fR \fIheight\fR [\fIdepth\fR] +.RS 4 +Updates the bounding box of the current page by embedding a virtual rectangle (\fIx\fR, +\fIy\fR, +\fIwidth\fR, +\fIheight\fR) where the lower left corner is located at the current DVI drawing position (\fIx\fR,\fIy\fR)\&. If the optional parameter +\fIdepth\fR +is specified, dvisvgm embeds a second rectangle (\fIx\fR, +\fIy\fR, +\fIwidth\fR, \-\fIdepth\fR)\&. The lengths +\fIwidth\fR, +\fIheight\fR +and +\fIdepth\fR +must be given as plain floating point numbers in TeX point units (1in = 72\&.27pt)\&. Depending on size and position of the virtual rectangle, this command either enlarges the overall bounding box or leaves it as is\&. It\(cqs not possible to reduce its extent\&. This special should be used in conjunction with +\fBdvisvgm:raw\fR +in order to update the viewport of the page properly\&. +.RE +.PP +\fBdvisvgm:bbox\fR a[bs] \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR +.RS 4 +This variant of the bbox special updates the bounding box by embedding a virtual rectangle (\fIx1\fR,\fIy1\fR,\fIx2\fR,\fIy2\fR)\&. The points (\fIx1\fR,\fIy1\fR) and (\fIx2\fR,\fIy2\fR) denote two diagonal corners of the rectangle given in TeX point units\&. +.RE +.PP +\fBdvisvgm:bbox\fR f[ix] \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR +.RS 4 +This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG\&. After executing this command, dvisvgm doesn\(cqt further alter the bounding box coordinates, except this special is called again later\&. The points (\fIx1\fR,\fIy1\fR) and (\fIx2\fR,\fIy2\fR) denote two diagonal corners of the rectangle given in TeX point units\&. +.sp +The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\especial{dvisvgm:raw } +\especial{dvisvgm:bbox 20 10 10} + +\especial{dvisvgm:raw } +\especial{dvisvgm:bbox abs 10 200 100 250} +.fi +.if n \{\ +.RE +.\} +.RE +.RE +.PP +\fBem\fR +.RS 4 +These specials were introduced with the emTeX distribution by Eberhard Mattes\&. They provide line drawing statements, instructions for embedding MSP, PCX, and BMP image files, as well as two PCL commands\&. dvisvgm supports only the line drawing statements and ignores all other em specials silently\&. A description of the command syntax can be found in the DVI driver documentation coming with emTeX (see CTAN)\&. +.RE +.PP +\fBhtml\fR +.RS 4 +The hyperref specials allow the definition of hyperlinks inside DVI files in various flavors\&. dvisvgm supports the plain HyperTeX special constructs as created with hyperref package option +\fIhypertex\fR\&. Internal links, i\&.e\&. references to other parts of the same document, are only converted if the link and the corresponding link target are located on the same page\&. Links between different pages are not supported yet\&. By default, all linked areas of the document are underlined\&. Option +\fB\-\-linkmark\fR +allows to change this behavior\&. See above for further details\&. Information on syntax and semantics of the HyperTeX specials can be found in the hyperref manual\&. +.RE +.PP +\fBpdf\fR +.RS 4 +pdfTeX and dvipdfmx introduced several special commands related to the generation of PDF files\&. Currently, only two of them, +\fIpdf:mapfile\fR +and +\fIpdf:mapline\fR +are supported by dvisvgm\&. These specials allow modifying the font map tree during the processing of DVI files\&. They are used by CTeX, for example\&. dvisvgm supports both, the dvips and dvipdfm font map format\&. For further information on the command syntax and semantics, see the documentation of \epdfmapfile in the pdfTeX user manual\&. +.RE +.PP +\fBps\fR +.RS 4 +The famous DVI driver dvips introduced its own set of specials in order to embed PostScript code into DVI files, which greatly improves the capabilities of DVI documents\&. One aim of dvisvgm is to completely evaluate all PostScript snippets and to convert a large amount of it to SVG\&. However, in contrast to dvips, dvisvgm uses floating point arithmetics to compute the precise position of each graphic element, i\&.e\&. it doesn\(cqt round the coordinates\&. Therefore, the relative locations of the graphic elements may slightly differ from those computed by dvips\&. +.sp +Since PostScript is a rather complex language, dvisvgm does not try to implement its own PostScript interpreter but relies on Ghostscript instead\&. If the Ghostscript library was not linked while building dvisvgm, it is looked up and loaded dynamically during runtime\&. In this case, dvisvgm looks for +\fIlibgs\&.so\fR +on Unix\-like systems, and for +\fIgsdll32\&.dll\fR +or +\fIgsdll64\&.dll\fR +on Windows\&. You can override these default file names with environment variable +LIBGS +or the command\-line option +\fB\-\-libgs\fR\&. The library must be installed and reachable through the ld search path (*nix) or the PATH environment variable (Windows)\&. If it cannot be found, the processing of PostScript specials is disabled\&. Use option +\fB\-\-list\-specials\fR +to check whether PS support is available, i\&.e\&. the entry +\fIps\fR +is present\&. +.RE +.PP +\fBtpic\fR +.RS 4 +The TPIC special set defines instructions for drawing simple geometric objects\&. Some LaTeX packages, like eepic and tplot, use these specials to describe graphics\&. +.RE +.SH "EXAMPLES" +.sp +.if n \{\ +.RS 4 +.\} +.nf +dvisvgm file +.fi +.if n \{\ +.RE +.\} +.sp +Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svg\fR\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +dvisvgm \-z file +.fi +.if n \{\ +.RE +.\} +.sp +Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svgz\fR with default compression level 9\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +dvisvgm \-p5 \-z3 \-ba4\-l \-onewfile file +.fi +.if n \{\ +.RE +.\} +.sp +Converts the fifth page of \fIfile\&.dvi\fR to \fInewfile\&.svgz\fR with compression level 3\&. The bounding box is set to DIN/ISO A4 in landscape format\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +dvisvgm \-\-transform="R20,w/3,2h/5 T1cm,1cm S2,3" file +.fi +.if n \{\ +.RE +.\} +.sp +Converts the first page of \fIfile\&.dvi\fR to \fIfile\&.svg\fR where three transformations are applied\&. +.SH "ENVIRONMENT" +.sp +dvisvgm uses the \fBkpathsea\fR library for locating the files that it opens\&. Hence, the environment variables described in the library\(cqs documentation influence the converter\&. +.sp +If dvisvgm was linked without the Ghostscript library, and if PostScript support has not been disabled, the shared Ghostscript library is looked up during runtime via dlopen()\&. The environment variable LIBGS can be used to specify path and file name of the library\&. +.sp +The pre\-compiled Windows versions of dvisvgm require a working installation of MiKTeX 2\&.9 or above\&. dvisvgm does not work together with the portable edition of MiKTeX because it relies on MiKTeX\(cqs COM interface only accessible in a local installation\&. To enable the evaluation of PostScript specials, the original Ghostscript DLL \fIgsdll32\&.dll\fR must be present and reachable through the search path\&. 64\-bit Windows builds require the 64\-bit Ghostscript DLL \fIgsdll64\&.dll\fR\&. Both DLLs come with the corresponding Ghostscript installers available from www\&.ghostscript\&.com\&. +.sp +The environment variable DVISVGM_COLORS specifies the colors used to highlight various parts of dvisvgm\(cqs message output\&. It is only evaluated if option \fB\-\-color\fR is given\&. The value of DVISVGM_COLORS is a list of colon\-separated entries of the form \fIgg\fR=\fIBF\fR, where \fIgg\fR denotes one of the color group indicators listed below, and \fIBF\fR are two hexadecimal digits specifying the background (first digit) and foreground/text color (second digit)\&. The color color values are defined as follows: 0=black, 1=red, 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, 7=gray, 8=bright red, 9=bright green, A=bright yellow, B=bright blue, C=bright magenta, D=bright cyan, E=bright gray, F=white\&. Depending on the terminal, the colors may differ\&. Rather than changing both the text and background color, it\(cqs also possible to change only one of them: An asterisk (*) in place of a hexadecimal digit indicates the default text or background color of the terminal\&. +.sp +All malformed entries in the list are silently ignored\&. +.TS +tab(:); +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt. +T{ +.sp +\fBer\fR +T}:T{ +.sp +error messages +T} +T{ +.sp +\fBwn\fR +T}:T{ +.sp +warning messages +T} +T{ +.sp +\fBpn\fR +T}:T{ +.sp +messages about page numbers +T} +T{ +.sp +\fBps\fR +T}:T{ +.sp +page size messages +T} +T{ +.sp +\fBfw\fR +T}:T{ +.sp +information about the files written +T} +T{ +.sp +\fBsm\fR +T}:T{ +.sp +state messages +T} +T{ +.sp +\fBtr\fR +T}:T{ +.sp +messages of the glyph tracer +T} +T{ +.sp +\fBpi\fR +T}:T{ +.sp +progress indicator +T} +.TE +.sp 1 +.sp +\fBExample:\fR er=01:pi=*5 sets the colors of error messages (er) to red (1) on black (0), and those of progress indicators (pi) to cyan (5) on default background (*)\&. +.SH "FILES" +.sp +The location of the following files is determined by the kpathsea library\&. To check the actual kpathsea configuration you can use the \fBkpsewhich\fR utility\&. +.TS +tab(:); +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt. +T{ +.sp +\fB*\&.enc\fR +T}:T{ +.sp +Font encoding files +T} +T{ +.sp +\fB*\&.fgd\fR +T}:T{ +.sp +Font glyph data files (cache files created by dvisvgm) +T} +T{ +.sp +\fB*\&.map\fR +T}:T{ +.sp +Font map files +T} +T{ +.sp +\fB*\&.mf\fR +T}:T{ +.sp +Metafont input files +T} +T{ +.sp +\fB*\&.pfb\fR +T}:T{ +.sp +PostScript Type 1 font files +T} +T{ +.sp +\fB*\&.pro\fR +T}:T{ +.sp +PostScript header/prologue files +T} +T{ +.sp +\fB*\&.tfm\fR +T}:T{ +.sp +TeX font metric files +T} +T{ +.sp +\fB*\&.ttf\fR +T}:T{ +.sp +TrueType font files +T} +T{ +.sp +\fB*\&.vf\fR +T}:T{ +.sp +Virtual font files +T} +.TE +.sp 1 +.SH "SEE ALSO" +.sp +\fBtex(1), mf(1), mktexmf(1), grodvi(1), potrace(1)\fR, and the \fBkpathsea library\fR info documentation\&. +.SH "RESOURCES" +.PP +Project home page +.RS 4 +http://dvisvgm\&.sourceforge\&.net +.RE +.PP +SourceForge project site +.RS 4 +http://sourceforge\&.net/projects/dvisvgm +.RE +.SH "BUGS" +.sp +Please report bugs using the bug tracker at Launchpad (see https://launchpad\&.net/dvisvgm)\&. +.SH "AUTHOR" +.sp +Written by Martin Gieseking +.SH "COPYING" +.sp +Copyright \(co 2005\-2013 Martin Gieseking\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 3 or, (at your option) any later version\&. +.SH "AUTHOR" +.PP +\fBMartin Gieseking\fR <\&martin\&.gieseking@uos\&.de\&> +.RS 4 +Author. +.RE diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.txt.in b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.txt.in new file mode 100644 index 00000000000..0d5edbdabc2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/doc/dvisvgm.txt.in @@ -0,0 +1,641 @@ +////////////////////////////////////////////////////////////////////////// +// This file is part of dvisvgm -- the DVI to SVG converter // +// Copyright (C) 2005-2013 Martin Gieseking // +// // +// 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 . // +////////////////////////////////////////////////////////////////////////// + +dvisvgm(1) +========== +Martin Gieseking <@PACKAGE_BUGREPORT@> +:man source: dvisvgm +:man version: @VERSION@ +:man manual: dvisvgm Manual + +NAME +---- +dvisvgm - converts DVI files to the XML-based SVG format + + +SYNOPSIS +-------- +*dvisvgm* [ 'options' ] 'file' [.dvi] + +*dvisvgm* -E [ 'options' ] 'file' [.eps] + + +DESCRIPTION +----------- +The command-line utility *dvisvgm* converts DVI files, as generated by TeX/LaTeX, to the +XML-based scalable vector graphics format SVG. Since the current SVG standard 1.1 doesn't +specify multi-page graphics, dvisvgm creates separate SVG files for each DVI page. +Because of compatibility reasons, only the first page is converted by default. In order +to select a different page or arbitrary page sequences, use option *-p* which is described below. + +dvisvgm should properly convert all pages that are made up of fonts and rules only. +However, the utility also supports a couple of DVI extensions defined in terms of 'DVI specials'. +For a more detailed overview, see section *support of specials* below. + +As SVG is a vector based graphics format, dvisvgm tries to convert the glyph +outlines of all used fonts into scalable path descriptions. The fastest way to do that +is to extract the path information from PFB (PostScript Type 1) files. So, if dvisvgm is able +to find a PFB file for a required font, it will read the necessary information from this file. + +TeX's main source for font descriptions is Metafont though, which produces bitmap output. That's why +not all obtainable TeX fonts are available in PFB format. In these cases, dvisvgm tries +to vectorize Metafont's output (GF fonts) by tracing the glyph bitmaps. The results are not +as perfect as most (manually optimized) PFB outlines but are nonetheless really nice in most cases. + + +OPTIONS +------- +*-a, --trace-all*=['retrace']:: +This option forces dvisvgm to trace not only the actually needed glyphs but all +glyphs of all bitmap fonts used in the DVI file. Since the tracing results are stored in +the font cache, all following DVI conversions (without option *--trace-all*) where these +fonts are involved, will be much faster. By default, dvisvgm traces only the actually +needed glyphs, and adds them to the cache. +The boolean option 'retrace' determines how to handle glyphs already stored in the cache. +By default, these glyphs are skipped. Setting argument 'retrace' to 'yes' or +'true' forces dvisvgm to trace the corresponding bitmaps again. ++ +[NOTE] +This option only takes affect if font caching is active. Thus, *--trace-all* cannot be +combined with option *--cache=none*. ++ + + +*-b, --bbox*='fmt':: +Sets the bounding box of the generated graphic to the specified format. The parameter 'fmt' +takes either one of the format specifiers listed below, or a sequence of four comma- or +whitespace-separated length values 'x1', 'y1', 'x2' and 'y2'. The latter define two diagonal +corners of the bounding box. Each length value consists of a floating point number and an optional +length unit (pt, bp, cm, mm, in, or pc). If the unit is omitted, TeX points (pt) are assumed. ++ +It's also possible to give only one length value 'l'. In this case, the minimal bounding box +is computed and enlarged by adding (-'l',-'l') to the upper left and ('l','l') to the lower +right corner. ++ +Alternatively, the following format specifiers are supported: + + *International DIN/ISO paper sizes*;; + A__n__, B__n__, C__n__, D__n__, where 'n' is a non-negative integer, e.g. A4 or a4 for DIN/ISO A4 + format (210mm × 297mm). + + *North American paper sizes*;; + invoice, executive, legal, letter, ledger + + *Special bounding box sizes*;; +[horizontal] + *dvi*::: page size stored in the DVI file + *min*::: computes the minimal/tightest bounding box + *none*::: no bounding box is assigned + +// + *Page orientation*;; + The default page orientation for DIN/ISO and American paper sizes is 'portrait', + i.e. 'width' < 'height'. Appending *-landscape* or simply *-l* to the format + string switches to 'landscape' mode ('width' > 'height'). For symmetry reasons you can + also explicitly add *-portrait* or *-p* to indicate the default portrait format. + Note that these suffixes are part of the size string and not separate options. Thus, + they must directly follow the size specifier without additional blanks. + Furthermore, the orientation suffixes can't be used with *dvi*, *min*, and *none*. ++ +[NOTE] +Option *-b, --bbox* only affects the bounding box and does not transform the page content. +Hence, if you choose a landscape format, the page won't be rotated. ++ +// + +// +*-C, --cache*[='dir']:: +To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion +information in cache files. By default, these files are stored in $HOME/.dvisvgm/cache. If you prefer +a different location, use option *--cache* to overwrite the default. Furthermore, it is also possible +to disable the font caching mechanism completely with option *--cache=none*. If argument 'dir' is omitted, +dvisvgm prints the path of the default cache directory and some information about the stored fonts. +Additionally, outdated and corrupted cache files are removed. + + +*--color*:: +Enables colorization of messages printed during the conversion process. The colors can be customized +via the environment variable +DVISVGM_COLORS+. See the ENVIRONMENT section below for further information. + + +*-E, --eps*:: +If this option is given, dvisvgm does not expect a DVI but an EPS input file, and tries to convert +it to SVG. In order to do so, a single 'psfile' special command is created and forwarded to the +PostScript special handler. +This option is only available if dvisvgm was built with PostScript support enabled, and requires +Ghostscript to be available. See option *--libgs* for further information. + + +*-e, --exact*:: +If this option is given, dvisvgm computes the precise bounding box of each character. By default, +the values stored in a font's TFM file are used to determine a glyph's extent. As these values are +intended to realize optimal character placements and are not designed to represent the exact dimensions, +they don't necessarily correspond with the bounds of the visual glyphs. Thus, width and/or height +of some glyphs may be larger than the respective TFM values. As a result, this can lead to clipped +characters at the bounds of the SVG graphic. With option *--exact*, dvisvgm analyzes the actual shape +of each character and derives a usually tight bounding box. + + +*-m, --fontmap*='filenames':: +Loads and evaluates a single or multiple font map files. These files are required to resolve +font file names and encodings. dvisvgm does not provide its own map file but tries to read +available ones coming with dvips or dvipdfm. If option *--fonrmapm* is not given, dvisvgm looks for the +default map files +ps2pk.map+, +dvipdfm.map+, and +psfonts.map+ (in this order). Otherwise, the +listed files are used. Multiple filenames must be separated by commas without leading and/or trailing +whitespace. +The map files are evaluated in the given order. By default, redefined mappings do not replace previous ones. +However, each filename can be preceded by an optional mode specifier (*+*, *-*, or *=*) to change this behavior: + + +mapfile;; + Only those entries in the given map file that don't redefine a font mapping are applied. + That's also the default mode if no mode specifier is given. + + -mapfile;; + Ensures that none of the font mappings defined in the given map file are used, i.e. previously + defined mappings for the specified fonts are removed. + + =mapfile;; + All mappings defined in the map file are applied. Previously defined settings for the same font + are replaced. ++ +If the first filename in the filename sequence is preceded by a mode specifier, dvisvgm loads the +default font map (see above) and applies the other map files afterwards. Otherwise, none of default +map files will be loaded automatically. ++ +Examples: *--fontmap=myfile1.map,+myfile2.map* loads `myfile1.map` followed by `myfile2.map` where all +redefinitions of `myfile2.map` are ignored. +*--fontmap==myfile1.map,-myfile2.map* loads the default map file followed by `myfile1.map` and `myfile2.map` +where all redefinitions of `myfile1.map` replace previous entries. Afterwards, all definitions for the fonts +given in `myfile2.map` are removed again. ++ +For further information about the map file formats, see the manuals of dvips and dvipdfm. + + +*-h, --help*[='mode']:: +Prints a short summary of all available command-line options. The optional 'mode' parameter is +an integer value between 0 and 2. It selects the display variant of the help text. Mode 0 +lists all options divided into categories with section headers. This is also the default if +dvisvgm is called without parameters. Mode 1 lists all options ordered by the short option name, +while mode 2 sorts the lines by the long option name. + + +*--keep*:: +Disables the removal of temporary files as created by Metafont (usually .gf, .tfm, and .log files). + + +*--libgs*='filename':: +This option is only available if the Ghostscript library is not directly linked to dvisvgm and if +PostScript support was not completely disabled during compilation. In this case, dvisvgm tries +to load the shared GS library dynamically during runtime. By default, it expects the library's name +to be libgs.so (on Unix-like systems) or gsdll32.dll/gsdll64.dll (Windows). Option *--libgs* can be +used to give a different name. Alternatively, it's also possible to set the GS library name by the +environment variable +LIBGS+. The latter has less precedence than the command-line option. + + +*-L, --linkmark*='type':: +Selects the method how to mark hyperlinked areas. The 'type' argument can take one of the values +'none', 'box', and 'line', where the latter is the default, i.e. all links are underlined when +dvisvgm is called without option *--linkmark*. Type 'box' draws a rectangle around the linked +area, and 'none' tells dvisvgm not to add any visible objects to hyperlinks. + + +*-l, --list-specials*:: +Prints a list of registered special handlers and exits. Each handler processes a set of special +statements belonging to the same category. In most cases, the categories are identified by the +prefix of the special statements. It's usually a leading word separated from the rest of the +statement by a colon or a blank, e.g. 'color' or 'ps'. + + +*-M, --mag*='factor':: +Sets the magnification factor applied in conjunction with Metafont calls prior tracing the glyphs. +The larger this value, the better the tracing results. Nevertheless, large magnification values +can cause Metafont arithmetic errors due to number overflows. So, use this option with care. +The default setting usually produces nice results. + + +*--no-mktexmf*:: +Suppresses the generation of missing font files. If dvisvgm can't find a font file +through the kpathsea lookup mechanism, it calls the external tools mktextfm or mktexmf by. +This option disables these calls. + + +*-n, --no-fonts*[='variant']:: +If this option is given, dvisvgm doesn't create SVG 'font' elements but uses 'paths' instead. The +resulting SVG files tends to be larger but concurrently more compatible with most applications that +don't support SVG fonts yet. The optional argument 'variant' selects the method how to substitute fonts +by paths. Variant 0 creates 'path' and 'use' elements. Variant 1 creates 'path' elements only. +Option *--no-fonts* implies *--no-styles*. + + +*-c, --scale*='sx'[,'sy']:: +Scales the page content horizontally by 'sx' and vertically by 'sy'. This option is equivalent +to *-TS*'sx','sy'. + + +*-S, --no-specials*[='names']:: +Disable processing of special commands embedded in the DVI file. If no further +parameter is given, all specials are ignored. To selectively disable sets of specials, +an optional comma-separated list of names can be appended to this option. A 'name' is the unique +identifier referencing the intended special handler. Option *--list-specials* lists all currently +available handlers and their names. +All unsupported special statements are silently ignored. + + +*--no-styles*:: +By default, dvisvgm creates CSS styles and class attributes to reference fonts because it's more +compact than repeatedly set the complete font information in each text element. However, if you +prefer direct font references, the default behavior can be disabled with option *--no-styles*. + + +*-o, --output*='pattern':: +Sets the name pattern of the output file. Parameter 'pattern' is a string that may +contain the variables *%f* and *%p*. *%f* stands for the base name of the DVI file, i.e. +the DVI filename without suffix, and *%p* is the current page number. +The default pattern is *%f-%p.svg* if the DVI file consists of more than one page, and +*%f.svg* otherwise. That means, a DVI file 'foo.dvi' is converted to 'foo.svg' if 'foo.dvi' +is a single-page document. Otherwise, multiple SVG files 'foo-01.svg', 'foo-02.svg', etc. are +produced. In Windows environments, the percent sign indicates dereferenced environment +variables, and must therefore be protected by a second percent sign, e.g. *--output=%%f-%%p*. + + +*-p, --page*='ranges':: +This option sets the pages to be processed. Parameter 'ranges' consists of a comma-separated list +of single page numbers and/or page ranges. A page range is a pair of numbers separated by a hyphen, +e.g. 5-12. Thus, a page sequence might look like this: 2-4,6,9-12,15. It doesn't matter if a page +is given more than once or if page ranges overlap. dvisvgm always extracts the page numbers in +ascending order and converts them only once. +In order to stay compatible with previous versions, the default page sequence is 1. dvisvgm +therefore converts only the first page and not the whole document in case option *--page* is omitted. +Usually, page ranges consist of two numbers denoting the first and last page to be converted. +If the conversion is to be started at page 1, or if it should continue up to the last DVI page, the +first or second range number can be omitted, respectively. Example: *--page=-10* converts all +pages up to page 10, *--page=10-* converts all pages starting with page 10. +Please consider that the page values don't refer to the page numbers printed on the page. +Instead, the physical page count is expected, where the first page always gets number 1. + + +*-d, --precision*='digits':: +Specifies the maximal number of decimal places applied to floating-point attribute values. +All attribute values written to the generated SVG file(s) are rounded accordingly. The +parameter 'digits' allows integer values from 0 to 6, where 0 enables the automatic selection +of significant decimal places. This is also the default value if dvisvgm is called without +option *--precision*. + + +*-P, --progress*[='delay']:: +Enables a simple progress indicator shown when time-consuming operations like +PostScript specials are processed. The indicator doesn't appear before the given +delay (in seconds) has elapsed. The default delay value is 0.5 seconds. + + +*-r, --rotate*='angle':: +Rotates the page content clockwise by 'angle' degrees around the page center. +This option is equivalent to *-TR*'angle'. + + +*-s, --stdout*:: +Don't write the SVG output to a file but redirect it to *stdout*. + + +*-T, --transform*='commands':: +Applies a sequence of transformations to the SVG content. Each transformation is described +by a 'command' beginning with a capital letter followed by a list of comma-separated +parameters. Following transformation commands are supported: + + *T* 'tx'[,'ty'];; + Translates (moves) the page in direction of vector ('tx','ty'). If 'ty' is omitted, + 'ty'=0 is assumed. + The expected unit length of 'tx' and 'ty' are TeX points (1pt = 1/72.27in). However, there + are several constants defined to simplify the unit conversion (see below). + + *S* 'sx'[,'sy'];; + Scales the page horizontally by 'sx' and vertically by 'sy'. If 'sy' is omitted, + 'sy'='sx' is assumed. + + *R* 'angle'[,'x','y'];; + Rotates the page clockwise by 'angle' degrees around point ('x','y'). If the optional + arguments 'x' and 'y' are omitted, the page will be rotated around its center depending on + the chosen page format. When option *-bnone* is given, the rotation center is origin (0,0). + + *KX* 'angle';; + Skews the page along the 'x'-axis by 'angle' degrees. Argument 'angle' can take any value + except 90+180__k__, where 'k' is an integer. + + *KY* 'angle';; + Skews the page along the 'y'-axis by 'angle' degrees. Argument 'angle' can take any value + except 90+180__k__, where 'k' is an integer. + + *FH* ['y'];; + Mirrors (flips) the page at the horizontal line through point (0,'y'). Omitting the optional argument + leads to 'y'='h'/2, where 'h' denotes the page height (see 'pre-defined constants' below). + + *FV* ['x'];; + Mirrors (flips) the page at the vertical line through point ('x',0). Omitting the optional argument + leads to 'x'='w'/2, where 'w' denotes the page width (see 'pre-defined constants' below). + + *M* 'm1',...,'m6';; + Applies a transformation described by the 3×3 matrix + \(('m1','m2','m3'),('m4','m5','m6'),(0,0,1)), where the inner triples denote + the rows. ++ +[NOTE] +================================================================================================= +All transformation commands of option *-T, --transform* are applied in the order of their appearance. +Multiple commands can optionally be separated by spaces. In this case the whole transformation string +has to be enclosed in double quotes. All parameters are expressions of floating point type. You can either +give plain numbers or arithmetic terms combined by the operators *+* (addition), *-* (subtraction), +*** (multiplication), */* (division) or *%* (modulo) with common associativity and +precedence rules. Parentheses may be used as well. + +Additionally, some pre-defined constants are provided: + +[horizontal] +*ux*:: horizontal position of upper left page corner in TeX point units +*uy*:: vertical position of upper left page corner in TeX point units +*h*:: page height in TeX point units (0 in case of *-bnone*) +*w*:: page width in TeX point units (0 in case of *-bnone*) + +Furthermore, you can use the length constants *pt*, *mm*, *cm* and *in*, e.g. ++2cm+ or +1.6in+. Thus, option +-TT1in,0R45+ moves the page content 1 inch to the right and rotates it +by 45 degrees around the page center afterwards. + +For single transformations you can also use options *-c*, *-t* and *-r*. Note that +the order in which these options are given is not significant, i.e. you can't use them to describe +transformation sequences. They are simply independent shorthand options for common transformations. + +================================================================================================= ++ +// + +// +*-t, --translate*='tx'[,'ty']:: +Translates (moves) the page content in direction of vector ('tx','ty'). This option is +equivalent to *-TT*'tx','ty'. + + +*-v, --verbosity*='level':: +Controls the type of messages printed during a dvisvgm run: +[horizontal] + *0*;; no message output + *1*;; error messages only + *2*;; warning messages only + *4*;; informational messages only + ++ +[NOTE] +By adding these values you can combine the categories. The default level is 7, i.e. all +messages are printed. ++ + + +*-V, --version*[='extended']:: +Prints the version of dvisvgm and exits. If the optional argument is set to 'yes', the +version numbers of the linked libraries are printed as well. + + +*-z, --zip*[='level']:: +Creates a compressed SVG file with suffix .svgz. The optional argument specifies the compression +level. Valid values are in the range of 1 to 9 (default value is 9). Larger values cause better +compression results but take more computation time. ++ +CAUTION: This option cannot be combined with *-s, --stdout*. + + +SUPPORT OF SPECIALS +------------------- +dvisvgm supports several sets of 'special commands' that can be used to enrich DVI files with additional +features, like color, graphics or hyperlinks. The evaluation of special commands is delegated to various handlers. +Each handler is responsible for all special statements of the same command set, i.e. commands beginning +with the same prefix. To get a list of actually provided special handlers, use option *--list-specials* (see above). + +*bgcolor*:: +Special statement for changing the background/page color. Since SVG 1.1 doesn't support background colors, +dvisvgm inserts a rectangle of the chosen color into the generated SVG document. This rectangle always gets +the same size as the selected or computed bounding box. This background color command is part of the color +special set but is handled separately in order to let the user turn it off. For an overview of the command +syntax, see the documentation of dvips, for instance. + +*color*:: +Statements of this command set provide instructions to change the text/paint color. For an overview of the +exact syntax, see the documentation of dvips, for instance. + +*dvisvgm*:: +dvisvgm offers its own small set of specials. The following list gives a brief overview. + *dvisvgm:raw* 'text';; + Adds an arbitrary sequence of characters to the SVG output. dvisvgm does not perform any validation here, + thus the user has to ensure that the resulting SVG is still valid. Parameter 'text' may + contain the macros *{?x}*, *{?y}*, and *{?color}* that are expanded to the current 'x' or 'y' coordinate + and the current color, respectively. Also, macro *{?nl}* expands to a newline character. + + *dvisvgm:img* 'width' 'height' 'file';; + Creates an image element at the current graphic position referencing the given file. JPEG, PNG, and SVG images + can be used here. However, dvisvgm does not check the file format or the file name suffix. The lengths 'width' + and 'height' must be given as plain floating point numbers in TeX point units (1in = 72.27pt). + + *dvisvgm:bbox* n[ew] 'name';; + Defines or resets a local bounding box called 'name'. The name may consist of letters and digits. + While processing a DVI page, dvisvgm continuously updates the (global) bounding box of the current page in order to + determine the minimal rectangle containing all visible page components (characters, images, drawing elements etc.) + Additionally to the global bounding box, the user can request an arbitrary number of named local bounding boxes. + Once defined, these boxes are updated together with the global bounding box starting with the first character that + follows the definition. Thus, the local boxes can be used to compute the extent of parts of the page. This is useful + for scenarios where the generated SVG file is post-processed. + In conjunction with special dvisvgm:raw, the macro *{?bbox 'name'}* expands to the four values 'x', 'y', 'w', and 'h' + (separated by spaces) specifying the coordinates of the upper left corner, width, and height of the local box 'name'. + If box 'name' wasn't previously defined, all four values equal zero. + + *dvisvgm:bbox* 'width' 'height' ['depth'];; + Updates the bounding box of the current page by embedding a virtual rectangle ('x', 'y', 'width', 'height') + where the lower left corner is located at the current DVI drawing position ('x','y'). If the optional parameter 'depth' + is specified, dvisvgm embeds a second rectangle ('x', 'y', 'width', -__depth__). The lengths 'width', 'height' and + 'depth' must be given as plain floating point numbers in TeX point units (1in = 72.27pt). Depending on size and position + of the virtual rectangle, this command either enlarges the overall bounding box or leaves it as is. It's not possible + to reduce its extent. This special should be used in conjunction with *dvisvgm:raw* in order to update the viewport + of the page properly. + + *dvisvgm:bbox* a[bs] 'x1' 'y1' 'x2' 'y2';; + This variant of the bbox special updates the bounding box by embedding a virtual rectangle ('x1','y1','x2','y2'). + The points ('x1','y1') and ('x2','y2') denote two diagonal corners of the rectangle given in TeX point units. + + *dvisvgm:bbox* f[ix] 'x1' 'y1' 'x2' 'y2';; + This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG. After executing + this command, dvisvgm doesn't further alter the bounding box coordinates, except this special is called again later. + The points ('x1','y1') and ('x2','y2') denote two diagonal corners of the rectangle given in TeX point units. ++ +The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: ++ +------------------------------------------------------------------------------------ +\special{dvisvgm:raw } +\special{dvisvgm:bbox 20 10 10} + +\special{dvisvgm:raw } +\special{dvisvgm:bbox abs 10 200 100 250} +------------------------------------------------------------------------------------ ++ + +*em*:: +These specials were introduced with the emTeX distribution by Eberhard Mattes. They provide line drawing +statements, instructions for embedding MSP, PCX, and BMP image files, as well as two PCL commands. +dvisvgm supports only the line drawing statements and ignores all other em specials silently. +A description of the command syntax can be found in the DVI driver documentation coming with emTeX (see CTAN). + +*html*:: +The hyperref specials allow the definition of hyperlinks inside DVI files in various flavors. dvisvgm supports +the plain HyperTeX special constructs as created with hyperref package option 'hypertex'. Internal links, i.e. +references to other parts of the same document, are only converted if the link and the corresponding link target +are located on the same page. Links between different pages are not supported yet. +By default, all linked areas of the document are underlined. Option *--linkmark* allows to change this behavior. +See above for further details. Information on syntax and semantics of the HyperTeX specials can be found in the +hyperref manual. + +*pdf*:: +pdfTeX and dvipdfmx introduced several special commands related to the generation of PDF files. Currently, only +two of them, 'pdf:mapfile' and 'pdf:mapline' are supported by dvisvgm. These specials allow modifying the font map +tree during the processing of DVI files. They are used by CTeX, for example. dvisvgm supports both, the dvips and +dvipdfm font map format. For further information on the command syntax and semantics, see the documentation of +\pdfmapfile in the pdfTeX user manual. + +*ps*:: +The famous DVI driver dvips introduced its own set of specials in order to embed PostScript code into DVI files, +which greatly improves the capabilities of DVI documents. One aim of dvisvgm is to completely evaluate all +PostScript snippets and to convert a large amount of it to SVG. However, in contrast to dvips, dvisvgm uses floating point +arithmetics to compute the precise position of each graphic element, i.e. it doesn't round the coordinates. Therefore, +the relative locations of the graphic elements may slightly differ from those computed by dvips. ++ +Since PostScript is a rather complex language, dvisvgm does not try to implement its own PostScript interpreter but relies on +Ghostscript instead. If the Ghostscript library was not linked while building dvisvgm, it is looked up and loaded dynamically +during runtime. In this case, dvisvgm looks for 'libgs.so' on Unix-like systems, and for 'gsdll32.dll' or 'gsdll64.dll' on Windows. +You can override these default file names with environment variable +LIBGS+ or the command-line option *--libgs*. +The library must be installed and reachable through the ld search path (\*nix) or the PATH environment +variable (Windows). If it cannot be found, the processing of PostScript specials is disabled. +Use option *--list-specials* to check whether PS support is available, i.e. the entry 'ps' is present. + +*tpic*:: +The TPIC special set defines instructions for drawing simple geometric objects. Some LaTeX packages, like +eepic and tplot, use these specials to describe graphics. + + +EXAMPLES +-------- +-------------- +dvisvgm file +-------------- +Converts the first page of 'file.dvi' to 'file.svg'. + +--------------- +dvisvgm -z file +--------------- +Converts the first page of 'file.dvi' to 'file.svgz' with default compression level 9. + +------------------------------------- +dvisvgm -p5 -z3 -ba4-l -onewfile file +------------------------------------- +Converts the fifth page of 'file.dvi' to 'newfile.svgz' with compression level 3. +The bounding box is set to DIN/ISO A4 in landscape format. + +----------------------------------------------------- +dvisvgm --transform="R20,w/3,2h/5 T1cm,1cm S2,3" file +----------------------------------------------------- +Converts the first page of 'file.dvi' to 'file.svg' where three transformations are applied. + + +ENVIRONMENT +----------- +dvisvgm uses the *kpathsea* library for locating the files that it opens. +Hence, the environment variables described in the library's documentation influence the converter. + +If dvisvgm was linked without the Ghostscript library, and if PostScript support has not been disabled, +the shared Ghostscript library is looked up during runtime via dlopen(). The environment variable +LIBGS+ +can be used to specify path and file name of the library. + +The pre-compiled Windows versions of dvisvgm require a working installation of MiKTeX 2.9 or above. +dvisvgm does not work together with the portable edition of MiKTeX because it relies on MiKTeX's COM +interface only accessible in a local installation. +To enable the evaluation of PostScript specials, the original Ghostscript DLL 'gsdll32.dll' must be present +and reachable through the search path. 64-bit Windows builds require the 64-bit Ghostscript DLL 'gsdll64.dll'. +Both DLLs come with the corresponding Ghostscript installers available from www.ghostscript.com. + +The environment variable +DVISVGM_COLORS+ specifies the colors used to highlight various parts of dvisvgm's +message output. It is only evaluated if option *--color* is given. The value of +DVISVGM_COLORS+ is a list of +colon-separated entries of the form 'gg'='BF', where 'gg' denotes one of the color group indicators listed +below, and 'BF' are two hexadecimal digits specifying the background (first digit) and foreground/text color +(second digit). The color color values are defined as follows: 0=black, 1=red, 2=green, 3=yellow, 4=blue, +5=magenta, 6=cyan, 7=gray, 8=bright red, 9=bright green, A=bright yellow, B=bright blue, C=bright magenta, +D=bright cyan, E=bright gray, F=white. Depending on the terminal, the colors may differ. Rather than changing +both the text and background color, it's also possible to change only one of them: An asterisk (*) in +place of a hexadecimal digit indicates the default text or background color of the terminal. + +All malformed entries in the list are silently ignored. + +[horizontal] +*er*:: error messages +*wn*:: warning messages +*pn*:: messages about page numbers +*ps*:: page size messages +*fw*:: information about the files written +*sm*:: state messages +*tr*:: messages of the glyph tracer +*pi*:: progress indicator + +*Example:* +er=01:pi=\*5+ sets the colors of error messages (+er+) to red (+1+) on black (+0+), and those +of progress indicators (+pi+) to cyan (+5+) on default background (+*+). + +FILES +----- +The location of the following files is determined by the kpathsea library. +To check the actual kpathsea configuration you can use the *kpsewhich* utility. + +[horizontal] +**.enc*:: Font encoding files +**.fgd*:: Font glyph data files (cache files created by dvisvgm) +**.map*:: Font map files +**.mf*:: Metafont input files +**.pfb*:: PostScript Type 1 font files +**.pro*:: PostScript header/prologue files +**.tfm*:: TeX font metric files +**.ttf*:: TrueType font files +**.vf*:: Virtual font files + +SEE ALSO +-------- +*tex(1), mf(1), mktexmf(1), grodvi(1), potrace(1)*, and the *kpathsea library* info documentation. + + +RESOURCES +--------- +Project home page::: http://dvisvgm.sourceforge.net +SourceForge project site::: http://sourceforge.net/projects/dvisvgm + + +BUGS +---- +Please report bugs using the bug tracker at Launchpad (see https://launchpad.net/dvisvgm). + + +AUTHOR +------ +Written by {author} <{email}> + + +COPYING +------- +Copyright (C) 2005-2013 Martin Gieseking. Free use of this software is +granted under the terms of the GNU General Public License (GPL) version 3 +or, (at your option) any later version. + +// vim: set syntax=asciidoc: diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.cpp new file mode 100644 index 00000000000..a225d360910 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.cpp @@ -0,0 +1,37 @@ +/************************************************************************* +** BgColorSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "BgColorSpecialHandler.h" +#include "ColorSpecialHandler.h" +#include "SpecialActions.h" + +using namespace std; + + +bool BgColorSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + ColorSpecialHandler csh; + return csh.process(prefix, is, actions); +} + + +const char** BgColorSpecialHandler::prefixes () const { + static const char *pfx[] = {"background", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.h new file mode 100644 index 00000000000..98dd814ba9e --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BgColorSpecialHandler.h @@ -0,0 +1,34 @@ +/************************************************************************* +** BgColorSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef BGCOLORSPECIALHANDLER_H +#define BGCOLORSPECIALHANDLER_H + +#include "SpecialManager.h" + +struct BgColorSpecialHandler : SpecialHandler +{ + const char* info () const {return "background color special";} + const char* name () const {return "bgcolor";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &is, SpecialActions *actions); +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.cpp new file mode 100644 index 00000000000..e72d5ee34ac --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.cpp @@ -0,0 +1,124 @@ +/************************************************************************* +** Bitmap.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "Bitmap.h" +#include "macros.h" + +using namespace std; + +Bitmap::Bitmap () : _rows(0), _cols(0), _xshift(0), _yshift(0), _bpr(0), _bytes(0) +{ +} + + +/** Constructs a Bitmap */ +Bitmap::Bitmap (int minx, int maxx, int miny , int maxy) { + resize(minx, maxx, miny, maxy); +} + + +/** Resizes the bitmap and clears all pixels. + * @param[in] minx index of leftmost pixel column + * @param[in] maxx index of rightmost pixel column + * @param[in] miny index of bottom row + * @param[in] maxy index of top row */ +void Bitmap::resize (int minx, int maxx, int miny , int maxy) { + _rows = abs(maxy-miny)+1; + _cols = abs(maxx-minx)+1; + _xshift = minx; + _yshift = miny; + _bpr = _cols/8 + (_cols % 8 ? 1 : 0); // bytes per row + _bytes.resize(_rows*_bpr); + FORALL(_bytes, vector::iterator, it) + *it = 0; +} + + +/** Sets n pixels of row r to 1 starting at pixel c. + * @param[in] r number of row + * @param[in] c number of column (pixel) + * @param[in] n number of bits to be set */ +void Bitmap::setBits (int r, int c, int n) { + r -= _yshift; + c -= _xshift; + UInt8 *byte = &_bytes[r*_bpr + c/8];// + (c%8 ? 1 : 0); + while (n > 0) { + int b = 7 - c%8; // number of leftmost bit in current byte to be set + int m = min(n, b+1); // number of bits to be set in current byte + int bitseq = (1 << m)-1; // sequence of n set bits (bits 0..n-1 are set) + bitseq <<= b-m+1; // move bit sequence so that bit b is the leftmost set bit + *byte |= UInt8(bitseq); // apply bit sequence to current byte + byte++; + n -= m; + c += m; + } +} + + +void Bitmap::forAllPixels (ForAllData &data) const { + for (int y=_rows-1; y >= 0 ; y--) { + for (int c=0; c < _bpr; c++) { + UInt8 byte = _bytes[y*_bpr+c]; + int x; + for (int b=7; (b >= 0) && ((x = 8*c+(7-b)) < _cols); b--) { + data.pixel(x, y, byte & (1 << b), *this); + } + } + } +} + + +struct BBoxData : public Bitmap::ForAllData +{ + BBoxData () : maxx(0), maxy(0) {} + void pixel (int x, int y, bool set, const Bitmap &bm) { + if (set) { + maxx = max(maxx, x); + maxy = max(maxy, y); + } + } + int maxx, maxy; +}; + + +void Bitmap::bbox (int &w, int &h) const { + BBoxData data; + forAllPixels(data); + w = data.maxx+1; + h = data.maxy+1; +} + + +ostream& Bitmap::write (ostream &os) const { +#if 0 + for (int r=_rows-1; r >= 0 ; r--) { + for (int c=0; c < _bpr; c++) { + UInt8 byte = _bytes[r*_bpr+c]; + for (int b=128; b; b>>=1) + os << (byte & b ? '*' : '-'); + os << ' '; + } + os << endl; + } +#endif + return os; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.h new file mode 100644 index 00000000000..1a1f19caf15 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Bitmap.h @@ -0,0 +1,109 @@ +/************************************************************************* +** Bitmap.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef BITMAP_H +#define BITMAP_H + +#include +#include +#include "types.h" + + +class Bitmap +{ + public: + struct ForAllData { + virtual ~ForAllData() {} + virtual void pixel (int x, int y, bool set, Bitmap &bm) {} + virtual void pixel (int x, int y, bool set, const Bitmap &bm) {} + }; + + public: + Bitmap (); + Bitmap (int minx, int maxx, int miny , int maxy); + void resize (int minx, int maxx, int miny , int maxy); + void setBits(int r, int c, int n); + const UInt8* operator[] (int r) const {return &_bytes[r*_bpr];} + int height () const {return _rows;} + int width () const {return _cols;} + int xshift () const {return _xshift;} + int yshift () const {return _yshift;} + int bytesPerRow () const {return _bpr;} + bool empty () const {return (!_rows && !_cols) || _bytes.empty();} + void bbox (int &w, int &h) const; + void forAllPixels (ForAllData &data) const; + + template + int copy (std::vector &target, bool vflip=false) const; + +// template +// void write (std::ostream &os, const std::vector &v) const; + + std::ostream& write (std::ostream &os) const; + + private: + int _rows, _cols; ///< number of rows, columns + int _xshift, _yshift; ///< horizontal/vertical shift + int _bpr; ///< number of bytes per row + std::vector _bytes; +}; + + +/** Copies the bitmap to a new target area and reorganize the bits. + * @param[out] target points to first T of new bitmap (must be deleted after usage) + * @param[in] vflip true if the new bitmap should be flipped vertically + * @return number of Ts per row */ +template +int Bitmap::copy (std::vector &target, bool vflip) const { + const int s = sizeof(T); + const int tpr = _bpr/s + (_bpr%s ? 1 : 0); // number of Ts per row + target.resize(_rows*tpr); + for (int r=0; r < _rows; r++) { + int targetrow = vflip ? _rows-r-1 : r; + for (int b=0; b < _bpr; b++) { + T &t = target[targetrow*tpr + b/s]; + T chunk = (T)_bytes[r*_bpr+b] << (8*(s-1-b%s)); + if (b % s == 0) + t = chunk; + else + t |= chunk; + } + } + return tpr; +} + + +/* +template +void Bitmap::write (std::ostream &os, const std::vector &v) const { + const int s = sizeof(T); + const int tpr = _bpr/s + (_bpr%s ? 1 : 0); // number of Ts per row + for (int r=_rows-1; r >= 0; r--) { + for (int t=0; t < tpr; t++) { + for (T b=(T)1<<(8*s-1); b; b>>=1) + os << ((v[r*tpr+t] & b) ? '*' : '-'); + os << ' '; + } + os << std::endl; + } +}*/ + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.cpp new file mode 100644 index 00000000000..85ec9c4c452 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.cpp @@ -0,0 +1,262 @@ +/************************************************************************* +** BoundingBox.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "BoundingBox.h" +#include "Matrix.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +BoundingBox::BoundingBox () + : _ulx(0), _uly(0), _lrx(0), _lry(0), _valid(false), _locked(false) +{ +} + + +BoundingBox::BoundingBox (double ulxx, double ulyy, double lrxx, double lryy) + : _ulx(min(ulxx,lrxx)), _uly(min(ulyy,lryy)), + _lrx(max(ulxx,lrxx)), _lry(max(ulyy,lryy)), + _valid(true), _locked(false) +{ +} + + +BoundingBox::BoundingBox (const DPair &p1, const DPair &p2) + : _ulx(min(p1.x(), p2.x())), _uly(min(p1.y(), p2.y())), + _lrx(max(p1.x(), p2.x())), _lry(max(p1.y(), p2.y())), + _valid(true), _locked(false) +{ +} + + +BoundingBox::BoundingBox (const Length &ulxx, const Length &ulyy, const Length &lrxx, const Length &lryy) + : _ulx(min(ulxx.pt(),lrxx.pt())), _uly(min(ulyy.pt(),lryy.pt())), + _lrx(max(ulxx.pt(),lrxx.pt())), _lry(max(ulyy.pt(),lryy.pt())), + _valid(true), _locked(false) +{ +} + + +BoundingBox::BoundingBox (const string &boxstr) + : _valid(false), _locked(false) +{ + set(boxstr); +} + + +/** Removes leading and trailing whitespace from the given string. */ +static string& strip (string &str) { + size_t n=0; + while (n < str.length() && isspace(str[n])) + ++n; + str.erase(0, n); + n=str.length()-1; + while (n > 0 && isspace(str[n])) + --n; + str.erase(n+1); + return str; +} + + +/** Sets or modifies the bounding box. If 'boxstr' consists of 4 length values, + * they denote the absolute position of two diagonal corners of the box. In case + * of a single length value l the current box is enlarged by adding (-l,-l) the upper + * left and (l,l) to the lower right corner. + * @param[in] boxstr whitespace and/or comma separated string of lengths. */ +void BoundingBox::set (string boxstr) { + vector coord; + const size_t len = boxstr.length(); + size_t l=0; + strip(boxstr); + string lenstr; + do { + while (l < len && isspace(boxstr[l])) + l++; + size_t r=l; + while (r < len && !isspace(boxstr[r]) && boxstr[r] != ',') + r++; + lenstr = boxstr.substr(l, r-l); + if (!lenstr.empty()) { + coord.push_back(Length(lenstr)); + if (boxstr[r] == ',') + r++; + l = r; + } + } while (!lenstr.empty() && coord.size() < 4); + + switch (coord.size()) { + case 1: + _ulx -= coord[0].pt(); + _uly -= coord[0].pt(); + _lrx += coord[0].pt(); + _lry += coord[0].pt(); + break; + case 2: + _ulx -= coord[0].pt(); + _uly -= coord[1].pt(); + _lrx += coord[0].pt(); + _lry += coord[1].pt(); + break; + case 4: + _ulx = min(coord[0].pt(), coord[2].pt()); + _uly = min(coord[1].pt(), coord[3].pt()); + _lrx = max(coord[0].pt(), coord[2].pt()); + _lry = max(coord[1].pt(), coord[3].pt()); + break; + default: + throw BoundingBoxException("1, 2 or 4 length parameters expected"); + } + _valid = true; +} + + +/** Enlarges the box so that point (x,y) is enclosed. */ +void BoundingBox::embed (double x, double y) { + if (!_locked) { + if (_valid) { + if (x < _ulx) + _ulx = x; + else if (x > _lrx) + _lrx = x; + if (y < _uly) + _uly = y; + else if (y > _lry) + _lry = y; + } + else { + _ulx = _lrx = x; + _uly = _lry = y; + _valid = true; + } + } +} + + +/** Enlarges the box so that box bb is enclosed. */ +void BoundingBox::embed (const BoundingBox &bb) { + if (!_locked && bb._valid) { + if (_valid) { + embed(bb._ulx, bb._uly); + embed(bb._lrx, bb._lry); + } + else { + _ulx = bb._ulx; + _uly = bb._uly; + _lrx = bb._lrx; + _lry = bb._lry; + _valid = true; + } + } +} + + +void BoundingBox::embed (const DPair &c, double r) { + embed(BoundingBox(c.x()-r, c.y()-r, c.x()+r, c.y()+r)); +} + + +void BoundingBox::expand (double m) { + if (!_locked) { + _ulx -= m; + _uly -= m; + _lrx += m; + _lry += m; + } +} + + +/** Intersects the current box with bbox and applies the result to *this. + * If both boxes are disjoint, *this is not altered. + * @param[in] bbox box to intersect with + * @return false if *this is locked or both boxes are disjoint */ +bool BoundingBox::intersect (const BoundingBox &bbox) { + if (_locked || _lrx < bbox._ulx || _lry < bbox._uly || _ulx > bbox._lrx || _uly > bbox._lry) + return false; + _ulx = max(_ulx, bbox._ulx); + _uly = max(_uly, bbox._uly); + _lrx = min(_lrx, bbox._lrx); + _lry = min(_lry, bbox._lry); + return true; +} + + +void BoundingBox::operator += (const BoundingBox &bb) { + if (!_locked) { + _ulx += bb._ulx; + _uly += bb._uly; + _lrx += bb._lrx; + _lry += bb._lry; + } +} + + +void BoundingBox::scale (double sx, double sy) { + if (!_locked) { + _ulx *= sx; + _lrx *= sx; + if (sx < 0) swap(_ulx, _lrx); + _uly *= sy; + _lry *= sy; + if (sy < 0) swap(_uly, _lry); + } +} + + +void BoundingBox::transform (const Matrix &tm) { + if (!_locked) { + DPair ul = tm * DPair(_lrx, _lry); + DPair lr = tm * DPair(_ulx, _uly); + DPair ll = tm * DPair(_ulx, _lry); + DPair ur = tm * DPair(_lrx, _uly); + _ulx = min(min(ul.x(), lr.x()), min(ur.x(), ll.x())); + _uly = min(min(ul.y(), lr.y()), min(ur.y(), ll.y())); + _lrx = max(max(ul.x(), lr.x()), max(ur.x(), ll.x())); + _lry = max(max(ul.y(), lr.y()), max(ur.y(), ll.y())); + } +} + + +string BoundingBox::toSVGViewBox () const { + ostringstream oss; + oss << XMLString(_ulx) << ' ' << XMLString(_uly) << ' ' << XMLString(width()) << ' ' << XMLString(height()); + return oss.str(); +} + + +ostream& BoundingBox::write (ostream &os) const { + return os << '(' << _ulx << ", " << _uly + << ", " << _lrx << ", " << _lry << ')'; +} + + +XMLElementNode* BoundingBox::toSVGRect () const { + XMLElementNode *rect = new XMLElementNode("rect"); + rect->addAttribute("x", minX()); + rect->addAttribute("y", minY()); + rect->addAttribute("width", width()); + rect->addAttribute("height", height()); + rect->addAttribute("fill", "none"); + return rect; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.h new file mode 100644 index 00000000000..b3a4016f52a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/BoundingBox.h @@ -0,0 +1,86 @@ +/************************************************************************* +** BoundingBox.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef BOUNDINGBOX_H +#define BOUNDINGBOX_H + +#include +#include +#include "Length.h" +#include "MessageException.h" +#include "Pair.h" +#include "macros.h" +#include "types.h" + + +class Matrix; +class XMLElementNode; + + +struct BoundingBoxException : MessageException +{ + BoundingBoxException (const std::string &msg) : MessageException(msg) {} +}; + + +class BoundingBox +{ + public: + BoundingBox (); + BoundingBox (double ulxx, double ulyy, double lrxx, double lryy); + BoundingBox (const DPair &p1, const DPair &p2); + BoundingBox (const Length &ulxx, const Length &ulyy, const Length &lrxx, const Length &lryy); + BoundingBox (const std::string &boxstr); + void set (std::string boxstr); + void embed (double x, double y); + void embed (const BoundingBox &bb); + void embed (const DPair &p) {embed(p.x(), p.y());} + void embed (const DPair &c, double r); + + template + void embed (const Pair &p) {embed(p.x(), p.y());} + + void expand (double m); + bool intersect (const BoundingBox &bbox); + double minX () const {return _ulx;} + double minY () const {return _uly;} + double maxX () const {return _lrx;} + double maxY () const {return _lry;} + double width () const {return _lrx-_ulx;} + double height () const {return _lry-_uly;} + void lock () {_locked = true;} + void unlock () {_locked = false;} + void operator += (const BoundingBox &bb); + void scale (double sx, double sy); + void transform (const Matrix &tm); + std::string toSVGViewBox () const; + std::ostream& write (std::ostream &os) const; + XMLElementNode* toSVGRect () const; + + private: + double _ulx, _uly; ///< coordinates of upper left vertex (in TeX point units) + double _lrx, _lry; ///< coordinates of lower right vertex (in TeX point unitx) + bool _valid : 1; ///< true if the box coordinates are properly set + bool _locked : 1; ///< if true, the box data is read-only +}; + +IMPLEMENT_OUTPUT_OPERATOR(BoundingBox) + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.cpp new file mode 100644 index 00000000000..2295ab17bde --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.cpp @@ -0,0 +1,112 @@ +/************************************************************************* +** CRC32.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "CRC32.h" + +using namespace std; + + +CRC32::CRC32 () : _crc32(0xFFFFFFFF) +{ + const UInt32 poly = 0xEDB88320; + for (int i = 0; i < 256; i++) { + UInt32 crc=i; + for (int j=8; j > 0; j--) { + if (crc & 1) + crc = (crc >> 1) ^ poly; + else + crc >>= 1; + } + _tab[i] = crc; + } +} + + +/** Resets CRC32 sum to 0. */ +void CRC32::reset () { + _crc32 = 0xFFFFFFFF; +} + + +/** Appends string bytes to the previous data and computes the resulting checksum. + * @param[in] data string to update the checksum with */ +void CRC32::update (const char *data) { + update((const UInt8*)data, strlen(data)); +} + + +/** Appends a single value to the previous data and computes the resulting checksum. + * @param[in] n value to update the checksum with + * @param[in] bytes number of bytes to consider (0-4) */ +void CRC32::update (UInt32 n, int bytes) { + for (int i=bytes-1; i >= 0; --i) { + UInt8 byte = UInt8((n >> (8*i)) & 0xff); + update(&byte, 1); + } +} + + +/** Appends a sequence of bytes to the previous data and computes the resulting checksum. + * @param[in] bytes pointer to array of bytes + * @param[in] len number of bytes in array */ +void CRC32::update (const UInt8 *bytes, size_t len) { + for (size_t i=0; i < len; ++i) + _crc32 = ((_crc32 >> 8) & 0x00FFFFFF) ^ _tab[(_crc32 ^ *bytes++) & 0xFF]; +} + + +void CRC32::update (istream &is) { + char buf [4096]; + while (is) { + is.read(buf, 4096); + update((UInt8*)buf, is.gcount()); + } +} + + +/** Returns the checksum computed from values added with the update functions. */ +UInt32 CRC32::get () const { + return _crc32 ^ 0xFFFFFFFF; +} + + +/** Computes the CRC32 checksum of a sequence of bytes. + * @param[in] bytes pointer to array of bytes + * @param[in] len number of bytes in array + * @return CRC32 checksum */ +UInt32 CRC32::compute (const UInt8 *bytes, size_t len) { + CRC32 crc32; + crc32.update(bytes, len); + return crc32.get(); +} + + +/** Computes the CRC32 checksum of a string. */ +UInt32 CRC32::compute (const char *str) { + return compute((const UInt8*)str, strlen(str)); +} + + +UInt32 CRC32::compute (istream &is) { + CRC32 crc32; + crc32.update(is); + return crc32.get(); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.h new file mode 100644 index 00000000000..ca8ec359d0f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CRC32.h @@ -0,0 +1,51 @@ +/************************************************************************* +** CRC32.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef CRC32_H +#define CRC32_H + +#include +#include +#include "types.h" + +class CRC32 +{ + public: + CRC32 (); + void update (const UInt8 *bytes, size_t len); + void update (UInt32 n, int bytes=4); + void update (const char *str); + void update (std::istream &is); + UInt32 get () const; + void reset (); + static UInt32 compute (const UInt8 *bytes, size_t len); + static UInt32 compute (const char *str); + static UInt32 compute (std::istream &is); + + protected: + CRC32 (const CRC32 &crc32) {} + + private: + UInt32 _crc32; + UInt32 _tab[256]; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.cpp new file mode 100644 index 00000000000..2814cc286e0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.cpp @@ -0,0 +1,178 @@ +/************************************************************************* +** Calculator.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "Calculator.h" + +using namespace std; + +// token types +const char END = 0; +const char NUMBER = 1; +const char NAME = 2; + + +#include + + +/** Evaluates a given arithmetic expression and returns its value. + * The evaluator is implemented as a recursive descendent parser. + * @param[in] is reads expression from this stream + * @return expression value */ +double Calculator::eval (istream &is) { + double ret = expr(is, false); + if (lookAhead(is) > 0) + throw CalculatorException("expression syntax error"); + return ret; +} + + +/** Evaluates a given arithmetic expression and returns its value. + * @param[in] expr expression to evaluate + * @return expression value */ +double Calculator::eval (const string &expr) { + istringstream iss; + iss.str(expr); + return eval(iss); +} + + +/** Evaluates the root rule of the expression grammar. */ +double Calculator::expr (istream &is, bool skip) { // expr: + double left = term(is, skip); + while (1) + 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 + } +} + + +double Calculator::term (istream &is, bool skip) { // term: + double left = prim(is, skip); + while (1) + switch (lookAhead(is)) { + case '*': left *= prim(is, true); 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: // prim => $1 + return left; + } +} + + +double Calculator::prim (istream &is, bool skip) { // 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); + } + 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"); + } +} + + +/** Determines type of next token without swallowing it. That means + * the same token will be read again next time. */ +char Calculator::lookAhead (istream &is) { + while (isspace(is.peek())) // skip whitespace + is.get(); + if (is.eof()) + return END; + int c = is.peek(); + if (isdigit(c) || c == '.') + return NUMBER; + if (isalpha(c)) + return NAME; + 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. + * @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: + is >> _numValue; + break; + case NAME: { + _strValue.clear(); + while (isalpha(is.peek())) + _strValue += char(is.get()); + break; + } + 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 { + map::const_iterator it = _variables.find(name); + if (it == _variables.end()) + throw CalculatorException("undefined variable '" + name + "'"); + return it->second; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.h new file mode 100644 index 00000000000..36bb39d679c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Calculator.h @@ -0,0 +1,57 @@ +/************************************************************************* +** Calculator.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef CALCULATOR_H +#define CALCULATOR_H + +#include +#include +#include +#include "MessageException.h" + + +struct CalculatorException : public MessageException +{ + CalculatorException (const std::string &msg) : MessageException(msg) {} +}; + +class Calculator +{ + public: + Calculator () : _numValue(0) {} + double eval (std::istream &is); + double eval (const std::string &expr); + 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); + + private: + std::map _variables; + double _numValue; + std::string _strValue; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.cpp new file mode 100644 index 00000000000..27b607555b9 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.cpp @@ -0,0 +1,369 @@ +/************************************************************************* +** CmdLineParserBase.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "CmdLineParserBase.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "Message.h" + +using namespace std; + +void CmdLineParserBase::init () { + _error = false; + _files.clear(); +} + + +/** Parses all options given on the command line. + * @param[in] printErrors enable/disable printing of error messages */ +void CmdLineParserBase::parse (int argc, char **argv, bool printErrors) { + init(); + _printErrors = printErrors; + bool filesOnly = false; // + for (int i=1; i < argc; i++) { + CharInputBuffer ib(argv[i], strlen(argv[i])); + BufferInputReader ir(ib); + if (filesOnly || ir.peek() != '-') + _files.push_back(argv[i]); + else { + ir.get(); + if (ir.peek() == '-') { + // scan long option + ir.get(); + if (ir.eof()) // "--" only + filesOnly = true; // treat all following options as filenames + else { + string longname; + while (isalnum(ir.peek()) || ir.peek() == '-') + longname += char(ir.get()); + if (const Option *opt = option(longname)) + (*opt->handler)(this, ir, *opt, true); + else if (!_error) { + if (printErrors) + Message::estream(false) << "unknown option --" << longname << '\n'; + _error = true; + } + } + } + else { + // scan short option(s) + bool combined = false; // multiple short options combined, e.g -abc + do { + int shortname = ir.get(); + if (const Option *opt = option(shortname)) { + if (!combined || opt->argmode == 0) { + if (opt->argmode == 'r' && strlen(argv[i]) == 2) { // required argument separated by whitespace? + if (i+1 < argc && argv[i+1][0] != '-') + ib.assign(argv[++i]); + } + (*opt->handler)(this, ir, *opt, false); + if (opt->argmode == 0) + combined = true; + } + else { + if (printErrors) + Message::estream(false) << "option -" << char(shortname) << " must be given separately\n"; + _error = true; + } + } + else if (shortname > 0) { + if (printErrors) + Message::estream(false) << "unknown option -" << char(shortname) << '\n'; + _error = true; + } + } + while (!_error && combined && !ir.eof()); + } + } + } +} + + +/** Prints an error message to stdout. + * @param[in] opt error occurred in this option + * @param[in] longopt the long option name was scanned + * @param[in] msg message to be printed */ +void CmdLineParserBase::error (const Option &opt, bool longopt, const char *msg) const { + if (_printErrors) { + Message::estream(false) << "option "; + if (longopt) + Message::estream(false) << "--" << opt.longname; + else + Message::estream(false) << '-' << opt.shortname; + Message::estream(false) << ": " << msg << '\n'; + } + _error = true; +} + + +#if 0 +#include + +/** Lists the scanned filenames. Just for debugging purposes. */ +void CmdLineParserBase::status () const { + cout << "file names:\n"; + for (size_t i=0; i < _files.size(); i++) + cout << " " << _files[i] << endl; + cout << endl; +} +#endif + + +/** Returns the option information of a given short option name. + * If the option name can't be found 0 is returned. + * @param[in] longname long version of the option without leading hyphen (e.g. p, not -p) */ +const CmdLineParserBase::Option* CmdLineParserBase::option (char shortname) const { + size_t numopts; // number of available options + for (const Option *opts = options(&numopts); numopts > 0; ++opts) { + if (opts->shortname == shortname) + return opts; + numopts--; + } + return 0; +} + + +/** Returns the option information of a given long option name. + * Parameter 'longname' hasn't to be the complete long option name. The function looks up + * all options that start with 'longname'. If a unique or an exact match was found, it's returned. + * Otherwise, the return value is 0. + * @param[in] longname long version of the option without leading hyphens (e.g. param, not --param) */ +const CmdLineParserBase::Option* CmdLineParserBase::option (const string &longname) const { + vector matches; // all matching options + size_t len = longname.length(); + size_t numopts; // number of available options + for (const Option *opts = options(&numopts); numopts > 0; ++opts) { + if (string(opts->longname, len) == longname) { + if (len == strlen(opts->longname)) // exact match? + return opts; + matches.push_back(opts); + } + numopts--; + } + switch (matches.size()) { + default: + if (_printErrors) { + Message::estream(false) << "option --" << longname << " is ambiguous ("; + for (size_t i=0; i < matches.size(); i++) { + if (i > 0) + Message::estream(false) << ", "; + Message::estream(false) << matches[i]->longname; + } + Message::estream(false) << ")\n"; + } + _error = true; + + case 0 : return 0; + case 1 : return matches[0]; + } +} + + +/** Returns true if a valid separator between option and argument was found. + * Arguments of long options are preceded by a '='. The argument of a short option + * directly follows the option without a separation character. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given */ +bool CmdLineParserBase::checkArgPrefix (InputReader &ir, const Option &opt, bool longopt) const { + if (longopt) { + if (ir.peek() == '=') + ir.get(); + else { + error(opt, longopt, "'=' expected"); + return false; + } + } + return true; +} + + +/** Returns true if a given option has no argument, .e.g. -p or --param. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given */ +bool CmdLineParserBase::checkNoArg (InputReader &ir, const Option &opt, bool longopt) const { + if (ir.eof()) + return true; + error(opt, longopt, "no argument expected"); + return false; +} + + +/** Gets an integer argument of a given option, e.g. -p5 or --param=5. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getIntArg (InputReader &ir, const Option &opt, bool longopt, int &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + if (ir.parseInt(arg) && ir.eof()) + return true; + error(opt, longopt, "integer value expected"); + } + return false; +} + + +/** Gets an unsigned integer argument of a given option, e.g. -p5 or --param=5. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getUIntArg (InputReader &ir, const Option &opt, bool longopt, unsigned &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + if (ir.parseUInt(arg) && ir.eof()) + return true; + error(opt, longopt, "unsigned integer value expected"); + } + return false; +} + + +/** Gets a double (floating point) argument of a given option, e.g. -p2.5 or --param=2.5. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getDoubleArg (InputReader &ir, const Option &opt, bool longopt, double &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + if (ir.parseDouble(arg) != 0 && ir.eof()) + return true; + error(opt, longopt, "floating point value expected"); + } + return false; +} + + +/** Gets a string argument of a given option, e.g. -pstr or --param=str. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getStringArg (InputReader &ir, const Option &opt, bool longopt, string &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + arg.clear(); + while (!ir.eof()) + arg += char(ir.get()); + if (!arg.empty()) + return true; + error(opt, longopt, "string argument expected"); + } + return false; +} + + +/** Gets a boolean argument of a given option, e.g. -pyes or --param=yes. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getBoolArg (InputReader &ir, const Option &opt, bool longopt, bool &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + string str; + while (!ir.eof()) + str += char(ir.get()); + if (str == "yes" || str == "y" || str == "true" || str == "1") { + arg = true; + return true; + } + else if (str == "no" || str == "n" || str == "false" || str == "0") { + arg = false; + return true; + } + error(opt, longopt, "boolean argument expected (yes, no, true, false, 0, 1)"); + } + return false; +} + + +/** Gets a (single) character argument of a given option, e.g. -pc or --param=c. + * @param[in] ir argument is read from this InputReader + * @param[in] opt scans argument of this option + * @param[in] longopt true if the long option name was given + * @param[out] arg the scanned option argument + * @return true if argument could be scanned without errors */ +bool CmdLineParserBase::getCharArg (InputReader &ir, const Option &opt, bool longopt, char &arg) const { + if (checkArgPrefix(ir, opt, longopt)) { + arg = char(ir.get()); + if (arg >= 0 && ir.eof()) + return true; + error(opt, longopt, "character argument expected"); + } + return false; +} + + +/** Compares the short option characters of two help lines. + * @return true if line1 should appear before line2 */ +static bool cmp_short (const char *line1, const char *line2) { + if (*line1 != 'o' || *line2 != 'o' || (line1[1] == ' ' && line2[1] == ' ')) + return strcmp(line1, line2) < 0; + char lopt1 = tolower(line1[2]); + char lopt2 = tolower(line2[2]); + if (lopt1 == lopt2) // same character but different case? + return line1[2] > line2[2]; // line with lower-case letter first + return lopt1 < lopt2; +} + + +/** Compares the long option names of two help lines. + * @return true if line1 should appear before line2 */ +static bool cmp_long (const char *line1, const char *line2) { + if (*line1 != 'o' || *line2 != 'o') + return strcmp(line1, line2) < 0; + return strcmp(line1+6, line2+6) < 0; +} + + +/** Prints the help text to stdout. + * @param[in] mode format of help text */ +void CmdLineParserBase::help (int mode) const { + size_t numlines; + const char **lines = helplines(&numlines); + if (mode == 0) { // list options with section headers + for (size_t i=0; i < numlines; i++) { + switch (*lines[i]) { + case 's': fputc('\n', stdout); break; // section header + case 'o': fputs(" ", stdout); break; // option info + } + puts(lines[i]+1); + } + } + else { + vector linevec(lines, lines+numlines); + sort(linevec.begin(), linevec.end(), mode == 1 ? cmp_short : cmp_long); + for (vector::iterator it=linevec.begin(); it != linevec.end(); ++it) { + if (**it != 's') { // skip section headers + puts(*it+1); + if (**it == 'd') + puts("\nOptions:"); + } + } + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.h new file mode 100644 index 00000000000..35e20e3735c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CmdLineParserBase.h @@ -0,0 +1,97 @@ +/************************************************************************* +** CmdLineParserBase.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef CMDLINEPARSERBASE_H +#define CMDLINEPARSERBASE_H + +#include +#include + +class InputReader; + +class CmdLineParserBase +{ + protected: + struct Option; + + struct OptionHandler { + virtual ~OptionHandler () {} + virtual void operator () (CmdLineParserBase *obj, InputReader &ir, const Option &opt, bool longopt) const=0; + }; + + template + class OptionHandlerImpl : public OptionHandler { + protected: + typedef void (T::*LocalHandler)(InputReader &ir, const Option &opt, bool longopt); + + public: + OptionHandlerImpl (LocalHandler handler) : _handler(handler) {} + + void operator () (CmdLineParserBase *obj, InputReader &ir, const Option &opt, bool longopt) const { + if (T *tobj = dynamic_cast(obj)) + (tobj->*_handler)(ir, opt, longopt); + } + + private: + LocalHandler _handler; + }; + + struct Option { + ~Option () {delete handler;} + char shortname; + const char *longname; + char argmode; // mode of option argument: '\0'=none, 'o'=optional, 'r'=required + const OptionHandler *handler; + }; + + public: + virtual void parse (int argc, char **argv, bool printErrors=true); + virtual void help (int mode=0) const; + virtual int numFiles () const {return _files.size();} + virtual const char* file (size_t n) {return n < _files.size() ? _files[n].c_str() : 0;} +// virtual void status () const; + virtual bool error () const {return _error;} + + protected: + CmdLineParserBase () : _printErrors(true), _error(false) {} + CmdLineParserBase (const CmdLineParserBase &cmd) : _printErrors(true), _error(false) {} + virtual ~CmdLineParserBase () {} + virtual void init (); + virtual void error (const Option &opt, bool longopt, const char *msg) const; + virtual const Option* options (size_t *numopts) const =0; + virtual const char** helplines (size_t *numlines) const =0; + bool checkArgPrefix (InputReader &ir, const Option &opt, bool longopt) const; + bool checkNoArg (InputReader &ir, const Option &opt, bool longopt) const; + bool getIntArg (InputReader &ir, const Option &opt, bool longopt, int &arg) const; + bool getUIntArg (InputReader &ir, const Option &opt, bool longopt, unsigned &arg) const; + bool getDoubleArg (InputReader &ir, const Option &opt, bool longopt, double &arg) const; + bool getStringArg (InputReader &ir, const Option &opt, bool longopt, std::string &arg) const; + bool getBoolArg (InputReader &ir, const Option &opt, bool longopt, bool &arg) const; + bool getCharArg (InputReader &ir, const Option &opt, bool longopt, char &arg) const; + const Option* option (char shortname) const; + const Option* option (const std::string &longname) const; + + private: + bool _printErrors; ///< if true, print error messages + mutable bool _error; ///< error occured while parsing options + std::vector _files; ///< filename parameters +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.cpp new file mode 100644 index 00000000000..45d5ce453da --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.cpp @@ -0,0 +1,127 @@ +/************************************************************************* +** Color.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "Color.h" + +using namespace std; + + + +const Color Color::BLACK(0); +const Color Color::WHITE(UInt8(255), UInt8(255), UInt8(255)); +const Color Color::TRANSPARENT(0xff000000); + + +static inline UInt8 float_to_byte (float v) { + return (UInt8) (floor(255*v+0.5)); +} + + +void Color::set (float r, float g, float b) { + set(float_to_byte(r), float_to_byte(g), float_to_byte(b)); +} + + +void Color::setHSB (float h, float s, float b) { + vector hsb(3), rgb(3); + hsb[0] = h; + hsb[1] = s; + hsb[2] = b; + HSB2RGB(hsb, rgb); + set(rgb[0], rgb[1], rgb[2]); +} + + +void Color::setCMYK (float c, float m, float y, float k) { + vector cmyk(4), rgb(3); + cmyk[0] = c; + cmyk[1] = m; + cmyk[2] = y; + cmyk[3] = k; + CMYK2RGB(cmyk, rgb); + set(rgb[0], rgb[1], rgb[2]); +} + + +void Color::operator *= (double c) { + UInt32 rgb=0; + for (int i=0; i < 3; i++) { + rgb |= UInt32(floor((_rgb & 0xff)*c+0.5)) << (8*i); + _rgb >>= 8; + } + _rgb = rgb; +} + + +string Color::rgbString () const { + ostringstream oss; + oss << '#'; + for (int i=2; i >= 0; i--) { + oss << setbase(16) << setfill('0') << setw(2) + << (((_rgb >> (8*i)) & 0xff)); + } + return oss.str(); +} + + +/** Approximates a CMYK color by an RGB triple. The component values + * are expected to be normalized, i.e. 0 <= cmyk[i],rgb[j] <= 1. + * @param[in] cmyk color in CMYK space + * @param[out] rgb RGB approximation */ +void Color::CMYK2RGB (const vector &cmyk, vector &rgb) { + for (int i=0; i < 3; i++) + rgb[i] = 1.0f-min(1.0f, cmyk[i]+cmyk[3]); +} + + +/** Converts a color given in HSB coordinates to RGB. + * @param[in] hsb color in HSB space + * @param[out] rgb color in RGB space */ +void Color::HSB2RGB (const vector &hsb, vector &rgb) { + if (hsb[1] == 0) + rgb[0] = rgb[1] = rgb[2] = hsb[2]; + else { + float h = hsb[0]-floor(hsb[0]); + int i = int(6*h); + float f = float(6.0*h-i); + float p = hsb[2]*(1-hsb[1]); + float q = hsb[2]*(1-hsb[1]*f); + float t = hsb[2]*(1-hsb[1]*(1-f)); + switch (i) { + case 0 : rgb[0]=hsb[2]; rgb[1]=t; rgb[2]=p; break; + case 1 : rgb[0]=q; rgb[1]=hsb[2]; rgb[2]=p; break; + case 2 : rgb[0]=p; rgb[1]=hsb[2]; rgb[2]=t; break; + case 3 : rgb[0]=p; rgb[1]=q; rgb[2]=hsb[2]; break; + case 4 : rgb[0]=t; rgb[1]=p; rgb[2]=hsb[2]; break; + case 5 : rgb[0]=hsb[2]; rgb[1]=p; rgb[2]=q; break; + default: ; // prevent compiler warning + } + } +} + + +void Color::getRGB (float &r, float &g, float &b) const { + r = float(((_rgb >> 16) & 255) / 255.0); + g = float(((_rgb >> 8) & 255) / 255.0); + b = float((_rgb & 255) / 255.0); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.h new file mode 100644 index 00000000000..24b33c7bb95 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Color.h @@ -0,0 +1,64 @@ +/************************************************************************* +** Color.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef COLOR_H +#define COLOR_H + +#include +#include +#include "types.h" + +#ifdef TRANSPARENT +#undef TRANSPARENT +#endif + +class Color +{ + public: + static const Color BLACK; + static const Color WHITE; + static const Color TRANSPARENT; + + public: + Color () : _rgb(0) {} + Color (UInt32 rgb) : _rgb(rgb) {} + Color (UInt8 r, UInt8 g, UInt8 b) {set(r,g,b);} + Color (float r, float g, float b) {set(r,g,b);} + Color (const std::vector &rgb) {set(rgb[0], rgb[1], rgb[2]);} + operator UInt32 () const {return _rgb;} + bool operator == (const Color &c) {return _rgb == c._rgb;} + bool operator != (const Color &c) {return _rgb != c._rgb;} + void set (UInt8 r, UInt8 g, UInt8 b) {_rgb = (r << 16) | (g << 8) | b;} + void set (float r, float g, float b); + void setGray (UInt8 g) {set(g,g,g);} + void setGray (float g) {set(g,g,g);} + void setHSB (float h, float s, float b); + void setCMYK (float c, float m, float y, float k); + void getRGB (float &r, float &g, float &b) const; + void operator *= (double c); + std::string rgbString () const; + static void CMYK2RGB (const std::vector &cmyk, std::vector &rgb); + static void HSB2RGB (const std::vector &hsb, std::vector &rgb); + + private: + UInt32 _rgb; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.cpp new file mode 100644 index 00000000000..d156a43770f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.cpp @@ -0,0 +1,269 @@ +/************************************************************************* +** ColorSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "ColorSpecialHandler.h" +#include "SpecialActions.h" + +using namespace std; + + + +/** Approximates a CMYK color by an RGB triple. The component values + * are expected to be normalized, i.e. 0 <= cmyk[i],rgb[j] <= 1. + * @param[in] cmyk color in CMYK space + * @param[out] rgb RGB approximation */ +static void cmyk_to_rgb (const vector &cmyk, vector &rgb) { + for (int i=0; i < 3; i++) + rgb[i] = 1.0f-min(1.0f, cmyk[i]+cmyk[3]); +} + + +/** Converts a color given in HSB coordinates to RGB. + * @param[in] hsb color in HSB space + * @param[out] rgb color in RGB space */ +static void hsb_to_rgb (const vector &hsb, vector &rgb) { + if (hsb[1] == 0) + rgb[0] = rgb[1] = rgb[2] = hsb[2]; + else { + float h = hsb[0]-floor(hsb[0]); + float i = floor(6*h); + float f = 6.0f*h-i; + float p = hsb[2]*(1-hsb[1]); + float q = hsb[2]*(1-hsb[1]*f); + float t = hsb[2]*(1-hsb[1]*(1-f)); + switch (int(i)) { + case 0 : rgb[0]=hsb[2]; rgb[1]=t; rgb[2]=p; break; + case 1 : rgb[0]=q; rgb[1]=hsb[2]; rgb[2]=p; break; + case 2 : rgb[0]=p; rgb[1]=hsb[2]; rgb[2]=t; break; + case 3 : rgb[0]=p; rgb[1]=q; rgb[2]=hsb[2]; break; + case 4 : rgb[0]=t; rgb[1]=p; rgb[2]=hsb[2]; break; + case 5 : rgb[0]=hsb[2]; rgb[1]=p; rgb[2]=q; break; + default: ; // prevent compiler warning + } + } +} + + +/** Converts a gray value to RGB. + * @param[in] gray normalized gray value (0 <= gray <= 1) + * @param[out] rgb resulting RGB triple */ +static void gray_to_rgb (const float gray, vector &rgb) { + for (int i=0; i < 3; i++) + rgb[i] = gray; +} + + +static float read_float (istream &is) { + is.clear(); + float v; + is >> v; + if (is.fail()) + throw SpecialException("number expected"); + return v; +} + + +/** Reads multiple float values from a given stream. The number of + * values read is determined by the size of the result vector. + * @param[in] is stream to be read from + * @param[out] v the resulting floats */ +static void read_floats (istream &is, vector &v) { + for (size_t i=0; i < v.size(); i++) + v[i] = read_float(is); +} + + +static bool color_constant (const string &c, vector &rgb) { + // converted color constants from color.pro + const struct { + const char *name; + const float rgb[3]; + } + constants[] = { + {"Apricot", {1, 0.68f, 0.48f}}, + {"Aquamarine", {0.18f, 1, 0.7f}}, + {"Bittersweet", {0.76f, 0.01f, 0}}, + {"Black", {0, 0, 0}}, + {"Blue", {0, 0, 1}}, + {"BlueGreen", {0.15f, 1, 0.67f}}, + {"BlueViolet", {0.1f, 0.05f, 0.96f}}, + {"BrickRed", {0.72f, 0, 0}}, + {"Brown", {0.4f, 0, 0}}, + {"BurntOrange", {1, 0.49f, 0}}, + {"CadetBlue", {0.38f, 0.43f, 0.77f}}, + {"CarnationPink", {1, 0.37f, 1}}, + {"Cerulean", {0.06f, 0.89f, 1}}, + {"CornflowerBlue", {0.35f, 0.87f, 1}}, + {"Cyan", {0, 1, 1}}, + {"Dandelion", {1, 0.71f, 0.16f}}, + {"DarkOrchid", {0.6f, 0.2f, 0.8f}}, + {"Emerald", {0, 1, 0.5f}}, + {"ForestGreen", {0, 0.88f, 0}}, + {"Fuchsia", {0.45f, 0.01f, 0.92f}}, + {"Goldenrod", {1, 0.9f, 0.16f}}, + {"Gray", {0.5f, 0.5f, 0.5f}}, + {"Green", {0, 1, 0}}, + {"GreenYellow", {0.85f, 1, 0.31f}}, + {"JungleGreen", {0.01f, 1, 0.48f}}, + {"Lavender", {1, 0.52f, 1}}, + {"LimeGreen", {0.5f, 1, 0}}, + {"Magenta", {1, 0, 1}}, + {"Mahogany", {0.65f, 0, 0}}, + {"Maroon", {0.68f, 0, 0}}, + {"Melon", {1, 0.54f, 0.5f}}, + {"MidnightBlue", {0, 0.44f, 0.57f}}, + {"Mulberry", {0.64f, 0.08f, 0.98f}}, + {"NavyBlue", {0.06f, 0.46f, 1}}, + {"OliveGreen", {0, 0.6f, 0}}, + {"Orange", {1, 0.39f, 0.13f}}, + {"OrangeRed", {1, 0, 0.5f}}, + {"Orchid", {0.68f, 0.36f, 1}}, + {"Peach", {1, 0.5f, 0.3f}}, + {"Periwinkle", {0.43f, 0.45f, 1}}, + {"PineGreen", {0, 0.75f, 0.16f}}, + {"Plum", {0.5f, 0, 1}}, + {"ProcessBlue", {0.04f, 1, 1}}, + {"Purple", {0.55f, 0.14f, 1}}, + {"RawSienna", {0.55f, 0, 0}}, + {"Red", {1, 0, 0}}, + {"RedOrange", {1, 0.23f, 0.13f}}, + {"RedViolet", {0.59f, 0, 0.66f}}, + {"Rhodamine", {1, 0.18f, 1}}, + {"RoyalBlue", {0, 0.5f, 1}}, + {"RoyalPurple", {0.25f, 0.1f, 1}}, + {"RubineRed", {1, 0, 0.87f}}, + {"Salmon", {1, 0.47f, 0.62f}}, + {"SeaGreen", {0.31f, 1, 0.5f}}, + {"Sepia", {0.3f, 0, 0}}, + {"SkyBlue", {0.38f, 1, 0.88f}}, + {"SpringGreen", {0.74f, 1, 0.24f}}, + {"Tan", {0.86f, 0.58f, 0.44f}}, + {"TealBlue", {0.12f, 0.98f, 0.64f}}, + {"Thistle", {0.88f, 0.41f, 1}}, + {"Turquoise", {0.15f, 1, 0.8f}}, + {"Violet", {0.21f, 0.12f, 1}}, + {"VioletRed", {1, 0.19f, 1}}, + {"White", {1, 1, 1}}, + {"WildStrawberry", {1, 0.04f, 0.61f}}, + {"Yellow", {1, 1, 0}}, + {"YellowGreen", {0.56f, 1, 0.26f}}, + {"YellowOrange", {1, 0.58f, 0}} + }; + // binary search + int first=0, last=68-1; + while (first <= last) { + int mid = first+(last-first)/2; + int cmp = strcmp(constants[mid].name, c.c_str()); + if (cmp > 0) + last = mid-1; + else if (cmp < 0) + first = mid+1; + else { + rgb[0] = constants[mid].rgb[0]; + rgb[1] = constants[mid].rgb[1]; + rgb[2] = constants[mid].rgb[2]; + return true; + } + } + return false; +} + + +/** Reads a color statement from an input stream and converts it to RGB. + * A color statement has the following syntax: + * + * Currently, the following color models are supported: rgb, cmyk, hsb and gray. + * Examples: rgb 1 0.5 0, gray 0.5 + * @param[in] model if model != "" this value specifies the model, otherwise it's read from the stream + * @param[in] is stream to be read from + * @param[out] resulting RGB triple + * @return true if statement has successfully been read */ +static void read_color (string model, istream &is, vector &rgb) { + if (model.empty()) + is >> model; + if (model == "rgb") + read_floats(is, rgb); + else if (model == "cmyk") { + vector cmyk(4); + read_floats(is, cmyk); + cmyk_to_rgb(cmyk, rgb); + } + else if (model == "hsb") { + vector hsb(3); + read_floats(is, hsb); + hsb_to_rgb(hsb, rgb); + } + else if (model == "gray") + gray_to_rgb(read_float(is), rgb); + else if (!color_constant(model, rgb)) + throw SpecialException("unknown color statement"); + if (rgb[0] > 1 || rgb[1] > 1 || rgb[2] > 1) { + ostringstream oss; + oss << "invalid RGB value (" << rgb[0] << ',' << rgb[1] << ',' << rgb[2] << ')'; + throw SpecialException(oss.str()); + } +} + + +bool ColorSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + vector rgb(3); + if (prefix && strcmp(prefix, "background") == 0) { + read_color("", is, rgb); + actions->setBgColor(rgb); + } + else { + string cmd; + is >> cmd; + if (cmd == "push") { // color push + read_color("", is, rgb); + _colorStack.push(rgb); + } + else if (cmd == "pop") { + if (!_colorStack.empty()) // color pop + _colorStack.pop(); + } + else { // color + read_color(cmd, is, rgb); + while (!_colorStack.empty()) + _colorStack.pop(); + _colorStack.push(rgb); + } + if (actions) { + if (_colorStack.empty()) + actions->setColor(Color::BLACK); + else + actions->setColor(_colorStack.top()); + } + } + return true; +} + + +const char** ColorSpecialHandler::prefixes () const { + static const char *pfx[] = {"color", 0}; + return pfx; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.h new file mode 100644 index 00000000000..a9b73dc8b74 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ColorSpecialHandler.h @@ -0,0 +1,43 @@ +/************************************************************************* +** ColorSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef COLORSPECIALHANDLER_H +#define COLORSPECIALHANDLER_H + +#include +#include +#include "SpecialHandler.h" + + +class ColorSpecialHandler : public SpecialHandler +{ + typedef std::vector RGB; + + public: + bool process (const char *prefix, std::istream &is, SpecialActions *actions); + const char* name () const {return "color";} + const char* info () const {return "complete support of color specials";} + const char** prefixes () const; + + private: + std::stack _colorStack; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.cpp new file mode 100644 index 00000000000..e615ac8eb25 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.cpp @@ -0,0 +1,306 @@ +// This file was automatically generated by opt2cpp. +// 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. +// (C) 2009-2013 Martin Gieseking + +#include +#include +#include +#include "InputReader.h" +#include "CommandLine.h" + +using namespace std; + +const CmdLineParserBase::Option CommandLine::_options[] = { + {'b', "bbox", 'r', new OptionHandlerImpl(&CommandLine::handle_bbox)}, + {'C', "cache", 'o', new OptionHandlerImpl(&CommandLine::handle_cache)}, + {'\0', "color", 0, new OptionHandlerImpl(&CommandLine::handle_color)}, +#if !defined(DISABLE_GS) + {'E', "eps", 0, new OptionHandlerImpl(&CommandLine::handle_eps)}, +#endif + {'e', "exact", 0, new OptionHandlerImpl(&CommandLine::handle_exact)}, + {'m', "fontmap", 'r', new OptionHandlerImpl(&CommandLine::handle_fontmap)}, + {'h', "help", 'o', new OptionHandlerImpl(&CommandLine::handle_help)}, + {'\0', "keep", 0, new OptionHandlerImpl(&CommandLine::handle_keep)}, +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + {'\0', "libgs", 'r', new OptionHandlerImpl(&CommandLine::handle_libgs)}, +#endif + {'L', "linkmark", 'r', new OptionHandlerImpl(&CommandLine::handle_linkmark)}, + {'l', "list-specials", 0, new OptionHandlerImpl(&CommandLine::handle_list_specials)}, + {'M', "mag", 'r', new OptionHandlerImpl(&CommandLine::handle_mag)}, + {'n', "no-fonts", 'o', new OptionHandlerImpl(&CommandLine::handle_no_fonts)}, + {'\0', "no-mktexmf", 0, new OptionHandlerImpl(&CommandLine::handle_no_mktexmf)}, + {'S', "no-specials", 'o', new OptionHandlerImpl(&CommandLine::handle_no_specials)}, + {'\0', "no-styles", 0, new OptionHandlerImpl(&CommandLine::handle_no_styles)}, + {'o', "output", 'r', new OptionHandlerImpl(&CommandLine::handle_output)}, + {'p', "page", 'r', new OptionHandlerImpl(&CommandLine::handle_page)}, + {'d', "precision", 'r', new OptionHandlerImpl(&CommandLine::handle_precision)}, + {'P', "progress", 'o', new OptionHandlerImpl(&CommandLine::handle_progress)}, + {'r', "rotate", 'r', new OptionHandlerImpl(&CommandLine::handle_rotate)}, + {'c', "scale", 'r', new OptionHandlerImpl(&CommandLine::handle_scale)}, + {'s', "stdout", 0, new OptionHandlerImpl(&CommandLine::handle_stdout)}, + {'a', "trace-all", 'o', new OptionHandlerImpl(&CommandLine::handle_trace_all)}, + {'T', "transform", 'r', new OptionHandlerImpl(&CommandLine::handle_transform)}, + {'t', "translate", 'r', new OptionHandlerImpl(&CommandLine::handle_translate)}, + {'v', "verbosity", 'r', new OptionHandlerImpl(&CommandLine::handle_verbosity)}, + {'V', "version", 'o', new OptionHandlerImpl(&CommandLine::handle_version)}, + {'z', "zip", 'o', new OptionHandlerImpl(&CommandLine::handle_zip)}, +}; + +const CmdLineParserBase::Option* CommandLine::options (size_t *numopts) const { + *numopts = sizeof(_options)/sizeof(CmdLineParserBase::Option); + return _options; +} + +void CommandLine::init () { + CmdLineParserBase::init(); + + // disable all options by default + _bbox_given = false; + _cache_given = false; + _color_given = false; +#if !defined(DISABLE_GS) + _eps_given = false; +#endif + _exact_given = false; + _fontmap_given = false; + _help_given = false; + _keep_given = false; +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + _libgs_given = false; +#endif + _linkmark_given = false; + _list_specials_given = false; + _mag_given = false; + _no_fonts_given = false; + _no_mktexmf_given = false; + _no_specials_given = false; + _no_styles_given = false; + _output_given = false; + _page_given = false; + _precision_given = false; + _progress_given = false; + _rotate_given = false; + _scale_given = false; + _stdout_given = false; + _trace_all_given = false; + _transform_given = false; + _translate_given = false; + _verbosity_given = false; + _version_given = false; + _zip_given = false; + + // set default option values + _bbox_arg = "min"; + _cache_arg.clear(); + _fontmap_arg.clear(); + _help_arg = 0; +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + _libgs_arg.clear(); +#endif + _linkmark_arg = "line"; + _mag_arg = 4; + _no_fonts_arg = 0; + _no_specials_arg.clear(); + _output_arg.clear(); + _page_arg = "1"; + _precision_arg = 0; + _progress_arg = 0.5; + _rotate_arg = 0; + _scale_arg.clear(); + _trace_all_arg = false; + _transform_arg.clear(); + _translate_arg.clear(); + _verbosity_arg = 7; + _version_arg = false; + _zip_arg = 9; +} + +const char** CommandLine::helplines (size_t *numlines) const { + static const char *lines[] = { + "dThis program converts DVI files, as created by TeX/LaTeX, to\nthe XML-based scalable vector graphics format SVG.\n\nUsage: dvisvgm [options] dvifile\n dvisvgm -E [options] epsfile", + "sInput options:", + "o-p, --page=ranges choose pages to convert [1]", + "o-m, --fontmap=filenames evaluate (additional) font map files", +#if !defined(DISABLE_GS) + "o-E, --eps convert an EPS file to SVG", +#endif + "sSVG output options:", + "o-b, --bbox=size set size of bounding box [min]", + "o-L, --linkmark=type select how to mark hyperlinked areas [line]", + "o-o, --output=pattern set name pattern of output files", + "o-d, --precision=number set number of decimal points (0-6) [0]", + "o-s, --stdout write SVG output to stdout", + "o-n, --no-fonts[=variant] draw glyphs by using path elements [0]", + "o --no-styles don't use styles to reference fonts", + "o-z, --zip[=level] create compressed .svgz file [9]", + "sSVG transformations:", + "o-r, --rotate=angle rotate page content clockwise", + "o-c, --scale=sx[,sy] scale page content", + "o-t, --translate=tx[,ty] shift page content", + "o-T, --transform=commands transform page content", + "sProcessing options:", + "o-C, --cache[=dir] set/print path of cache directory", + "o-e, --exact compute exact glyph boxes", + "o --keep keep temporary files", +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + "o --libgs=filename set name of Ghostscript shared library", +#endif + "o-M, --mag=factor magnification of Metafont output [4]", + "o --no-mktexmf don't try to create missing fonts", + "o-S, --no-specials[=prefixes] don't process [selected] specials", + "o-a, --trace-all[=retrace] trace all glyphs of bitmap fonts [no]", + "sMessage options:", + "o --color colorize messages", + "o-h, --help[=mode] print this summary of options and exit [0]", + "o-l, --list-specials print supported special sets and exit", + "o-P, --progress[=delay] enable progess indicator [0.5]", + "o-v, --verbosity=level set verbosity level (0-7) [7]", + "o-V, --version[=extended] print version and exit [no]", + }; + *numlines = sizeof(lines)/sizeof(char*); + return lines; +} + +void CommandLine::handle_bbox (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _bbox_arg)) + _bbox_given = true; +} + +void CommandLine::handle_cache (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getStringArg(ir, opt, longopt, _cache_arg)) + _cache_given = true; +} + +void CommandLine::handle_color (InputReader &ir, const Option &opt, bool longopt) { + _color_given = true; +} + +#if !defined(DISABLE_GS) +void CommandLine::handle_eps (InputReader &ir, const Option &opt, bool longopt) { + _eps_given = true; +} +#endif + +void CommandLine::handle_exact (InputReader &ir, const Option &opt, bool longopt) { + _exact_given = true; +} + +void CommandLine::handle_fontmap (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _fontmap_arg)) + _fontmap_given = true; +} + +void CommandLine::handle_help (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getIntArg(ir, opt, longopt, _help_arg)) + _help_given = true; +} + +void CommandLine::handle_keep (InputReader &ir, const Option &opt, bool longopt) { + _keep_given = true; +} + +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) +void CommandLine::handle_libgs (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _libgs_arg)) + _libgs_given = true; +} +#endif + +void CommandLine::handle_linkmark (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _linkmark_arg)) + _linkmark_given = true; +} + +void CommandLine::handle_list_specials (InputReader &ir, const Option &opt, bool longopt) { + _list_specials_given = true; +} + +void CommandLine::handle_mag (InputReader &ir, const Option &opt, bool longopt) { + if (getDoubleArg(ir, opt, longopt, _mag_arg)) + _mag_given = true; +} + +void CommandLine::handle_no_fonts (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getIntArg(ir, opt, longopt, _no_fonts_arg)) + _no_fonts_given = true; +} + +void CommandLine::handle_no_mktexmf (InputReader &ir, const Option &opt, bool longopt) { + _no_mktexmf_given = true; +} + +void CommandLine::handle_no_specials (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getStringArg(ir, opt, longopt, _no_specials_arg)) + _no_specials_given = true; +} + +void CommandLine::handle_no_styles (InputReader &ir, const Option &opt, bool longopt) { + _no_styles_given = true; +} + +void CommandLine::handle_output (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _output_arg)) + _output_given = true; +} + +void CommandLine::handle_page (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _page_arg)) + _page_given = true; +} + +void CommandLine::handle_precision (InputReader &ir, const Option &opt, bool longopt) { + if (getIntArg(ir, opt, longopt, _precision_arg)) + _precision_given = true; +} + +void CommandLine::handle_progress (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getDoubleArg(ir, opt, longopt, _progress_arg)) + _progress_given = true; +} + +void CommandLine::handle_rotate (InputReader &ir, const Option &opt, bool longopt) { + if (getDoubleArg(ir, opt, longopt, _rotate_arg)) + _rotate_given = true; +} + +void CommandLine::handle_scale (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _scale_arg)) + _scale_given = true; +} + +void CommandLine::handle_stdout (InputReader &ir, const Option &opt, bool longopt) { + _stdout_given = true; +} + +void CommandLine::handle_trace_all (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getBoolArg(ir, opt, longopt, _trace_all_arg)) + _trace_all_given = true; +} + +void CommandLine::handle_transform (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _transform_arg)) + _transform_given = true; +} + +void CommandLine::handle_translate (InputReader &ir, const Option &opt, bool longopt) { + if (getStringArg(ir, opt, longopt, _translate_arg)) + _translate_given = true; +} + +void CommandLine::handle_verbosity (InputReader &ir, const Option &opt, bool longopt) { + if (getUIntArg(ir, opt, longopt, _verbosity_arg)) + _verbosity_given = true; +} + +void CommandLine::handle_version (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getBoolArg(ir, opt, longopt, _version_arg)) + _version_given = true; +} + +void CommandLine::handle_zip (InputReader &ir, const Option &opt, bool longopt) { + if (ir.eof() || getIntArg(ir, opt, longopt, _zip_arg)) + _zip_given = true; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.h new file mode 100644 index 00000000000..e1611191816 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/CommandLine.h @@ -0,0 +1,171 @@ +// This file was automatically generated by opt2cpp. +// 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. +// (C) 2009-2013 Martin Gieseking + +#ifndef COMMANDLINE_H +#define COMMANDLINE_H + +#if HAVE_CONFIG_H +#include "config.h" +#endif +#include "CmdLineParserBase.h" + +class CommandLine : public CmdLineParserBase +{ + public: + CommandLine () {init();} + CommandLine (int argc, char **argv, bool printErrors) {parse(argc, argv, printErrors);} + bool page_given () const {return _page_given;} + const std::string& page_arg () const {return _page_arg;} + bool fontmap_given () const {return _fontmap_given;} + const std::string& fontmap_arg () const {return _fontmap_arg;} +#if !defined(DISABLE_GS) + bool eps_given () const {return _eps_given;} +#endif + bool bbox_given () const {return _bbox_given;} + const std::string& bbox_arg () const {return _bbox_arg;} + bool linkmark_given () const {return _linkmark_given;} + const std::string& linkmark_arg () const {return _linkmark_arg;} + bool output_given () const {return _output_given;} + const std::string& output_arg () const {return _output_arg;} + bool precision_given () const {return _precision_given;} + int precision_arg () const {return _precision_arg;} + bool stdout_given () const {return _stdout_given;} + bool no_fonts_given () const {return _no_fonts_given;} + int no_fonts_arg () const {return _no_fonts_arg;} + bool no_styles_given () const {return _no_styles_given;} + bool zip_given () const {return _zip_given;} + int zip_arg () const {return _zip_arg;} + bool rotate_given () const {return _rotate_given;} + double rotate_arg () const {return _rotate_arg;} + bool scale_given () const {return _scale_given;} + const std::string& scale_arg () const {return _scale_arg;} + bool translate_given () const {return _translate_given;} + const std::string& translate_arg () const {return _translate_arg;} + bool transform_given () const {return _transform_given;} + const std::string& transform_arg () const {return _transform_arg;} + bool cache_given () const {return _cache_given;} + const std::string& cache_arg () const {return _cache_arg;} + bool exact_given () const {return _exact_given;} + bool keep_given () const {return _keep_given;} +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + bool libgs_given () const {return _libgs_given;} + const std::string& libgs_arg () const {return _libgs_arg;} +#endif + bool mag_given () const {return _mag_given;} + double mag_arg () const {return _mag_arg;} + bool no_mktexmf_given () const {return _no_mktexmf_given;} + bool no_specials_given () const {return _no_specials_given;} + const std::string& no_specials_arg () const {return _no_specials_arg;} + bool trace_all_given () const {return _trace_all_given;} + bool trace_all_arg () const {return _trace_all_arg;} + bool color_given () const {return _color_given;} + bool help_given () const {return _help_given;} + int help_arg () const {return _help_arg;} + bool list_specials_given () const {return _list_specials_given;} + bool progress_given () const {return _progress_given;} + double progress_arg () const {return _progress_arg;} + bool verbosity_given () const {return _verbosity_given;} + unsigned verbosity_arg () const {return _verbosity_arg;} + bool version_given () const {return _version_given;} + bool version_arg () const {return _version_arg;} + + protected: + void init (); + const CmdLineParserBase::Option* options (size_t *numopts) const; + const char** helplines (size_t *numlines) const; + void handle_page (InputReader &ir, const Option &opt, bool longopt); + void handle_fontmap (InputReader &ir, const Option &opt, bool longopt); +#if !defined(DISABLE_GS) + void handle_eps (InputReader &ir, const Option &opt, bool longopt); +#endif + void handle_bbox (InputReader &ir, const Option &opt, bool longopt); + void handle_linkmark (InputReader &ir, const Option &opt, bool longopt); + void handle_output (InputReader &ir, const Option &opt, bool longopt); + void handle_precision (InputReader &ir, const Option &opt, bool longopt); + void handle_stdout (InputReader &ir, const Option &opt, bool longopt); + void handle_no_fonts (InputReader &ir, const Option &opt, bool longopt); + void handle_no_styles (InputReader &ir, const Option &opt, bool longopt); + void handle_zip (InputReader &ir, const Option &opt, bool longopt); + void handle_rotate (InputReader &ir, const Option &opt, bool longopt); + void handle_scale (InputReader &ir, const Option &opt, bool longopt); + void handle_translate (InputReader &ir, const Option &opt, bool longopt); + void handle_transform (InputReader &ir, const Option &opt, bool longopt); + void handle_cache (InputReader &ir, const Option &opt, bool longopt); + void handle_exact (InputReader &ir, const Option &opt, bool longopt); + void handle_keep (InputReader &ir, const Option &opt, bool longopt); +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + void handle_libgs (InputReader &ir, const Option &opt, bool longopt); +#endif + void handle_mag (InputReader &ir, const Option &opt, bool longopt); + void handle_no_mktexmf (InputReader &ir, const Option &opt, bool longopt); + void handle_no_specials (InputReader &ir, const Option &opt, bool longopt); + void handle_trace_all (InputReader &ir, const Option &opt, bool longopt); + void handle_color (InputReader &ir, const Option &opt, bool longopt); + void handle_help (InputReader &ir, const Option &opt, bool longopt); + void handle_list_specials (InputReader &ir, const Option &opt, bool longopt); + void handle_progress (InputReader &ir, const Option &opt, bool longopt); + void handle_verbosity (InputReader &ir, const Option &opt, bool longopt); + void handle_version (InputReader &ir, const Option &opt, bool longopt); + + private: + static const CmdLineParserBase::Option _options[]; + bool _page_given; + std::string _page_arg; + bool _fontmap_given; + std::string _fontmap_arg; +#if !defined(DISABLE_GS) + bool _eps_given; +#endif + bool _bbox_given; + std::string _bbox_arg; + bool _linkmark_given; + std::string _linkmark_arg; + bool _output_given; + std::string _output_arg; + bool _precision_given; + int _precision_arg; + bool _stdout_given; + bool _no_fonts_given; + int _no_fonts_arg; + bool _no_styles_given; + bool _zip_given; + int _zip_arg; + bool _rotate_given; + double _rotate_arg; + bool _scale_given; + std::string _scale_arg; + bool _translate_given; + std::string _translate_arg; + bool _transform_given; + std::string _transform_arg; + bool _cache_given; + std::string _cache_arg; + bool _exact_given; + bool _keep_given; +#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS) + bool _libgs_given; + std::string _libgs_arg; +#endif + bool _mag_given; + double _mag_arg; + bool _no_mktexmf_given; + bool _no_specials_given; + std::string _no_specials_arg; + bool _trace_all_given; + bool _trace_all_arg; + bool _color_given; + bool _help_given; + int _help_arg; + bool _list_specials_given; + bool _progress_given; + double _progress_arg; + bool _verbosity_given; + unsigned _verbosity_arg; + bool _version_given; + bool _version_arg; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.cpp new file mode 100644 index 00000000000..30317455ba6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.cpp @@ -0,0 +1,56 @@ +/************************************************************************* +** DLLoader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "DLLoader.h" + + +DLLoader::DLLoader (const char *dlname) { +#ifdef __WIN32__ + _handle = LoadLibrary(dlname); +#else + _handle = dlopen(dlname, RTLD_LAZY); +#endif +} + + +DLLoader::~DLLoader () { + if (_handle) { +#ifdef __WIN32__ + FreeLibrary(_handle); +#else + dlclose(_handle); +#endif + } +} + + +/** Loads a function or variable from the dynamic/shared library. + * @param[in] name name of function/variable to load + * @return pointer to loaded symbol, or 0 if the symbol could not be loaded */ +void* DLLoader::loadSymbol (const char *name) { + if (_handle) { +#ifdef __WIN32__ + return (void*)GetProcAddress(_handle, name); +#else + return dlsym(_handle, name); +#endif + } + return 0; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.h new file mode 100644 index 00000000000..3052d13714e --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DLLoader.h @@ -0,0 +1,52 @@ +/************************************************************************* +** DLLoader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DLLOADER_H +#define DLLOADER_H + +#ifdef __WIN32__ + #undef NOMINMAX + #define NOMINMAX 1 + #include +#else + #include +#endif + + +class DLLoader +{ + public: + DLLoader (const char *dlname); + virtual ~DLLoader (); + bool loaded () const {return _handle != 0;} + + protected: + DLLoader () : _handle(0) {} + void* loadSymbol (const char *name); + + private: +#ifdef __WIN32__ + HINSTANCE _handle; +#else + void *_handle; +#endif +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.cpp new file mode 100644 index 00000000000..f9c95dc3754 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.cpp @@ -0,0 +1,26 @@ +/************************************************************************* +** DVIActions.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "DVIActions.h" + +const double DVIActions::BP = 72.0/72.27; +const double DVIActions::IN = 1.0/72.27; +const double DVIActions::CM = 2.54*IN; +const double DVIActions::MM = 25.4*IN; diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.h new file mode 100644 index 00000000000..9bb7186e60c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIActions.h @@ -0,0 +1,56 @@ +/************************************************************************* +** DVIActions.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DVIACTIONS_H +#define DVIACTIONS_H + +#include +#include "Message.h" +#include "types.h" + +class BoundingBox; +struct Font; +class SpecialManager; + + +struct DVIActions +{ + static const double BP; + static const double IN; + static const double CM; + static const double MM; + virtual ~DVIActions () {} + virtual void setChar (double x, double y, unsigned c, const Font *f) {} + virtual void setRule (double x, double y, double height, double width) {} + virtual void moveToX (double x) {} + virtual void moveToY (double y) {} + virtual void defineFont (int num, const Font *font) {} + virtual void setFont (int num, const Font *font) {} + virtual void special (const std::string &s) {} + virtual void preamble (const std::string &cmt) {} + virtual void postamble () {} + virtual void beginPage (unsigned pageno, Int32 *c) {} + virtual void endPage (unsigned pageno) {} + virtual BoundingBox& bbox () =0; + virtual const SpecialManager* setProcessSpecials (const char *ignorelist) {return 0;} + virtual void progress (size_t current, size_t total, const char *id=0) {} +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.cpp new file mode 100644 index 00000000000..323580fef51 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.cpp @@ -0,0 +1,682 @@ +/************************************************************************* +** DVIReader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "types.h" +#include "DVIActions.h" +#include "DVIReader.h" +#include "Font.h" +#include "FontManager.h" +#include "Message.h" +#include "SignalHandler.h" +#include "VectorStream.h" +#include "macros.h" + +using namespace std; + +bool DVIReader::COMPUTE_PAGE_LENGTH = false; + + +DVIReader::DVIReader (istream &is, DVIActions *a) : StreamReader(is), _actions(a) +{ + _inPage = false; + _pageHeight = _pageWidth = 0; + _scaleFactor = 0.0; + _tx = _ty = 0; // no cursor translation + _prevYPos = numeric_limits::min(); + _inPostamble = false; + _totalPages = 0; // we don't know the correct value yet + _currFontNum = 0; + _currPageNum = 0; + _pageLength = 0; + _pagePos = 0; +} + + +DVIActions* DVIReader::replaceActions (DVIActions *a) { + DVIActions *prev_actions = _actions; + _actions = a; + return prev_actions; +} + + +/** Evaluates the next DVI command, and computes the corresponding handler. + * @param[in] compute_size if true, the size of variable-length parameters is computed + * @param[out] handler handler for current DVI command + * @param[out] number of parameter bytes + * @param[out] param the handler must be called with this parameter + * @return opcode of current DVI command */ +int DVIReader::evalCommand (bool compute_size, CommandHandler &handler, int &length, int ¶m) { + struct DVICommand { + CommandHandler handler; + int length; // number of parameter bytes + }; + + /* Each cmdFOO command reads the necessary number of bytes from the stream, so executeCommand + doesn't need to know the exact DVI command format. Some cmdFOO methods are used for multiple + DVI commands because they only differ in length of their parameters. */ + static const DVICommand commands[] = { + {&DVIReader::cmdSetChar, 1}, {&DVIReader::cmdSetChar, 2}, {&DVIReader::cmdSetChar, 3}, {&DVIReader::cmdSetChar, 4}, // 128-131 + {&DVIReader::cmdSetRule, 8}, // 132 + {&DVIReader::cmdPutChar, 1}, {&DVIReader::cmdPutChar, 2}, {&DVIReader::cmdPutChar, 3}, {&DVIReader::cmdPutChar, 4}, // 133-136 + {&DVIReader::cmdPutRule, 8}, // 137 + {&DVIReader::cmdNop, 0}, // 138 + {&DVIReader::cmdBop, 44}, {&DVIReader::cmdEop, 0}, // 139-140 + {&DVIReader::cmdPush, 0}, {&DVIReader::cmdPop, 0}, // 141-142 + {&DVIReader::cmdRight, 1}, {&DVIReader::cmdRight, 2}, {&DVIReader::cmdRight, 3}, {&DVIReader::cmdRight, 4}, // 143-146 + {&DVIReader::cmdW0, 0}, // 147 + {&DVIReader::cmdW, 1}, {&DVIReader::cmdW, 2}, {&DVIReader::cmdW, 3}, {&DVIReader::cmdW, 4}, // 148-151 + {&DVIReader::cmdX0, 0}, // 152 + {&DVIReader::cmdX, 1}, {&DVIReader::cmdX, 2}, {&DVIReader::cmdX, 3}, {&DVIReader::cmdX, 4}, // 153-156 + {&DVIReader::cmdDown, 1}, {&DVIReader::cmdDown, 2}, {&DVIReader::cmdDown, 3}, {&DVIReader::cmdDown, 4}, // 157-160 + {&DVIReader::cmdY0, 0}, // 161 + {&DVIReader::cmdY, 1}, {&DVIReader::cmdY, 2}, {&DVIReader::cmdY, 3}, {&DVIReader::cmdY, 4}, // 162-165 + {&DVIReader::cmdZ0, 0}, // 166 + {&DVIReader::cmdZ, 1}, {&DVIReader::cmdZ, 2}, {&DVIReader::cmdZ, 3}, {&DVIReader::cmdZ, 4}, // 167-170 + {&DVIReader::cmdFontNum, 1}, {&DVIReader::cmdFontNum, 2}, {&DVIReader::cmdFontNum, 3}, {&DVIReader::cmdFontNum, 4}, // 235-238 + {&DVIReader::cmdXXX, 1}, {&DVIReader::cmdXXX, 2}, {&DVIReader::cmdXXX, 3}, {&DVIReader::cmdXXX, 4}, // 239-242 + {&DVIReader::cmdFontDef, 1}, {&DVIReader::cmdFontDef, 2}, {&DVIReader::cmdFontDef, 3}, {&DVIReader::cmdFontDef, 4}, // 243-246 + {&DVIReader::cmdPre, 0}, {&DVIReader::cmdPost, 0}, {&DVIReader::cmdPostPost, 0} // 247-249 + }; + + const int opcode = in().get(); + if (!in() || opcode < 0) // at end of file + throw InvalidDVIFileException("invalid file"); + + param = -1; + if (opcode >= 0 && opcode <= 127) { + handler = &DVIReader::cmdSetChar0; + length = 0; + param = opcode; + } + else if (opcode >= 171 && opcode <= 234) { + handler = &DVIReader::cmdFontNum0; + length = 0; + param = opcode-171; + } + else if (opcode >= 250) { + ostringstream oss; + oss << "undefined DVI command (opcode " << opcode << ')'; + throw DVIException(oss.str()); + } + else { + const int offset = opcode <= 170 ? 128 : 235-(170-128+1); + handler = commands[opcode-offset].handler; + if (!compute_size) + length = commands[opcode-offset].length; + else { + if (opcode >= 239 && opcode <= 242) { // specials + int len = opcode-238; + UInt32 bytes = readUnsigned(len); + in().seekg(-len, ios_base::cur); + length = len+bytes; + } + else if (opcode >= 243 && opcode <= 246) { // fontdefs + int len = opcode-242; + len += 12; + in().seekg(len, ios_base::cur); // skip fontnum, checksum, ssize, dsize + UInt32 bytes = readUnsigned(1); // length of font path + bytes += readUnsigned(1); // length of font name + in().seekg(-len-2, ios_base::cur); + length = len+bytes; + } + else + length = commands[opcode-offset].length; + } + } + if (param < 0) + param = length; + return opcode; +} + + +/** Reads a single DVI command from the current position of the input stream and calls the + * corresponding cmdFOO method. + * @return opcode of the executed command */ +int DVIReader::executeCommand () { + SignalHandler::instance().check(); + CommandHandler handler; + int len; // number of parameter bytes + int param; // parameter of handler + streampos pos = in().tellg(); + int opcode = evalCommand(false, handler, len, param); + (this->*handler)(param); + if (_currPos.v+_ty != _prevYPos) { + _tx = _ty = 0; + _prevYPos = _currPos.v; + } + if (COMPUTE_PAGE_LENGTH && _inPage && _actions) { + // ensure progress() is called at 0% + if (opcode == 139) // bop? + _actions->progress(0, _pageLength); + // ensure progress() is called at 100% + if (in().peek() == 140) // eop reached? + _pagePos = _pageLength; + else + _pagePos += in().tellg()-pos; + _actions->progress(_pagePos, _pageLength); + } + return opcode; +} + + +/** Executes all DVI commands read from the input stream. */ +void DVIReader::executeAll () { + int opcode = 0; + while (!in().eof() && opcode >= 0) { + try { + opcode = executeCommand(); + } + catch (const InvalidDVIFileException &e) { + // end of stream reached + opcode = -1; + } + } +} + + +#if 0 +/** Executes all DVI commands from the preamble to postpost. */ +bool DVIReader::executeDocument () { + in().clear(); // reset all status bits + if (!in()) + return false; + in().seekg(0); // move file pointer to first byte of the input stream + while (!in().eof() && executeCommand() != 249); // stop reading after postpost (249) + return true; +} + +bool DVIReader::executeAllPages () { + in().clear(); // reset all status bits + if (!in()) + return false; + in().seekg(0); // move file pointer to first byte of the input stream + while (!in().eof() && executeCommand() != 248); // stop reading when postamble (248) is reached + return true; +} +#endif + + +/** Reads and executes the commands of a single page. + * This methods stops reading after the page's eop command has been executed. + * @param[in] n number of page to be executed + * @returns true if page was read successfully */ +bool DVIReader::executePage (unsigned n) { + in().clear(); // reset all status bits + if (!in()) + throw DVIException("invalid DVI file"); + in().seekg(-1, ios_base::end); // stream pointer to last byte + while (in().peek() == 223) + in().seekg(-1, ios_base::cur); // skip fill bytes + in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) + UInt32 q = readUnsigned(4); // pointer to begin of postamble + in().seekg(q, ios_base::beg); // now on begin of postamble + if (executeCommand() != 248) // execute postamble command but not the fontdefs + return false; + if (n < 1 || n > _totalPages) + return false; + in().seekg(_prevBop, ios_base::beg); // now on last bop + _inPostamble = false; // we jumped out of the postamble + unsigned pageCount = _totalPages; + for (; pageCount > n && _prevBop > 0; pageCount--) { + in().seekg(41, ios_base::cur); // skip bop and 10*4 \count bytes => now on pointer to prev bop + _prevBop = readSigned(4); + in().seekg(_prevBop, ios_base::beg); + } + _currPageNum = n; + while (pageCount == n && executeCommand() != 140); // 140 == eop + return true; +} + + +bool DVIReader::executePages (unsigned first, unsigned last) { + in().clear(); + if (!in()) + throw DVIException("invalid DVI file"); + if (first > last) + swap(first, last); + in().seekg(-1, ios_base::end); // stream pointer to last byte + while (in().peek() == 223) + in().seekg(-1, ios_base::cur); // skip fill bytes + in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) + UInt32 q = readUnsigned(4); // pointer to begin of postamble + in().seekg(q, ios_base::beg); // now on begin of postamble + if (executeCommand() != 248) // execute postamble command but not the fontdefs + return false; + first = max(1u, min(first, _totalPages)); + last = max(1u, min(last, _totalPages)); + in().seekg(_prevBop, ios_base::beg); // now on last bop + _inPostamble = false; // we jumped out of the postamble + unsigned count = _totalPages; + for (; count > first && _prevBop > 0; count--) { + in().seekg(41, ios_base::cur); // skip bop and 10*4 \count bytes => now on pointer to prev bop + _prevBop = readSigned(4); + in().seekg(_prevBop, ios_base::beg); + } + while (first <= last) { + _currPageNum = first++; + while (executeCommand () != 140); // 140 == eop + } + return true; +} + + +void DVIReader::executePreamble () { + in().clear(); + if (!in()) + throw DVIException("invalid DVI file"); + in().seekg(0, ios_base::beg); + if (in().get() != 247) + throw DVIException("invalid DVI file"); + cmdPre(0); +} + + +/** Reads and executes the commands of the postamble. */ +void DVIReader::executePostamble () { + in().clear(); // reset all status bits + if (!in()) + throw DVIException("invalid DVI file"); + in().seekg(-1, ios_base::end); // stream pointer to last byte + while (in().peek() == 223) + in().seekg(-1, ios_base::cur); // skip fill bytes + + in().seekg(-4, ios_base::cur); // now on first byte of q (pointer to begin of postamble) + UInt32 q = readUnsigned(4); // pointer to begin of postamble + in().seekg(q, ios_base::beg); // now on begin of postamble + while (executeCommand() != 249); // read all commands until postpost (= 249) is reached +} + + +/** Returns the current x coordinate in TeX point units. + * This is the horizontal position where the next output would be placed. */ +double DVIReader::getXPos () const { + return _currPos.h+_tx; +} + + +/** Returns the current y coordinate in TeX point units. + * This is the vertical position where the next output would be placed. */ +double DVIReader::getYPos () const { + return _currPos.v+_ty; +} + + +double DVIReader::getPageHeight () const { + return _pageHeight; +} + + +double DVIReader::getPageWidth () const { + return _pageWidth; +} + +///////////////////////////////////// + +/** Reads and executes DVI preamble command. */ +void DVIReader::cmdPre (int) { + UInt32 i = readUnsigned(1); // identification number (should be 2) + UInt32 num = readUnsigned(4); // numerator units of measurement + UInt32 den = readUnsigned(4); // denominator units of measurement + _mag = readUnsigned(4); // magnification + UInt32 k = readUnsigned(1); // length of following comment + string cmt = readString(k); // comment + if (i != 2) { + ostringstream oss; + oss << "DVI format version " << i << " not supported"; + throw DVIException(oss.str()); + } + // 1 dviunit * num/den == multiples of 0.0000001m + // 1 dviunit * _scaleFactor: length of 1 dviunit in TeX points * _mag/1000 + _scaleFactor = num/25400000.0*7227.0/den*_mag/1000.0; + if (_actions) + _actions->preamble(cmt); +} + + +/** Reads and executes DVI postamble command. */ +void DVIReader::cmdPost (int) { + _prevBop = readUnsigned(4); // pointer to previous bop + UInt32 num = readUnsigned(4); + UInt32 den = readUnsigned(4); + _mag = readUnsigned(4); + _pageHeight = readUnsigned(4); // height of tallest page in dvi units + _pageWidth = readUnsigned(4); // width of widest page in dvi units + readUnsigned(2); // max. stack depth + _totalPages = readUnsigned(2); // total number of pages + // 1 dviunit * num/den == multiples of 0.0000001m + // 1 dviunit * _scaleFactor: length of 1 dviunit in TeX points * _mag/1000 + _scaleFactor = num/25400000.0*7227.0/den*_mag/1000.0; + _pageHeight *= _scaleFactor; // to pt units + _pageWidth *= _scaleFactor; + _inPostamble = true; + if (_actions) + _actions->postamble(); +} + + +/** Reads and executes DVI postpost command. */ +void DVIReader::cmdPostPost (int) { + _inPostamble = false; + readUnsigned(4); // pointer to begin of postamble + UInt32 i = readUnsigned(1); // identification byte (should be 2) + if (i == 2) + while (readUnsigned(1) == 223); // skip fill bytes (223), eof bit should be set now + else + throw DVIException("invalid identification value in postpost"); +} + + +/** Reads and executes Begin-Of-Page command. */ +void DVIReader::cmdBop (int) { + Int32 c[10]; + for (int i=0; i < 10; i++) + c[i] = readSigned(4); + readSigned(4); // pointer to peceeding bop (-1 in case of first page) + _currPos.reset(); // set all DVI registers to 0 + while (!_posStack.empty()) + _posStack.pop(); + _currFontNum = 0; + _inPage = true; + _pageLength = 0; + _pagePos = 0; + if (COMPUTE_PAGE_LENGTH) { + // compute number of bytes in current page + int length, param; + CommandHandler handler; + // read all commands until eop is found + while (evalCommand(true, handler, length, param) != 140) { + in().seekg(length, ios_base::cur); + _pageLength += length+1; // parameter length + opcode length (1 byte) + } + ++_pageLength; // add length of eop command (1 byte) + in().seekg(-int(_pageLength), ios_base::cur); // go back to first command following bop + _pageLength += 45; // add length of bop command + } + beginPage(_currPageNum, c); + if (_actions) + _actions->beginPage(_currPageNum, c); +} + + +/** Reads and executes End-Of-Page command. */ +void DVIReader::cmdEop (int) { + if (!_posStack.empty()) + throw DVIException("stack not empty at end of page"); + _inPage = false; + endPage(_currPageNum); + if (_actions) + _actions->endPage(_currPageNum); +} + + +/** Reads and executes push command. */ +void DVIReader::cmdPush (int) { + _posStack.push(_currPos); +} + + +/** Reads and executes pop command (restores pushed position information). */ +void DVIReader::cmdPop (int) { + if (_posStack.empty()) + throw DVIException("stack empty at pop command"); + else { + DVIPosition prevPos = _currPos; + _currPos = _posStack.top(); + _posStack.pop(); + if (_actions) { + if (prevPos.h != _currPos.h) + _actions->moveToX(_currPos.h + _tx); + if (prevPos.v != _currPos.v) + _actions->moveToY(_currPos.v + _ty); + } + } +} + + +/** Helper function that actually sets/puts a charater. It is called by the + * cmdSetChar and cmdPutChar methods. + * @param[in] c character to typeset + * @param[in] moveCursor if true, register h is increased by the character width + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::putChar (UInt32 c, bool moveCursor) { + if (!_inPage) + throw DVIException("set_char or put_char outside of page"); + + FontManager &fm = FontManager::instance(); + Font *font = fm.getFont(_currFontNum); + if (!font) + throw DVIException("no font selected"); + + if (VirtualFont *vf = dynamic_cast(font)) { // is current font a virtual font? + vector *dvi = const_cast*>(vf->getDVI(c)); // get DVI snippet that describes character c + if (dvi) { + DVIPosition pos = _currPos; // save current cursor position + _currPos.x = _currPos.y = _currPos.w = _currPos.z = 0; + int save_fontnum = _currFontNum; // save current font number + fm.enterVF(vf); // new font number context + cmdFontNum0(fm.vfFirstFontNum(vf)); + double save_scale = _scaleFactor; + _scaleFactor = vf->scaledSize()/(1 << 20); + + VectorInputStream vis(*dvi); + istream &is = replaceStream(vis); + try { + executeAll(); // execute DVI fragment + } + catch (const DVIException &e) { + // Message::estream(true) << "invalid dvi in vf: " << e.getMessage() << endl; // @@ + } + replaceStream(is); // restore previous input stream + _scaleFactor = save_scale; // restore previous scale factor + fm.leaveVF(); // restore previous font number context + cmdFontNum0(save_fontnum); // restore previous font number + _currPos = pos; // restore previous cursor position + } + } + else if (_actions) { + _actions->setChar(_currPos.h+_tx, _currPos.v+_ty, c, font); + } + if (moveCursor) + _currPos.h += font->charWidth(c) * font->scaleFactor() * _mag/1000.0; +} + + +/** Reads and executes set_char_x command. Puts a character at the current + * position and advances the cursor. + * @param[in] c character to set + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::cmdSetChar0 (int c) { + putChar(c, true); +} + + +/** Reads and executes setx command. Puts a character at the current + * position and advances the cursor. + * @param[in] len number of parameter bytes (possible values: 1-4) + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::cmdSetChar (int len) { + // According to the dvi specification all character codes are unsigned + // except len == 4. At the moment all char codes are treated as unsigned... + UInt32 c = readUnsigned(len); // if len == 4 c may be signed + putChar(c, true); +} + + +/** Reads and executes putx command. Puts a character at the current + * position but doesn't change the cursor position. + * @param[in] len number of parameter bytes (possible values: 1-4) + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::cmdPutChar (int len) { + // According to the dvi specification all character codes are unsigned + // except len == 4. At the moment all char codes are treated as unsigned... + Int32 c = readUnsigned(len); + putChar(c, false); +} + + +/** Reads and executes set_rule command. Puts a solid rectangle at the current + * position and updates the cursor position. + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::cmdSetRule (int) { + if (_inPage) { + double height = _scaleFactor*readSigned(4); + double width = _scaleFactor*readSigned(4); + if (_actions && height > 0 && width > 0) + _actions->setRule(_currPos.h+_tx, _currPos.v+_ty, height, width); + _currPos.h += width; + if (_actions && (height <= 0 || width <= 0)) + _actions->moveToX(_currPos.h+_tx); + } + else + throw DVIException("set_rule outside of page"); +} + + +/** Reads and executes set_rule command. Puts a solid rectangle at the current + * position but leaves the cursor position unchanged. + * @throw DVIException if method is called ouside a bop/eop pair */ +void DVIReader::cmdPutRule (int) { + if (_inPage) { + double height = _scaleFactor*readSigned(4); + double width = _scaleFactor*readSigned(4); + if (_actions && height > 0 && width > 0) + _actions->setRule(_currPos.h+_tx, _currPos.v+_ty, height, width); + } + else + throw DVIException("put_rule outside of page"); +} + + +void DVIReader::cmdNop (int) {} + +void DVIReader::cmdRight (int len) {_currPos.h += _scaleFactor*readSigned(len); if (_actions) _actions->moveToX(_currPos.h+_tx);} +void DVIReader::cmdDown (int len) {_currPos.v += _scaleFactor*readSigned(len); if (_actions) _actions->moveToY(_currPos.v+_ty);} +void DVIReader::cmdX0 (int) {_currPos.h += _currPos.x; if (_actions) _actions->moveToX(_currPos.h+_tx);} +void DVIReader::cmdY0 (int) {_currPos.v += _currPos.y; if (_actions) _actions->moveToY(_currPos.v+_ty);} +void DVIReader::cmdW0 (int) {_currPos.h += _currPos.w; if (_actions) _actions->moveToX(_currPos.h+_tx);} +void DVIReader::cmdZ0 (int) {_currPos.v += _currPos.z; if (_actions) _actions->moveToY(_currPos.v+_ty);} +void DVIReader::cmdX (int len) {_currPos.x = _scaleFactor*readSigned(len); cmdX0(0);} +void DVIReader::cmdY (int len) {_currPos.y = _scaleFactor*readSigned(len); cmdY0(0);} +void DVIReader::cmdW (int len) {_currPos.w = _scaleFactor*readSigned(len); cmdW0(0);} +void DVIReader::cmdZ (int len) {_currPos.z = _scaleFactor*readSigned(len); cmdZ0(0);} + + +void DVIReader::cmdXXX (int len) { + if (_inPage) { + UInt32 numBytes = readUnsigned(len); + string s = readString(numBytes); + if (_actions) + _actions->special(s); + } + else + throw DVIException("special outside of page"); +} + + +/** Selects a previously defined font by its number. + * @param[in] num font number + * @throw DVIException if font number is undefined */ +void DVIReader::cmdFontNum0 (int num) { + if (Font *font = FontManager::instance().getFont(num)) { + _currFontNum = num; + if (_actions && !dynamic_cast(font)) + _actions->setFont(FontManager::instance().fontID(num), font); // all fonts get a recomputed ID + } + else { + ostringstream oss; + oss << "undefined font number " << num; + throw DVIException(oss.str()); + } +} + + +/** Selects a previously defined font. + * @param[in] len size of font number variable (in bytes) + * @throw DVIException if font number is undefined */ +void DVIReader::cmdFontNum (int len) { + UInt32 num = readUnsigned(len); + cmdFontNum0(num); +} + + +/** Helper function to handle a font definition. + * @param[in] fontnum local font number + * @param[in] name font name + * @param[in] checksum checksum to be compared with TFM checksum + * @param[in] ds design size in TeX point units + * @param[in] ss scaled size in TeX point units */ +void DVIReader::defineFont (UInt32 fontnum, const string &name, UInt32 cs, double ds, double ss) { + FontManager &fm = FontManager::instance(); + int id = fm.registerFont(fontnum, name, cs, ds, ss); + Font *font = fm.getFontById(id); + if (VirtualFont *vf = dynamic_cast(font)) { + // read vf file, register its font and character definitions + fm.enterVF(vf); + ifstream ifs(vf->path(), ios::binary); + VFReader vfReader(ifs); + vfReader.replaceActions(this); + vfReader.executeAll(); + fm.leaveVF(); + } + if (_actions) + _actions->defineFont(id, font); +} + + +/** Defines a new font. + * @param[in] len size of font number variable (in bytes) */ +void DVIReader::cmdFontDef (int len) { + UInt32 fontnum = readUnsigned(len); // font number + UInt32 checksum = readUnsigned(4); // font checksum (to be compared with corresponding TFM checksum) + UInt32 ssize = readUnsigned(4); // scaled size of font in DVI units + UInt32 dsize = readUnsigned(4); // design size of font in DVI units + UInt32 pathlen = readUnsigned(1); // length of font path + UInt32 namelen = readUnsigned(1); // length of font name + string fontpath = readString(pathlen); + string fontname = readString(namelen); + + // process font definitions between bop and eop only, skip those in the postamble + if (_inPage) + defineFont(fontnum, fontname, checksum, dsize*_scaleFactor, ssize*_scaleFactor); +} + + +/** This template method is called by the VFReader after reading a font definition from a VF file. + * @param[in] fontnum local font number + * @param[in] name font name + * @param[in] checksum checksum to be compared with TFM checksum + * @param[in] dsize design size in TeX point units + * @param[in] ssize scaled size in TeX point units */ +void DVIReader::defineVFFont (UInt32 fontnum, string path, string name, UInt32 checksum, double dsize, double ssize) { + VirtualFont *vf = FontManager::instance().getVF(); + defineFont(fontnum, name, checksum, dsize, ssize * vf->scaleFactor()); +} + + +/** This template method is called by the VFReader after reading a character definition from a VF file. + * @param[in] c character number + * @param[in] dvi DVI fragment describing the character */ +void DVIReader::defineVFChar (UInt32 c, vector *dvi) { + FontManager::instance().assignVfChar(c, dvi); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.h new file mode 100644 index 00000000000..2d24d6b24f6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIReader.h @@ -0,0 +1,147 @@ +/************************************************************************* +** DVIReader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DVIREADER_H +#define DVIREADER_H + +#include +#include +#include +#include +#include "MessageException.h" +#include "StreamReader.h" +#include "VFActions.h" +#include "types.h" + + +struct DVIException : public MessageException +{ + DVIException (const std::string &msg) : MessageException(msg) {} +}; + +struct InvalidDVIFileException : public DVIException +{ + InvalidDVIFileException(const std::string &msg) : DVIException(msg) {} +}; + +struct DVIActions; +struct FileFinder; + +class DVIReader : public StreamReader, protected VFActions +{ + typedef void (DVIReader::*CommandHandler)(int); + + struct DVIPosition + { + double h, v; + double x, w, y, z; + DVIPosition () {reset();} + void reset () {h = v = x = w = y = z = 0.0;} + }; + + public: + DVIReader (std::istream &is, DVIActions *a=0); + + bool executeDocument (); + void executeAll (); + bool executeAllPages (); + void executePreamble (); + void executePostamble (); + bool executePage (unsigned n); + bool executePages (unsigned first, unsigned last); + bool inPostamble () const {return _inPostamble;} + double getXPos () const; + double getYPos () const; + void finishLine () {_prevYPos = std::numeric_limits::min();} + void translateToX (double x) {_tx=x-_currPos.h-_tx;} + void translateToY (double y) {_ty=y-_currPos.v-_ty;} + double getPageWidth () const; + double getPageHeight () const; + int getCurrentFontNumber () const {return _currFontNum;} + unsigned getCurrentPageNumber () const {return _currPageNum;} + unsigned getTotalPages () const {return _totalPages;} + DVIActions* getActions () const {return _actions;} + DVIActions* replaceActions (DVIActions *a); + + protected: + int executeCommand (); + int evalCommand (bool compute_size, CommandHandler &handler, int &length, int ¶m); + void putChar (UInt32 c, bool moveCursor); + void defineFont (UInt32 fontnum, const std::string &name, UInt32 cs, double ds, double ss); + virtual void beginPage (unsigned pageno, Int32 *c) {} + virtual void endPage (unsigned pageno) {} + + // VFAction methods + void defineVFFont (UInt32 fontnum, std::string path, std::string name, UInt32 checksum, double dsize, double ssize); + void defineVFChar (UInt32 c, std::vector *dvi); + + // the following methods represent the DVI commands + // they are called by executeCommand and should not be used directly + void cmdSetChar0 (int c); + void cmdSetChar (int len); + void cmdPutChar (int len); + void cmdSetRule (int len); + void cmdPutRule (int len); + void cmdNop (int len); + void cmdBop (int len); + void cmdEop (int len); + void cmdPush (int len); + void cmdPop (int len); + void cmdRight (int len); + void cmdDown (int len); + void cmdX0 (int len); + void cmdY0 (int len); + void cmdW0 (int len); + void cmdZ0 (int len); + void cmdX (int len); + void cmdY (int len); + void cmdW (int len); + void cmdZ (int len); + void cmdFontDef (int len); + void cmdFontNum0 (int n); + void cmdFontNum (int len); + void cmdXXX (int len); + void cmdPre (int len); + void cmdPost (int len); + void cmdPostPost (int len); + + private: + DVIActions *_actions; ///< actions to be performed on various DVI events + bool _inPage; ///< true if between bop and eop + unsigned _totalPages; ///< total number of pages in dvi file + unsigned _currPageNum; ///< current page number + int _currFontNum; ///< current font number + double _scaleFactor; ///< 1 dvi unit = scaleFactor * TeX points + UInt32 _mag; ///< magnification factor * 1000 + bool _inPostamble; ///< true if stream pointer is inside the postamble + Int32 _prevBop; ///< pointer to previous bop + double _pageHeight, _pageWidth; ///< page height and width in TeX points + DVIPosition _currPos; ///< current cursor position + std::stack _posStack; + double _prevYPos; ///< previous vertical cursor position + double _tx, _ty; ///< tranlation of cursor position + size_t _pageLength; ///< number of bytes between current bop end eop + std::streampos _pagePos; ///< distance of current DVI command from bop (in bytes) + + public: + static bool COMPUTE_PAGE_LENGTH; ///< if true, the bop handler computes the number of bytes of the current page +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.cpp new file mode 100644 index 00000000000..cfa246f0f09 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.cpp @@ -0,0 +1,363 @@ +/************************************************************************* +** DVIToSVG.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifdef HAVE_CONFIG_H + #include "config.h" + #ifdef TARGET_SYSTEM + #define VERSION_STR VERSION " (" TARGET_SYSTEM ")" + #else + #define VERSION_STR VERSION + #endif +#else + #define VERSION_STR "" +#endif + +#include +#include +#include +#include +#include "Calculator.h" +#include "DVIToSVG.h" +#include "DVIToSVGActions.h" +#include "Font.h" +#include "FontManager.h" +#include "FileFinder.h" +#include "GlyphTracerMessages.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "Matrix.h" +#include "Message.h" +#include "PageRanges.h" +#include "PageSize.h" +#include "SVGOutputBase.h" +#include "SVGTree.h" +#include "TFM.h" +#include "XMLDocument.h" +#include "XMLDocTypeNode.h" +#include "XMLNode.h" +#include "XMLString.h" +// +/////////////////////////////////// +// special handlers + +#include "BgColorSpecialHandler.h" +#include "ColorSpecialHandler.h" +#include "DvisvgmSpecialHandler.h" +#include "EmSpecialHandler.h" +#include "PdfSpecialHandler.h" +#include "HtmlSpecialHandler.h" +#ifndef HAVE_LIBGS + #include "NoPsSpecialHandler.h" +#endif +#ifndef DISABLE_GS + #include "PsSpecialHandler.h" +#endif +#include "TpicSpecialHandler.h" +/////////////////////////////////// + + +using namespace std; + + +/** Returns time stamp of current date/time. */ +static string datetime () { + time_t t; + time(&t); + struct tm *tm = localtime(&t); + char *timestr = asctime(tm); + timestr[24] = 0; // remove newline + return timestr; +} + +class PSHeaderActions : public DVIActions +{ + public : + PSHeaderActions (DVIToSVG &dvisvg) : _dvisvg(dvisvg) {} + + void special (const std::string &s) { + // execute PS headers only + if (!s.empty() && (s[0] == '!' || s.substr(0, 7) == "header=")) + _dvisvg.specialManager().process(s, 0); + } + + BoundingBox& bbox () {return _bbox;} + + private: + DVIToSVG &_dvisvg; + BoundingBox _bbox; +}; + + +/** 'a': trace all glyphs even if some of them are already cached + * 'm': trace missing glyphs, i.e. glyphs not yet cached + * 0 : only trace actually required glyphs */ +char DVIToSVG::TRACE_MODE = 0; + + +DVIToSVG::DVIToSVG (istream &is, SVGOutputBase &out) : DVIReader(is), _out(out) +{ + replaceActions(new DVIToSVGActions(*this, _svg)); +} + + +DVIToSVG::~DVIToSVG () { + delete replaceActions(0); +} + + +/** Starts the conversion process. + * @param[in] first number of first page to convert + * @param[in] last number of last page to convert + * @param[out] pageinfo (number of converted pages, number of total pages) */ +void DVIToSVG::convert (unsigned first, unsigned last, pair *pageinfo) { + if (getTotalPages() == 0) { + executePreamble(); + executePostamble(); // collect scaling information + } + if (first > last) + swap(first, last); + if (first > getTotalPages()) { + ostringstream oss; + oss << "file contains only " << getTotalPages() << " page"; + if (getTotalPages() > 1) + oss << 's'; + throw DVIException(oss.str()); + } + last = min(last, getTotalPages()); + + if (first > 1) { + // ensure loading of PostScript prologues given at the beginning of the first page + // (prologue files are always referenced in first page) + PSHeaderActions headerActions(*this); + DVIActions *save = replaceActions(&headerActions); + executePage(1); + replaceActions(save); + } + for (unsigned i=first; i <= last; ++i) { + executePage(i); + embedFonts(_svg.rootNode()); + _svg.write(_out.getPageStream(getCurrentPageNumber(), getTotalPages())); + string fname = _out.filename(i, getTotalPages()); + Message::mstream(false, Message::MC_PAGE_WRITTEN) << "\npage written to " << (fname.empty() ? "" : fname) << '\n'; + _svg.reset(); + static_cast(getActions())->reset(); + } + if (pageinfo) { + pageinfo->first = last-first+1; + pageinfo->second = getTotalPages(); + } +} + + +/** Convert DVI pages specified by a page range string. + * @param[in] rangestr string describing the pages to convert + * @param[out] pageinfo (number of converted pages, number of total pages) */ +void DVIToSVG::convert (const string &rangestr, pair *pageinfo) { + if (getTotalPages() == 0) { + executePreamble(); + executePostamble(); // collect scaling information + } + PageRanges ranges; + if (!ranges.parse(rangestr, getTotalPages())) + throw MessageException("invalid page range format"); + FORALL(ranges, PageRanges::ConstIterator, it) + convert(it->first, it->second); + if (pageinfo) { + pageinfo->first = ranges.pages(); + pageinfo->second = getTotalPages(); + } +} + + +/** This template method is called by parent class DVIReader before + * executing the BOP actions. + * @param[in] c contains information about the page (page number etc.) */ +void DVIToSVG::beginPage (unsigned pageno, Int32 *c) { + if (dynamic_cast(getActions())) { + Message::mstream().indent(0); + Message::mstream(false, Message::MC_PAGE_NUMBER) << "processing page " << pageno << " [" << c[0] << ']'; + Message::mstream().indent(1); + _svg.appendToDoc(new XMLCommentNode(" This file was generated by dvisvgm " VERSION_STR " ")); + _svg.appendToDoc(new XMLCommentNode(" " + datetime() + " ")); + } +} + + +/** This template method is called by parent class DVIReader before + * executing the EOP actions. */ +void DVIToSVG::endPage (unsigned pageno) { + if (!dynamic_cast(getActions())) + return; + + _specialManager.notifyEndPage(pageno); + // set bounding box and apply page transformations + BoundingBox &bbox = getActions()->bbox(); + if (!_transCmds.empty()) { + Calculator calc; + calc.setVariable("ux", bbox.minX()); + calc.setVariable("uy", bbox.minY()); + calc.setVariable("w", bbox.width()); + calc.setVariable("h", bbox.height()); + calc.setVariable("pt", 1); + calc.setVariable("in", 72.27); + calc.setVariable("cm", 72.27/2.54); + calc.setVariable("mm", 72.27/25.4); + Matrix matrix(_transCmds, calc); + static_cast(getActions())->setPageMatrix(matrix); + if (_bboxString == "min") + bbox.transform(matrix); + } + if (string("dvi none min").find(_bboxString) == string::npos) { + istringstream iss(_bboxString); + StreamInputReader ir(iss); + ir.skipSpace(); + if (isalpha(ir.peek())) { + // set explicitly given page format + PageSize size(_bboxString); + if (size.valid()) { + // convention: DVI position (0,0) equals (1in, 1in) relative + // to the upper left vertex of the page (see DVI specification) + const double border = -72.27; + bbox = BoundingBox(border, border, size.widthInPT()+border, size.heightInPT()+border); + } + } + else { // set/modify bounding box by explicitly given values + try { + bbox.set(_bboxString); + } + catch (const MessageException &e) { + } + } + } + else if (_bboxString == "dvi") { + // center page content + double dx = (getPageWidth()-bbox.width())/2; + double dy = (getPageHeight()-bbox.height())/2; + bbox += BoundingBox(-dx, -dy, dx, dy); + } + if (_bboxString != "none") { + if (bbox.width() == 0) + Message::wstream(false) << "\npage is empty\n"; + else { + _svg.setBBox(bbox); + + Message::mstream(false) << '\n'; + Message::mstream(false, Message::MC_PAGE_SIZE) << "page size: " << bbox.width() << "pt" + " x " << bbox.height() << "pt" + " (" << bbox.width()/72.27*25.4 << "mm" + " x " << bbox.height()/72.27*25.4 << "mm)"; + Message::mstream(false) << '\n'; + } + } +} + + +static void collect_chars (map > &fm) { + typedef const map > UsedCharsMap; + FORALL(fm, UsedCharsMap::const_iterator, it) { + if (it->first->uniqueFont() != it->first) { + FORALL(it->second, set::const_iterator, cit) + fm[it->first->uniqueFont()].insert(*cit); + } + } +} + + +/** Adds the font information to the SVG tree. + * @param[in] svgElement the font nodes are added to this node */ +void DVIToSVG::embedFonts (XMLElementNode *svgElement) { + if (!svgElement) + return; + if (!getActions()) // no dvi actions => no chars written => no fonts to embed + return; + + typedef map > UsedCharsMap; + const DVIToSVGActions *svgActions = static_cast(getActions()); + UsedCharsMap &usedChars = svgActions->getUsedChars(); + + collect_chars(usedChars); + + GlyphTracerMessages messages; + FORALL(usedChars, UsedCharsMap::const_iterator, it) { + const Font *font = it->first; + if (const PhysicalFont *ph_font = dynamic_cast(font)) { + if (TRACE_MODE) + ph_font->traceAllGlyphs(TRACE_MODE == 'a', &messages); + + if (font->path()) // does font file exist? + _svg.append(*ph_font, it->second, &messages); + else + Message::wstream(true) << "can't embed font '" << font->name() << "'\n"; + } + else + Message::wstream(true) << "can't embed font '" << font->name() << "'\n"; + } + _svg.appendFontStyles(svgActions->getUsedFonts()); +} + + +/** Enables or disables processing of specials. If ignorelist == 0, all + * supported special handlers are loaded. To disable selected sets of specials, + * the corresponding prefixes can be given separated by non alpha-numeric characters, + * e.g. "color, ps, em" or "color: ps em" etc. + * A single "*" in the ignore list disables all specials. + * @param[in] ignorelist list of special prefixes to ignore + * @param[in] pswarning if true, shows warning about disabled PS support + * @return the SpecialManager that handles special statements */ +const SpecialManager* DVIToSVG::setProcessSpecials (const char *ignorelist, bool pswarning) { + if (ignorelist && strcmp(ignorelist, "*") == 0) { // ignore all specials? + _specialManager.unregisterHandlers(); + } + else { + // add special handlers + SpecialHandler *handlers[] = { + 0, // placeholder for PsSpecialHandler + new BgColorSpecialHandler, // handles background color special + new ColorSpecialHandler, // handles color specials + new DvisvgmSpecialHandler, // handles raw SVG embeddings + new EmSpecialHandler, // handles emTeX specials + new HtmlSpecialHandler, // handles hyperref specials + new PdfSpecialHandler, // handles pdf specials + new TpicSpecialHandler, // handles tpic specials + 0 + }; + SpecialHandler **p = handlers; +#if !defined(DISABLE_GS) + if (Ghostscript().available()) + *p = new PsSpecialHandler; + else +#endif + { +#if defined(DISABLE_GS) || !defined(HAVE_LIBGS) + *p = new NoPsSpecialHandler; // dummy PS special handler that only prints warning messages +#endif + if (pswarning) { +#if defined(DISABLE_GS) + Message::wstream() << "this build of dvisvgm doesn't support the processing of PostScript specials\n"; +#else + Message::wstream() << "processing of PostScript specials is disabled (Ghostscript not found)\n"; +#endif + } + } + _specialManager.unregisterHandlers(); + _specialManager.registerHandlers(p, ignorelist); + } + return &_specialManager; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.h new file mode 100644 index 00000000000..309c6204c23 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVG.h @@ -0,0 +1,63 @@ +/************************************************************************* +** DVIToSVG.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DVITOSVG_H +#define DVITOSVG_H + +#include +#include +#include +#include "DVIReader.h" +#include "SpecialManager.h" +#include "SVGTree.h" + +struct SVGOutputBase; + +class DVIToSVG : public DVIReader +{ + public: + DVIToSVG (std::istream &is, SVGOutputBase &out); + ~DVIToSVG (); + void convert (unsigned firstPage, unsigned lastPage, std::pair *pageinfo=0); + void convert (const std::string &range, std::pair *pageinfo=0); + const SpecialManager* setProcessSpecials (const char *ignorelist=0, bool pswarning=false); + const SpecialManager& specialManager () const {return _specialManager;} + void setPageSize (const std::string &name) {_bboxString = name;} + void setTransformation (const std::string &cmds) {_transCmds = cmds;} + + public: + static char TRACE_MODE; + + protected: + DVIToSVG (const DVIToSVG &); + DVIToSVG operator = (const DVIToSVG &); + void beginPage (unsigned pageno, Int32 *c); + void endPage (unsigned pageno); + void embedFonts (XMLElementNode *svgElement); + + private: + SVGTree _svg; + SVGOutputBase &_out; + std::string _bboxString; + std::string _transCmds; + SpecialManager _specialManager; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.cpp new file mode 100644 index 00000000000..15bf47824e0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.cpp @@ -0,0 +1,347 @@ +/************************************************************************* +** DVIToSVGActions.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "BoundingBox.h" +#include "DVIToSVG.h" +#include "DVIToSVGActions.h" +#include "Font.h" +#include "FontManager.h" +#include "GlyphTracerMessages.h" +#include "SpecialManager.h" +#include "System.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +double DVIToSVGActions::PROGRESSBAR_DELAY=1000; // initial delay in seconds (values >= 1000 disable the progressbar) +bool DVIToSVGActions::EXACT_BBOX = false; + + +DVIToSVGActions::DVIToSVGActions (DVIToSVG &dvisvg, SVGTree &svg) + : _svg(svg), _dvisvg(dvisvg), _pageMatrix(0), _bgcolor(Color::TRANSPARENT), _boxes(0) +{ + _currentFontNum = -1; + _pageCount = 0; +} + + +DVIToSVGActions::~DVIToSVGActions () { + delete _pageMatrix; + delete _boxes; +} + + +void DVIToSVGActions::reset() { + _usedChars.clear(); + _usedFonts.clear(); + _bbox = BoundingBox(); + _currentFontNum = -1; + _bgcolor = Color::TRANSPARENT; +} + + +void DVIToSVGActions::setPageMatrix (const Matrix &matrix) { + delete _pageMatrix; + _pageMatrix = new Matrix(matrix); +} + + +void DVIToSVGActions::moveToX (double x) { + _dvisvg.specialManager().notifyPositionChange(getX(), getY()); + _svg.setX(getX()); // get current horizontal DVI position +} + + +void DVIToSVGActions::moveToY (double y) { + _dvisvg.specialManager().notifyPositionChange(getX(), getY()); + _svg.setY(y); +} + + +/** This method is called when a "set char" command was found in the DVI file. + * It draws a character of the current font. + * @param[in] x horizontal position of left bounding box edge + * @param[in] y vertical position of the character's baseline + * @param[in] c character code relative to the current font + * @param[in] font font to be used */ +void DVIToSVGActions::setChar (double x, double y, unsigned c, const Font *font) { + // If we use SVG fonts there is no need to record all font name/char/size combinations + // because the SVG font mechanism handles this automatically. It's sufficient to + // record font names and chars. The various font sizes can be ignored here. + // For a given font object, Font::uniqueFont() returns the same unique font object for + // all fonts with the same name. + _usedChars[SVGTree::USE_FONTS ? font->uniqueFont() : font].insert(c); + + // However, we record all required fonts + _usedFonts.insert(font); + + _svg.appendChar(c, x, y, *font); + // update bounding box + double wl=0, wr=0, h=0, d=0; // left/right width, height, and depth of character c + static string fontname; + GlyphTracerMessages callback(fontname != font->name(), false); + fontname = font->name(); + BoundingBox charbox; + const PhysicalFont *ph_font = dynamic_cast(font); + if (EXACT_BBOX && ph_font && ph_font->getGlyphBox(c, charbox, &callback)) { + if ((wl = charbox.minX()) > 0) wl=0; + if ((wr = charbox.maxX()) < 0) wr=0; + if ((h = charbox.maxY()) < 0) h=0; + if ((d = -charbox.minY()) < 0) d=0; + } + else { + double s = font->scaleFactor(); + wr = s*(font->charWidth(c) + font->italicCorr(c)); + h = s*font->charHeight(c); + d = s*font->charDepth(c); + } + + BoundingBox bbox(x+wl, y-h, x+wr, y+d); +/* XMLElementNode *rect = new XMLElementNode("rect"); + rect->addAttribute("x", x+wl); + rect->addAttribute("y", y-h); + rect->addAttribute("width", (-wl+wr)); + rect->addAttribute("height", (h+d)); + rect->addAttribute("fill", "none"); + rect->addAttribute("stroke", "red"); + rect->addAttribute("stroke-width", "0.5"); + _svg.appendToPage(rect);*/ + if (!getMatrix().isIdentity()) + bbox.transform(getMatrix()); + embed(bbox); +} + + +/** This method is called when a "set rule" or "put rule" command was found in the + * DVI file. It draws a solid unrotated rectangle. + * @param[in] x horizontal position of left edge + * @param[in] y vertical position of bottom(!) edge + * @param[in] height length of the vertical edges + * @param[in] width length of the horizontal edges */ +void DVIToSVGActions::setRule (double x, double y, double height, double width) { +/* x *= BP; + y *= BP; + height *= BP; + width *= BP; */ + // (x,y) is the lower left corner of the rectangle + XMLElementNode *rect = new XMLElementNode("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().getSVG()); + if (getColor() != Color::BLACK) + rect->addAttribute("fill", _svg.getColor().rgbString()); + _svg.appendToPage(rect); + + // update bounding box + BoundingBox bb(x, y-height, x+width, y); + if (!getMatrix().isIdentity()) + bb.transform(getMatrix()); + embed(bb); +} + + +/** This method is called when a "set font" command was found in the DVI file. The + * font must be previously defined. + * @param[in] num unique number of the font in the DVI file (not necessarily equal to the DVI font number) + * @param[in] font pointer to the font object (always represents a physical font and never a virtual font) */ +void DVIToSVGActions::setFont (int num, const Font *font) { + _currentFontNum = num; + _svg.setFont(num, font); +} + + +/** This method is called when a "special" command was found in the DVI file. + * @param[in] s the special expression */ +void DVIToSVGActions::special (const string &s) { + try { + _dvisvg.specialManager().process(s, this, this); + // @@ output message in case of unsupported specials? + } + catch (const SpecialException &e) { + Message::estream(true) << "error in special '" << s << "': " << e.what() << '\n'; + } +} + + +void DVIToSVGActions::beginSpecial (const char *prefix) { +} + + +void DVIToSVGActions::endSpecial (const char *) { +} + + +/** This method is called when the DVI preamble was read + * @param[in] cmt preamble comment text. */ +void DVIToSVGActions::preamble (const string &cmt) { +} + + +void DVIToSVGActions::postamble () { +} + + +/** This method is called when a "begin of page (bop)" command was found in the DVI file. + * @param[in] c array with 10 components representing \count0 ... \count9. c[0] contains the + * current (printed) page number (may differ from page count) */ +void DVIToSVGActions::beginPage (unsigned pageno, Int32 *c) { + _svg.newPage(++_pageCount); + _bbox = BoundingBox(); // clear bounding box + if (_boxes) + _boxes->clear(); +} + + +/** This method is called when an "end of page (eop)" command was found in the DVI file. */ +void DVIToSVGActions::endPage (unsigned pageno) { + _svg.transformPage(_pageMatrix); + if (_bgcolor != Color::TRANSPARENT) { + // create a rectangle filled with the background color + XMLElementNode *r = new XMLElementNode("rect"); + r->addAttribute("x", _bbox.minX()); + r->addAttribute("y", _bbox.minY()); + r->addAttribute("width", _bbox.width()); + r->addAttribute("height", _bbox.height()); + r->addAttribute("fill", _bgcolor.rgbString()); + _svg.prependToPage(r); + } +} + + +void DVIToSVGActions::setBgColor (const Color &color) { + _bgcolor = color; +} + + +void DVIToSVGActions::embed(const BoundingBox& bbox) { + _bbox.embed(bbox); + if (_boxes) { + FORALL(*_boxes, BoxMap::iterator, it) + it->second.embed(bbox); + } +} + + +void DVIToSVGActions::embed(const DPair& p, double r) { + if (r == 0) + _bbox.embed(p); + else + _bbox.embed(p, r); + if (_boxes) + FORALL(*_boxes, BoxMap::iterator, it) + it->second.embed(p, r); +} + + +BoundingBox& DVIToSVGActions::bbox(const string& name, bool reset) { + if (!_boxes) + _boxes = new BoxMap; + BoundingBox &box = (*_boxes)[name]; + if (reset) + box = BoundingBox(); + return box; +} + + +/** This method is called by subprocesses like the PS handler when + * a computation step has finished. Since the total number of steps + * can't be determined in advance, we don't show a percent value but + * a rotating dash. */ +void DVIToSVGActions::progress (const char *id) { + if (PROGRESSBAR_DELAY < 1000) { + static double time=0; + // slow down updating of the progress indicator to prevent flickering + if (System::time() - time > 0.1) { + progress(0, 0, id); + time = System::time(); + } + } +} + + +/** Returns the number of digits of a given integer. */ +static int digits (int n) { + if (n == 0) + return 1; + if (n > 0) + return int(log10(double(n))+1); + return int(log10(double(-n))+2); +} + + +/** Draws a simple progress indicator. + * @param[in] current current iteration step (of 'total' steps) + * @param[in] total total number of iteration steps + * @param[in] id ID of the subprocess providing the information */ +void DVIToSVGActions::progress (size_t current, size_t total, const char *id) { + static double time=0; + static bool draw=false; // show progress indicator? + static const char *prev_id=0; + if (current == 0 && total > 0) { + time = System::time(); + draw = false; + Message::mstream() << '\n'; + } + // don't show the progress indicator before the given time has elapsed + if (!draw && System::time()-time > PROGRESSBAR_DELAY) { + draw = true; + Terminal::cursor(false); + } + if (draw && (System::time() - time > 0.1 || (total > 0 && current == total) || prev_id != id)) { + static int step = -1; // >=0: rotating dash + static size_t prev_current=0, prev_total=1; + const char *tips = "-\\|/"; + if (total == 0) { + current = prev_current; + total = prev_total; + step = (step+1) % 4; + } + else { + prev_current = current; + prev_total = total; + step = -1; + } + // adapt length of progress indicator to terminal width + int cols = Terminal::columns(); + int width = (cols == 0 || cols > 60) ? 50 : 49-60+cols; + double factor = double(current)/double(total); + int length = int(width*factor); + Message::mstream(false, Message::MC_PROGRESS) + << '[' << string(length, '=') + << (factor < 1.0 ? (step < 0 ? ' ' : tips[step]) : '=') + << string(width-length, ' ') + << "] " << string(3-digits(int(100*factor)), ' ') << int(100*factor) + << "%\r"; + // overprint indicator when finished + if (factor == 1.0) { + Message::estream().clearline(); + Terminal::cursor(true); + } + time = System::time(); + prev_id = id; + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.h new file mode 100644 index 00000000000..f89f95e2ca9 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DVIToSVGActions.h @@ -0,0 +1,105 @@ +/************************************************************************* +** DVIToSVGActions.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DVITOSVGACTIONS_H +#define DVITOSVGACTIONS_H + +#include +#include +#include "BoundingBox.h" +#include "DVIActions.h" +#include "Matrix.h" +#include "SpecialActions.h" +#include "SpecialManager.h" +#include "SVGTree.h" +#include "DVIReader.h" + + +class DVIToSVG; +struct FileFinder; +struct Font; +struct XMLNode; + +class DVIToSVGActions : public DVIActions, public SpecialActions, public SpecialManager::Listener +{ + typedef std::map > CharMap; + typedef std::set FontSet; + typedef std::map BoxMap; + + public: + DVIToSVGActions (DVIToSVG &dvisvg, SVGTree &svg); + ~DVIToSVGActions (); + void reset (); + void setChar (double x, double y, unsigned c, const Font *f); + void setRule (double x, double y, double height, double width); + void setBgColor (const Color &color); + void setColor (const Color &color) {_svg.setColor(color);} + void setMatrix (const Matrix &m) {_svg.setMatrix(m);} + const Matrix& getMatrix () const {return _svg.getMatrix();} + Color getColor () const {return _svg.getColor();} + void appendToPage (XMLNode *node) {_svg.appendToPage(node);} + void appendToDefs (XMLNode *node) {_svg.appendToDefs(node);} + void prependToPage (XMLNode *node) {_svg.prependToPage(node);} + void pushContextElement (XMLElementNode *node) {_svg.pushContextElement(node);} + void popContextElement () {_svg.popContextElement();} + void moveToX (double x); + void moveToY (double y); + void setFont (int num, const Font *font); + void special (const std::string &s); + void preamble (const std::string &cmt); + void postamble (); + void beginPage (unsigned pageno, Int32 *c); + void endPage (unsigned pageno); + void beginSpecial (const char *prefix); + void endSpecial (const char *prefix); + void progress (size_t current, size_t total, const char *id=0); + void progress (const char *id); + CharMap& getUsedChars () const {return _usedChars;} + const FontSet& getUsedFonts () const {return _usedFonts;} + void setPageMatrix (const Matrix &tm); + double getX() const {return _dvisvg.getXPos();} + double getY() const {return _dvisvg.getYPos();} + void setX (double x) {_dvisvg.translateToX(x); _svg.setX(x);} + void setY (double y) {_dvisvg.translateToY(y); _svg.setY(y);} + void finishLine () {_dvisvg.finishLine();} + BoundingBox& bbox () {return _bbox;} + BoundingBox& bbox (const std::string &name, bool reset=false); + void embed (const BoundingBox &bbox); + void embed (const DPair &p, double r=0); + + public: + static double PROGRESSBAR_DELAY; ///< progress bar doesn't appear before this time has elapsed (in sec) + static bool EXACT_BBOX; + + private: + SVGTree &_svg; + DVIToSVG &_dvisvg; + BoundingBox _bbox; + int _pageCount; + int _currentFontNum; + mutable CharMap _usedChars; + FontSet _usedFonts; + Matrix *_pageMatrix; // transformation of whole page + Color _bgcolor; + BoxMap *_boxes; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.cpp new file mode 100644 index 00000000000..c13ebe35a38 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.cpp @@ -0,0 +1,116 @@ +/************************************************************************* +** Directory.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "Directory.h" + +using namespace std; + +#ifdef __WIN32__ + #include +#else + #include + #include +#endif + + +Directory::Directory () { +#if __WIN32__ + handle = INVALID_HANDLE_VALUE; +#else + dir = 0; + dirent = 0; +#endif +} + + +Directory::Directory (string dirname) { + open(dirname); +} + +Directory::~Directory () { + close(); +} + + +bool Directory::open (string dname) { + _dirname = dname; +#ifdef __WIN32__ + firstread = true; + if (dname[dname.length()-1] == '/' || dname[dname.length()-1] == '\\') + dname = dname.substr(0, dname.length()-1); + dname += "\\*"; + handle = FindFirstFile(dname.c_str(), &fileData); + return handle != INVALID_HANDLE_VALUE; +#else + dir = opendir(_dirname.c_str()); + return dir; +#endif +} + + +void Directory::close () { +#ifdef __WIN32__ + FindClose(handle); +#else + closedir(dir); +#endif +} + + +/** Reads first/next directory entry. + * @param[in] type type of entry to return (a: file or dir, f: file, d: dir) + * @return name of entry */ +const char* Directory::read (char type) { +#ifdef __WIN32__ + if (handle == INVALID_HANDLE_VALUE) + return 0; + while (firstread || FindNextFile(handle, &fileData)) { + firstread = false; + if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (type == 'a' || type == 'd') + return fileData.cFileName; + } + else if (type == 'a' || type == 'f') + return fileData.cFileName; + } + FindClose(handle); + handle = INVALID_HANDLE_VALUE; + return 0; +#else + if (!dir) + return 0; + while ((dirent = readdir(dir))) { + string path = string(_dirname) + "/" + dirent->d_name; + struct stat stats; + stat(path.c_str(), &stats); + if (S_ISDIR(stats.st_mode)) { + if (type == 'a' || type == 'd') + return dirent->d_name; + } + else if (type == 'a' || type == 'f') + return dirent->d_name; + } + closedir(dir); + dir = 0; + return 0; +#endif +} + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.h new file mode 100644 index 00000000000..6420bec6d19 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Directory.h @@ -0,0 +1,54 @@ +/************************************************************************* +** Directory.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DIRECTORY_H +#define DIRECTORY_H + +#include +#ifdef __WIN32__ + #include + #undef max +#else + #include +#endif + +class Directory +{ + public: + Directory (); + Directory (std::string path); + ~Directory (); + bool open (std::string path); + void close (); + const char* read (char type='a'); + + private: + std::string _dirname; +#ifdef __WIN32__ + bool firstread; + HANDLE handle; + WIN32_FIND_DATA fileData; +#else + DIR *dir; + struct dirent *dirent; +#endif +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.cpp new file mode 100644 index 00000000000..11e3c0fc42a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.cpp @@ -0,0 +1,202 @@ +/************************************************************************* +** DvisvgmSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "DvisvgmSpecialHandler.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "SpecialActions.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +/** Replaces constants of the form {?name} by their corresponding value. + * @param[in,out] str text to expand + * @param[in] actions interfcae to the world outside the special handler */ +static void expand_constants (string &str, SpecialActions *actions) { + struct Constant { + const char *name; + string val; + } + constants[] = { + {"x", XMLString(actions->getX())}, + {"y", XMLString(actions->getY())}, + {"color", actions->getColor().rgbString()}, + {"nl", "\n"}, + {0, ""} + }; + bool repl_bbox = true; + while (repl_bbox) { + size_t pos = str.find(string("{?bbox ")); + if (pos == string::npos) + repl_bbox = false; + else { + size_t endpos = pos+7; + while (endpos < str.length() && isalnum(str[endpos])) + ++endpos; + if (str[endpos] == '}') { + BoundingBox &box=actions->bbox(str.substr(pos+7, endpos-pos-7)); + str.replace(pos, endpos-pos+1, box.toSVGViewBox()); + } + else + repl_bbox = false; + } + } + for (const Constant *p=constants; p->name; p++) { + const string pattern = string("{?")+p->name+"}"; + size_t pos = str.find(pattern); + while (pos != string::npos) { + str.replace(pos, strlen(p->name)+3, p->val); + pos = str.find(pattern, pos+p->val.length()); // look for further matches + } + } +} + + +/** Embeds the virtual rectangle (x, y ,w , h) into the current bounding box, + * where (x,y) is the lower left vertex composed of the current DVI position. + * @param[in] w width of the rectangle in TeX point units + * @param[in] h height of the rectangle in TeX point units + * @param[in] d depth of the rectangle in TeX point units */ +static void update_bbox (double w, double h, double d, SpecialActions *actions) { + double x = actions->getX(); + double y = actions->getY(); + actions->embed(BoundingBox(x, y, x+w, y-h)); + actions->embed(BoundingBox(x, y, x+w, y+d)); +} + + +/** Inserts raw text into the SVG tree. + * @param[in,out] in the raw text is read from this input buffer + * @param[in] actions interfcae to the world outside the special handler + * @param[in] group true if the text should be wrapped by a group element */ +static void raw (InputReader &in, SpecialActions *actions, bool group=false) { + string str; + while (!in.eof()) { + int c = in.get(); + if (isprint(c)) + str += char(c); + } + expand_constants(str, actions); + if (!str.empty()) { + XMLNode *node = new XMLTextNode(str); + if (group) { + XMLElementNode *g = new XMLElementNode("g"); + g->addAttribute("x", actions->getX()); + g->addAttribute("y", actions->getY()); + if (actions->getColor() != Color::BLACK) + g->addAttribute("fill", actions->getColor().rgbString()); + g->append(node); + node = g; + } + actions->appendToPage(node); + } +} + + +/** Evaluates the special dvisvgm:bbox. + * variant 1: dvisvgm:bbox [r[el]] [] + * variant 2: dvisvgm:bbox a[bs] + * variant 3: dvisvgm:bbox f[ix] + * variant 4: dvisvgm:bbox n[ew] */ +static void bbox (InputReader &in, SpecialActions *actions) { + in.skipSpace(); + int c = in.peek(); + if (isalpha(c)) { + while (!isspace(in.peek())) // skip trailing characters + in.get(); + if (c == 'n') { + in.skipSpace(); + string name; + while (isalnum(in.peek())) + name += char(in.get()); + in.skipSpace(); + if (!name.empty() && in.eof()) + actions->bbox(name, true); // create new user box + } + else if (c == 'a' || c == 'f') { + double p[4]; + for (int i=0; i < 4; i++) + p[i] = in.getDouble(); + BoundingBox b(p[0], p[1], p[2], p[3]); + if (c == 'a') + actions->embed(b); + else { + actions->bbox() = b; + actions->bbox().lock(); + } + } + } + else + c = 'r'; // no mode specifier => relative box parameters + + if (c == 'r') { + double w = in.getDouble(); + double h = in.getDouble(); + double d = in.getDouble(); + update_bbox(w, h, d, actions); + } +} + + +static void img (InputReader &in, SpecialActions *actions) { + double w = in.getDouble(); + double h = in.getDouble(); + string f = in.getString(); + update_bbox(w, h, 0, actions); + XMLElementNode *img = new XMLElementNode("image"); + img->addAttribute("x", actions->getX()); + img->addAttribute("y", actions->getY()); + img->addAttribute("width", w); + img->addAttribute("height", h); + img->addAttribute("xlink:href", f); + if (actions && !actions->getMatrix().isIdentity()) + img->addAttribute("transform", actions->getMatrix().getSVG()); + actions->appendToPage(img); +} + + +/** Evaluates and executes a dvisvgm special statement. + * @param[in] prefix special prefix read by the SpecialManager + * @param[in] is the special statement is read from this stream + * @param[in,out] in the raw text is read from this input buffer */ +bool DvisvgmSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + if (actions) { + StreamInputBuffer ib(is); + BufferInputReader in(ib); + string cmd = in.getWord(); + if (cmd == "raw") // raw + raw(in, actions); + else if (cmd == "bbox") // bbox [r] or bbox a + bbox(in, actions); + else if (cmd == "img") { // img + img(in, actions); + } + } + return true; +} + + +const char** DvisvgmSpecialHandler::prefixes () const { + static const char *pfx[] = {"dvisvgm:", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.h new file mode 100644 index 00000000000..93e726fe634 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/DvisvgmSpecialHandler.h @@ -0,0 +1,35 @@ +/************************************************************************* +** DvisvgmSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef DVISVGMSPECIALHANDLER_H +#define DVISVGMSPECIALHANDLER_H + +#include "SpecialHandler.h" + +class DvisvgmSpecialHandler : public SpecialHandler +{ + public: + const char* name () const {return "dvisvgm";} + const char* info () const {return "special set for embedding raw SVG snippets";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &in, SpecialActions *actions); +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.cpp new file mode 100644 index 00000000000..cbeb5600366 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.cpp @@ -0,0 +1,114 @@ +/************************************************************************* +** EPSFile.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "EPSFile.h" +#include "InputBuffer.h" +#include "InputReader.h" + +using namespace std; + + +/** Reads a little-endian 32-bit integer from the given input stream. */ +static UInt32 getUInt32 (istream &is) { + UInt32 value=0; + char buf[4]; + is.read(buf, 4); + for (int i=0; i < 4; i++) + value |= ((buf[i] & 255) << (8*i)); + return value; +} + + +static size_t getline (istream &is, char *line, size_t n) { + char buf[512]; + is.get(buf, min(n, (size_t)512)-1); + n = is.gcount(); + size_t linelen=0; + for (size_t i=0; i < n; i++) + if (isprint(buf[i])) + line[linelen++] = buf[i]; + line[linelen] = 0; + if (is.peek() == '\n') + is.get(); + else + is.ignore(numeric_limits::max(), '\n'); + return linelen; +} + + +EPSFile::EPSFile (const std::string& fname) : _ifs(fname.c_str(), ios::binary), _headerValid(false), _offset(0), _pslength(0) +{ + if (_ifs) { + if (getUInt32(_ifs) != 0xC6D3D0C5) // no binary header present? + _ifs.seekg(0, ios_base::beg); // go back to the first byte + else { + _offset = getUInt32(_ifs); // stream offset where PS part of the file begins + _pslength = getUInt32(_ifs); // length of PS section in bytes + _ifs.seekg(_offset, ios_base::beg); // continue reading at the beginning of the PS section + } + string str; + str += _ifs.get(); + str += _ifs.get(); + _headerValid = (str == "%!"); + _ifs.seekg(0, ios_base::beg); + } +} + + +/** Returns an input stream for the EPS file. The stream pointer is automatically moved + * to the beginning of the ASCII (PostScript) part of the file. */ +istream& EPSFile::istream () const { + _ifs.clear(); + _ifs.seekg(_offset, ios_base::beg); + return _ifs; +} + + +/** Extracts the bounding box information from the DSC header/footer (if present) + * @param[out] the extracted bounding box + * @return true if %%BoundingBox data could be read successfully */ +bool EPSFile::bbox (BoundingBox &box) const { + std::istream &is = EPSFile::istream(); + if (is) { + char buf[64]; + while (is) { + size_t linelen = getline(is, buf, 64); + if (strncmp(buf, "%%BoundingBox:", 14) == 0) { + CharInputBuffer ib(buf, linelen); + BufferInputReader ir(ib); + ir.skip(14); + ir.skipSpace(); + if (!ir.check("(atend)", true)) { + int val[4]; + for (int i=0; i < 4; i++) { + ir.skipSpace(); + ir.parseInt(val[i]); + } + box = BoundingBox(val[0], val[1], val[2], val[3]); + return true; + } + } + } + } + return false; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.h new file mode 100644 index 00000000000..60a4c007d39 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSFile.h @@ -0,0 +1,46 @@ +/************************************************************************* +** EPSFile.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef EPSFILE_H +#define EPSFILE_H + +#include +#include +#include "BoundingBox.h" +#include "types.h" + +class EPSFile +{ + public: + EPSFile (const std::string &fname); + std::istream& istream () const; + bool hasValidHeader () const {return _headerValid;} + bool bbox (BoundingBox &box) const; + UInt32 pslength () const {return _pslength;} + + private: + mutable std::ifstream _ifs; + bool _headerValid; ///< true if file has a valid header + UInt32 _offset; ///< stream offset where ASCII part of the file begins + UInt32 _pslength; ///< length of PS section (in bytes) +}; + +#endif + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.cpp new file mode 100644 index 00000000000..1bf0c81e9b2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.cpp @@ -0,0 +1,78 @@ +/************************************************************************* +** EPSToSVG.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "EPSFile.h" +#include "EPSToSVG.h" +#include "Message.h" +#include "MessageException.h" +#include "PsSpecialHandler.h" +#include "SVGOutputBase.h" + +#ifdef HAVE_CONFIG_H + #include "config.h" + #ifdef TARGET_SYSTEM + #define VERSION_STR VERSION " (" TARGET_SYSTEM ")" + #else + #define VERSION_STR VERSION + #endif +#else + #define VERSION_STR "" +#endif + + +using namespace std; + + +void EPSToSVG::convert () { + if (!Ghostscript().available()) + throw MessageException("Ghostscript is required to process the EPS file"); + EPSFile epsfile(_fname); + if (!epsfile.hasValidHeader()) + throw PSException("invalid EPS file"); + + BoundingBox bbox; + epsfile.bbox(bbox); + Message::mstream(false, Message::MC_PAGE_NUMBER) << "processing file " << _fname << '\n'; + Message::mstream().indent(1); + _svg.newPage(1); + // create a psfile special and forward it to the PsSpecialHandler + stringstream ss; + ss << "\"" << _fname << "\" " + "llx=" << bbox.minX() << " " + "lly=" << bbox.minY() << " " + "urx=" << bbox.maxX() << " " + "ury=" << bbox.maxY(); + PsSpecialHandler pshandler; + pshandler.process("psfile=", ss, this); + // output SVG file + _svg.setBBox(_bbox); + _svg.appendToDoc(new XMLCommentNode(" This file was generated by dvisvgm " VERSION_STR " ")); + _svg.write(_out.getPageStream(1, 1)); + string svgfname = _out.filename(1, 1); + Message::mstream(false, Message::MC_PAGE_SIZE) << "graphic size: " << bbox.width() << "pt" + " x " << bbox.height() << "pt" + " (" << bbox.width()/72.27*25.4 << "mm" + " x " << bbox.height()/72.27*25.4 << "mm)\n"; + Message::mstream(false, Message::MC_PAGE_WRITTEN) << "graphic written to " << (svgfname.empty() ? "" : svgfname) << '\n'; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.h new file mode 100644 index 00000000000..3d97ce465e2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EPSToSVG.h @@ -0,0 +1,68 @@ +/************************************************************************* +** EPSToSVG.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef EPSTOSVG_H +#define EPSTOSVG_H + +#include +#include "SpecialActions.h" +#include "SVGTree.h" + +struct SVGOutputBase; + +class EPSToSVG : protected SpecialActions +{ + public: + EPSToSVG (const std::string &fname, SVGOutputBase &out) : _fname(fname), _out(out), _x(0), _y(0) {} + void convert (); + void setTransformation (const Matrix &m); + void setPageSize (const std::string &name); + + protected: + // implement abstract base class SpecialActions + double getX () const {return _x;} + double getY () const {return _y;} + void setX (double x) {_x = x; _svg.setX(x);} + void setY (double y) {_y = y; _svg.setY(y);} + void finishLine () {} + void setColor (const Color &color) {_svg.setColor(color);} + Color getColor () const {return _svg.getColor();} + void setMatrix (const Matrix &m) {_svg.setMatrix(m);} + const Matrix& getMatrix () const {return _svg.getMatrix();} + void setBgColor (const Color &color) {} + void appendToPage (XMLNode *node) {_svg.appendToPage(node);} + void appendToDefs (XMLNode *node) {_svg.appendToDefs(node);} + void prependToPage (XMLNode *node) {_svg.prependToPage(node);} + void pushContextElement (XMLElementNode *node) {_svg.pushContextElement(node);} + void popContextElement () {_svg.popContextElement();} + void embed (const BoundingBox &bbox) {_bbox.embed(bbox);} + void embed (const DPair &p, double r=0) {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);} + BoundingBox& bbox () {return _bbox;} + BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;} + + private: + std::string _fname; ///< name of EPS file + SVGTree _svg; + SVGOutputBase &_out; + double _x, _y; + BoundingBox _bbox; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.cpp new file mode 100644 index 00000000000..dbd1fd4b169 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.cpp @@ -0,0 +1,231 @@ +/************************************************************************* +** EmSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "EmSpecialHandler.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "SpecialActions.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +EmSpecialHandler::EmSpecialHandler () : _linewidth(0.4), _actions(0) { +} + + +/** Computes the "cut vector" that is used to compute the line shape. + * Because each line has a width > 0 the actual shape of the line is a tetragon. + * The 4 vertices can be influenced by the cut parameter c that specifies + * a horizontal, vertical or orthogonal cut of a line end. Depending on c and the + * line's slope a cut vector v can be computed that, relatively to endpoint p, denotes + * the 2 vertices of that line end: v1=p+v and v2=p-v. + * @param[in] c cut direction ('h', 'v' or 'p') + * @param[in] v direction vector of line to be drawn + * @param[in] lw width of line to be drawn + * @return the "cut vector" */ +static DPair cut_vector (char c, const DPair &v, double lw) { + if (c == 'p') + return v.ortho()/v.length() * (lw/2); + DPair cut; + if (c == 'v' && v.x() != 0) { + double slope = v.y()/v.x(); + double h = sqrt(lw*lw*(1+slope*slope)); + cut.y(0.5*h); + } + else if (v.y() != 0) { // c == 'h' + double slope = v.x()/v.y(); + double h = sqrt(lw*lw*(1+slope*slope)); + double sgn = slope < 0 ? 1.0 : -1.0; + cut.x(0.5*h*sgn); + } + return cut; +} + + +/** Creates the SVG element that will a the line. + * @param[in] p1 first endpoint in TeX point units + * @param[in] p2 second endpoint in TeX point units + * @param[in] c1 cut method of first endpoint ('h', 'v' or 'p') + * @param[in] c2 cut method of second endpoint ('h', 'v' or 'p') + * @param[in] lw line width in TeX point units */ +static void create_line (const DPair &p1, const DPair &p2, char c1, char c2, double lw, SpecialActions *actions) { + XMLElementNode *node=0; + DPair dir = p2-p1; + if (dir.x() == 0 || dir.y() == 0 || (c1 == 'p' && c2 == 'p')) { + // draw regular line + node = new XMLElementNode("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().rgbString()); + // update bounding box + actions->embed(p1); + actions->embed(p2); + } + else { + // draw polygon + 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; + node = new XMLElementNode("polygon"); + 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->addAttribute("points", oss.str()); + if (actions->getColor() != Color::BLACK) + node->addAttribute("fill", actions->getColor().rgbString()); + // update bounding box + actions->embed(q11); + actions->embed(q12); + actions->embed(q21); + actions->embed(q22); + } + actions->appendToPage(node); +} + + +static double read_length (InputReader &in) { + struct Unit { + const char *name; + double factor; + } + units[] = { + {"pt", 1.0}, + {"pc", 12.0}, + {"in", 72.27}, + {"bp", 72.27/72}, + {"cm", 72.27/2.54}, + {"mm", 72.27/25.4}, + {"dd", 1238.0/1157}, + {"cc", 1238.0/1157*12}, + {"sp", 1.0/65536}, + {0, 0} + }; + double len = in.getDouble(); + in.skipSpace(); + for (Unit *p=units; p->name; p++) + if (in.check(p->name)) { + len *= p->factor; + break; + } + return len; +} + + +bool EmSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + // em:moveto => move graphic cursor to dvi cursor + // em:lineto => draw line from graphic cursor to dvi cursor, move graphic cursor to dvi cursor + // em:linewidth => set line width to + // em:point [,[,]] => defines point as (,); if and/or is missing, + // the corresponding dvi cursor coordinate is inserted + // and are lengths + // em:line [h|v|p], [h|v|p] [,] => draws line of width from point # to point # + // point number suffixes: + // h: cut line horizontally + // v: cut line vertically + // p: cut line orthogonally to line direction (default) + // if is omitted, the global line width is used + // + // supported length units: pt, pc, in, bp, cm, mm, dd, cc, sp + // default line width: 0.4pt + + if (actions) { + _actions = actions; // save pointer to SpecialActions for later use in endPage + StreamInputBuffer ib(is, 128); + BufferInputReader in(ib); + string cmd = in.getWord(); + if (cmd == "moveto") + _pos = DPair(actions->getX(), actions->getY()); + else if (cmd == "lineto") { + DPair p(actions->getX(), actions->getY()); + create_line(_pos, p, 'p', 'p', _linewidth, actions); + _pos = p; + } + else if (cmd == "linewidth") + _linewidth = read_length(in); + else if (cmd == "point") { + DPair p(actions->getX(), actions->getY()); + int n = in.getInt(); + if (in.getPunct() == ',') { + p.x(in.getDouble()); + if (in.getPunct() == ',') + p.y(in.getDouble()); + } + _points[n] = p; + } + else if (cmd == "line") { + int n1 = in.getInt(); + int c1 = 'p'; + if (isalpha(in.peek())) + c1 = in.get(); + in.getPunct(); + int n2 = in.getInt(); + int c2 = 'p'; + if (isalpha(in.peek())) + c2 = in.get(); + double lw = _linewidth; + if (in.getPunct() == ',') + lw = read_length(in); + map::iterator it1=_points.find(n1); + map::iterator it2=_points.find(n2); + if (it1 != _points.end() && it2 != _points.end()) + create_line(it1->second, it2->second, char(c1), char(c2), lw, actions); + else { + // Line endpoints havn't necessarily to be defined before + // a line definition. If a point wasn't defined yet we push the line + // in a wait list and process the lines at the end of the page. + _lines.push_back(Line(n1, n2, char(c1), char(c2), lw)); + } + } + } + return true; +} + + +/** This method is called at the end of a DVI page. Here we have to draw all pending + * lines that are still in the line list. All line endpoints must be defined until here. */ +void EmSpecialHandler::dviEndPage (unsigned pageno) { + if (_actions) { + FORALL(_lines, list::iterator, it) { + map::iterator pit1=_points.find(it->p1); + map::iterator pit2=_points.find(it->p2); + if (pit1 != _points.end() && pit2 != _points.end()) + create_line(pit1->second, pit2->second, it->c1, it->c2, it->width, _actions); + // all lines with still undefined points are ignored + } + } + // line and point definitions are local to a page + _lines.clear(); + _points.clear(); +} + + +const char** EmSpecialHandler::prefixes () const { + static const char *pfx[] = {"em:", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.h new file mode 100644 index 00000000000..56cb934b385 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/EmSpecialHandler.h @@ -0,0 +1,57 @@ +/************************************************************************* +** EmSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef EMSPECIALHANDLER_H +#define EMSPECIALHANDLER_H + +#include +#include +#include "Pair.h" +#include "SpecialHandler.h" + + +class EmSpecialHandler : public SpecialHandler, public DVIEndPageListener +{ + struct Line { + Line (int pp1, int pp2, char cc1, char cc2, double w) : p1(pp1), p2(pp2), c1(cc1), c2(cc2), width(w) {} + int p1, p2; ///< point numbers of line ends + char c1, c2; ///< cut type of line ends (h, v or p) + double width; ///< line width + }; + + public: + EmSpecialHandler (); + const char* name () const {return "em";} + const char* info () const {return "line drawing statements of the emTeX special set";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &in, SpecialActions *actions); + + protected: + void dviEndPage (unsigned pageno); + + private: + std::map _points; ///< points defined by special em:point + std::list _lines; ///< list of lines with undefined end points + double _linewidth; ///< global line width + DPair _pos; ///< current position of "graphic cursor" + SpecialActions *_actions; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.cpp new file mode 100644 index 00000000000..8c9aaf5bacb --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.cpp @@ -0,0 +1,248 @@ +/************************************************************************* +** FileFinder.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "FileFinder.h" +#include "FileSystem.h" +#include "FontMap.h" +#include "Message.h" + +#ifdef MIKTEX + #include "MessageException.h" + #include "MiKTeXCom.h" + static MiKTeXCom *miktex=0; +#else + #include +#endif + +// --------------------------------------------------- + +static bool _initialized = false; +static bool _mktex_enabled = false; + +// --------------------------------------------------- + +static const char* find_file (const std::string &fname); +static const char* find_mapped_file (std::string fname); +static const char* mktex (const std::string &fname); + + +/** Initializes the file finder. This function must be called before any other + * FileFinder function. + * @param[in] argv0 argv[0] of main() function + * @param[in] progname name of application using the FileFinder + * @param[in] enable_mktexmf if true, tfm and mf file generation is activated */ +void FileFinder::init (const char *argv0, const char *progname, bool enable_mktexmf) { + if (_initialized) + return; + + _mktex_enabled = enable_mktexmf; +#ifdef MIKTEX + miktex = new MiKTeXCom; +#else + kpse_set_program_name(argv0, progname); + // enable tfm and mf generation (actually invoked by calls of kpse_make_tex) + kpse_set_program_enabled(kpse_tfm_format, 1, kpse_src_env); + kpse_set_program_enabled(kpse_mf_format, 1, kpse_src_env); + kpse_make_tex_discard_errors = false; // don't suppress messages of mktexFOO tools +#ifdef TEXLIVEWIN32 + texlive_gs_init(); +#endif +#endif + _initialized = true; +} + + +/** Cleans up the FileFinder. This function must be called before leaving the + * applications main() function. */ +void FileFinder::finish () { +#ifdef MIKTEX + if (miktex) { + delete miktex; + miktex = 0; + } +#endif + _initialized = false; +} + + +/** Returns the version string of the underlying file searching library (kpathsea, MiKTeX) */ +std::string FileFinder::version () { +#ifdef MIKTEX + bool autoinit=false; + try { + if (!_initialized) { + init("", "", false); + autoinit = true; + } + string ret = miktex->getVersion(); + if (autoinit) + finish(); + return ret; + } + catch (MessageException &e) { + if (autoinit) + finish(); + return "not available"; + } +#else + if (const char *v = strrchr(KPSEVERSION, ' ')) + return v+1; +#endif + return "unknown"; +} + + +/** Determines filetype by the filename extension and calls kpse_find_file + * to actually look up the file. + * @param[in] fname name of file to look up + * @return file path on success, 0 otherwise */ +static const char* find_file (const std::string &fname) { + if (!_initialized) + return 0; + + size_t pos = fname.rfind('.'); + if (pos == std::string::npos) + return 0; // no extension => no search + const std::string ext = fname.substr(pos+1); // file extension + static std::string buf; +#ifdef MIKTEX + if (ext == "dll" || ext == "exe") { + // lookup dll and exe files in the MiKTeX bin directory first + buf = miktex->getBinDir() + "/" + fname; + if (FileSystem::exists(buf.c_str())) + return buf.c_str(); + } + return miktex->findFile(fname.c_str()); +#else +#ifdef TEXLIVEWIN32 + if (ext == "exe") { + // lookup exe files in directory where dvisvgm is located + if (const char *path = kpse_var_value("SELFAUTOLOC")) { + buf = std::string(path) + "/" + fname; + return FileSystem::exists(buf.c_str()) ? buf.c_str() : 0; + } + return 0; + } +#endif + static std::map types; + if (types.empty()) { + types["tfm"] = kpse_tfm_format; + types["pfb"] = kpse_type1_format; + types["vf"] = kpse_vf_format; + types["mf"] = kpse_mf_format; + types["ttc"] = kpse_truetype_format; + types["ttf"] = kpse_truetype_format; + types["map"] = kpse_fontmap_format; + types["sty"] = kpse_tex_format; + types["enc"] = kpse_enc_format; + types["pro"] = kpse_tex_ps_header_format; + types["sfd"] = kpse_sfd_format; + } + std::map::iterator it = types.find(ext.c_str()); + if (it == types.end()) + return 0; + + if (char *path = kpse_find_file(fname.c_str(), it->second, 0)) { + // In the current version of libkpathsea, each call of kpse_find_file produces + // a memory leak since the path buffer is not freed. I don't think we can do + // anything against it here... + buf = path; + std::free(path); + return buf.c_str(); + } + return 0; +#endif +} + + +/** Checks whether the given file is mapped to a different name and if the + * file can be found under this name. + * @param[in] fname name of file to look up + * @param[in] fontmap font mappings + * @return file path on success, 0 otherwise */ +static const char* find_mapped_file (std::string fname) { + size_t pos = fname.rfind('.'); + if (pos == std::string::npos) + return 0; + const std::string ext = fname.substr(pos+1); // file extension + const std::string base = fname.substr(0, pos); + if (const FontMap::Entry *entry = FontMap::instance().lookup(base)) { + const char *path=0; + if (entry->fontname.find('.') != std::string::npos) // does the mapped filename has an extension? + path = find_file(entry->fontname); // look for that file + else { // otherwise, use extension of unmapped file + fname = entry->fontname + "." + ext; + (path = find_file(fname)) || (path = mktex(fname)); + } + return path; + } + return 0; +} + + +/** Runs external mktexFOO tool to create missing tfm or mf file. + * @param[in] fname name of file to build + * @return file path on success, 0 otherwise */ +static const char* mktex (const std::string &fname) { + if (!_initialized) + return 0; + + size_t pos = fname.rfind('.'); + if (!_mktex_enabled || pos == std::string::npos) + return 0; + + std::string ext = fname.substr(pos+1); // file extension + if (ext != "tfm" && ext != "mf") + return 0; + + const char *path = 0; +#ifdef MIKTEX + // maketfm and makemf are located in miktex/bin which is in the search PATH + string toolname = (ext == "tfm" ? "miktex-maketfm" : "miktex-makemf"); + system((toolname+".exe "+fname).c_str()); + path = find_file(fname); +#else + kpse_file_format_type type = (ext == "tfm" ? kpse_tfm_format : kpse_mf_format); + path = kpse_make_tex(type, fname.c_str()); +#endif + return path; +} + + +/** Searches a file in the TeX directory tree. + * If the file doesn't exist, maximal two further steps are applied + * (if "extended" is true): + * - checks whether the filename is mapped to a different name and returns + * the path to that name + * - in case of tfm or mf files: invokes the external mktextfm/mktexmf tool + * to create the missing file + * @param[in] fname name of file to look up + * @param[in] extended if true, use fontmap lookup and mktexFOO calls + * @return path to file on success, 0 otherwise */ +const char* FileFinder::lookup (const std::string &fname, bool extended) { + const char *path; + if ((path = find_file(fname)) || (extended && ((path = find_mapped_file(fname)) || (path = mktex(fname))))) + return path; + return 0; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.h new file mode 100644 index 00000000000..f0d8dbba001 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileFinder.h @@ -0,0 +1,34 @@ +/************************************************************************* +** FileFinder.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef KPSFILEFINDER_H +#define KPSFILEFINDER_H + +#include + +struct FileFinder +{ + static void init (const char *argv0, const char *progname, bool enable_mktexmf); + static void finish (); + static std::string version (); + static const char* lookup (const std::string &fname, bool extended=true); +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.cpp new file mode 100644 index 00000000000..2d7e676772a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.cpp @@ -0,0 +1,257 @@ +/************************************************************************* +** FilePath.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "FilePath.h" +#include "FileSystem.h" +#include "MessageException.h" +#include "macros.h" + +using namespace std; + + +/** Removes redundant slashes from a given path. */ +static string& single_slashes (string &str) { + size_t pos=0; + while ((pos = str.find("//", pos)) != string::npos) + str.replace(pos, 2, "/"); + return str; +} + + +#ifdef __WIN32__ +static char strip_drive_letter (string &path) { + char letter = 0; + if (path.length() >= 2 && path[1] == ':' && isalpha(path[0])) { + letter = tolower(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) + ":").c_str())) { + path.insert(0, FileSystem::getcwd()+"/"); + strip_drive_letter(path); + } + else + throw MessageException("drive " + string(1, target_drive) + ": not accessible"); + } + } + } + return target_drive; +} + + +static void tolower (string &str) { + for (size_t i=0; i < str.length(); ++i) + str[i] = tolower(str[i]); +} +#endif + + +/** Constructs a FilePath object from a given path. Relative paths are + * relative to the current working directory. + * @param[in] path absolute or relative path to a file or directory */ +FilePath::FilePath (const string &path) { + init(path, !FileSystem::isDirectory(path.c_str()), FileSystem::getcwd()); +} + + +/** Constructs a FilePath object. + * @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 + * @param[in] current_dir if 'path' is a relative path expression it will be related to 'current_dir' */ +FilePath::FilePath (const string &path, bool isfile, string current_dir) { + init(path, isfile, current_dir); +} + + +/** Initializes a FilePath object. This method should be called by the constructors only. + * @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 + * @param[in] current_dir if 'path' is a relative path expression it will be related to 'current_dir' */ +void FilePath::init (string path, bool isfile, string current_dir) { + single_slashes(path); + single_slashes(current_dir); +#ifdef __WIN32__ + tolower(path); + path = FileSystem::adaptPathSeperators(path); + _drive = strip_drive_letter(path); +#endif + if (isfile) { + size_t pos = path.rfind('/'); + _fname = path.substr((pos == string::npos) ? 0 : pos+1); + if (pos != string::npos) + path.erase(pos); + else + path.clear(); + } + if (current_dir.empty()) + current_dir = FileSystem::getcwd(); +#ifdef __WIN32__ + tolower(current_dir); + _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 + "/"); + string elem; + FORALL (path, string::const_iterator, it) { + if (*it == '/') { + add(elem); + elem.clear(); + } + else + elem += *it; + } + add(elem); +} + + +/** Adds a location step to the current path. */ +void FilePath::add (const string &dir) { + if (dir == ".." && !_dirs.empty()) + _dirs.pop_back(); + else if (dir.length() > 0 && dir != ".") + _dirs.push_back(dir); +} + + +/** Returns the suffix of the filename. If FilePath represents the + * location of a directory (and not of a file) an empty string + * is returned. */ +string FilePath::suffix () const { + size_t start = 0; + // ignore leading dots + while (start < _fname.length() && _fname[start] == '.') + start++; + string sub = _fname.substr(start); + size_t pos = sub.rfind('.'); + if (pos != string::npos && pos < sub.length()-1) + return sub.substr(pos+1); + return ""; +} + + +/** Changes the suffix of the filename. If FilePath represents the + * location of a directory (and not of a file) nothing happens. + * @param[in] s new suffix */ +void FilePath::suffix (const string &s) { + if (!_fname.empty()) { + string current_suffix = suffix(); + if (!current_suffix.empty()) + _fname.erase(_fname.length()-current_suffix.length()-1); + _fname += "."+s; + } +} + + +/** Returns the filename without suffix. + * Example: FilePath("/a/b/c.def", true) == "c" */ +string FilePath::basename () const { + if (!_fname.empty()) { + size_t len = suffix().length(); + if (len > 0) + len++; // strip dot too + return _fname.substr(0, _fname.length()-len); + } + return ""; +} + + +/** Returns the absolute path string of this FilePath. + * @param[in] with_filename if false, the filename is omitted + * @return the absolute path string */ +string FilePath::absolute (bool with_filename) const { + string path; + FORALL (_dirs, ConstIterator, it) { + path += "/" + *it; + } + 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); +} + + +/** Returns a path string of this FilePath relative to reldir. If we wanted to + * navigate from /a/b/c/d to /a/b/e/f using the shell command "cd", we could do that + * with the relative path argument: "cd ../../e/f". This function returns such a relative + * path. Example: FilePath("/a/b/e/f").relative("/a/b/c/d") => "../../e/f". + * @param[in] reldir absolute path to a directory + * @param[in] with_filename if false, the filename is omitted + * @return the relative path string */ +string FilePath::relative (string reldir, bool with_filename) const { + if (reldir.empty()) + reldir = FileSystem::getcwd(); +#ifdef __WIN32__ + adapt_current_path(reldir, _drive); +#endif + if (reldir[0] != '/') + return absolute(); + FilePath rel(reldir, false); + string path; +#ifdef __WIN32__ + if (rel._drive && _drive && rel._drive != _drive) + path += string(1, _drive) + ":"; +#endif + ConstIterator i = _dirs.begin(); + ConstIterator j = rel._dirs.begin(); + while (i != _dirs.end() && j != rel._dirs.end() && *i == *j) + ++i, ++j; + for (; j != rel._dirs.end(); ++j) + path += "../"; + for (; i != _dirs.end(); ++i) + path += *i + "/"; + if (!path.empty()) + path.erase(path.length()-1, 1); // remove trailing slash + if (with_filename && !_fname.empty()) { + if (!path.empty() && path != "/") + path += "/"; + path += _fname; + } + if (path.empty()) + path = "."; + return single_slashes(path); +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.h new file mode 100644 index 00000000000..5bd3fdf98e2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FilePath.h @@ -0,0 +1,59 @@ +/************************************************************************* +** FilePath.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FILEPATH_H +#define FILEPATH_H + +#include +#include + +class FilePath +{ + typedef std::vector Directories; + typedef Directories::iterator Iterator; + typedef Directories::const_iterator ConstIterator; + public: + FilePath (const std::string &path); + FilePath (const std::string &path, bool isfile, std::string current_dir=""); + std::string absolute (bool with_filename=true) const; + std::string relative (std::string reldir="", bool with_filename=true) const; + std::string basename () const; + std::string suffix () const; + void suffix (const std::string &s); + size_t depth () const {return _dirs.size();} + bool isFile () const {return !_fname.empty();} + bool empty () const {return _dirs.empty() && _fname.empty();} + const std::string& filename () const {return _fname;} + void filename (const std::string &fname) {_fname = fname;} + + protected: + void init (std::string path, bool isfile, std::string current_dir); + void add (const std::string &elem); + + private: + Directories _dirs; + std::string _fname; +#ifdef __WIN32__ + char _drive; +#endif +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.cpp new file mode 100644 index 00000000000..67e48595db9 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.cpp @@ -0,0 +1,333 @@ +/************************************************************************* +** FileSystem.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "FileSystem.h" +#include "macros.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + + +using namespace std; + +#ifdef __WIN32__ + #include + #include + const char *FileSystem::DEVNULL = "nul"; + const char FileSystem::PATHSEP = '\\'; + #define unlink _unlink +#else + #include + #include + #include + #include + const char *FileSystem::DEVNULL = "/dev/null"; + const char FileSystem::PATHSEP = '/'; +#endif + + +bool FileSystem::remove (const string &fname) { + return unlink(fname.c_str()) == 0; +} + + +/** Copies a file. + * @param[in] src path of file to copy + * @param[in] dest path of target file + * @param[in] remove_src remove file 'src' if true + * @return true on success */ +bool FileSystem::copy (const string &src, const string &dest, bool remove_src) { + ifstream ifs(src.c_str(), ios::in|ios::binary); + ofstream ofs(dest.c_str(), ios::out|ios::binary); + if (ifs && ofs) { + ofs << ifs.rdbuf(); + if (!ifs.fail() && !ofs.fail() && remove_src) { + ofs.close(); + ifs.close(); + return remove(src); + } + else + return !remove_src; + } + return false; +} + + +bool FileSystem::rename (const string &oldname, const string &newname) { + return ::rename(oldname.c_str(), newname.c_str()) == 0; +} + + +UInt64 FileSystem::filesize (const string &fname) { +#ifdef __WIN32__ + // unfortunately, stat doesn't work properly under Windows + // so we have to use this freaky code + WIN32_FILE_ATTRIBUTE_DATA attr; + GetFileAttributesExA(fname.c_str(), GetFileExInfoStandard, &attr); + return (static_cast(attr.nFileSizeHigh) << (8*sizeof(attr.nFileSizeLow))) | attr.nFileSizeLow; +#else + struct stat attr; + return (stat(fname.c_str(), &attr) == 0) ? attr.st_size : 0; +#endif +} + + +string FileSystem::adaptPathSeperators (string path) { + for (size_t i=0; i < path.length(); i++) + if (path[i] == PATHSEP) + path[i] = '/'; + return path; +} + + +string FileSystem::getcwd () { + char buf[1024]; +#ifdef __WIN32__ + return adaptPathSeperators(_getcwd(buf, 1024)); +#else + return ::getcwd(buf, 1024); +#endif +} + + +/** Changes the work directory. + * @param[in] path to new work directory + * @return true on success */ +bool FileSystem::chdir (const char *dir) { + bool success = false; + if (dir) { +#ifdef __WIN32__ + success = (_chdir(dir) == 0); +#else + success = (chdir(dir) == 0); +#endif + } + return success; +} + + +/** Returns the user's home directory. */ +const char* FileSystem::userdir () { +#ifdef __WIN32__ + const char *drive=getenv("HOMEDRIVE"); + const char *path=getenv("HOMEPATH"); + if (drive && path) { + static string ret = string(drive)+path; + if (!ret.empty()) + return ret.c_str(); + } + return 0; +#else + const char *dir=getenv("HOME"); + if (!dir) { + if (const char *user=getenv("USER")) { + if (struct passwd *pw=getpwnam(user)) + dir = pw->pw_dir; + } + } + return dir; +#endif +} + + +/** Private wrapper function for mkdir: creates a single folder. + * @param[in] dir folder name + * @return true on success */ +static bool s_mkdir (const char *dir) { + bool success = true; + if (!FileSystem::exists(dir)) { +#ifdef __WIN32__ + success = (_mkdir(dir) == 0); +#else + success = (mkdir(dir, 0776) == 0); +#endif + } + return success; +} + + +static bool inline s_rmdir (const char *dir) { +#ifdef __WIN32__ + return (_rmdir(dir) == 0); +#else + return (rmdir(dir) == 0); +#endif +} + + +/** Removes leading and trailing whitespace from a string. */ +static string trim (const string &str) { + int first=0, last=str.length()-1; + while (isspace(str[first])) + first++; + while (isspace(str[last])) + last--; + return str.substr(first, last-first+1); +} + + +/** Creates a new folder relative to the current work directory. If necessary, + * the parent folders are also created. + * @param[in] dir single folder name or path to folder + * @return true if folder(s) could be created */ +bool FileSystem::mkdir (const char *dir) { + bool success = false; + if (dir) { + success = true; + const string dirstr = adaptPathSeperators(trim(dir)); + for (size_t pos=1; success && (pos = dirstr.find('/', pos)) != string::npos; pos++) + success &= s_mkdir(dirstr.substr(0, pos).c_str()); + success &= s_mkdir(dirstr.c_str()); + } + return success; +} + + +/** Removes a directory and its contents. + * @param[in] dirname path to directory + * @return true on success */ +bool FileSystem::rmdir (const char *dirname) { + bool ok = false; + if (dirname && isDirectory(dirname)) { + ok = true; +#ifdef __WIN32__ + string pattern = string(dirname) + "/*"; + WIN32_FIND_DATA data; + HANDLE h = FindFirstFile(pattern.c_str(), &data); + bool ready = (h == INVALID_HANDLE_VALUE); + while (!ready && ok) { + const char *fname = data.cFileName; + string path = string(dirname) + "/" + fname; + if (isDirectory(path.c_str())) { + if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) + ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); + } + else if (isFile(path.c_str())) + ok = remove(path); + else + ok = false; + ready = !FindNextFile(h, &data); + } + FindClose(h); +#else + if (DIR *dir = opendir(dirname)) { + struct dirent *ent; + while ((ent = readdir(dir)) && ok) { + const char *fname = ent->d_name; + string path = string(fname) + "/" + fname; + if (isDirectory(path.c_str())) { + if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) + ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); + } + else if (isFile(path.c_str())) + ok = remove(path); + else + ok = false; + } + closedir(dir); + } +#endif + ok = s_rmdir(dirname); + } + return ok; +} + + +/** Checks if a file or directory exits. */ +bool FileSystem::exists (const char *fname) { + if (!fname) + return false; +#ifdef __WIN32__ + return GetFileAttributes(fname) != INVALID_FILE_ATTRIBUTES; +#else + struct stat attr; + return stat(fname, &attr) == 0; +#endif +} + + +/** Returns true if 'fname' references a directory. */ +bool FileSystem::isDirectory (const char *fname) { + if (!fname) + return false; +#ifdef __WIN32__ + return GetFileAttributes(fname) & FILE_ATTRIBUTE_DIRECTORY; +#else + struct stat attr; + return stat(fname, &attr) == 0 && S_ISDIR(attr.st_mode); +#endif +} + + +/** Returns true if 'fname' references a file. */ +bool FileSystem::isFile (const char *fname) { + if (!fname) + return false; +#ifdef __WIN32__ + ifstream ifs(fname); + return ifs; +#else + struct stat attr; + return stat(fname, &attr) == 0 && S_ISREG(attr.st_mode); +#endif +} + + +int FileSystem::collect (const char *dirname, vector &entries) { + entries.clear(); +#ifdef __WIN32__ + string pattern = string(dirname) + "/*"; + WIN32_FIND_DATA data; + HANDLE h = FindFirstFile(pattern.c_str(), &data); + bool ready = (h == INVALID_HANDLE_VALUE); + while (!ready) { + string fname = data.cFileName; + string path = string(dirname)+"/"+fname; + string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; + if (fname != "." && fname != "..") + entries.push_back(typechar+fname); + ready = !FindNextFile(h, &data); + } + FindClose(h); +#else + if (DIR *dir = opendir(dirname)) { + struct dirent *ent; + while ((ent = readdir(dir))) { + string fname = ent->d_name; + string path = string(dirname)+"/"+fname; + string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; + if (fname != "." && fname != "..") + entries.push_back(typechar+fname); + } + closedir(dir); + } +#endif + return entries.size(); +} + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.h new file mode 100644 index 00000000000..c920a5046e6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FileSystem.h @@ -0,0 +1,48 @@ +/************************************************************************* +** FileSystem.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FILESYSTEM_H +#define FILESYSTEM_H + +#include +#include +#include "types.h" + +struct FileSystem +{ + static bool remove (const std::string &fname); + static bool rename (const std::string &oldname, const std::string &newname); + static bool copy (const std::string &src, const std::string &dest, bool remove_src=false); + static UInt64 filesize (const std::string &fname); + static std::string adaptPathSeperators (std::string path); + static std::string getcwd (); + static bool chdir (const char *dir); + static bool exists (const char *file); + static bool mkdir (const char *dir); + static bool rmdir (const char *fname); + static int collect (const char *dirname, std::vector &entries); + static bool isDirectory (const char *fname); + static bool isFile (const char *fname); + static const char* userdir (); + static const char* DEVNULL; + static const char PATHSEP; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.cpp new file mode 100644 index 00000000000..45950818ea3 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.cpp @@ -0,0 +1,453 @@ +/************************************************************************* +** Font.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "FileFinder.h" +#include "FileSystem.h" +#include "Font.h" +#include "FontEngine.h" +#include "FontMap.h" +#include "GFGlyphTracer.h" +#include "Glyph.h" +#include "Message.h" +#include "MetafontWrapper.h" +#include "TFM.h" +#include "VFReader.h" +#include "SignalHandler.h" +#include "Subfont.h" +#include "SVGTree.h" +#include "macros.h" + +using namespace std; + + +/** Returns true if 'unicode' is a valid unicode value in XML documents. + * XML version 1.0 doesn't allow various unicode character references + * ( for example). */ +static bool valid_unicode (UInt32 unicode) { + UInt32 ranges[] = { + 0x0000, 0x0020, + 0x007f, 0x0084, + 0x0086, 0x009f, + 0xfdd0, 0xfddf + }; + for (int i=0; i < 4; i++) + if (unicode >= ranges[2*i] && unicode <= ranges[2*i+1]) + return false; + return true; +} + + +UInt32 Font::unicode (UInt32 c) const { + // @@ this should be optimized :-) + return valid_unicode(c) ? c : 0x3400+c; +} + + +/////////////////////////////////////////////////////////////////////////////////////// + + +TFMFont::TFMFont (string name, UInt32 cs, double ds, double ss) + : _metrics(0), _fontname(name), _checksum(cs), _dsize(ds), _ssize(ss) +{ +} + + +TFMFont::~TFMFont () { + delete _metrics; +} + + +/** Returns a font metrics object for the current font. + * @throw FontException if TFM file can't be found */ +const FontMetric* TFMFont::getMetrics () const { + if (!_metrics) { + try { + _metrics = FontMetric::read(_fontname.c_str()); + if (!_metrics) { + _metrics = new NullFontMetric; + Message::wstream(true) << "can't find "+_fontname+".tfm\n"; + } + } + catch (FontMetricException &e) { + _metrics = new NullFontMetric; + Message::wstream(true) << e.what() << " in " << _fontname << ".tfm\n"; + } + } + return _metrics; +} + + +double TFMFont::charWidth (int c) const { + double w = getMetrics() ? getMetrics()->getCharWidth(c) : 0; + if (style()) + w *= style()->extend; + return w; +} + + +double TFMFont::italicCorr (int c) const { + double w = getMetrics() ? getMetrics()->getItalicCorr(c) : 0; + if (style()) + w *= style()->extend; + return w; +} + + +double TFMFont::charDepth (int c) const {return getMetrics() ? getMetrics()->getCharDepth(c) : 0;} +double TFMFont::charHeight (int c) const {return getMetrics() ? getMetrics()->getCharHeight(c) : 0;} + + +bool TFMFont::verifyChecksums () const { + if (_checksum != 0 && getMetrics() && getMetrics()->getChecksum() != 0) + return _checksum == getMetrics()->getChecksum(); + return true; +} + +////////////////////////////////////////////////////////////////////////////// + +// static class variables +bool PhysicalFont::KEEP_TEMP_FILES = false; +const char *PhysicalFont::CACHE_PATH = 0; +double PhysicalFont::METAFONT_MAG = 4; +FontCache PhysicalFont::_cache; + + +Font* PhysicalFont::create (string name, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type) { + return new PhysicalFontImpl(name, 0, checksum, dsize, ssize, type); +} + + +Font* PhysicalFont::create (string name, int fontindex, UInt32 checksum, double dsize, double ssize) { + return new PhysicalFontImpl(name, fontindex, checksum, dsize, ssize, PhysicalFont::TTC); +} + + +const char* PhysicalFont::path () const { + string ext; + switch (type()) { + case PFB: ext = "pfb"; break; + case TTC: ext = "ttc"; break; + case TTF: ext = "ttf"; break; + case MF : ext = "mf"; break; + } + return FileFinder::lookup(name()+"."+ext); +} + + +/** Returns the number of units per EM. The EM square is the virtual area a glyph is designed on. + * All coordinates used to specify portions of the glyph are relative to the origin (0,0) at the + * lower left corner of this square, while the upper right corner is located at (m,m), where m + * is an integer value defined with the font, and returned by this function. */ +int PhysicalFont::unitsPerEm() const { + if (type() == MF) + return 1000; + FontEngine::instance().setFont(*this); + return FontEngine::instance().getUnitsPerEM(); +} + + +int PhysicalFont::hAdvance () const { + if (type() == MF) + return 0; + FontEngine::instance().setFont(*this); + return FontEngine::instance().getHAdvance(); +} + + +double PhysicalFont::hAdvance (int c) const { + if (type() == MF) + return unitsPerEm()*charWidth(c)/designSize(); + FontEngine::instance().setFont(*this); + if (FontEncoding *enc = encoding()) + return FontEngine::instance().getHAdvance(enc->getEntry(c)); + if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) + if (Subfont *sf = map_entry->subfont) + c = sf->decode(c); + return FontEngine::instance().getHAdvance(c); +} + + +string PhysicalFont::glyphName (int c) const { + if (type() == MF) + return ""; + FontEngine::instance().setFont(*this); + if (FontEncoding *enc = encoding()) { + const char *name = enc->getEntry(c); + return name ? name : ""; + } + if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) + if (Subfont *sf = map_entry->subfont) + c = sf->decode(c); + return FontEngine::instance().getGlyphName(c); +} + + +int PhysicalFont::ascent () const { + if (type() == MF) + return 0; + FontEngine::instance().setFont(*this); + return FontEngine::instance().getAscender(); +} + + +int PhysicalFont::descent () const { + if (type() == MF) + return 0; + FontEngine::instance().setFont(*this); + return FontEngine::instance().getDescender(); +} + + +/** Extracts the glyph outlines of a given character. + * @param[in] c character code of requested glyph + * @param[out] glyph path segments of the glyph outline + * @param[in] cb optional callback object for tracer class + * @return true if outline could be computed */ +bool PhysicalFont::getGlyph (int c, GraphicPath &glyph, GFGlyphTracer::Callback *cb) const { + if (type() == MF) { + const Glyph *cached_glyph=0; + if (CACHE_PATH) { + _cache.write(CACHE_PATH); + _cache.read(name().c_str(), CACHE_PATH); + cached_glyph = _cache.getGlyph(c); + } + if (cached_glyph) { + glyph = *cached_glyph; + return true; + } + else { + string gfname; + if (createGF(gfname)) { + try { + double ds = getMetrics() ? getMetrics()->getDesignSize() : 1; + GFGlyphTracer tracer(gfname, unitsPerEm()/ds, cb); + tracer.setGlyph(glyph); + tracer.executeChar(c); + glyph.closeOpenSubPaths(); + if (CACHE_PATH) + _cache.setGlyph(c, glyph); + return true; + } + catch (GFException &e) { + // @@ print error message + } + } + else { + Message::wstream(true) << "failed creating " << name() << ".gf\n"; + } + } + } + else { // PFB or TTF + bool ok=true; + FontEngine::instance().setFont(*this); + if (FontEncoding *enc = encoding()) { + if (const char *encname = enc->getEntry(c)) + ok = FontEngine::instance().traceOutline(encname, glyph, false); + } + else { + if (const FontMap::Entry *map_entry = FontMap::instance().lookup(name())) + if (Subfont *sf = map_entry->subfont) + c = sf->decode(c); + ok = FontEngine::instance().traceOutline(c, glyph, false); + } + glyph.closeOpenSubPaths(); + return ok; + } + return false; +} + + +/** Creates a GF file for this font object. + * @param[out] gfname name of GF font file + * @return true on success */ +bool PhysicalFont::createGF (string &gfname) const { + SignalHandler::instance().check(); + gfname = name()+".gf"; + MetafontWrapper mf(name()); + bool ok = mf.make("ljfour", METAFONT_MAG); // call Metafont if necessary + return ok && mf.success() && getMetrics(); +} + + +/** Traces all glyphs of the current font and stores them in the cache. If caching is disabled, nothing happens. + * @param[in] includeCached if true, glyphs already cached are traced again + * @param[in] cb optional callback methods called by the tracer + * @return number of glyphs traced */ +int PhysicalFont::traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb) const { + int count = 0; + if (type() == MF && CACHE_PATH) { + if (const FontMetric *metrics = getMetrics()) { + int fchar = metrics->firstChar(); + int lchar = metrics->lastChar(); + string gfname; + Glyph glyph; + if (createGF(gfname)) { + _cache.read(name().c_str(), CACHE_PATH); + double ds = getMetrics() ? getMetrics()->getDesignSize() : 1; + GFGlyphTracer tracer(gfname, unitsPerEm()/ds, cb); + tracer.setGlyph(glyph); + for (int i=fchar; i <= lchar; i++) { + if (includeCached || !_cache.getGlyph(i)) { + glyph.newpath(); + tracer.executeChar(i); + glyph.closeOpenSubPaths(); + _cache.setGlyph(i, glyph); + ++count; + } + } + _cache.write(CACHE_PATH); + } + } + } + return count; +} + + +/** Computes the exact bounding box of a glyph. + * @param[in] c character code of the glyph + * @param[out] bbox the computed bounding box + * @param[in] optional calback object forwarded to the tracer + * @return true if the box could be computed successfully */ +bool PhysicalFont::getGlyphBox(int c, BoundingBox& bbox, GFGlyphTracer::Callback* cb) const { + Glyph glyph; + if (getGlyph(c, glyph, cb)) { + glyph.computeBBox(bbox); + double s = scaledSize()/unitsPerEm(); + bbox.scale(s, s); + return true; + } + return false; +} + + +Font* VirtualFont::create (string name, UInt32 checksum, double dsize, double ssize) { + return new VirtualFontImpl(name, checksum, dsize, ssize); +} + + +////////////////////////////////////////////////////////////////////////////// + + +PhysicalFontImpl::PhysicalFontImpl (string name, int fontindex, UInt32 cs, double ds, double ss, PhysicalFont::Type type) + : TFMFont(name, cs, ds, ss), _filetype(type), _fontIndex(fontindex), _style(0), _charmap(0) +{ +} + + +PhysicalFontImpl::~PhysicalFontImpl () { + if (CACHE_PATH) + _cache.write(CACHE_PATH); + if (!KEEP_TEMP_FILES) + tidy(); + delete _style; + delete _charmap; +} + + +UInt32 PhysicalFontImpl::unicode (UInt32 c) const { + if (type() == MF) + return Font::unicode(c); + + if (_charmap == 0) { + FontEngine &fe = FontEngine::instance(); + if (fe.setFont(*this)) { + _charmap = new map; + fe.buildTranslationMap(*_charmap); + } + } + typedef map::const_iterator ConstIterator; + ConstIterator it = _charmap->find(c); + if (it != _charmap->end()) + return it->second; + + // No unicode equivalent found in font file. + // Now we should look for a smart alternative but at the moment + // it's sufficient to simply choose a valid unused unicode value... + map reverse_map; + FORALL(*_charmap, ConstIterator, it) + reverse_map[it->second] = it->first; + // can we use charcode itself as unicode replacement? + if (valid_unicode(c) && (reverse_map.empty() || reverse_map.find(c) != reverse_map.end())) + return c; + return 0x3400+c; +} + + +void PhysicalFontImpl::tidy () const { + if (type() == MF) { + const char *ext[] = {"gf", "tfm", "log", 0}; + for (const char **p=ext; *p; ++p) { + if (FileSystem::exists((name()+"."+(*p)).c_str())) + FileSystem::remove(name()+"."+(*p)); + } + } +} + + +void PhysicalFontImpl::setStyle (double bold, double extend, double slant) { + if (_style) { + _style->bold = bold; + _style->extend = extend; + _style->slant = slant; + } + else if (bold != 0 || extend != 1 || slant != 0) + _style = new Style(bold, extend, slant); +} + + +////////////////////////////////////////////////////////////////////////////// + +VirtualFontImpl::VirtualFontImpl (string name, UInt32 cs, double ds, double ss) + : TFMFont(name, cs, ds, ss) +{ +} + + +VirtualFontImpl::~VirtualFontImpl () { + // delete dvi vectors received by VFReaderAction + for (map::iterator i=_charDefs.begin(); i != _charDefs.end(); ++i) + delete i->second; +} + + +const char* VirtualFontImpl::path () const { + return FileFinder::lookup(name()+".vf"); +} + + +void VirtualFontImpl::assignChar (UInt32 c, DVIVector *dvi) { + if (dvi) { + if (_charDefs.find(c) == _charDefs.end()) + _charDefs[c] = dvi; + else + delete dvi; + } +} + + +const vector* VirtualFontImpl::getDVI (int c) const { + map::const_iterator it = _charDefs.find(c); + return (it == _charDefs.end() ? 0 : it->second); +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.h new file mode 100644 index 00000000000..1f04140d4d2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Font.h @@ -0,0 +1,280 @@ +/************************************************************************* +** Font.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONT_H +#define FONT_H + +#include +#include +#include +#include "FontCache.h" +#include "FontEncoding.h" +#include "GFGlyphTracer.h" +#include "Glyph.h" +#include "GraphicPath.h" +#include "MessageException.h" +#include "VFActions.h" +#include "VFReader.h" +#include "types.h" + +struct FontMetric; + + +/** Abstract base for all font classes. */ +struct Font { + struct Style { + Style () : bold(0), extend(0), slant(0) {} + Style (float b, float e, float s) : bold(b), extend(e), slant(s) {} + double bold; ///< stroke width in pt used to draw the glyph outlines + double extend; ///< factor to strech/shrink the glyphs horizontally + double slant; ///< horizontal slanting/skewing value (= tan(phi)) + }; + + virtual ~Font () {} + virtual Font* clone (double ds, double sc) const =0; + virtual const Font* uniqueFont () const =0; + virtual std::string name () const =0; + virtual double designSize () const =0; + virtual double scaledSize () const =0; + virtual double scaleFactor () const {return scaledSize()/designSize();} + virtual double charWidth (int c) const =0; + virtual double charDepth (int c) const =0; + virtual double charHeight (int c) const =0; + virtual double italicCorr (int c) const =0; + virtual const FontMetric* getMetrics () const =0; + virtual const char* path () const =0; + virtual FontEncoding* encoding () const {return FontEncoding::encoding(name());} + virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const =0; + virtual UInt32 unicode (UInt32 c) const; + virtual void tidy () const {} + virtual bool verifyChecksums () const {return true;} + virtual int fontIndex () const {return 0;} + virtual const Style* style () const {return 0;} +}; + + +/** Empty font without any glyphs. Instances of this class are used + * if no physical or virtual font file can be found. + * The metric values returned by the member functions are based on cmr10. */ +struct EmptyFont : public Font +{ + public: + EmptyFont (std::string name) : _fontname(name) {} + Font* clone (double ds, double sc) const {return new EmptyFont(*this);} + const Font* uniqueFont () const {return this;} + std::string name () const {return _fontname;} + double designSize () const {return 10;} // cmr10 design size in pt + double scaledSize () const {return 10;} // cmr10 scaled size in pt + double charWidth (int c) const {return 9.164;} // width of cmr10's 'M' in pt + double charHeight (int c) const {return 6.833;} // height of cmr10's 'M' in pt + double charDepth (int c) const {return 0;} + double italicCorr (int c) const {return 0;} + const FontMetric* getMetrics () const {return 0;} + const char* path () const {return 0;} + bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const {return false;} + + private: + std::string _fontname; +}; + + +/** Interface for all physical fonts. */ +class PhysicalFont : public virtual Font +{ + public: + enum Type {MF, PFB, TTC, TTF}; + static Font* create (std::string name, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type); + static Font* create (std::string name, int fontindex, UInt32 checksum, double dsize, double ssize); + virtual Type type () const =0; + virtual bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const; + virtual bool getGlyphBox (int c, BoundingBox &bbox, GFGlyphTracer::Callback *cb=0) const; + virtual int hAdvance () const; + virtual double hAdvance (int c) const; + std::string glyphName (int c) const; + virtual int unitsPerEm () const; + virtual int ascent () const; + virtual int descent () const; + virtual int traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *cb=0) const; + const char* path () const; + virtual void setStyle (double bold, double extend, double slant) {} + + protected: + bool createGF (std::string &gfname) const; + + public: + static bool KEEP_TEMP_FILES; + static const char *CACHE_PATH; ///< path to cache directory (0 if caching is disabled) + static double METAFONT_MAG; ///< magnification factor for Metafont calls + + protected: + static FontCache _cache; +}; + + +/** Interface for all virtual fonts. */ +class VirtualFont : public virtual Font +{ + friend class FontManager; + public: + typedef std::vector DVIVector; + + public: + static Font* create (std::string name, UInt32 checksum, double dsize, double ssize); + virtual const DVIVector* getDVI (int c) const =0; + bool getGlyph (int c, Glyph &glyph, GFGlyphTracer::Callback *cb=0) const {return false;} + + protected: + virtual void assignChar (UInt32 c, DVIVector *dvi) =0; +}; + + +class TFMFont : public virtual Font +{ + public: + TFMFont (std::string name, UInt32 checksum, double dsize, double ssize); + ~TFMFont (); + const FontMetric* getMetrics () const; + std::string name () const {return _fontname;} + double designSize () const {return _dsize;} + double scaledSize () const {return _ssize;} + double charWidth (int c) const; + double charDepth (int c) const; + double charHeight (int c) const; + double italicCorr (int c) const; + bool verifyChecksums () const; + + private: + mutable FontMetric *_metrics; + std::string _fontname; + UInt32 _checksum; ///< cheksum to be compared with TFM checksum + double _dsize; ///< design size in TeX point units + double _ssize; ///< scaled size +}; + + +class PhysicalFontProxy : public PhysicalFont +{ + friend class PhysicalFontImpl; + public: + Font* clone (double ds, double sc) const {return new PhysicalFontProxy(*this, ds, sc);} + const Font* uniqueFont () const {return _pf;} + std::string name () const {return _pf->name();} + double designSize () const {return _dsize;} + double scaledSize () const {return _ssize;} + double charWidth (int c) const {return _pf->charWidth(c);} + double charDepth (int c) const {return _pf->charDepth(c);} + double charHeight (int c) const {return _pf->charHeight(c);} + double italicCorr (int c) const {return _pf->italicCorr(c);} + const FontMetric* getMetrics () const {return _pf->getMetrics();} + Type type () const {return _pf->type();} + UInt32 unicode (UInt32 c) const {return _pf->unicode(c);} + int fontIndex () const {return _pf->fontIndex();} + const Style* style () const {return _pf->style();} + + protected: + PhysicalFontProxy (const PhysicalFont *font, double ds, double ss) : _pf(font), _dsize(ds), _ssize(ss) {} + PhysicalFontProxy (const PhysicalFontProxy &proxy, double ds, double ss) : _pf(proxy._pf), _dsize(ds), _ssize(ss) {} + + private: + const PhysicalFont *_pf; + double _dsize; ///< design size in TeX point units + double _ssize; ///< scaled size +}; + + +class PhysicalFontImpl : public PhysicalFont, public TFMFont +{ + friend class PhysicalFont; + public: + ~PhysicalFontImpl(); + Font* clone (double ds, double ss) const {return new PhysicalFontProxy(this, ds, ss);} + const Font* uniqueFont () const {return this;} + Type type () const {return _filetype;} + int fontIndex() const {return _fontIndex;} + const Style* style () const {return _style;} + void setStyle (double bold, double extend, double slant); + UInt32 unicode (UInt32 c) const; + void tidy () const; + + protected: + PhysicalFontImpl (std::string name, int fontindex, UInt32 checksum, double dsize, double ssize, PhysicalFont::Type type); + + private: + Type _filetype; + int _fontIndex; + Style *_style; + mutable std::map *_charmap; +}; + + +class VirtualFontProxy : public VirtualFont +{ + friend class VirtualFontImpl; + public: + Font* clone (double ds, double ss) const {return new VirtualFontProxy(*this, ds, ss);} + const Font* uniqueFont () const {return _vf;} + std::string name () const {return _vf->name();} + const DVIVector* getDVI (int c) const {return _vf->getDVI(c);} + double designSize () const {return _dsize;} + double scaledSize () const {return _ssize;} + double charWidth (int c) const {return _vf->charWidth(c);} + double charDepth (int c) const {return _vf->charDepth(c);} + double charHeight (int c) const {return _vf->charHeight(c);} + double italicCorr (int c) const {return _vf->italicCorr(c);} + const FontMetric* getMetrics () const {return _vf->getMetrics();} + const char* path () const {return _vf->path();} + + protected: + VirtualFontProxy (const VirtualFont *font, double ds, double ss) : _vf(font), _dsize(ds), _ssize(ss) {} + VirtualFontProxy (const VirtualFontProxy &proxy, double ds, double ss) : _vf(proxy._vf), _dsize(ds), _ssize(ss) {} + void assignChar (UInt32 c, DVIVector *dvi) {delete dvi;} + + private: + const VirtualFont *_vf; + double _dsize; ///< design size in TeX point units + double _ssize; ///< scaled size in TeX point units +}; + + +class VirtualFontImpl : public VirtualFont, public TFMFont +{ + friend class VirtualFont; + public: + ~VirtualFontImpl (); + Font* clone (double ds, double ss) const {return new VirtualFontProxy(this, ds, ss);} + const Font* uniqueFont () const {return this;} + const DVIVector* getDVI (int c) const; + const char* path () const; + + protected: + VirtualFontImpl (std::string name, UInt32 checksum, double dsize, double ssize); + void assignChar (UInt32 c, DVIVector *dvi); + + private: + std::map _charDefs; ///< dvi subroutines defining the characters +}; + + +struct FontException : public MessageException +{ + FontException (std::string msg) : MessageException(msg) {} +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.cpp new file mode 100644 index 00000000000..a36df9afa82 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.cpp @@ -0,0 +1,387 @@ +/************************************************************************* +** FontCache.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include +#include "CRC32.h" +#include "FileSystem.h" +#include "FontCache.h" +#include "Glyph.h" +#include "Pair.h" +#include "StreamReader.h" +#include "StreamWriter.h" +//#include "gzstream.h" +#include "types.h" + +using namespace std; + +const UInt8 FontCache::VERSION = 5; + + +static Pair32 read_pair (int bytes, StreamReader &sr) { + Int32 x = sr.readSigned(bytes); + Int32 y = sr.readSigned(bytes); + return Pair32(x, y); +} + + +FontCache::FontCache () : _changed(false) +{ +} + + +FontCache::~FontCache () { + clear(); +} + + +/** Removes all data from the cache. This does not affect the cache files. */ +void FontCache::clear () { + _glyphs.clear(); + _fontname.clear(); +} + + +/** Assigns glyph data to a character and adds it to the cache. + * @param[in] c character code + * @param[in] glyph font glyph data */ +void FontCache::setGlyph (int c, const Glyph &glyph) { + _glyphs[c] = glyph; + _changed = true; +} + + +/** Returns the corresponding glyph data of a given character of the current font. + * @param[in] c character code + * @return font glyph data (0 if no matching data was found) */ +const Glyph* FontCache::getGlyph (int c) const { + GlyphMap::const_iterator it = _glyphs.find(c); + return (it != _glyphs.end()) ? &it->second : 0; +} + + +/** Writes the current cache data to a file (only if anything changed after + * the last call of read()). + * @param[in] fontname name of current font + * @param[in] dir directory where the cache file should go + * @return true if writing was successful */ +bool FontCache::write (const char *fontname, const char *dir) const { + if (!_changed) + return true; + + if (fontname && strlen(fontname) > 0) { + if (dir == 0 || strlen(dir) == 0) + dir = FileSystem::getcwd().c_str(); + ostringstream oss; + oss << dir << '/' << fontname << ".fgd"; +// ogzstream ofs(oss.str().c_str(), 9, ios::binary|ios::out); + ofstream ofs(oss.str().c_str(), ios::binary); + return write(fontname, ofs); + } + return false; +} + + +bool FontCache::write (const char* dir) const { + return _fontname.empty() ? false : write(_fontname.c_str(), dir); +} + + +/** Returns the minimal number of bytes needed to store the given value. */ +static int max_int_size (Int32 value) { + Int32 limit = 0x7f; + for (int i=1; i <= 4; i++) { + if ((value < 0 && -value <= limit+1) || (value >= 0 && value <= limit)) + return i; + limit = (limit << 8) | 0xff; + } + return 4; +} + + +/** Returns the minimal number of bytes needed to store the biggest + * pair component of the given vector. */ +static int max_int_size (const Pair *pairs, size_t n) { + int ret=0; + for (size_t i=0; i < n; i++) { + ret = max(ret, max_int_size(pairs[i].x())); + ret = max(ret, max_int_size(pairs[i].y())); + } + return ret; +} + + +/** Writes the current cache data to a stream (only if anything changed after + * the last call of read()). + * @param[in] fontname name of current font + * @param[in] os output stream + * @return true if writing was successful */ +bool FontCache::write (const char *fontname, ostream &os) const { + if (!_changed) + return true; + if (!os) + return false; + + StreamWriter sw(os); + CRC32 crc32; + + struct WriteActions : Glyph::Actions { + WriteActions (StreamWriter &sw, CRC32 &crc32) : _sw(sw), _crc32(crc32) {} + + void draw (char cmd, const Glyph::Point *points, int n) { + int bytes = max_int_size(points, n); + int cmdchar = (bytes << 5) | (cmd - 'A'); + _sw.writeUnsigned(cmdchar, 1, _crc32); + for (int i=0; i < n; i++) { + _sw.writeSigned(points[i].x(), bytes, _crc32); + _sw.writeSigned(points[i].y(), bytes, _crc32); + } + } + StreamWriter &_sw; + CRC32 &_crc32; + } actions(sw, crc32); + + sw.writeUnsigned(VERSION, 1, crc32); + sw.writeUnsigned(0, 4); // space for checksum + sw.writeString(fontname, crc32, true); + sw.writeUnsigned(_glyphs.size(), 4, crc32); + FORALL(_glyphs, GlyphMap::const_iterator, it) { + const Glyph &glyph = it->second; + sw.writeUnsigned(it->first, 4, crc32); + sw.writeUnsigned(glyph.size(), 2, crc32); + glyph.iterate(actions, false); + } + os.seekp(1); + sw.writeUnsigned(crc32.get(), 4); // insert CRC32 checksum + os.seekp(0, ios::end); + return true; +} + + +/** Reads font glyph information from a file. + * @param[in] fontname name of font data to read + * @param[in] dir directory where the cache files are located + * @return true if reading was successful */ +bool FontCache::read (const char *fontname, const char *dir) { + if (_fontname == fontname) + return true; + clear(); + if (fontname && strlen(fontname) > 0) { + if (dir == 0 || strlen(dir) == 0) + dir = FileSystem::getcwd().c_str(); + ostringstream oss; + oss << dir << '/' << fontname << ".fgd"; + ifstream ifs(oss.str().c_str(), ios::binary); +// igzstream ifs(oss.str().c_str(), 9, ios::binary|ios::in); + return read(fontname, ifs); + } + return false; +} + + +/** Reads font glyph information from a stream. + * @param[in] fontname name of font data to read + * @param[in] dir input stream + * @return true if reading was successful */ +bool FontCache::read (const char *fontname, istream &is) { + if (_fontname == fontname) + return true; + clear(); + _fontname = fontname; + if (!is) + return false; + + StreamReader sr(is); + CRC32 crc32; + if (sr.readUnsigned(1, crc32) != VERSION) + return false; + + UInt32 crc32_cmp = sr.readUnsigned(4); + crc32.update(is); + if (crc32.get() != crc32_cmp) + return false; + + is.clear(); + is.seekg(5); // continue reading after checksum + + string fname = sr.readString(); + if (fname != fontname) + return false; + + UInt32 num_glyphs = sr.readUnsigned(4); + while (num_glyphs-- > 0) { + UInt32 c = sr.readUnsigned(4); // character code + UInt16 s = sr.readUnsigned(2); // number of path commands + Glyph &glyph = _glyphs[c]; + while (s-- > 0) { + UInt8 cmdval = sr.readUnsigned(1); + UInt8 cmdchar = (cmdval & 0x1f) + 'A'; + int bytes = cmdval >> 5; + switch (cmdchar) { + case 'C': { + Pair32 p1 = read_pair(bytes, sr); + Pair32 p2 = read_pair(bytes, sr); + Pair32 p3 = read_pair(bytes, sr); + glyph.cubicto(p1, p2, p3); + break; + } + case 'L': + glyph.lineto(read_pair(bytes, sr)); + break; + case 'M': + glyph.moveto(read_pair(bytes, sr)); + break; + case 'Q': { + Pair32 p1 = read_pair(bytes, sr); + Pair32 p2 = read_pair(bytes, sr); + glyph.conicto(p1, p2); + break; + } + case 'Z': + glyph.closepath(); + } + } + } + _changed = false; + return true; +} + + +/** Collects font cache information. + * @param[in] dirname path to font cache directory + * @param[out] infos the collected font information + * @param[out] invalid names of outdated/corrupted cache files + * @return true on success */ +bool FontCache::fontinfo (const char *dirname, vector &infos, vector &invalid) { + infos.clear(); + invalid.clear(); + if (dirname) { + vector fnames; + FileSystem::collect(dirname, fnames); + FORALL(fnames, vector::iterator, it) { + if ((*it)[0] == 'f' && it->length() > 5 && it->substr(it->length()-4) == ".fgd") { + FontInfo info; + string path = string(dirname)+"/"+(it->substr(1)); + ifstream ifs(path.c_str(), ios::binary); + if (fontinfo(ifs, info)) + infos.push_back(info); + else + invalid.push_back(it->substr(1)); + } + } + } + return !infos.empty(); +} + + +/** Collects font cache information of a single font. + * @param[in] is input stream of the cache file + * @param[out] info the collected data + * @return true if data could be read, false if cache file is unavailable, outdated, or corrupted */ +bool FontCache::fontinfo (std::istream &is, FontInfo &info) { + info.name.clear(); + info.numchars = info.numbytes = info.numcmds = 0; + if (is) { + is.clear(); + is.seekg(0); + StreamReader sr(is); + CRC32 crc32; + if ((info.version = sr.readUnsigned(1, crc32)) != VERSION) + return false; + + info.checksum = sr.readUnsigned(4); + crc32.update(is); + if (crc32.get() != info.checksum) + return false; + + is.clear(); + is.seekg(5); // continue reading after checksum + + info.name = sr.readString(); + info.numchars = sr.readUnsigned(4); + for (UInt32 i=0; i < info.numchars; i++) { + sr.readUnsigned(4); // character code + UInt16 s = sr.readUnsigned(2); // number of path commands + while (s-- > 0) { + UInt8 cmdval = sr.readUnsigned(1); + UInt8 cmdchar = (cmdval & 0x1f) + 'A'; + int bytes = cmdval >> 5; + int bc = 0; + switch (cmdchar) { + case 'C': bc = 6*bytes; break; + case 'H': + case 'L': + case 'M': + case 'T': + case 'V': bc = 2*bytes; break; + case 'Q': + case 'S': bc = 4*bytes; break; + case 'Z': break; + default : return false; + } + info.numbytes += bc+1; // command length + command + info.numcmds++; + is.seekg(bc, ios_base::cur); + } + info.numbytes += 6; // number of path commands + char code + } + info.numbytes += 6+info.name.length(); // version + 0-byte + fontname + number of chars + } + return true; +} + + +/** Collects font cache information and write it to a stream. + * @param[in] dirname path to font cache directory + * @param[in] os output is written to this stream + * @param[in] purge if true, outdated and corrupted cache files are removed */ +void FontCache::fontinfo (const char *dirname, ostream &os, bool purge) { + if (dirname) { + vector infos; + vector invalid_files; + if (fontinfo(dirname, infos, invalid_files)) { + os << "cache format version " << infos[0].version << endl; + typedef map SortMap; + SortMap sortmap; + FORALL(infos, vector::iterator, it) + sortmap[it->name] = &(*it); + + FORALL(sortmap, SortMap::iterator, it) { + os << dec << setfill(' ') << left + << setw(10) << left << it->second->name + << setw(5) << right << it->second->numchars << " glyph" << (it->second->numchars == 1 ? ' ':'s') + << setw(10) << right << it->second->numcmds << " cmd" << (it->second->numcmds == 1 ? ' ':'s') + << setw(12) << right << it->second->numbytes << " byte" << (it->second->numbytes == 1 ? ' ':'s') + << setw(6) << "crc:" << setw(8) << hex << right << setfill('0') << it->second->checksum + << endl; + } + } + else + os << "cache is empty\n"; + FORALL(invalid_files, vector::iterator, it) { + string path=string(dirname)+"/"+(*it); + if (FileSystem::remove(path)) + os << "invalid cache file " << (*it) << " removed\n"; + } + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.h new file mode 100644 index 00000000000..cf4cbef7ec2 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontCache.h @@ -0,0 +1,74 @@ +/************************************************************************* +** FontCache.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTCACHE_H +#define FONTCACHE_H + +#include +#include +#include +#include "types.h" +#include "Glyph.h" + +#ifdef VERSION +#undef VERSION +#endif + + +class FontCache +{ + typedef std::map GlyphMap; + + public: + struct FontInfo + { + std::string name; // fontname + UInt16 version; // file format version + UInt32 checksum; // CRC32 checksum of file data + UInt32 numchars; // number of characters + UInt32 numbytes; // number of bytes + UInt32 numcmds; // number of path commands + }; + + public: + FontCache (); + ~FontCache (); + bool read (const char *fontname, const char *dir); + bool read (const char *fontname, std::istream &is); + bool write (const char *dir) const; + bool write (const char *fontname, const char *dir) const; + bool write (const char *fontname, std::ostream &os) const; + const Glyph* getGlyph (int c) const; + void setGlyph (int c, const Glyph &glyph); + void clear (); + const std::string& fontname () const {return _fontname;} + + static bool fontinfo (const char *dirname, std::vector &infos, std::vector &invalid); + static bool fontinfo (std::istream &is, FontInfo &info); + static void fontinfo (const char *dirname, std::ostream &os, bool purge=false); + + private: + static const UInt8 VERSION; + std::string _fontname; + GlyphMap _glyphs; + bool _changed; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.cpp new file mode 100644 index 00000000000..c506292362c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.cpp @@ -0,0 +1,164 @@ +/************************************************************************* +** FontEncoding.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "Font.h" +#include "FontEncoding.h" +#include "FontMap.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "FileFinder.h" +#include "Message.h" + +using namespace std; + +static string read_entry (InputReader &in); +static bool valid_name_char (int c); + + +FontEncoding::FontEncoding (const string &encname) : _encname(encname) +{ + read(); +} + + +const char* FontEncoding::path () const { + return FileFinder::lookup(_encname+".enc", false); +} + + +/** Search for suitable enc-file and read its encoding information. + * The file contents must be a valid PostScript vector with 256 entries. */ +void FontEncoding::read () { + if (const char *p = path()) { + ifstream ifs(p); + read(ifs); + } + else + Message::wstream(true) << "encoding file '" << _encname << ".enc' not found\n"; +} + + +/** Read encoding information from stream. */ +void FontEncoding::read (istream &is) { + StreamInputBuffer ib(is, 256); + BufferInputReader in(ib); + _table.resize(256); + + // find beginning of vector + while (!in.eof()) { + in.skipSpace(); + if (in.peek() == '%') + in.skipUntil("\n"); + else + if (in.get() == '[') + break; + } + + // read vector entries + int n=0; + while (!in.eof()) { + in.skipSpace(); + if (in.peek() == '%') + in.skipUntil("\n"); + else if (in.peek() == ']') { + in.get(); + break; + } + else { + string entry = read_entry(in); + if (entry == ".notdef") + entry.clear(); + if (n < 256) + _table[n++] = entry; + } + } + // remove trailing .notdef names + for (n--; n > 0 && _table[n].empty(); n--); + _table.resize(n+1); +} + + +static string read_entry (InputReader &in) { + string entry; + bool accept_slashes=true; + while (!in.eof() && ((in.peek() == '/' && accept_slashes) || valid_name_char(in.peek()))) { + if (in.peek() != '/') + accept_slashes = false; + entry += in.get(); + } + if (entry.length() > 1) { + // strip leading slashes + // According to the PostScript specification, a single slash without further + // following characters is a valid name. + size_t n=0; + while (n < entry.length() && entry[n] == '/') + n++; + entry = entry.substr(n); + } + return entry; +} + + +static bool valid_name_char (int c) { + const char *delimiters = "<>(){}[]/~%"; + return isprint(c) && !isspace(c) && !strchr(delimiters, c); +} + + +/** Returns an entry of the encoding table. + * @param[in] c character code + * @return character name assigned to character code c*/ +const char* FontEncoding::getEntry (int c) const { + if (c >= 0 && (size_t)c < _table.size()) + return !_table[c].empty() ? _table[c].c_str() : 0; + return 0; +} + + +struct EncodingMap : public map +{ + ~EncodingMap () { + for (EncodingMap::iterator it=begin(); it != end(); ++it) + delete it->second; + } +}; + + +/** Returns the encoding of a font. + * @param[in] fontname name of font whose encoding will be returned + * @return pointer to encoding object, or 0 if there is no encoding defined */ +FontEncoding* FontEncoding::encoding (string fontname) { + static EncodingMap encmap; + size_t pos = fontname.rfind('.'); + if (pos != string::npos) + fontname = fontname.substr(0, pos); // strip extension + if (const FontMap::Entry *entry = FontMap::instance().lookup(fontname)) { + EncodingMap::const_iterator it = encmap.find(entry->encname); + if (it != encmap.end()) + return it->second; + if (FileFinder::lookup(entry->encname + ".enc", false)) { + FontEncoding *enc = new FontEncoding(entry->encname); + encmap[entry->encname] = enc; + return enc; + } + } + return 0; +} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.h new file mode 100644 index 00000000000..3170d850256 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEncoding.h @@ -0,0 +1,48 @@ +/************************************************************************* +** FontEncoding.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTENCODING_H +#define FONTENCODING_H + +#include +#include +#include +#include +#include "types.h" + + +class FontEncoding +{ + public: + FontEncoding (const std::string &name); + void read (); + void read (std::istream &is); + int size () const {return _table.size();} + std::string name () const {return _encname;} + const char* getEntry (int c) const; + const char* path () const; + static FontEncoding* encoding (std::string fontname); + + private: + std::string _encname; + std::vector _table; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.cpp new file mode 100644 index 00000000000..ab53b1bd644 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.cpp @@ -0,0 +1,379 @@ +/************************************************************************* +** FontEngine.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include FT_GLYPH_H +#include FT_OUTLINE_H +#include FT_TRUETYPE_TABLES_H +#include FT_TYPES_H +#include "Font.h" +#include "FontEngine.h" +#include "Message.h" + +using namespace std; + + +/** Converts a floating point value to a 16.16 fixed point value. */ +static inline FT_Fixed to_16dot16 (double val) { + return static_cast(val*65536.0 + 0.5); +} + +/** Converts an integer to a 16.16 fixed point value. */ +static inline FT_Fixed to_16dot16 (int val) { + return static_cast(val) << 16; +} + +/** Converts a floating point value to a 26.6 fixed point value. */ +static inline FT_F26Dot6 to_26dot6 (double val) { + return static_cast(val*64.0 + 0.5); +} + +/** Converts an integer to a 26.6 fixed point value. */ +static inline FT_F26Dot6 to_26dot6 (int val) { + return static_cast(val) << 6; +} + + +/////////////////////////////////////////////////////////////////////////// + + +FontEngine::FontEngine () : _currentFace(0), _currentFont(0) +{ + _currentChar = _currentGlyphIndex = 0; + _horDeviceRes = _vertDeviceRes = 300; + if (FT_Init_FreeType(&_library)) + Message::estream(true) << "FontEngine: error initializing FreeType library\n"; +} + + +FontEngine::~FontEngine () { + if (_currentFace && FT_Done_Face(_currentFace)) + Message::estream(true) << "FontEngine: error removing glyph\n"; + if (FT_Done_FreeType(_library)) + Message::estream(true) << "FontEngine: error removing FreeType library\n"; +} + + +/** Returns the singleton instance of this class. */ +FontEngine& FontEngine::instance () { + static FontEngine engine; + return engine; +} + + +string FontEngine::version () { + FT_Int major, minor, patch; + FT_Library &lib = instance()._library; + FT_Library_Version(lib, &major, &minor, &patch); + ostringstream oss; + oss << major << '.' << minor << '.' << patch; + return oss.str(); +} + + +void FontEngine::setDeviceResolution (int x, int y) { + _horDeviceRes = x; + _vertDeviceRes = y; +} + + +/** Builds a table that maps glyph indexes to char codes. + * @param[in] face font face to be used + * @param[out] reverseMap the resulting map */ +static void build_reverse_map (FT_Face face, map &reverseMap) { + FT_UInt glyphIndex; + UInt32 charcode = FT_Get_First_Char(face, &glyphIndex); + while (glyphIndex) { +// if (reverseMap.find(glyphIndex) == reverseMap.end()) + reverseMap[glyphIndex] = charcode; + charcode = FT_Get_Next_Char(face, charcode, &glyphIndex); + } +} + + +/** Sets the font to be used. + * @param[in] fname path to font file + * @param[in] fontindex index of font in font collection (multi-font files, like TTC) + * @return true on success */ +bool FontEngine::setFont (const string &fname, int fontindex) { + if (FT_New_Face(_library, fname.c_str(), fontindex, &_currentFace)) { + Message::estream(true) << "FontEngine: error reading file " << fname << '\n'; + return false; + } + // look for a custom character map + for (int i=0; i < _currentFace->num_charmaps; i++) { + FT_CharMap charmap = _currentFace->charmaps[i]; + if (charmap->encoding == FT_ENCODING_ADOBE_CUSTOM) { + FT_Set_Charmap(_currentFace, charmap); + break; + } + } + return true; +} + + +bool FontEngine::setFont (const Font &font) { + if (!_currentFont || _currentFont->name() != font.name()) { + _currentFont = &font; + return setFont(font.path(), font.fontIndex()); + } + return true; +} + + +void FontEngine::buildTranslationMap (map &translationMap) const { + FT_CharMap unicodeMap=0, customMap=0; + for (int i=0; i < _currentFace->num_charmaps; i++) { + FT_CharMap charmap = _currentFace->charmaps[i]; + if (charmap->encoding == FT_ENCODING_ADOBE_CUSTOM) + customMap = charmap; + else if (charmap->encoding == FT_ENCODING_UNICODE) + unicodeMap = charmap; + } + if (unicodeMap == 0 || customMap == 0) + return; + + map reverseMap; + build_reverse_map(_currentFace, reverseMap); + + FT_Set_Charmap(_currentFace, unicodeMap); + FT_UInt glyphIndex; + UInt32 charcode = FT_Get_First_Char(_currentFace, &glyphIndex); + while (glyphIndex) { + translationMap[reverseMap[glyphIndex]] = charcode; + charcode = FT_Get_Next_Char(_currentFace, charcode, &glyphIndex); + } + FT_Set_Charmap(_currentFace, customMap); +} + + +const char* FontEngine::getFamilyName () const { + return _currentFace ? _currentFace->family_name : 0; +} + + +const char* FontEngine::getStyleName () const { + return _currentFace ? _currentFace->style_name : 0; +} + + +int FontEngine::getUnitsPerEM () const { + return _currentFace ? _currentFace->units_per_EM : 0; +} + + +int FontEngine::getAscender () const { + return _currentFace ? _currentFace->ascender : 0; +} + + +int FontEngine::getDescender () const { + return _currentFace ? _currentFace->descender : 0; +} + + +int FontEngine::getHAdvance () const { + if (_currentFace) { + TT_OS2 *table = static_cast(FT_Get_Sfnt_Table(_currentFace, ft_sfnt_os2)); + return table ? table->xAvgCharWidth : 0; + } + return 0; +} + + +int FontEngine::getHAdvance (unsigned c) const { + if (_currentFace) { + int index = FT_Get_Char_Index(_currentFace, (FT_ULong)c); + FT_Load_Glyph(_currentFace, index, FT_LOAD_NO_SCALE); + return _currentFace->glyph->metrics.horiAdvance; + } + return 0; +} + + +int FontEngine::getHAdvance (const char *name) const { + if (_currentFace && name) { + int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); + FT_Load_Glyph(_currentFace, index, FT_LOAD_NO_SCALE); + return _currentFace->glyph->metrics.horiAdvance; + } + return 0; +} + + +/** Get first available character of the current font face. */ +int FontEngine::getFirstChar () const { + if (_currentFace) + return _currentChar = FT_Get_First_Char(_currentFace, &_currentGlyphIndex); + return 0; +} + + +/** Get the next available character of the current font face. */ +int FontEngine::getNextChar () const { + if (_currentFace && _currentGlyphIndex) + return _currentChar = FT_Get_Next_Char(_currentFace, _currentChar, &_currentGlyphIndex); + return getFirstChar(); +} + + +/** Returns the glyph name for a given charater code. + * @param[in] c char code + * @return glyph name */ +string FontEngine::getGlyphName (unsigned c) const { + if (_currentFace && FT_HAS_GLYPH_NAMES(_currentFace)) { + char buf[256]; + int index = FT_Get_Char_Index(_currentFace, c); + FT_Get_Glyph_Name(_currentFace, index, buf, 256); + return string(buf); + } + return ""; +} + + +/* Returns the character code for a given glyph name. + * @param name glyph name + * @return char code or 0 if name couldn't be found +int FontEngine::getCharByGlyphName (const char *name) const { + if (_currentFace && FT_HAS_GLYPH_NAMES(_currentFace)) { + int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); + map::const_iterator it = _reverseMap.find(index); + if (it != _reverseMap.end()) + return it->second; + } + return 0; +}*/ + + +vector FontEngine::getPanose () const { + vector panose(10); + if (_currentFace) { + TT_OS2 *table = static_cast(FT_Get_Sfnt_Table(_currentFace, ft_sfnt_os2)); + if (table) + for (int i=0; i < 10; i++) + panose[i] = table->panose[i]; + } + return panose; +} + + +// handle API change in freetype version 2.2.1 +#if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 2 || (FREETYPE_MINOR == 2 && FREETYPE_PATCH >= 1))) + typedef const FT_Vector *FTVectorPtr; +#else + typedef FT_Vector *FTVectorPtr; +#endif + + +// Callback functions used by trace_outline/FT_Outline_Decompose +static int moveto (FTVectorPtr to, void *user) { + Glyph *glyph = static_cast(user); + glyph->moveto(to->x, to->y); + return 0; +} + + +static int lineto (FTVectorPtr to, void *user) { + Glyph *glyph = static_cast(user); + glyph->lineto(to->x, to->y); + return 0; +} + + +static int conicto (FTVectorPtr control, FTVectorPtr to, void *user) { + Glyph *glyph = static_cast(user); + glyph->conicto(control->x, control->y, to->x, to->y); + return 0; +} + + +static int cubicto (FTVectorPtr control1, FTVectorPtr control2, FTVectorPtr to, void *user) { + Glyph *glyph = static_cast(user); + glyph->cubicto(control1->x, control1->y, control2->x, control2->y, to->x, to->y); + return 0; +} + + +/** Traces the outline of a glyph by calling the corresponding "drawing" functions. + * Each glyph is composed of straight lines, quadratic (conic) or cubic B�zier curves. + * This function takes all these outline segments and processes them by calling + * the corresponding functions. The functions must be provided in form of a + * FEGlyphCommands object. + * @param[in] index index of the glyph that will be traced + * @param[in] commands the drawing commands to be executed + * @param[in] scale if true the current pt size will be considered otherwise the plain TrueType units are used. + * @return false on errors */ +static bool trace_outline (FT_Face face, const Font *font, int index, Glyph &glyph, bool scale) { + if (face) { + if (FT_Load_Glyph(face, index, scale ? FT_LOAD_DEFAULT : FT_LOAD_NO_SCALE)) { + Message::estream(true) << "can't load glyph " << int(index) << '\n'; + return false; + } + if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) { + Message::estream(true) << "no outlines found in glyph " << int(index) << '\n'; + return false; + } + FT_Outline outline = face->glyph->outline; + // apply style parameters if set + if (const Font::Style *style = font->style()) { + FT_Matrix matrix = {to_16dot16(style->extend), to_16dot16(style->slant), 0, to_16dot16(1)}; + FT_Outline_Transform(&outline, &matrix); + if (style->bold != 0) + FT_Outline_Embolden(&outline, style->bold/font->scaledSize()*face->units_per_EM); + } + const FT_Outline_Funcs funcs = {moveto, lineto, conicto, cubicto, 0, 0}; + FT_Outline_Decompose(&outline, &funcs, &glyph); + return true; + } + Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; + return false; +} + + +/** Traces the outline of a glyph by calling the corresponding "drawing" functions. + * Each glyph is composed of straight lines, quadratic (conic) or cubic B�zier curves. + * This function takes all these outline segments and processes them by calling + * the corresponding functions. The functions must be provided in form of a + * FEGlyphCommands object. + * @param[in] chr the glyph of this character will be traced + * @param[in] commands the drawing commands to be executed + * @param[in] scale if true the current pt size will be considered otherwise + * the plain TrueType units are used. + * @return false on errors */ +bool FontEngine::traceOutline (UInt16 chr, Glyph &glyph, bool scale) const { + if (_currentFace) { + int index = FT_Get_Char_Index(_currentFace, chr); + return trace_outline(_currentFace, _currentFont, index, glyph, scale); + } + Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; + return false; +} + + +bool FontEngine::traceOutline (const char *name, Glyph &glyph, bool scale) const { + if (_currentFace) { + int index = FT_Get_Name_Index(_currentFace, (FT_String*)name); + return trace_outline(_currentFace, _currentFont, index, glyph, scale); + } + Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; + return false; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.h new file mode 100644 index 00000000000..68652b66523 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontEngine.h @@ -0,0 +1,73 @@ +/************************************************************************* +** FontEngine.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTENGINE_H +#define FONTENGINE_H + +#include +#include FT_FREETYPE_H +#include +#include +#include +#include "types.h" +#include "Glyph.h" + +struct Font; + +/** This class provides methods to handle font files and font data. + * It's a wrapper for the Freetype font library. */ +class FontEngine +{ + public: + ~FontEngine (); + static FontEngine& instance (); + static std::string version (); + void setDeviceResolution (int x, int y); + bool setFont (const Font &font); + bool traceOutline (UInt16 chr, Glyph &glyph, bool scale=true) const; + bool traceOutline (const char *name, Glyph &glyph, bool scale) const; + const char* getFamilyName () const; + const char* getStyleName () const; + int getUnitsPerEM () const; + int getAscender () const; + int getDescender () const; + int getHAdvance () const; + int getHAdvance (unsigned int c) const; + int getHAdvance (const char *name) const; + int getFirstChar () const; + int getNextChar () const; + std::vector getPanose () const; + std::string getGlyphName (unsigned int c) const; + int getCharByGlyphName (const char *name) const; + void buildTranslationMap (std::map &translationMap) const; + + protected: + FontEngine (); + bool setFont (const std::string &fname, int fontindex=0); + + private: + int _horDeviceRes, _vertDeviceRes; + mutable unsigned int _currentChar, _currentGlyphIndex; + FT_Face _currentFace; + FT_Library _library; + const Font *_currentFont; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.cpp new file mode 100644 index 00000000000..0481b59a969 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.cpp @@ -0,0 +1,296 @@ +/************************************************************************* +** FontManager.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "Font.h" +#include "FontEncoding.h" +#include "FontManager.h" +#include "FontMap.h" +#include "FileFinder.h" +#include "Message.h" +#include "macros.h" + +using namespace std; + + +FontManager::~FontManager () { + FORALL(_fonts, vector::iterator, i) + delete *i; +} + + +/** Returns the singleton instance */ +FontManager& FontManager::instance () { + static FontManager fm; + return fm; +} + + +/** Returns a unique ID that identifies the font. + * @param[in] n local font number, as used in DVI and VF files + * @return non-negative font ID if font was found, -1 otherwise */ +int FontManager::fontID (int n) const { + if (_vfStack.empty()) { + Num2IdMap::const_iterator it = _num2id.find(n); + return (it == _num2id.end()) ? -1 : it->second; + } + VfNum2IdMap::const_iterator vit = _vfnum2id.find(_vfStack.top()); + if (vit == _vfnum2id.end()) + return -1; + const Num2IdMap &num2id = vit->second; + Num2IdMap::const_iterator it = num2id.find(n); + return (it == num2id.end()) ? -1 : it->second; +} + + +/** Returns a unique ID that identifies the font. Not the font object but the + * font pointer is looked up to get the ID. Thus, two different pointers + * referencing different objects of the same font are mapped to different IDs. + * @param[in] font pointer to font object to be identified + * @return non-negative font ID if font was found, -1 otherwise */ +int FontManager::fontID (const Font *font) const { + for (size_t i=0; i < _fonts.size(); i++) + if (_fonts[i] == font) + return i; + return -1; +} + + +/** Returns a unique ID that identifies the font. + * @param[in] name name of font to be identified, e.g. cmr10 + * @return non-negative font ID if font was found, -1 otherwise */ +int FontManager::fontID (const string &name) const { + map::const_iterator it = _name2id.find(name); + if (it == _name2id.end()) + return -1; + return it->second; +} + + +int FontManager::fontnum (int id) const { + if (id < 0 || size_t(id) > _fonts.size()) + return -1; + if (_vfStack.empty()) { + FORALL(_num2id, Num2IdMap::const_iterator, i) + if (i->second == id) + return i->first; + } + else { + VfNum2IdMap::const_iterator it = _vfnum2id.find(_vfStack.top()); + if (it == _vfnum2id.end()) + return -1; + const Num2IdMap &num2id = it->second; + FORALL(num2id, Num2IdMap::const_iterator, i) + if (i->second == id) + return i->first; + } + return -1; +} + + +int FontManager::vfFirstFontNum (VirtualFont *vf) const { + VfFirstFontMap::const_iterator it = _vfFirstFontMap.find(vf); + return (it == _vfFirstFontMap.end()) ? -1 : (int) it->second; +} + + +/** Returns a previously registered font. + * @param[in] n local font number, as used in DVI and VF files + * @return pointer to font if font was found, 0 otherwise */ +Font* FontManager::getFont (int n) const { + int id = fontID(n); + return (id < 0) ? 0 : _fonts[id]; +} + + +Font* FontManager::getFont (const string &name) const { + int id = fontID(name); + if (id < 0) + return 0; + return _fonts[id]; +} + + +Font* FontManager::getFontById (int id) const { + if (id < 0 || size_t(id) >= _fonts.size()) + return 0; + return _fonts[id]; +} + + +/** Returns the current active virtual font. */ +VirtualFont* FontManager::getVF () const { + return _vfStack.empty() ? 0 : _vfStack.top(); +} + + +static Font* create_font (const string &filename, const string &fontname, int fontindex, UInt32 checksum, double dsize, double ssize) { + string ext; + if (const char *dot = strrchr(filename.c_str(), '.')) + ext = dot+1; + if (!ext.empty() && FileFinder::lookup(filename)) { + if (ext == "pfb") + return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::PFB); + if (ext == "ttf") + return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::TTF); + if (ext == "ttc") + return PhysicalFont::create(fontname, fontindex, checksum, dsize, ssize); + if (ext == "vf") + return VirtualFont::create(fontname, checksum, dsize, ssize); + if (ext == "mf") + return PhysicalFont::create(fontname, checksum, dsize, ssize, PhysicalFont::MF); + } + return 0; +} + + +/** Registers a new font to be managed by the FontManager. If there is + * already a registered font assigned to number n, nothing happens. + * @param[in] fontnum local font number, as used in DVI and VF files + * @param[in] name TFM fontname given in DVI file, e.g. cmr10 + * @param[in] checksum checksum to be compared with TFM checksum + * @param[in] dsize design size in TeX point units + * @param[in] ssize scaled size in TeX point units + * @return id of registered font */ +int FontManager::registerFont (UInt32 fontnum, string name, UInt32 checksum, double dsize, double ssize) { + int id = fontID(fontnum); + if (id >= 0) + return id; + + Font *newfont = 0; + const int newid = _fonts.size(); // the new font gets this ID + Name2IdMap::iterator it = _name2id.find(name); + if (it != _name2id.end()) { // font with same name already registered? + Font *font = _fonts[it->second]; + newfont = font->clone(dsize, ssize); + } + else { + string filename = name; + int fontindex = 0; + const FontMap::Entry *map_entry = FontMap::instance().lookup(name); + if (map_entry) { + filename = map_entry->fontname; + fontindex = map_entry->fontindex; + } + // try to find font file with the exact given name + if (filename.rfind(".") != string::npos) + newfont = create_font(filename, name, fontindex, checksum, dsize, ssize); + else { + // try various font file formats if the given file has no extension + const char *exts[] = {".pfb", ".ttc", ".ttf", ".vf", ".mf", 0}; + for (const char **p = exts; *p && !newfont; ++p) + newfont = create_font(filename+*p, name, fontindex, checksum, dsize, ssize); + } + if (map_entry) + if (PhysicalFont *pf = dynamic_cast(newfont)) + pf->setStyle(map_entry->bold, map_entry->extend, map_entry->slant); + if (!newfont) { + // create dummy font as a placeholder if the proper font is not available + newfont = new EmptyFont(name); + if (filename.rfind(".") == string::npos) + filename += ".mf"; + // print warning message about missing font file (only once for each filename) + static set missing_fonts; + if (missing_fonts.find(filename) == missing_fonts.end()) { + Message::wstream(true) << "font file '" << filename << "' not found\n"; + missing_fonts.insert(filename); + } + } + else if (!newfont->verifyChecksums()) + Message::wstream(true) << "checksum mismatch in font " << name << '\n'; + _name2id[name] = newid; + } + _fonts.push_back(newfont); + if (_vfStack.empty()) // register font referenced in dvi file? + _num2id[fontnum] = newid; + else { // register font referenced in vf file + VirtualFont *vf = const_cast(_vfStack.top()); + _vfnum2id[vf][fontnum] = newid; + if (_vfFirstFontMap.find(vf) == _vfFirstFontMap.end()) // first fontdef of VF? + _vfFirstFontMap[vf] = fontnum; + } + return newid; +} + + +/** Enters a new virtual font frame. + * This method must be called before processing a VF character. + * @param[in] vf virtual font */ +void FontManager::enterVF (VirtualFont *vf) { + if (vf) + _vfStack.push(vf); +} + + +/** Leaves a previously entered virtual font frame. */ +void FontManager::leaveVF () { + if (!_vfStack.empty()) + _vfStack.pop(); +} + + +/** Assigns a sequence of DVI commands to a char code. + * @param[in] c character code + * @param[in] dvi points to vector with DVI commands */ +void FontManager::assignVfChar (int c, vector *dvi) { + if (!_vfStack.empty() && dvi) + _vfStack.top()->assignChar(c, dvi); +} + + +ostream& FontManager::write (ostream &os, Font *font, int level) { +#if 0 + if (font) { + int id = -1; + for (int i=0; i < fonts.size() && id < 0; i++) + if (fonts[i] == font) + id = i; + + VirtualFont *vf = dynamic_cast(font); + for (int j=0; j < level+1; j++) + os << " "; + os << "id " << id + << " fontnum " << fontnum(id) << " " + << (vf ? "VF" : "PF") << " " + << font->name() + << endl; + + if (vf) { + enterVF(vf); + const Num2IdMap &num2id = vfnum2id.find(vf)->second; + FORALL(num2id, Num2IdMap::const_iterator, i) { + Font *font = fonts[i->second]; + write(os, font, level+1); + } + leaveVF(); + } + } + else { + for (int i=0; i < fonts.size(); i++) + write(os, fonts[i], level); + os << endl; + } +#endif + return os; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.h new file mode 100644 index 00000000000..9207ecba460 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontManager.h @@ -0,0 +1,81 @@ +/************************************************************************* +** FontManager.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTMANAGER_H +#define FONTMANAGER_H + +#include +#include +#include +#include +#include +#include +#include "types.h" + + +struct FileFinder; +struct Font; +class VirtualFont; + +/** This class provides methods for easy DVI font handling. + * DVI and VF files use local font numbers to reference fonts. For SVG output + * we need a single list with unique IDs of all physical fonts. Characters of + * virtual fonts are completely replaced by their DVI description so they don't + * appear anywhere in the output. */ +class FontManager +{ + typedef std::map Num2IdMap; + typedef std::map Name2IdMap; + typedef std::map VfNum2IdMap; + typedef std::map VfFirstFontMap; + typedef std::stack VfStack; + + public: + ~FontManager (); + static FontManager& instance (); + int registerFont (UInt32 fontnum, std::string fontname, UInt32 checksum, double dsize, double scale); + Font* getFont (int n) const; + Font* getFont (const std::string &name) const; + Font* getFontById (int id) const; + VirtualFont* getVF () const; + int fontID (int n) const; + int fontID (const Font *font) const; + int fontID (const std::string &name) const; + int fontnum (int id) const; + int vfFirstFontNum (VirtualFont *vf) const; + void enterVF (VirtualFont *vf); + void leaveVF (); + void assignVfChar (int c, std::vector *dvi); + const std::vector& getFonts () const {return _fonts;} + std::ostream& write (std::ostream &os, Font *font=0, int level=0); + + protected: + FontManager () {} + + private: + std::vector _fonts; ///< all registered Fonts + Num2IdMap _num2id; ///< DVI font number -> fontID + Name2IdMap _name2id; ///< fontname -> fontID + VfNum2IdMap _vfnum2id; + VfStack _vfStack; ///< stack of currently processed virtual fonts + VfFirstFontMap _vfFirstFontMap; ///< VF -> local font number of first font defined in VF +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.cpp new file mode 100644 index 00000000000..cd349080d14 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.cpp @@ -0,0 +1,302 @@ +/************************************************************************* +** FontMap.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include +#include "Directory.h" +#include "FileFinder.h" +#include "FontManager.h" +#include "FontMap.h" +#include "MapLine.h" +#include "Message.h" +#include "Subfont.h" + +using namespace std; + + +FontMap::~FontMap () { + for (Iterator it=_entries.begin(); it != _entries.end(); ++it) + delete it->second; +} + + +/** Returns the singleton instance. */ +FontMap& FontMap::instance() { + static FontMap fontmap; + return fontmap; +} + + +/** Reads and evaluates a single font map file. + * @param[in] fname name of map file to read + * @param[in] mode selects how to integrate the map file entries into the global map tree + * @return true if file could be opened */ +bool FontMap::read (const string &fname, FontMap::Mode mode) { + ifstream ifs(fname.c_str()); + if (!ifs) + return false; + + int line_number = 1; + while (ifs) { + if (strchr("\n&#%;*", ifs.peek())) // comment line? + ifs.ignore(numeric_limits::max(), '\n'); + else { + try { + MapLine mapline(ifs); + apply(mapline, mode); + } + catch (const MapLineException &e) { + Message::wstream(true) << fname << ", line " << line_number << ": " << e.what() << '\n'; + } + catch (const SubfontException &e) { + Message::wstream(true) << e.filename(); + if (e.lineno() > 0) + Message::wstream(false) << ", line " << e.lineno(); + Message::wstream(false) << e.what() << '\n'; + } + } + line_number++; + } + return true; +} + + +bool FontMap::read (const string &fname, char modechar) { + Mode mode; + switch (modechar) { + case '=': mode = FM_REPLACE; break; + case '-': mode = FM_REMOVE; break; + default : mode = FM_APPEND; + } + return read(fname, mode); +} + + +/** Applies a mapline according to the given mode (append, remove, replace). + * @param[in] mapline the mapline to be applied + * @param[in] mode mode to use + * @return true in case of success */ +bool FontMap::apply (const MapLine& mapline, FontMap::Mode mode) { + switch (mode) { + case FM_APPEND: + return append(mapline); + case FM_REMOVE: + return remove(mapline); + default: + return replace(mapline); + } +} + + +/** Applies a mapline according to the given mode (append, remove, replace). + * @param[in] mapline the mapline to be applied + * @param[in] modechar character that denotes the mode (+, -, or =) + * @return true in case of success */ +bool FontMap::apply (const MapLine& mapline, char modechar) { + Mode mode; + switch (modechar) { + case '=': mode = FM_REPLACE; break; + case '-': mode = FM_REMOVE; break; + default : mode = FM_APPEND; + } + return apply(mapline, mode); +} + + +/** Reads and evaluates a sequence of map files. Each map file is looked up in the local + * directory and the TeX file tree. + * @param[in] fname_seq comma-separated list of map file names + * @return true if at least one of the given map files was found */ +bool FontMap::read (const string &fname_seq) { + bool found = false; + size_t left=0; + while (left < fname_seq.length()) { + const char modechar = fname_seq[left]; + if (strchr("+-=", modechar)) + left++; + string fname; + size_t right = fname_seq.find(',', left); + if (right != string::npos) + fname = fname_seq.substr(left, right-left); + else { + fname = fname_seq.substr(left); + right = fname_seq.length(); + } + if (!fname.empty()) { + if (!read(fname, modechar)) { + if (const char *path = FileFinder::lookup(fname, false)) + found = found || read(path, modechar); + else + Message::wstream(true) << "map file " << fname << " not found\n"; + } + } + left = right+1; + } + return found; +} + + +/** Appends given map line data to the font map if there is no entry for the corresponding + * font in the map yet. + * @param[in] mapline parsed font data + * @return true if data has been appended */ +bool FontMap::append (const MapLine &mapline) { + bool ret = false; + if (!mapline.texname().empty()) { + if (!mapline.fontfname().empty() || !mapline.encname().empty()) { + vector subfonts; + if (mapline.sfd()) + mapline.sfd()->subfonts(subfonts); + else + subfonts.push_back(0); + for (size_t i=0; i < subfonts.size(); i++) { + string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); + Iterator it = _entries.find(fontname); + if (it == _entries.end()) { + _entries[fontname] = new Entry(mapline, subfonts[i]); + ret = true; + } + } + } + } + return ret; +} + + +/** Replaces the map data of the given font. + * If the font is locked (because it's already in use) nothing happens. + * @param[in] mapline parsed font data + * @return true if data has been replaced */ +bool FontMap::replace (const MapLine &mapline) { + if (mapline.texname().empty()) + return false; + if (mapline.fontfname().empty() && mapline.encname().empty()) + return remove(mapline); + + vector subfonts; + if (mapline.sfd()) + mapline.sfd()->subfonts(subfonts); + else + subfonts.push_back(0); + for (size_t i=0; i < subfonts.size(); i++) { + string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); + Iterator it = _entries.find(fontname); + if (it == _entries.end()) + _entries[fontname] = new Entry(mapline, subfonts[i]); + else if (!it->second->locked) + *it->second = Entry(mapline, subfonts[i]); + } + return true; +} + + +/** Removes the map entry of the given font. + * If the font is locked (because it's already in use) nothing happens. + * @param[in] mapline parsed font data + * @return true if entry has been removed */ +bool FontMap::remove (const MapLine &mapline) { + bool ret = false; + if (!mapline.texname().empty()) { + vector subfonts; + if (mapline.sfd()) + mapline.sfd()->subfonts(subfonts); + else + subfonts.push_back(0); + for (size_t i=0; i < subfonts.size(); i++) { + string fontname = mapline.texname()+(subfonts[i] ? subfonts[i]->id() : ""); + Iterator it = _entries.find(fontname); + if (it != _entries.end() && !it->second->locked) { + _entries.erase(it); + ret = true; + } + } + } + return ret; +} + + +ostream& FontMap::write (ostream &os) const { + for (ConstIterator it=_entries.begin(); it != _entries.end(); ++it) + os << it->first << " -> " << it->second->fontname << " [" << it->second->encname << "]\n"; + return os; +} + + +/** Reads and evaluates all map files in the given directory. + * @param[in] path to directory containing the map files to be read */ +void FontMap::readdir (const string &dirname) { + Directory dir(dirname); + while (const char *fname = dir.read('f')) { + if (strlen(fname) >= 4 && strcmp(fname+strlen(fname)-4, ".map") == 0) { + string path = dirname + "/" + fname; + read(path.c_str()); + } + } +} + + +/** Returns name of font that is mapped to a given font. + * @param[in] fontname name of font whose mapped name is retrieved + * @returns name of mapped font */ +const FontMap::Entry* FontMap::lookup (const string &fontname) const { + ConstIterator it = _entries.find(fontname); + if (it == _entries.end()) + return 0; + return it->second; +} + + +/** Sets the lock flag for the given font in order to avoid changing the map data of this font. + * @param[in] fontname name of font to be locked */ +void FontMap::lockFont (const string& fontname) { + Iterator it = _entries.find(fontname); + if (it != _entries.end()) + it->second->locked = true; +} + + +/** Removes all (unlocked) entries from the font map. + * @param[in] unlocked_only if true, only unlocked entries are removed */ +void FontMap::clear (bool unlocked_only) { + if (!unlocked_only) + _entries.clear(); + else { + Iterator it=_entries.begin(); + while (it != _entries.end()) { + if (it->second->locked) + ++it; + else { + delete it->second; + _entries.erase(it++); + } + } + } +} + +///////////////////////////////////////////////// + +FontMap::Entry::Entry (const MapLine &mapline, Subfont *sf) + : fontname(mapline.fontfname()), encname(mapline.encname()), subfont(sf), fontindex(mapline.fontindex()), locked(false), + bold(mapline.bold()), slant(mapline.slant()), extend(mapline.extend()) +{ +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.h new file mode 100644 index 00000000000..b3c1b85a304 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMap.h @@ -0,0 +1,75 @@ +/************************************************************************* +** FontMap.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTMAP_H +#define FONTMAP_H + +#include +#include +#include + +class MapLine; +class Subfont; + +class FontMap +{ + public: + struct Entry + { + Entry (const MapLine &mapline, Subfont *subfont=0); + std::string fontname; ///< target font name + std::string encname; ///< name of font encoding + Subfont *subfont; + int fontindex; ///< index of font in multi-font file + bool locked; + double bold, slant, extend; + }; + + protected: + typedef std::map::iterator Iterator; + typedef std::map::const_iterator ConstIterator; + + public: + enum Mode {FM_APPEND, FM_REMOVE, FM_REPLACE}; + + ~FontMap (); + static FontMap& instance (); + bool read (const std::string &fname, Mode mode); + bool read (const std::string &fname, char modechar); + bool read (const std::string &fname_seq); + void readdir (const std::string &dirname); + bool apply (const MapLine &mapline, Mode mode); + bool apply (const MapLine &mapline, char modechar); + bool append (const MapLine &mapline); + bool replace (const MapLine &mapline); + bool remove (const MapLine &mapline); + void lockFont (const std::string &fontname); + void clear (bool unlocked_only=false); + std::ostream& write (std::ostream &os) const; + const Entry* lookup(const std::string &fontname) const; + + protected: + FontMap () {} + + private: + std::map _entries; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.cpp new file mode 100644 index 00000000000..7d0b262e457 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.cpp @@ -0,0 +1,40 @@ +/************************************************************************* +** FontMetrics.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "FileFinder.h" +#include "FontMetric.h" +#include "JFM.h" +#include "TFM.h" + +using namespace std; + + +FontMetric* FontMetric::read (const char *fontname) { + const char *path = FileFinder::lookup(string(fontname) + ".tfm"); + ifstream ifs(path, ios::binary); + if (!ifs) + return 0; + UInt16 id = 256*ifs.get(); + id += ifs.get(); + if (id == 9 || id == 11) // Japanese font metric file? + return new JFM(ifs); + return new TFM(ifs); +} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.h new file mode 100644 index 00000000000..58dde4d9ab3 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/FontMetric.h @@ -0,0 +1,62 @@ +/************************************************************************* +** FontMetrics.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef FONTMETRIC_H +#define FONTMETRIC_H + +#include +#include "MessageException.h" +#include "types.h" + +struct FontMetric +{ + virtual ~FontMetric () {} + virtual double getDesignSize () const =0; + virtual double getCharWidth (int c) const =0; + virtual double getCharHeight (int c) const =0; + virtual double getCharDepth (int c) const =0; + virtual double getItalicCorr (int c) const =0; + virtual UInt32 getChecksum () const =0; + virtual UInt16 firstChar () const =0; + virtual UInt16 lastChar () const =0; + static FontMetric* read (const char *fontname); +}; + + +struct NullFontMetric : public FontMetric +{ + double getDesignSize () const {return 1;} + double getCharWidth (int c) const {return 0;} + double getCharHeight (int c) const {return 0;} + double getCharDepth (int c) const {return 0;} + double getItalicCorr (int c) const {return 0;} + UInt32 getChecksum () const {return 0;} + UInt16 firstChar () const {return 0;} + UInt16 lastChar () const {return 0;} +}; + + +struct FontMetricException : public MessageException +{ + FontMetricException (const std::string &msg) : MessageException(msg) {} +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.cpp new file mode 100644 index 00000000000..c40702e595f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.cpp @@ -0,0 +1,92 @@ +/************************************************************************* +** GFGlyphTracer.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "GFGlyphTracer.h" +#include "Pair.h" + +using namespace std; + +GFGlyphTracer::GFGlyphTracer () : GFTracer(_ifs, 0), _glyph(0), _callback(0) +{ +} + +/** Constructs a new glyph tracer. + * @param[in] is GF input stream + * @param[in] upp target units per TeX point */ +GFGlyphTracer::GFGlyphTracer (string &fname, double upp, Callback *cb) + : GFTracer(_ifs, upp), _glyph(0), _callback(cb) +{ + if (_callback) + _callback->setFont(fname); + _ifs.open(fname.c_str(), ios::binary); +} + + +void GFGlyphTracer::reset (string &fname, double upp) { + if (_callback) + _callback->setFont(fname); + if (_ifs.is_open()) + _ifs.close(); + unitsPerPoint(upp); + _ifs.open(fname.c_str(), ios::binary); +} + + +bool GFGlyphTracer::executeChar (UInt8 c) { + if (_glyph) { + if (_callback) + _callback->beginChar(c); + bool ok = GFTracer::executeChar(c); + if (_callback) { + if (ok) + _callback->endChar(c); + else + _callback->emptyChar(c); + return ok; + } + } + return false; +} + + +void GFGlyphTracer::moveTo (double x, double y) { + _glyph->moveto(int(x), int(y)); +} + + +void GFGlyphTracer::lineTo (double x, double y) { + _glyph->lineto(int(x), int(y)); +} + + +void GFGlyphTracer::curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y) { + _glyph->cubicto(int(c1x), int(c1y), int(c2x), int(c2y), int(x), int(y)); +} + + +void GFGlyphTracer::closePath () { + _glyph->closepath(); +} + + +void GFGlyphTracer::endChar (UInt32 c) { + _glyph->newpath(); + GFTracer::endChar(c); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.h new file mode 100644 index 00000000000..379ed1d98c8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFGlyphTracer.h @@ -0,0 +1,60 @@ +/************************************************************************* +** GFGlyphTracer.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GFGLYPHTRACER_H +#define GFGLYPHTRACER_H + +#include +#include +#include "GFTracer.h" +#include "Glyph.h" + +class GFGlyphTracer : public GFTracer +{ + public: + struct Callback { + virtual ~Callback () {} + virtual void setFont (const std::string &fontname) {} + virtual void beginChar (UInt8 c) {} + virtual void endChar (UInt8 c) {} + virtual void emptyChar (UInt8 c) {} + }; + + public: + GFGlyphTracer (); + GFGlyphTracer (std::string &fname, double upp, Callback *cb=0); + void reset (std::string &fname, double upp); + void setCallback (Callback *cb) {_callback = cb;} + bool executeChar (UInt8 c); + void moveTo (double x, double y); + void lineTo (double x, double y); + void curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y); + void closePath (); + void endChar (UInt32 c); + void setGlyph (Glyph &glyph) {_glyph = &glyph;} + const Glyph& getGlyph () const {return *_glyph;} + + private: + std::ifstream _ifs; + Glyph *_glyph; + Callback *_callback; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.cpp new file mode 100644 index 00000000000..1bb6c426549 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.cpp @@ -0,0 +1,352 @@ +/************************************************************************* +** GFReader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "GFReader.h" +#include "macros.h" +#include "SignalHandler.h" + +using namespace std; + +struct GFCommand +{ + void (GFReader::*method)(int); + int numBytes; +}; + + +static inline double fix2double (Int32 fix) { + return double(fix)/(1 << 20); +} + + +static inline double scaled2double (Int32 scaled) { + return double(scaled)/(1 << 16); +} + + +GFReader::GFReader (istream &is) : _in(is), _penDown(false) +{ + _minX = _maxX = _minY = _maxY = _x = _y = 0; +} + + +UInt32 GFReader::readUnsigned (int bytes) { + UInt32 ret = 0; + for (int i=bytes-1; i >= 0 && !_in.eof(); i--) { + UInt32 b = _in.get(); + ret |= b << (8*i); + } + return ret; +} + + +Int32 GFReader::readSigned (int bytes) { + Int32 ret = _in.get(); + if (ret & 128) // negative value? + ret |= 0xffffff00; + for (int i=bytes-2; i >= 0 && !_in.eof(); i--) + ret = (ret << 8) | _in.get(); + return ret; +} + + +string GFReader::readString (int bytes) { + vector buf(bytes+1); + if (bytes > 0) + _in.get(&buf[0], bytes+1); // reads 'bytes' bytes (pos. bytes+1 is set to 0) + else + buf[0] = 0; + return &buf[0]; +} + + +/** Reads a single GF command from the current position of the input stream and calls the + * corresponding cmdFOO method. + * @return opcode of the executed command */ +int GFReader::executeCommand () { + SignalHandler::instance().check(); + /* Each cmdFOO command reads the necessary number of bytes from the stream so executeCommand + doesn't need to know the exact GF command format. Some cmdFOO methods are used for multiple + GF commands because they only differ in the size of their parameters. */ + static const GFCommand commands[] = { + {&GFReader::cmdPaint, 1}, {&GFReader::cmdPaint, 2}, {&GFReader::cmdPaint, 3}, // 64-66 + {&GFReader::cmdBoc, 0}, {&GFReader::cmdBoc1, 0}, // 67-68 + {&GFReader::cmdEoc, 0}, // 69 + {&GFReader::cmdSkip, 0}, {&GFReader::cmdSkip, 1}, {&GFReader::cmdSkip, 2},{&GFReader::cmdSkip, 3}, // 70-73 + {&GFReader::cmdXXX, 1}, {&GFReader::cmdXXX, 2}, {&GFReader::cmdXXX, 3}, {&GFReader::cmdXXX, 4}, // 239-242 + {&GFReader::cmdYYY, 0}, // 243 + {&GFReader::cmdNop, 0}, // 244 + {&GFReader::cmdCharLoc, 0}, {&GFReader::cmdCharLoc0, 0}, // 245-246 + {&GFReader::cmdPre, 0}, {&GFReader::cmdPost, 0}, {&GFReader::cmdPostPost, 0} // 247-249 + }; + + int opcode = _in.get(); + if (opcode < 0) // at end of file? + throw GFException("unexpected end of file"); + + if (opcode >= 0 && opcode <= 63) + cmdPaint0(opcode); + else if (opcode >= 74 && opcode <= 238) + cmdNewRow(opcode-74); + else if (opcode >= 250) { + ostringstream oss; + oss << "undefined GF command (opcode " << opcode << ")"; + throw GFException(oss.str()); + } + else { + int offset = opcode <= 73 ? 64 : 239-(73-64+1); + const GFCommand &cmd = commands[opcode-offset]; + if (cmd.method) + (this->*cmd.method)(cmd.numBytes); + } + return opcode; +} + + +bool GFReader::executeChar (UInt8 c) { + _in.clear(); + if (_charInfoMap.empty()) + executePostamble(); // read character info + _in.clear(); + Iterator it = _charInfoMap.find(c); + if (_in && it != _charInfoMap.end()) { + _in.seekg(it->second.location, ios_base::beg); + while (executeCommand() != 69); // execute all commands until eoc is reached + return true; + } + return false; +} + + +bool GFReader::executeAllChars () { + _in.clear(); + if (_charInfoMap.empty()) + executePostamble(); // read character info + _in.clear(); + if (_in) { + _in.seekg(0); + while (executeCommand() != 248); // execute all commands until postamble is reached + return true; + } + return false; +} + + +bool GFReader::executePostamble () { + _in.clear(); + if (!_in) + return false; + _in.seekg(-1, ios_base::end); + while (_in.peek() == 223) // skip fill bytes + _in.seekg(-1, ios_base::cur); + _in.seekg(-4, ios_base::cur); + UInt32 q = readUnsigned(4); // pointer to begin of postamble + _in.seekg(q, ios_base::beg); // now on begin of postamble + while (executeCommand() != 249); // execute all commands until postpost is reached + return true; +} + + +/** Returns the design size of this font int TeX point units. */ +double GFReader::getDesignSize () const { + return fix2double(_designSize); +} + +/** Returns the number of horizontal pixels per point. */ +double GFReader::getHPixelsPerPoint () const { + return scaled2double(_hppp); +} + +/** Returns the number of vertical pixels per point. */ +double GFReader::getVPixelsPerPoint () const { + return scaled2double(_vppp); +} + +/** Returns the width of character c in TeX point units */ +double GFReader::getCharWidth (UInt32 c) const { + ConstIterator it = _charInfoMap.find(c%256); + return it == _charInfoMap.end() ? 0 : it->second.width*getDesignSize()/(1<<24); +} + +/////////////////////// + + +/** Reads the preamble. */ +void GFReader::cmdPre (int) { + UInt32 i = readUnsigned(1); + if (i == 131) { + UInt32 k = readUnsigned(1); + string s = readString(k); + preamble(s); + } + else + throw GFException("invalid identification number in GF preamble"); +} + + +/** Reads the postamble. */ +void GFReader::cmdPost (int) { + readUnsigned(4); // pointer to byte after final eoc + _designSize = readUnsigned(4); // design size of font in points + _checksum = readUnsigned(4); // checksum + _hppp = readUnsigned(4); // horizontal pixels per point (scaled int) + _vppp = readUnsigned(4); // vertical pixels per point (scaled int) + _in.seekg(16, ios_base::cur); // skip x and y bounds + postamble(); +} + + +/** Reads trailing bytes at end of stream. */ +void GFReader::cmdPostPost (int) { + readUnsigned(4); // pointer to begin of postamble + UInt32 i = readUnsigned(1); + if (i == 131) + while (readUnsigned(1) == 223); // skip fill bytes + else + throw GFException("invalid identification number in GF preamble"); +} + + +/** Inverts "paint color" (black to white or vice versa) of n pixels + * and advances the cursor by n. + * @param[in] n number of pixels to be inverted */ +void GFReader::cmdPaint0 (int n) { + if (_penDown) // set pixels? + _bitmap.setBits(_y, _x, n); + _x += n; + _penDown = !_penDown; // inverse pen state +} + + +/** Inverts "paint color" (black to white or vice versa) of n pixels + * and advances the cursor by n. The number n of pixels is read from + * the input stream. + * @param[in] len size of n in bytes */ +void GFReader::cmdPaint (int len) { + UInt32 pixels = readUnsigned(len); + cmdPaint0(pixels); +} + + +/** Beginning of character (generic format). */ +void GFReader::cmdBoc (int) { + _currentChar = readSigned(4); + readSigned(4); // pointer to previous boc with same c mod 256 + _minX = readSigned(4); + _maxX = readSigned(4); + _minY = readSigned(4); + _maxY = readSigned(4); + _x = _minX; + _y = _maxY; + _penDown = false; + _bitmap.resize(_minX, _maxX, _minY, _maxY); + beginChar(_currentChar); +} + + +/** Beginning of character (compact format). */ +void GFReader::cmdBoc1 (int) { + _currentChar = readUnsigned(1); + UInt32 dx = readUnsigned(1); + _maxX = readUnsigned(1); + _minX = _maxX - dx; + UInt32 dy = readUnsigned(1); + _maxY = readUnsigned(1); + _minY = _maxY - dy; + _x = _minX; + _y = _maxY; + _penDown = false; + _bitmap.resize(_minX, _maxX, _minY, _maxY); + beginChar(_currentChar); +} + + +/** End of character. */ +void GFReader::cmdEoc (int) { + endChar(_currentChar); +} + + +/** Moves cursor to the beginning of a following row and sets + * paint color to white. + * @param[in] len if 0: move to next row, otherwise: number of bytes to read. + * The read value denotes the number of rows to be skipped. */ +void GFReader::cmdSkip (int len) { + if (len == 0) + _y--; + else + _y -= readUnsigned(len)+1; + _x = _minX; + _penDown = false; +} + + +/** Moves cursor to pixel number 'col' in the next row and sets + * the paint color to black. + * @param[in] col pixel/column number */ +void GFReader::cmdNewRow (int col) { + _x = _minX + col ; + _y--; + _penDown = true; +} + + +void GFReader::cmdXXX (int len) { + UInt32 n = readUnsigned(len); + string str = readString(n); + special(str); +} + + +void GFReader::cmdYYY (int) { + Int32 y = readSigned(4); + numspecial(y); +} + + +/** Does nothing. */ +void GFReader::cmdNop (int) { +} + + +/** Reads character locator (part of postamble) */ +void GFReader::cmdCharLoc0 (int) { + UInt8 c = readUnsigned(1); // character code mod 256 + UInt8 dm = readUnsigned(1); // + Int32 w = readSigned(4); // (1<<24)*characterWidth/designSize + Int32 p = readSigned(4); // pointer to begin of (last) character data + Int32 dx = 65536*dm; + Int32 dy = 0; + _charInfoMap[c] = CharInfo(dx, dy, w, p); +} + + +/** Reads character locator (part of postamble) */ +void GFReader::cmdCharLoc (int) { + UInt32 c = readUnsigned(1); // character code mod 256 + Int32 dx = readSigned(4); // horizontal escapement (scaled pixel units) + Int32 dy = readSigned(4); // vertical escapement (scaled pixel units) + Int32 w = readSigned(4); // (1<<24)*characterWidth/designSize + Int32 p = readSigned(4); // pointer to begin of (last) character data + _charInfoMap[c] = CharInfo(dx, dy, w, p); +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.h new file mode 100644 index 00000000000..0d9a7bb0e32 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFReader.h @@ -0,0 +1,110 @@ +/************************************************************************* +** GFReader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GFREADER_H +#define GFREADER_H + +#include +#include +#include +#include "Bitmap.h" +#include "MessageException.h" +#include "types.h" + + +class CharInfo; + + +struct GFException : public MessageException +{ + GFException (const std::string &msg) : MessageException(msg) {} +}; + + +class GFReader +{ + struct CharInfo + { + CharInfo () : dx(0), dy(0), width(0), location(0) {} + CharInfo (Int32 dxx, Int32 dyy, Int32 w, UInt32 p) : dx(dxx), dy(dyy), width(w), location(p) {} + + Int32 dx, dy; + Int32 width; // 2^24 * (true width)/(design size) + UInt32 location; + }; + + typedef std::map::iterator Iterator; + typedef std::map::const_iterator ConstIterator; + public: + GFReader (std::istream &is); + virtual ~GFReader () {} + bool executeChar (UInt8 c); + bool executeAllChars (); + bool executePostamble (); + virtual void preamble (const std::string &str) {} + virtual void postamble () {} + virtual void beginChar (UInt32 c) {} + virtual void endChar (UInt32 c) {} + virtual void special (std::string str) {} + virtual void numspecial (Int32 y) {} + const Bitmap& getBitmap () const {return _bitmap;} + double getDesignSize () const; + double getHPixelsPerPoint () const; + double getVPixelsPerPoint () const; + double getCharWidth (UInt32 c) const; + UInt32 getChecksum () const {return _checksum;} + + protected: + Int32 readSigned (int bytes); + UInt32 readUnsigned (int bytes); + std::string readString (int len); + int executeCommand (); + std::istream& getInputStream () const {return _in;} + + void cmdPre (int); + void cmdPost (int); + void cmdPostPost (int); + void cmdPaint0 (int pixels); + void cmdPaint (int len); + void cmdBoc (int); + void cmdBoc1 (int); + void cmdEoc (int); + void cmdSkip (int len); + void cmdNewRow (int col); + void cmdXXX (int len); + void cmdYYY (int); + void cmdNop (int); + void cmdCharLoc0 (int); + void cmdCharLoc (int); + + private: + std::istream &_in; + Int32 _minX, _maxX, _minY, _maxY; + Int32 _x, _y; // current pen location (pixel units) + Int32 _currentChar; + Bitmap _bitmap; // bitmap of current char + FixWord _designSize; // designSize + ScaledInt _hppp, _vppp; // horizontal and vertical pixel per point + UInt32 _checksum; + std::map _charInfoMap; + bool _penDown; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.cpp new file mode 100644 index 00000000000..69a078456a0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.cpp @@ -0,0 +1,102 @@ +/************************************************************************* +** GFTracer.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "GFTracer.h" +#include "Glyph.h" +#include "Message.h" + +#ifdef __MSVC__ +#include +#else +extern "C" { +#include +} +#endif + +using namespace std; + + +GFTracer::GFTracer (istream &is) + : GFReader(is), _unitsPerPoint(0.0) +{ +} + + +/** Constructs a new GFTracer. + * @param[in] is GF file is read from this stream + * @param[in] upp target units per TeX point */ +GFTracer::GFTracer (istream &is, double upp) + : GFReader(is), _unitsPerPoint(upp) +{ +} + + +void GFTracer::beginChar (UInt32 c) { +} + + +void GFTracer::endChar (UInt32 c) { + const Bitmap &bitmap = getBitmap(); + if (bitmap.empty()) + return; + + // prepare potrace's bitmap structure + vector buffer; + potrace_bitmap_t pobitmap; + pobitmap.w = bitmap.width(); + pobitmap.h = bitmap.height(); + pobitmap.dy = bitmap.copy(buffer); + pobitmap.map = &buffer[0]; + potrace_param_t *param = potrace_param_default(); + potrace_state_t *state = potrace_trace(param, &pobitmap); + potrace_param_free(param); + + if (!state || state->status == POTRACE_STATUS_INCOMPLETE) + Message::wstream(true) << "error while tracing character\n"; + else { + double hsf=1.0, vsf=1.0; // horizontal a d vertical scale factor + if (_unitsPerPoint != 0.0) { + hsf = _unitsPerPoint/getHPixelsPerPoint(); // horizontal scale factor + vsf = _unitsPerPoint/getVPixelsPerPoint(); // vertical scale factor + } + for (potrace_path_t *path = state->plist; path; path = path->next) { + potrace_dpoint_t &p = path->curve.c[path->curve.n-1][2]; // start/end point + moveTo(hsf*(p.x+bitmap.xshift()), vsf*(p.y+bitmap.yshift())); + for (int i=0; i < path->curve.n; i++) { + if (path->curve.tag[i] == POTRACE_CURVETO) { + curveTo(hsf*(path->curve.c[i][0].x+bitmap.xshift()), vsf*(path->curve.c[i][0].y+bitmap.yshift()), + hsf*(path->curve.c[i][1].x+bitmap.xshift()), vsf*(path->curve.c[i][1].y+bitmap.yshift()), + hsf*(path->curve.c[i][2].x+bitmap.xshift()), vsf*(path->curve.c[i][2].y+bitmap.yshift())); + } + else { + lineTo(hsf*(path->curve.c[i][1].x+bitmap.xshift()), vsf*(path->curve.c[i][1].y+bitmap.yshift())); + if (i == path->curve.n-1) + closePath(); + else + lineTo(hsf*(path->curve.c[i][2].x+bitmap.xshift()), vsf*(path->curve.c[i][2].y+bitmap.yshift())); + } + } + } + } + potrace_state_free(state); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.h new file mode 100644 index 00000000000..ba15961db65 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GFTracer.h @@ -0,0 +1,47 @@ +/************************************************************************* +** GFTracer.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GFTRACER_H +#define GFTRACER_H + +#include +#include "GFReader.h" + +class GFTracer : public GFReader +{ + public: + GFTracer (std::istream &is); + GFTracer (std::istream &is, double upp); + virtual ~GFTracer () {} + virtual void moveTo (double x, double y) {} + virtual void lineTo (double x, double y) {} + virtual void curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y) {} + virtual void closePath () {} + void beginChar (UInt32 c); + void endChar (UInt32 c); + + protected: + void unitsPerPoint(double upp) {_unitsPerPoint = upp;} + + private: + double _unitsPerPoint; ///< target units per TeX point +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.cpp new file mode 100644 index 00000000000..7da863cbc82 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.cpp @@ -0,0 +1,269 @@ +/************************************************************************* +** Ghostscript.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "Ghostscript.h" +#if !defined(DISABLE_GS) + +#include +#include +#include + +#if defined(HAVE_LIBGS) + #include +#else + #include "ierrors.h" +#endif + +using namespace std; + +// default name of dynamic/shared Ghostscript library +#if defined(__WIN64__) + #define GS_DL_NAME "gsdll64.dll" +#elif defined(__WIN32__) + #define GS_DL_NAME "gsdll32.dll" +#else + #define GS_DL_NAME "libgs.so" +#endif + + +string Ghostscript::LIBGS_NAME; + + +/** Loads the Ghostscript library but does not create an instance. This + * constructor should only be used to call available() and revision(). */ +Ghostscript::Ghostscript () +#if !defined(HAVE_LIBGS) + : DLLoader(LIBGS_NAME.empty() ? GS_DL_NAME : LIBGS_NAME.c_str()) +#endif +{ + _inst = 0; +} + + +/** Tries to load the shared library and to initialize Ghostscript. + * @param[in] argc number of parameters in array argv + * @param[in] argv parameters passed to Ghostscript + * @param[in] caller this parameter is passed to all callback functions */ +Ghostscript::Ghostscript (int argc, const char **argv, void *caller) +#if !defined(HAVE_LIBGS) + : DLLoader(LIBGS_NAME.empty() ? GS_DL_NAME : LIBGS_NAME.c_str()) +#endif +{ + _inst = 0; + init(argc, argv, caller); +} + + +/** Exits Ghostscript and unloads the dynamic library. */ +Ghostscript::~Ghostscript () { + if (_inst) { + exit(); + delete_instance(); + } +} + + +bool Ghostscript::init (int argc, const char **argv, void *caller) { + if (!_inst) { + int status = new_instance(&_inst, caller); + if (status < 0) + _inst = 0; + else { + init_with_args(argc, (char**)argv); + } + } + return _inst != 0; +} + + +/** Returns true if Ghostscript library was found and can be loaded. */ +bool Ghostscript::available () { +#if defined(HAVE_LIBGS) + return true; +#else + return loaded(); +#endif +} + + +/** 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) { +#if defined(HAVE_LIBGS) + return (gsapi_revision(r, sizeof(gsapi_revision_t)) == 0); +#else + if (PFN_gsapi_revision fn = (PFN_gsapi_revision)loadSymbol("gsapi_revision")) + return (fn(r, sizeof(gsapi_revision_t)) == 0); + return false; +#endif +} + + +/** Returns product name and revision number of the GS library. + * @param[in] revonly if true, only the revision number is returned */ +string Ghostscript::revision (bool revonly) { + gsapi_revision_t r; + if (revision(&r)) { + ostringstream oss; + if (!revonly) + oss << r.product << ' '; + oss << (r.revision/100) << '.' << setfill('0') << setw(2) << (r.revision%100); + return oss.str(); + } + return ""; +} + + +/** Creates a new instance of Ghostscript. This method is called by the constructor and + * should not be used elsewhere. + * @param[out] psinst handle of newly created instance (or 0 on error) + * @param[in] caller pointer forwarded to callback functions */ +int Ghostscript::new_instance (void **psinst, void *caller) { +#if defined(HAVE_LIBGS) + return gsapi_new_instance(psinst, caller); +#else + if (PFN_gsapi_new_instance fn = (PFN_gsapi_new_instance)loadSymbol("gsapi_new_instance")) + return fn(psinst, caller); + *psinst = 0; + return 0; +#endif +} + + +/** Destroys the current instance of Ghostscript. This method is called by the destructor + * and should not be used elsewhere. */ +void Ghostscript::delete_instance () { +#if defined(HAVE_LIBGS) + gsapi_delete_instance(_inst); +#else + if (PFN_gsapi_delete_instance fn = (PFN_gsapi_delete_instance)loadSymbol("gsapi_delete_instance")) + fn(_inst); +#endif +} + + +/** Exits the interpreter. Must be called before destroying the GS instance. */ +int Ghostscript::exit () { +#if defined(HAVE_LIBGS) + return gsapi_exit(_inst); +#else + if (PFN_gsapi_exit fn = (PFN_gsapi_exit)loadSymbol("gsapi_exit")) + return fn(_inst); + return 0; +#endif +} + + +/** Sets the I/O callback functions. + * @param[in] in pointer to stdin handler + * @param[in] out pointer to stdout handler + * @param[in] err pointer to stderr handler */ +int Ghostscript::set_stdio (Stdin in, Stdout out, Stderr err) { +#if defined(HAVE_LIBGS) + return gsapi_set_stdio(_inst, in, out, err); +#else + if (PFN_gsapi_set_stdio fn = (PFN_gsapi_set_stdio)loadSymbol("gsapi_set_stdio")) + return fn(_inst, in, out, err); + return 0; +#endif +} + + +/** Initializes Ghostscript with a set of optional parameters. This + * method is called by the constructor and should not be used elsewhere. + * @param[in] argc number of paramters + * @param[in] argv parameters passed to Ghostscript */ +int Ghostscript::init_with_args (int argc, char **argv) { +#if defined(HAVE_LIBGS) + return gsapi_init_with_args(_inst, argc, argv); +#else + if (PFN_gsapi_init_with_args fn = (PFN_gsapi_init_with_args)loadSymbol("gsapi_init_with_args")) + return fn(_inst, argc, argv); + return 0; +#endif +} + + +/** Tells Ghostscript that several calls of run_string_continue will follow. */ +int Ghostscript::run_string_begin (int user_errors, int *pexit_code) { +#if defined(HAVE_LIBGS) + return gsapi_run_string_begin(_inst, user_errors, pexit_code); +#else + if (PFN_gsapi_run_string_begin fn = (PFN_gsapi_run_string_begin)loadSymbol("gsapi_run_string_begin")) + return fn(_inst, user_errors, pexit_code); + *pexit_code = 0; + return 0; +#endif +} + + +/** Executes a chunk of PostScript commands given by a buffer of characters. The size of + * this buffer must not exceed 64KB. Longer programs can be split into arbitrary smaller chunks + * and passed to Ghostscript by successive calls of run_string_continue. + * @param[in] str buffer containing the PostScript code + * @param[in] length number of characters in buffer + * @param[in] user_errors if non-negative, the default PS error values will be generated, otherwise this value is returned + * @param[out] pexit_code takes the PS error code */ +int Ghostscript::run_string_continue (const char *str, unsigned length, int user_errors, int *pexit_code) { +#if defined(HAVE_LIBGS) + return gsapi_run_string_continue(_inst, str, length, user_errors, pexit_code); +#else + if (PFN_gsapi_run_string_continue fn = (PFN_gsapi_run_string_continue)loadSymbol("gsapi_run_string_continue")) + return fn(_inst, str, length, user_errors, pexit_code); + *pexit_code = 0; + return 0; +#endif +} + + +/** Terminates the successive code feeding. Must be called after the last call of run_string_continue. */ +int Ghostscript::run_string_end (int user_errors, int *pexit_code) { +#if defined(HAVE_LIBGS) + return gsapi_run_string_end(_inst, user_errors, pexit_code); +#else + if (PFN_gsapi_run_string_end fn = (PFN_gsapi_run_string_end)loadSymbol("gsapi_run_string_end")) + return fn(_inst, user_errors, pexit_code); + *pexit_code = 0; + return 0; +#endif +} + + +const char* Ghostscript::error_name (int code) { + if (code < 0) + code = -code; + const char *error_names[] = { ERROR_NAMES }; + if (code == 0 || (size_t)code > sizeof(error_names)/sizeof(error_names[0])) + return 0; +#if defined(HAVE_LIBGS) + // use array defined in libgs to avoid linking the error strings into the binary + return gs_error_names[code-1]; +#elif defined(__WIN32__) + // gs_error_names is private in the Ghostscript DLL so we can't access it here + return error_names[code-1]; +#else + if (const char **error_names = (const char**)loadSymbol("gs_error_names")) + return error_names[code-1]; + return 0; +#endif +} + +#endif // !DISABLE_GS diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.h new file mode 100644 index 00000000000..ccfd5b0b0f4 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Ghostscript.h @@ -0,0 +1,104 @@ +/************************************************************************* +** Ghostscript.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GHOSTSCRIPT_H +#define GHOSTSCRIPT_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#if defined(DISABLE_GS) + #include "iapi.h" +#elif defined(HAVE_LIBGS) + #include +#else + #include "DLLoader.h" + #include "iapi.h" +#endif + +#if defined(__WIN32__) && !defined(_Windows) + #define _Windows +#endif + +#if defined(DISABLE_GS) +struct Ghostscript +{ + typedef int (GSDLLCALLPTR Stdin) (void *caller, char *buf, int len); + typedef int (GSDLLCALLPTR Stdout) (void *caller, const char *str, int len); + typedef int (GSDLLCALLPTR Stderr) (void *caller, const char *str, int len); + + Ghostscript () {} + Ghostscript (int argc, const char **argv, void *caller=0) {} + bool available () {return false;} + bool revision (gsapi_revision_t *r) {return false;} + std::string revision (bool revonly=false) {return "";} + int set_stdio (Stdin in, Stdout out, Stderr err) {return 0;} + int run_string_begin (int user_errors, int *pexit_code) {return 0;} + int run_string_continue (const char *str, unsigned int length, int user_errors, int *pexit_code) {return 0;} + int run_string_end (int user_errors, int *pexit_code) {return 0;} + int exit () {return 0;} +}; + +#else + +/** Wrapper class of (a subset of) the Ghostscript API. */ +class Ghostscript +#if !defined(HAVE_LIBGS) +: public DLLoader +#endif +{ + public: + typedef int (GSDLLCALLPTR Stdin) (void *caller, char *buf, int len); + typedef int (GSDLLCALLPTR Stdout) (void *caller, const char *str, int len); + typedef int (GSDLLCALLPTR Stderr) (void *caller, const char *str, int len); + + public: + Ghostscript (); + Ghostscript (int argc, const char **argv, void *caller=0); + ~Ghostscript (); + bool init (int argc, const char **argv, void *caller=0); + bool available (); + bool revision (gsapi_revision_t *r); + std::string revision (bool revonly=false); + int set_stdio (Stdin in, Stdout out, Stderr err); + int run_string_begin (int user_errors, int *pexit_code); + int run_string_continue (const char *str, unsigned int length, int user_errors, int *pexit_code); + int run_string_end (int user_errors, int *pexit_code); + int exit (); + const char* error_name (int code); + + static std::string LIBGS_NAME; + + protected: + Ghostscript (const Ghostscript &gs) {} + int init_with_args (int argc, char **argv); + int new_instance (void **psinst, void *caller); + void delete_instance (); + + private: + void *_inst; ///< Ghostscript handle needed to call the gsapi_foo functions +}; + +#endif // DISABLE_GS + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Glyph.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Glyph.h new file mode 100644 index 00000000000..b598dc5002d --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Glyph.h @@ -0,0 +1,28 @@ +/************************************************************************* +** Glyph.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GLYPH_H +#define GLYPH_H + +#include "GraphicPath.h" + +typedef GraphicPath Glyph; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GlyphTracerMessages.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GlyphTracerMessages.h new file mode 100644 index 00000000000..2b0cedcd8b6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GlyphTracerMessages.h @@ -0,0 +1,65 @@ +/************************************************************************* +** GlyphTracerMessages.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GLYPHTRACERMESSAGES_H +#define GLYPHTRACERMESSAGES_H + +#include +#include "GFGlyphTracer.h" +#include "Message.h" +#include "types.h" + +class GlyphTracerMessages : public GFGlyphTracer::Callback +{ + public: + GlyphTracerMessages (bool sfmsg=true, bool autonl=true) : _sfmsg(sfmsg), _autonl(autonl) {} + + ~GlyphTracerMessages () { + if (_autonl) + Message::mstream() << '\n'; + } + + void endChar (UInt8 c) { + std::ostringstream oss; + oss << '['; + if (isprint(c)) + oss << c; + else + oss << '#' << unsigned(c); + oss << ']'; + Message::mstream(false, Message::MC_TRACING) << oss.str(); + } + + void setFont (const std::string &fname) { + if (_sfmsg && fname != _fname) { + if (!_fname.empty()) + Message::mstream() << '\n'; + Message::mstream(false, Message::MC_STATE) << "tracing glyphs of " << fname.substr(0, fname.length()-3) << '\n'; + _fname = fname; + } + } + + private: + std::string _fname; + bool _sfmsg, _autonl; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GraphicPath.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GraphicPath.h new file mode 100644 index 00000000000..46a3b0cc335 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/GraphicPath.h @@ -0,0 +1,340 @@ +/************************************************************************* +** GraphicPath.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef GRAPHICPATH_H +#define GRAPHICPATH_H + +#include +#include +#include +#include "BoundingBox.h" +#include "Matrix.h" +#include "Pair.h" +#include "XMLString.h" + + +template +class GraphicPath +{ + public: + typedef Pair Point; + + struct Command { + enum Type {MOVETO, LINETO, CONICTO, CUBICTO, CLOSEPATH}; + + Command (Type t) : type(t) {} + + Command (Type t, const Point &p) : type(t) { + params[0] = p; + } + + Command (Type t, const Point &p1, const Point &p2) : type(t) { + params[0] = p1; + params[1] = p2; + } + + Command (Type t, const Point &p1, const Point &p2, const Point &p3) : type(t) { + params[0] = p1; + params[1] = p2; + params[2] = p3; + } + + int numParams () const { + switch (type) { + case CLOSEPATH : return 0; + case MOVETO : + case LINETO : return 1; + case CONICTO : return 2; + case CUBICTO : return 3; + } + return 0; + } + + void transform (const Matrix &matrix) { + for (int i=0; i < numParams(); i++) + params[i] = matrix * params[i]; + } + + Type type; + Point params[3]; + }; + + struct Actions + { + virtual ~Actions () {} + virtual void moveto (const Point &p) {} + virtual void lineto (const Point &p) {} + virtual void hlineto (const T &y) {} + virtual void vlineto (const T &x) {} + virtual void sconicto (const Point &p) {} + virtual void conicto (const Point &p1, const Point &p2) {} + virtual void scubicto (const Point &p1, const Point &p2) {} + virtual void cubicto (const Point &p1, const Point &p2, const Point &p3) {} + virtual void closepath () {} + virtual void draw (char cmd, const Point *points, int n) {} + virtual bool quit () {return false;} + }; + + typedef typename std::vector::iterator Iterator; + typedef typename std::vector::const_iterator ConstIterator; + typedef typename std::vector::const_reverse_iterator ConstRevIterator; + + public: + void newpath () { + _commands.clear(); + } + + /// Returns true if path is empty (there is nothing to draw) + bool empty () const { + return _commands.empty(); + } + + + /// Returns the number of path commands used to describe the path. + size_t size () const { + return _commands.size(); + } + + void moveto (const T &x, const T &y) { + moveto(Point(x, y)); + } + + void moveto (const Point &p) { + // avoid sequences of several MOVETOs; always use latest + if (_commands.empty() || _commands.back().type != Command::MOVETO) + _commands.push_back(Command(Command::MOVETO, p)); + else + _commands.back().params[0] = p; + } + + void lineto (const T &x, const T &y) { + lineto(Point(x, y)); + } + + void lineto (const Point &p) { + _commands.push_back(Command(Command::LINETO, p)); + } + + void conicto (const T &x1, const T &y1, const T &x2, const T &y2) { + conicto(Point(x1, y1), Point(x2, y2)); + } + + void conicto (const Point &p1, const Point &p2) { + _commands.push_back(Command(Command::CONICTO, p1, p2)); + } + + void cubicto (const T &x1, const T &y1, const T &x2, const T &y2, const T &x3, const T &y3) { + cubicto(Point(x1, y1), Point(x2, y2), Point(x3, y3)); + } + + void cubicto (const Point &p1, const Point &p2, const Point &p3) { + _commands.push_back(Command(Command::CUBICTO, p1, p2, p3)); + } + + void closepath () { + _commands.push_back(Command(Command::CLOSEPATH)); + } + + + const std::vector& commands () const { + return _commands; + } + + + /** Detects all open subpaths and closes them by adding a closePath command. + * Most font formats only support closed outline paths so there are no explicit closePath statements + * in the glyph's outline description. All open paths are automatically closed by the renderer. + * This method detects all open paths and adds the missing closePath statement. */ + void closeOpenSubPaths () { + Command *prevCommand = 0; + FORALL(_commands, Iterator, it) { + if (it->type == Command::MOVETO && prevCommand && prevCommand->type != Command::CLOSEPATH) { + prevCommand = &(*it); + it = _commands.insert(it, Command(Command::CLOSEPATH))+1; +// ++it; // skip inserted closePath command in next iteration step + } + else + prevCommand = &(*it); + } + if (!_commands.empty() && _commands.back().type != Command::CLOSEPATH) + closepath(); + } + + + /** Writes the path data as SVG path drawing command to a given output stream. + * @param[in] os output stream used to write the SVG commands to + * @param[in] sx horizontal scale factor + * @param[in] sy vertical scale factor + * @param[in] dx horizontal translation in TeX point units + * @param[in] sy vertical translation in TeX point units */ + void writeSVG (std::ostream &os, double sx=1.0, double sy=1.0, double dx=0.0, double dy=0.0) const { + struct WriteActions : Actions { + WriteActions (std::ostream &os, double sx, double sy, double dx, double dy) + : _os(os), _sx(sx), _sy(sy), _dx(dx), _dy(dy) {} + + void draw (char cmd, const Point *points, int n) { + _os << cmd; + switch (cmd) { + case 'H': _os << XMLString(_sx*points->x()+_dx); break; + case 'V': _os << XMLString(_sy*points->y()+_dy); break; + default : + for (int i=0; i < n; i++) { + if (i > 0) + _os << ' '; + _os << XMLString(_sx*points[i].x()+_dx) << ' ' << XMLString(_sy*points[i].y()+_dy); + } + } + } + std::ostream &_os; + double _sx, _sy, _dx, _dy; + } actions(os, sx, sy, dx, dy); + iterate(actions, true); + } + + + /** Computes the bounding box of the current path. + * @param[out] bbox the computed bounding box */ + void computeBBox (BoundingBox &bbox) const { + struct BBoxActions : Actions { + BBoxActions (BoundingBox &bb) : bbox(bb) {} + void moveto (const Point &p) {bbox.embed(p);} + void lineto (const Point &p) {bbox.embed(p);} + void conicto (const Point &p1, const Point &p2) {bbox.embed(p1); bbox.embed(p2);} + void cubicto (const Point &p1, const Point &p2, const Point &p3) {bbox.embed(p1); bbox.embed(p2); bbox.embed(p3);} + BoundingBox &bbox; + } actions(bbox); + iterate(actions, false); + } + + + /** Checks whether the current path describes a dot/point only (with no extent). + * @param[out] p coordinates of the point if path describes a dot + * @return true if path is a dot/point */ + bool isDot (Point &p) const { + struct DotActions : Actions { + DotActions () : differs(false) {} + void moveto (const Point &p) {point = p;} + void lineto (const Point &p) {differs = (p != point);} + void conicto (const Point &p1, const Point &p2) {differs = (point != p1 || point != p2);} + void cubicto (const Point &p1, const Point &p2, const Point &p3) {differs = (point != p1 || point != p2 || point != p3);} + bool quit () {return differs;} + Point point; + bool differs; + } actions; + iterate(actions, false); + p = actions.point; + return !actions.differs; + } + + + /** Transforms the path according to a given Matrix. + * @param[in] matrix Matrix describing the affine transformation */ + void transform (const Matrix &matrix) { + FORALL(_commands, Iterator, it) + it->transform(matrix); + } + + void iterate (Actions &actions, bool optimize) const; + + private: + std::vector _commands; +}; + + +/** Iterates over all commands defining this path and calls the corresponding template methods. + * In the case of successive bezier curve sequences, control points or tangent slopes are often + * identical so that the path description contains redundant information. SVG provides shorthand + * curve commands that require less parameters. If 'optimize' is true, this method detects such + * command sequences. + * @param[in] actions template methods called by each iteration step + * @param[in] optimize if true, shorthand drawing commands (sconicto, scubicto,...) are considered */ +template +void GraphicPath::iterate (Actions &actions, bool optimize) const { + ConstIterator prev = _commands.end(); // pointer to preceding command + Point fp; // first point of current path + Point cp; // current point + Point pstore[2]; + for (ConstIterator it=_commands.begin(); it != _commands.end() && !actions.quit(); ++it) { + const Point *params = it->params; + switch (it->type) { + case Command::MOVETO: + actions.moveto(params[0]); + actions.draw('M', params, 1); + fp = params[0]; + break; + case Command::LINETO: + if (optimize) { + if (cp.x() == params[0].x()) { + actions.vlineto(params[0].y()); + actions.draw('V', params, 1); + } + else if (cp.y() == params[0].y()) { + actions.hlineto(params[0].x()); + actions.draw('H', params, 1); + } + else { + actions.lineto(params[0]); + actions.draw('L', params, 1); + } + } + else { + actions.lineto(params[0]); + actions.draw('L', params, 1); + } + break; + case Command::CONICTO: + if (optimize && prev != _commands.end() && prev->type == Command::CONICTO && params[0] == pstore[1]*T(2)-pstore[0]) { + actions.sconicto(params[1]); + actions.draw('T', params+1, 1); + } + else { + actions.conicto(params[0], params[1]); + actions.draw('Q', params, 2); + } + pstore[0] = params[0]; // store control point and + pstore[1] = params[1]; // curve endpoint + break; + case Command::CUBICTO: + // is first control point reflection of preceding second control point? + if (optimize && prev != _commands.end() && prev->type == Command::CUBICTO && params[0] == pstore[1]*T(2)-pstore[0]) { + actions.scubicto(params[1], params[2]); + actions.draw('S', params+1, 2); + } + else { + actions.cubicto(params[0], params[1], params[2]); + actions.draw('C', params, 3); + } + pstore[0] = params[1]; // store second control point and + pstore[1] = params[2]; // curve endpoint + break; + case Command::CLOSEPATH: + actions.closepath(); + actions.draw('Z', params, 0); + cp = fp; + } + // update current point + const int np = it->numParams(); + if (np > 0) + cp = it->params[np-1]; + prev = it; + } +} + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.cpp new file mode 100644 index 00000000000..bf19c6335d1 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.cpp @@ -0,0 +1,205 @@ +/************************************************************************* +** HtmlSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include + +#include "HtmlSpecialHandler.h" +#include "InputReader.h" +#include "Message.h" +#include "SVGTree.h" +#include "XMLNode.h" + +using namespace std; + +// variable to select the link marker variant (none, underlined, or boxed) +HtmlSpecialHandler::LinkMarker HtmlSpecialHandler::LINK_MARKER = HtmlSpecialHandler::LM_LINE; + + +bool HtmlSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + if (!actions) + return true; + _actions = actions; + StreamInputReader ir(is); + ir.skipSpace(); + map attribs; + map::iterator it; + if (ir.check(" 0) { + if ((it = attribs.find("href")) != attribs.end()) // + hrefAnchor(it->second); + else if ((it = attribs.find("name")) != attribs.end()) // + nameAnchor(it->second); + else + return false; // none or only invalid attributes + } + else if (ir.check("")) + closeAnchor(); + else if (ir.check(" 0 && (it = attribs.find("href")) != attribs.end()) + _base = it->second; + return true; +} + + +/** Handles anchors with href attribute: ... + * @param uri value of href attribute */ +void HtmlSpecialHandler::hrefAnchor (string uri) { + closeAnchor(); + int id=0; + if (uri[0] == '#') { // reference to named anchor? + string name = uri.substr(1); + NamedAnchors::iterator it = _namedAnchors.find(name); + if (it == _namedAnchors.end()) { + id = _namedAnchors.size()+1; + _namedAnchors[name] = NamedAnchor(-id, 0); + } + } + if (!_base.empty() && uri.find("://") != string::npos) { + if (*_base.rbegin() != '/' && uri[0] != '/' && uri[0] != '#') + uri = "/" + uri; + uri = _base + uri; + } + XMLElementNode *anchor = new XMLElementNode("a"); + anchor->addAttribute("xlink:href", id ? "#loc"+XMLString(id) : uri); + anchor->addAttribute("xlink:title", uri); + _actions->pushContextElement(anchor); + _actions->bbox("{anchor}", true); // start computing the bounding box of the linked area + _anchorYPos = _actions->getY(); + _anchorType = AT_HREF; +} + + +/** Handles anchors with name attribute: ... + * @param name value of name attribute */ +void HtmlSpecialHandler::nameAnchor (const string &name) { + closeAnchor(); + _anchorName = name; + NamedAnchors::iterator it = _namedAnchors.find(name); + if (it == _namedAnchors.end()) { // first occurrence of this anchor + int id = _namedAnchors.size()+1; + _namedAnchors[name] = NamedAnchor(id, _actions->getY()); + } + else if (it->second.id < 0) { // anchor referenced but not defined yet + it->second.id *= -1; + it->second.pos = _actions->getY(); + } + else + Message::wstream(true) << "named hyperref anchor '" << name << "' redefined\n"; + _anchorType = AT_NAME; +} + + +/** Handles the closing tag ( of the current anchor element. */ +void HtmlSpecialHandler::closeAnchor () { + if (_anchorType == AT_HREF) { + markLinkedBox(); + _actions->popContextElement(); + } + else if (_anchorType == AT_NAME) + _anchorName.clear(); + _anchorType = AT_NONE; +} + + +/** Marks a single rectangular area of the linked part of the document with a line or + * a box so that it's noticeable by the user. Additionally, an invisible rectangle is + * placed over this area in order to avoid flickering of the mouse cursor when moving + * it over the hyperlinked area. */ +void HtmlSpecialHandler::markLinkedBox () { + const BoundingBox &bbox = _actions->bbox("{anchor}"); + if (bbox.width() > 0 && bbox.height() > 0) { // does the bounding box extend in both dimensions? + if (LINK_MARKER != LM_NONE) { + const double linewidth = min(0.5, bbox.height()/15); + XMLElementNode *rect = new XMLElementNode("rect"); + double x = bbox.minX(); + double y = bbox.maxY()+linewidth; + double w = bbox.width(); + double h = linewidth; + if (LINK_MARKER == LM_LINE) + rect->addAttribute("fill", _actions->getColor().rgbString()); + else { // LM_BOX + x -= linewidth; + y = bbox.minY()-linewidth; + w += 2*linewidth; + h += bbox.height()+linewidth; + rect->addAttribute("fill", "none"); + rect->addAttribute("stroke", _actions->getColor().rgbString()); + rect->addAttribute("stroke-width", linewidth); + } + rect->addAttribute("x", x); + rect->addAttribute("y", y); + rect->addAttribute("width", w); + rect->addAttribute("height", h); + _actions->appendToPage(rect); + } + // 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) { + XMLElementNode *rect = new XMLElementNode("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); + _actions->appendToPage(rect); + } + } +} + + +/** This method is called every time the DVI position changes. */ +void HtmlSpecialHandler::dviMovedTo (double x, double y) { + if (_actions && _anchorType != AT_NONE) { + if (y != _anchorYPos) { // does vertical position changed inside a linked area? + markLinkedBox(); + _anchorYPos = y; + _actions->bbox("{anchor}", true); // start a new box on the new line + } + } +} + + +void HtmlSpecialHandler::dviEndPage (unsigned pageno) { + if (_actions) { + // create views for all collected named anchors defined on the recent page + const BoundingBox &pagebox = _actions->bbox(); + for (NamedAnchors::iterator it=_namedAnchors.begin(); it != _namedAnchors.end(); ++it) { + if (it->second.id > 0) { // current anchor referenced? + ostringstream oss; + oss << pagebox.minX() << ' ' << it->second.pos << ' ' + << pagebox.width() << ' ' << pagebox.height(); + XMLElementNode *view = new XMLElementNode("view"); + view->addAttribute("id", "loc"+XMLString(it->second.id)); + view->addAttribute("viewBox", oss.str()); + _actions->appendToDefs(view); + } + } + closeAnchor(); + _namedAnchors.clear(); + _actions = 0; + } +} + + +const char** HtmlSpecialHandler::prefixes () const { + static const char *pfx[] = {"html:", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.h new file mode 100644 index 00000000000..2c0bb7e88a4 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/HtmlSpecialHandler.h @@ -0,0 +1,69 @@ +/************************************************************************* +** HtmlSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef HTMLSPECIALHANDLER_H +#define HTMLSPECIALHANDLER_H + +#include +#include +#include "SpecialHandler.h" + +struct SpecialActions; + +class HtmlSpecialHandler : public SpecialHandler, public DVIEndPageListener, public DVIPositionListener +{ + struct NamedAnchor { + NamedAnchor () : id(0), pos(0) {} + NamedAnchor (int i, double p) : id(i), pos(p) {} + int id; ///< unique numerical ID (< 0 if anchor is unreferenced) + double pos; ///< vertical position of named anchor (in TeX point units) + }; + + enum AnchorType {AT_NONE, AT_HREF, AT_NAME}; + typedef std::map NamedAnchors; + + public: + HtmlSpecialHandler () : _actions(0), _anchorType(AT_NONE), _anchorYPos(0) {} + bool process (const char *prefix, std::istream &in, SpecialActions *actions); + const char* name () const {return "html";} + const char* info () const {return "hyperref specials";} + const char** prefixes () const; + + enum LinkMarker {LM_NONE, LM_LINE, LM_BOX}; + static LinkMarker LINK_MARKER; ///< selects how linked areas are marked + + protected: + void hrefAnchor (std::string uri); + void nameAnchor (const std::string &name); + void dviEndPage (unsigned pageno); + void dviMovedTo (double x, double y); + void closeAnchor (); + void markLinkedBox (); + + private: + SpecialActions *_actions; + AnchorType _anchorType; ///< type of active anchor + double _anchorYPos; ///< current vertical position inside linked area + std::string _anchorName; ///< name of currently active named anchor + std::string _base; ///< base URL that is prepended to all relative targets + NamedAnchors _namedAnchors; ///< information about all named anchors processed +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.cpp new file mode 100644 index 00000000000..ad99305fa3c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.cpp @@ -0,0 +1,137 @@ +/************************************************************************* +** InputBuffer.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "InputBuffer.h" + +using namespace std; + + +StreamInputBuffer::StreamInputBuffer (istream &is, size_t bufsize) + : _is(is), _bufsize(bufsize), _buf1(new UInt8[_bufsize]), _buf2(new UInt8[_bufsize]), _bufptr(_buf1) +{ + _size1 = fillBuffer(_buf1); + _size2 = fillBuffer(_buf2); +} + + +StreamInputBuffer::~StreamInputBuffer () { + delete [] _buf1; + delete [] _buf2; +} + + +int StreamInputBuffer::get () { + if (pos() == _size1) { + if (_size2 == 0) + return -1; + swap(_buf1, _buf2); + _size1 = _size2; + _bufptr = _buf1; + _size2 = fillBuffer(_buf2); + } + UInt8 c = *_bufptr++; + return c; +} + + +/** Returns the next character to be read without skipping it. + * Same as peek(0). */ +int StreamInputBuffer::peek () const { + if (pos() < _size1) + return *_bufptr; + return _size2 > 0 ? *_buf2 : -1; +} + + +/** Returns the n-th next character without skipping it. */ +int StreamInputBuffer::peek (size_t n) const { + if (pos()+n < _size1) + return *(_bufptr+n); + if (pos()+n < _size1+_size2) + return *(_buf2 + pos()+n-_size1); + return -1; +} + + +/** Fills the buffer by reading a sequence of characters from the assigned + * input stream. + * @param[in] buf pointer to character buffer to be filled + * @return number of characters read */ +int StreamInputBuffer::fillBuffer (UInt8 *buf) { + if (_is && !_is.eof()) { + _is.read((char*)buf, _bufsize); + return _is.gcount(); + } + return 0; +} + +/////////////////////////////////////////////// + +SplittedCharInputBuffer::SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2) { + _buf[0] = buf1; + _buf[1] = buf2; + _size[0] = buf1 ? s1 : 0; + _size[1] = buf2 ? s2 : 0; + _index = _size[0] ? 0 : 1; +} + + +int SplittedCharInputBuffer::get () { + if (_size[_index] == 0) + return -1; + int ret = *_buf[_index]++; + _size[_index]--; + if (_index == 0 && _size[0] == 0) + _index++; + return ret; +} + + +int SplittedCharInputBuffer::peek () const { + return _size[_index] ? *_buf[_index] : -1; +} + + +int SplittedCharInputBuffer::peek (size_t n) const { + if (n < _size[_index]) + return _buf[_index][n]; + n -= _size[_index]; + if (_index == 0 && n < _size[1]) + return _buf[1][n]; + return -1; +} + +/////////////////////////////////////////////// + + +int TextStreamInputBuffer::get () { + int c = StreamInputBuffer::get(); + if (c == '\n') { + _line++; + _col = 1; + } + else + _col++; + return c; +} + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.h new file mode 100644 index 00000000000..c25df9a1452 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputBuffer.h @@ -0,0 +1,145 @@ +/************************************************************************* +** InputBuffer.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef INPUTBUFFER_H +#define INPUTBUFFER_H + +#include +#include +#include +#include +#include +#include "types.h" + +struct InputBuffer +{ + virtual ~InputBuffer () {} + virtual int get () =0; + virtual int peek () const =0; + virtual int peek (size_t n) const =0; + virtual bool eof () const =0; + virtual void invalidate () =0; +}; + + +class StreamInputBuffer : public InputBuffer +{ + public: + StreamInputBuffer (std::istream &is, size_t bufsize=1024); + ~StreamInputBuffer (); + int get (); + int peek () const; + int peek (size_t n) const; + bool eof () const {return pos() == _size1 && _size2 == 0;} + void invalidate () {_bufptr = _buf1+_size1; _size2 = 0;} + + protected: + int fillBuffer (UInt8 *buf); + size_t pos () const {return _bufptr-_buf1;} + + private: + std::istream &_is; + const size_t _bufsize; ///< maximal number of bytes each buffer can hold + UInt8 *_buf1; ///< pointer to first buffer + UInt8 *_buf2; ///< pointer to second buffer + size_t _size1; ///< number of bytes in buffer 1 + size_t _size2; ///< number of bytes in buffer 2 + UInt8 *_bufptr; ///< pointer to next byte to read +}; + + +class StringInputBuffer : public InputBuffer +{ + public: + StringInputBuffer (const std::string &str) : _str(str), _pos(0) {} + int get () {return _pos < _str.length() ? _str[_pos++] : -1;} + int peek () const {return _pos < _str.length() ? _str[_pos] : -1;} + int peek (size_t n) const {return _pos+n < _str.length() ? _str[_pos+n] : -1;} + bool eof () const {return _pos >= _str.length();} + void invalidate () {_pos = _str.length();} + + private: + const std::string &_str; + size_t _pos; +}; + + +class CharInputBuffer : public InputBuffer +{ + public: + CharInputBuffer (const char *buf, size_t size) : _pos(buf), _size(buf ? size : 0) {} + + int get () { + if (_size <= 0) + return -1; + else { + _size--; + return *_pos++; + } + } + + + void assign (const char *buf, size_t size) { + _pos = buf; + _size = size; + } + + void assign (const char *buf) {assign(buf, std::strlen(buf));} + int peek () const {return _size > 0 ? *_pos : -1;} + int peek (size_t n) const {return _size >= n ? _pos[n] : -1;} + bool eof () const {return _size <= 0;} + void invalidate () {_size = 0;} + + private: + const char *_pos; + size_t _size; +}; + + +class SplittedCharInputBuffer : public InputBuffer +{ + public: + SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2); + int get (); + int peek () const; + int peek (size_t n) const; + bool eof () const {return _size[_index] == 0;} + void invalidate () {_size[_index] = 0;} + + private: + const char *_buf[2]; + size_t _size[2]; + int _index; +}; + + +class TextStreamInputBuffer : public StreamInputBuffer +{ + public: + TextStreamInputBuffer (std::istream &is) : StreamInputBuffer(is), _line(1), _col(1) {} + int get (); + int line () const {return _line;} + int col () const {return _col;} + + private: + int _line, _col; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.cpp new file mode 100644 index 00000000000..c2eaa249ff0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.cpp @@ -0,0 +1,329 @@ +/************************************************************************* +** InputReader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "InputReader.h" + +using namespace std; + + +/** Skips n characters. */ +void InputReader::skip (size_t n) { + while (n-- > 0) + get(); +} + + +/** Moves the buffer pointer to the next non-space character. A following call + * of get() returns this character. */ +void InputReader::skipSpace () { + while (isspace(peek())) + get(); +} + + +/** Tries to find a given string and skips all characters preceding that string. + * @param[in] s string to look for (must not be longer than the maximal buffer size) + * @param[in] consume if true, the buffer pointer is moved to the first character following string s + * @return true if s was found */ +bool InputReader::skipUntil (const char *s, bool consume) { + bool found = false; + while (!eof() && !(found = check(s, consume))) + get(); + return found; +} + + +/** Looks for the first occurrence of a given character. + * @param[in] c character to lookup + * @return position of character relative to current location, -1 if character was not found */ +int InputReader::find (char c) const { + int pos = 0; + int cc; + while ((cc = peek(pos)) >= 0 && cc != c) + pos++; + return cc < 0 ? -1 : pos; +} + + +/** Checks if the next characters to be read match a given string. + * @param[in] s string to be matched + * @param[in] consume if true, the characters of the matched string are skipped + * @return true if s matches */ +bool InputReader::check (const char *s, bool consume) { + size_t count = 0; + for (const char *p=s; *p; p++) { + if (peek(count++) != *p) + return false; + } + if (consume) + skip(count); + return true; +} + + +int InputReader::compare (const char *s, bool consume) { + size_t count = 0; + for (const char *p=s; *p; p++) { + int c = peek(count++); + if (c != *p) + return *p < c ? -1 : 1; + } + if (consume) + skip(count); + return 0; +} + + +/** Reads an integer from the buffer. All characters that are part of + * the read integer constant are skipped. If this function returns false, + * the buffer pointer points to the same position as before the function call. + * @param[out] val contains the read integer value on success + * @param[in] accept_sign if false, only positive integers (without sign) are accepted + * @return true if integer could be read */ +bool InputReader::parseInt (int &val, bool accept_sign) { + val = 0; + int fac=1; + char sign; // explicitly given sign + if (accept_sign && ((sign = peek()) == '+' || sign == '-')) { + if (isdigit(peek(1))) { + get(); // skip sign + if (sign == '-') + fac = -1; + } + else + return false; + } + else if (!isdigit(peek())) + return false; + + while (isdigit(peek())) + val = val*10 + (get()-'0'); + val *= fac; + return true; +} + + +bool InputReader::parseUInt (unsigned &val) { + val = 0; + if (!isdigit(peek())) + return false; + while (isdigit(peek())) + val = val*10 + (get()-'0'); + return true; +} + + +bool InputReader::parseInt (int base, int &val) { + if (base < 2 || base > 32) + return false; + + const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; + const char maxdigit = digits[base-1]; + char c; + if (!isalnum(c = tolower(peek())) || c > maxdigit) + return false; + + val = 0; + while (isalnum(c = tolower(peek())) && c <= maxdigit) { + get(); + int digit = c - (c <= '9' ? '0' : 'a'-10); + val = val*base + digit; + } + return true; +} + + +/** Reads a double from the buffer. All characters that are part of + * the read double constant are skipped. If this function returns false, + * the buffer pointer points to the same position as before the function call. + * @param[out] val contains the read double value on success + * @return number details: 0=no number, 'i'=integer, 'f'=floating point number */ +char InputReader::parseDouble (double &val) { + int fac=1; + int int_part=0; + bool is_float = false; + skipSpace(); + char sign = peek(); + if (parseInt(int_part)) { // match [+-]?[0-9]+\.? + if (peek() == '.') { + get(); + is_float = true; + } + if (int_part < 0 || sign == '-') { + fac = -1; + int_part = -int_part; + } + } + else { // match [+-]?\. + char sign; // explicitly given sign + if ((sign = peek()) == '+' || sign == '-') { // match [+-]?\.[0-9] + if (peek(1) != '.' || !isdigit(peek(2))) + return 0; + if (sign == '-') + fac = -1; + skip(2); // skip sign and dot + } + else if (peek() == '.' && isdigit(peek(1))) + get(); + else + return 0; + is_float = true; + } + // parse fractional part + double frac_part=0.0; + for (double u=10; isdigit(peek()); u*=10) + frac_part += (get()-'0')/u; + val = (int_part + frac_part) * fac; + // parse exponent + char c; + if (tolower(peek()) == 'e' && (isdigit(c=peek(1)) || ((c == '+' || c == '-') && isdigit(peek(2))))) { + get(); // skip 'e' + int exp; + parseInt(exp); + val *= pow(10.0, exp); + is_float = true; + } + return is_float ? 'f' : 'i'; +} + + +/** Reads an integer value from the buffer. If no valid integer constant + * could be found at the current position 0 is returned. */ +int InputReader::getInt () { + skipSpace(); + int val; + return parseInt(val) ? val : 0; +} + + +/** Reads an double value from the buffer. If no valid double constant + * could be found at the current position 0 is returned. */ +double InputReader::getDouble () { + skipSpace(); + double val; + return parseDouble(val) ? val : 0.0; +} + + +string InputReader::getWord () { + string ret; + skipSpace(); + while (isalpha(peek())) + ret += get(); + return ret; +} + + +char InputReader::getPunct () { + skipSpace(); + if (ispunct(peek())) + return get(); + return 0; +} + + +/** Reads a string delimited by a given quotation character. + * Before reading the string, all leading whitespace is skipped. Then, the function checks + * for the given quotation character. If it is found, all characters until the second + * appearance of the quotation char are appended to the result. Otherwise, an empty string + * is returned. If the quotation character is 0, the behavior of this function is identical to + * a call of getString(). + * @param[in] quotechar the quotation character bounding the string to be read + * @return the string read */ +string InputReader::getQuotedString (char quotechar) { + if (quotechar == 0) + return getString(); + + string ret; + skipSpace(); + if (peek() == quotechar) { + get(); + while (!eof() && peek() != quotechar) + ret += get(); + get(); + } + return ret; +} + + +/** Reads a string delimited by whitespace and/or invisible characters. + * Before reading the string, all leading whitespace is skipped. Then, the function adds + * all printable characters to the result until a whitespace, an unprintable character, or + * EOF is found. + * @return the string read */ +string InputReader::getString () { + string ret; + skipSpace(); + while (!eof() && !isspace(peek()) && isprint(peek())) + ret += get(); + return ret; +} + + +/** Reads a given number of characters and returns the resulting string. + * @param n number of character to read + * @return the string read */ +string InputReader::getString (size_t n) { + string ret; + while (n-- > 0) + ret += get(); + return ret; +} + + +/** Parses a sequence of key-value pairs of the form KEY=VALUE or KEY="VALUE" + * @param[out] attr the scanned atributes + * @param[in] quotechar quote character used to enclose the attribute values + * @return number of attributes scanned */ +int InputReader::parseAttributes (map &attr, char quotechar) { + bool ready=false; + while (!eof() && !ready) { + string key; + skipSpace(); + while (isalnum(peek())) + key += get(); + skipSpace(); + if (peek() == '=') { + get(); + skipSpace(); + string val = getQuotedString(quotechar); + attr[key] = val; + } + else + ready = true; + } + return attr.size(); +} + +////////////////////////////////////////// + + +int StreamInputReader::peek (size_t n) const { + if (n == 0) + return peek(); + vector chars(n); + _is.read(&chars[0], n); + int ret = peek(); + for (int i=n-1; i >= 0; i--) + _is.putback(chars[i]); + return ret; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.h new file mode 100644 index 00000000000..7d1ee838110 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/InputReader.h @@ -0,0 +1,89 @@ +/************************************************************************* +** InputReader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef INPUTREADER_H +#define INPUTREADER_H + +#include +#include +#include +#include "InputBuffer.h" + + +class InputReader +{ + public: + virtual ~InputReader() {} + virtual int get () =0; + virtual int peek () const =0; + virtual int peek (size_t n) const =0; + virtual bool eof () const =0; + virtual bool check (char c) const {return peek() == c;} + virtual bool check (const char *s, bool consume=true); + virtual int compare (const char *s, bool consume=true); + virtual void skip (size_t n); + virtual bool skipUntil (const char *s, bool consume=true); + virtual int find (char c) const; + virtual void skipSpace (); + virtual int getInt (); + virtual bool parseInt (int &val, bool accept_sign=true); + virtual bool parseInt (int base, int &val); + virtual bool parseUInt (unsigned &val); + virtual char parseDouble (double &val); + virtual double getDouble (); + virtual std::string getWord (); + virtual char getPunct (); + virtual std::string getQuotedString (char quotechar); + virtual std::string getString (); + virtual std::string getString (size_t n); + virtual int parseAttributes (std::map &attr, char quotechar=0); + virtual operator bool () const {return !eof();} +}; + + +class StreamInputReader : public InputReader +{ + public: + StreamInputReader (std::istream &is) : _is(is) {} + int get () {return _is.get();} + int peek () const {return _is.peek();} + int peek (size_t n) const; + bool eof () const {return !_is || _is.eof();} + + private: + std::istream &_is; +}; + + +class BufferInputReader : public InputReader +{ + public: + BufferInputReader (InputBuffer &ib) : _ib(&ib) {} + void assign (InputBuffer &ib) {_ib = &ib;} + int get () {return _ib->get();} + int peek () const {return _ib->peek();} + int peek (size_t n) const {return _ib->peek(n);} + bool eof () const {return _ib->eof();} + + private: + InputBuffer *_ib; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.cpp new file mode 100644 index 00000000000..9c6425645de --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.cpp @@ -0,0 +1,96 @@ +/************************************************************************* +** JFM.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "JFM.h" +#include "StreamReader.h" + +using namespace std; + + +JFM::JFM (istream &is) { + is.seekg(0); + StreamReader sr(is); + UInt16 id = UInt16(sr.readUnsigned(2)); // JFM ID (9 or 11) + if (id != 9 && id != 11) { + ostringstream oss; + oss << "invalid JFM identifier " << id << " (9 or 11 expected)"; + throw FontMetricException(oss.str()); + } + UInt16 nt = UInt16(sr.readUnsigned(2)); // length of character type table + UInt16 lf = UInt16(sr.readUnsigned(2)); // length of entire file in 4 byte words + UInt16 lh = UInt16(sr.readUnsigned(2)); // length of header in 4 byte words + UInt16 bc = UInt16(sr.readUnsigned(2)); // smallest character code in font + UInt16 ec = UInt16(sr.readUnsigned(2)); // largest character code in font + UInt16 nw = UInt16(sr.readUnsigned(2)); // number of words in width table + UInt16 nh = UInt16(sr.readUnsigned(2)); // number of words in height table + UInt16 nd = UInt16(sr.readUnsigned(2)); // number of words in depth table + UInt16 ni = UInt16(sr.readUnsigned(2)); // number of words in italic corr. table + UInt16 nl = UInt16(sr.readUnsigned(2)); // number of words in glue/kern table + UInt16 nk = UInt16(sr.readUnsigned(2)); // number of words in kern table + UInt16 ng = UInt16(sr.readUnsigned(2)); // number of words in glue table + UInt16 np = UInt16(sr.readUnsigned(2)); // number of font parameter words + + if (7+nt+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ng+np != lf) + throw FontMetricException("inconsistent length values"); + + setCharRange(bc, ec); + readHeader(sr); + is.seekg(28+lh*4); + readTables(sr, nt, nw, nh, nd, ni); +} + + +void JFM::readTables (StreamReader &sr, int nt, int nw, int nh, int nd, int ni) { + UInt16 minchar=0xFFFF, maxchar=0; + for (int i=0; i < nt; i++) { + UInt16 c = (UInt16)sr.readUnsigned(2); + UInt16 t = (UInt16)sr.readUnsigned(2); + if (t > 0) { + minchar = min(minchar, c); + maxchar = max(maxchar, c); + } + } + if (minchar <= maxchar) { + _minchar = minchar; + _charTypeTable.resize(maxchar-minchar+1); + memset(&_charTypeTable[0], 0, nt*sizeof(UInt16)); + sr.seek(-nt*4, ios::cur); + for (int i=0; i < nt; i++) { + UInt16 c = (UInt16)sr.readUnsigned(2); + UInt16 t = (UInt16)sr.readUnsigned(2); + if (c >= minchar) + _charTypeTable[c-minchar] = t; + } + } + TFM::readTables(sr, nw, nh, nd, ni); +} + + +int JFM::charIndex (int c) const { + if (_charTypeTable.empty()) + return TFM::charIndex(c); + UInt16 chartype = 0; + if (c >= _minchar && size_t(c) < _minchar+_charTypeTable.size()) + chartype = _charTypeTable[c-_minchar]; + return TFM::charIndex(chartype); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.h new file mode 100644 index 00000000000..2a59c486104 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/JFM.h @@ -0,0 +1,42 @@ +/************************************************************************* +** JFM.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef JFM_H +#define JFM_H + +#include +#include "TFM.h" + + +class JFM : public TFM +{ + public: + JFM (std::istream &is); + + protected: + void readTables (StreamReader &sr, int nt, int nw, int nh, int nd, int ni); + int charIndex (int c) const; + + private: + UInt16 _minchar; ///< character code of first entry in character type table + std::vector _charTypeTable; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.cpp new file mode 100644 index 00000000000..aae20b74e59 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.cpp @@ -0,0 +1,84 @@ +/************************************************************************* +** Length.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "InputReader.h" +#include "Length.h" + +#define UNIT(c1,c2) ((c1 << 8)|c2) + +using namespace std; + + +void Length::set (const string &len) { + switch (len.length()) { + case 0: + _pt = 0; + break; + case 1: + if (isdigit(len[0])) + _pt = len[0] - '0'; + else + throw UnitException("invalid length: "+len); + break; + default: + istringstream iss(len); + StreamInputReader ir(iss); + double val; + if (!ir.parseDouble(val)) + throw UnitException("invalid length: "+len); + string unit = ir.getWord(); + set(val, unit); + } +} + + +void Length::set (double val, Unit unit) { + switch (unit) { + case PT: _pt = val; break; + case BP: _pt = val*72.27/72; break; + case IN: _pt = val*72.27; break; + case CM: _pt = val/2.54*72.27; break; + case MM: _pt = val/25.4*72.27; break; + case PC: _pt = val/12*72.27; break; + } +} + + +void Length::set (double val, string unitstr) { + if (unitstr.empty()) + unitstr = "pt"; + else if (unitstr.length() != 2) + throw UnitException("invalid length unit: "+unitstr); + + Unit unit; + switch (UNIT(unitstr[0], unitstr[1])) { + case UNIT('p','t'): unit = PT; break; + case UNIT('b','p'): unit = BP; break; + case UNIT('i','n'): unit = IN; break; + case UNIT('c','m'): unit = CM; break; + case UNIT('m','m'): unit = MM; break; + case UNIT('p','c'): unit = PC; break; + default: + throw UnitException("invalid length unit: "+unitstr); + } + set(val, unit); +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.h new file mode 100644 index 00000000000..995ba068cee --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Length.h @@ -0,0 +1,62 @@ +/************************************************************************* +** Length.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef LENGTH_H +#define LENGTH_H + +#include +#include "MessageException.h" + +#ifdef IN +#undef IN +#endif + +struct UnitException : MessageException +{ + UnitException (const std::string &msg) : MessageException(msg) {} +}; + + +class Length +{ + public: + enum Unit {PT, BP, CM, MM, IN, PC}; + + public: + Length () : _pt(0) {} + Length (double val, Unit unit=PT) {set(val, unit);} + Length (double val, const std::string &unit) {set(val, unit);} + Length (const std::string &len) {set(len);} + void set (double val, Unit unit); + void set (double val, std::string unit); + void set (const std::string &len); + + double pt () const {return _pt;} + double in () const {return _pt/72.27;} + double bp () const {return in()*72;} + double cm () const {return in()*2.54;} + double mm () const {return cm()*10;} + double pc () const {return in()*12;} + + private: + double _pt; // length in TeX point units +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Makefile.am new file mode 100644 index 00000000000..4312db05d86 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Makefile.am @@ -0,0 +1,52 @@ +:## This file is part of dvisvgm +## Copyright (C) 2005-2013 Martin Gieseking +## +## Process this file with automake. + +bin_PROGRAMS = dvisvgm +noinst_LIBRARIES = libdvisvgm.a + +dvisvgm_SOURCES = gzstream.h \ + dvisvgm.cpp gzstream.cpp + +dvisvgm_LDADD = $(noinst_LIBRARIES) @EXTRA_LIBS@ +dvisvgm_DEPENDENCIES = $(noinst_LIBRARIES) @EXTRA_LIBS@ + +libdvisvgm_a_SOURCES = Bitmap.h BoundingBox.h BgColorSpecialHandler.h Calculator.h CmdLineParserBase.h Color.h CRC32.h \ + ColorSpecialHandler.h CommandLine.h Directory.h DLLoader.h DVIActions.h DVIReader.h DvisvgmSpecialHandler.h DVIToSVG.h \ + DVIToSVGActions.h EmSpecialHandler.h EPSFile.h EPSToSVG.h FileFinder.h FilePath.h FileSystem.h Font.h FontCache.h \ + FontEncoding.h FontEngine.h FontManager.h FontMap.h FontMetric.h GFReader.h GFTracer.h GFGlyphTracer.h Ghostscript.h \ + Glyph.h GlyphTracerMessages.h GraphicPath.h HtmlSpecialHandler.h InputBuffer.h InputReader.h JFM.h Length.h macros.h \ + MapLine.h Matrix.h Message.h MessageException.h MetafontWrapper.h NoPsSpecialHandler.h PageRanges.h PageSize.h Pair.h \ + PdfSpecialHandler.h Process.h PSInterpreter.h PSPattern.h PsSpecialHandler.h SignalHandler.h SpecialActions.h SpecialHandler.h \ + SpecialManager.h StreamReader.h StreamWriter.h Subfont.h SVGOutputBase.h SVGTree.h System.h Terminal.h TpicSpecialHandler.h \ + TFM.h types.h VectorStream.h VFActions.h VFReader.h XMLDocTypeNode.h XMLDocument.h XMLNode.h XMLString.h \ + BgColorSpecialHandler.cpp Bitmap.cpp BoundingBox.cpp Calculator.cpp CmdLineParserBase.cpp Color.cpp \ + ColorSpecialHandler.cpp CommandLine.cpp CRC32.cpp Directory.cpp DLLoader.cpp DVIActions.cpp DVIReader.cpp \ + DvisvgmSpecialHandler.cpp DVIToSVG.cpp DVIToSVGActions.cpp EmSpecialHandler.cpp EPSFile.cpp EPSToSVG.cpp FileFinder.cpp \ + FilePath.cpp FileSystem.cpp Font.cpp FontCache.cpp FontEncoding.cpp FontEngine.cpp FontManager.cpp FontMap.cpp \ + FontMetric.cpp GFReader.cpp GFGlyphTracer.cpp GFTracer.cpp Ghostscript.cpp HtmlSpecialHandler.cpp InputBuffer.cpp \ + InputReader.cpp JFM.cpp Length.cpp MapLine.cpp Matrix.cpp Message.cpp MetafontWrapper.cpp NoPsSpecialHandler.cpp \ + PageRanges.cpp PageSize.cpp PdfSpecialHandler.cpp Process.cpp psdefs.cpp PSInterpreter.cpp PSPattern.cpp PsSpecialHandler.cpp \ + SignalHandler.cpp SpecialManager.cpp StreamReader.cpp StreamWriter.cpp Subfont.cpp SVGTree.cpp System.cpp Terminal.cpp TFM.cpp \ + TpicSpecialHandler.cpp VFReader.cpp XMLDocument.cpp XMLNode.cpp XMLString.cpp + +EXTRA_DIST = options.xml iapi.h ierrors.h MiKTeXCom.h MiKTeXCom.cpp + +AM_CXXFLAGS = -Wall -Wnon-virtual-dtor + +# the command-line parser is generated from options.xml by opt2cpp +CommandLine.cpp: options.xml + if test -f opt2cpp.xsl; then \ + rm -f $@ $*.h; \ + xsltproc opt2cpp.xsl $<; \ + fi + +# Create a C string definition containing the PostScript routines psdefs.ps needed by class PSInterpreter +$(srcdir)/psdefs.cpp: psdefs.ps + if test -f $<; then \ + ps2c PSInterpreter::PSDEFS $< >$@; \ + fi + +psdefs.ps: ; + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.cpp new file mode 100644 index 00000000000..99dce4f9547 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.cpp @@ -0,0 +1,275 @@ +/************************************************************************* +** MapLine.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "InputBuffer.h" +#include "InputReader.h" +#include "MapLine.h" +#include "Subfont.h" + +using namespace std; + + +/** Constructs a MapLine object by parsing a single mapline from the given stream. */ +MapLine::MapLine (istream &is) + : _sfd(0), _fontindex(0), _slant(0), _bold(0), _extend(1) +{ + char buf[256]; + is.getline(buf, 256); + parse(buf); +} + + +// Some of the following functions have been derived from the dvipdfmx source file fontmap.c: +// http://cvs.ktug.or.kr/viewcvs/dvipdfmx/src/fontmap.c?revision=1.43&view=markup + + +/** Returns true if the given string is in dvips mapline format, and false if it's in dvipdfm format. + @param[in] line string to check */ +bool MapLine::isDVIPSFormat (const char *line) const { + if (strchr(line, '"') || strchr(line, '<')) // these chars are only present in dvips maps + return true; + char prevchar = ' '; + int entry_count=0; + for (const char *p=line; *p; ++p) { + if (isspace(prevchar)) { + if (*p == '-') // options starting with '-' are only present in dvipdfm map files + return false; + if (!isspace(*p)) + entry_count++; + } + prevchar = *p; + } + // tfm_name and ps_name only => dvips map + return entry_count == 2; +} + + +/** Separates main font name and subfont definition name from a given combined name. + * Example: "basename@sfdname@10" => {"basename10", "sfdname"} + * @param[in,out] fontname complete fontname; after separation: main fontname only + * @param[out] sfdname name of subfont definition + * @return true on success */ +static bool split_fontname (string &fontname, string &sfdname) { + size_t pos1; // index of first '@' + if ((pos1 = fontname.find('@')) != string::npos && pos1 > 0) { + size_t pos2; // index of second '@' + if ((pos2 = fontname.find('@', pos1+1)) != string::npos && pos2 > pos1+1) { + sfdname = fontname.substr(pos1+1, pos2-pos1-1); + fontname = fontname.substr(0, pos1) + fontname.substr(pos2+1); + return true; + } + } + return false; +} + + +/** Parses a single mapline and stores the scanned data in member variables. + * The line may either be given in dvips or dvipdfmx mapfile format. + * @param[in] line the mapline */ +void MapLine::parse (const char *line) { + CharInputBuffer ib(line, strlen(line)); + BufferInputReader ir(ib); + _texname = ir.getString(); + string sfdname; + split_fontname(_texname, sfdname); + if (!sfdname.empty()) + _sfd = SubfontDefinition::lookup(sfdname); + if (isDVIPSFormat(line)) + parseDVIPSLine(ir); + else + parseDVIPDFMLine(ir); +} + + +/** Parses a single line in dvips mapfile format. + * @param[in] ir the input stream must be assigned to this reader */ +void MapLine::parseDVIPSLine (InputReader &ir) { + ir.skipSpace(); + if (ir.peek() != '<' && ir.peek() != '"') + _psname = ir.getString(); + ir.skipSpace(); + while (ir.peek() == '<' || ir.peek() == '"') { + if (ir.peek() == '<') { + ir.get(); + if (ir.peek() == '[') + ir.get(); + string name = ir.getString(); + if (name.length() > 4 && name.substr(name.length()-4) == ".enc") + _encname = name.substr(0, name.length()-4); + else + _fontfname = name; + } + else { // ir.peek() == '"' => list of PS font operators + string options = ir.getQuotedString('"'); + StringInputBuffer sib(options); + BufferInputReader sir(sib); + while (!sir.eof()) { + double number; + if (sir.parseDouble(number)) { + // operator with preceding numeric parameter (value opstr) + string opstr = sir.getString(); + if (opstr == "SlantFont") + _slant = number; + else if (opstr == "ExtendFont") + _extend = number; + } + else { + // operator without parameter => skip for now + sir.getString(); + } + } + } + ir.skipSpace(); + } +} + + +static void throw_number_expected (char opt, bool integer_only=false) { + ostringstream oss; + oss << "option -" << opt << ": " << (integer_only ? "integer" : "floating point") << " value expected"; + throw MapLineException(oss.str()); +} + + +/** Parses a single line in dvipdfmx mapfile format. + * @param[in] ir the input stream must be assigned to this reader */ +void MapLine::parseDVIPDFMLine (InputReader &ir) { + ir.skipSpace(); + if (ir.peek() != '-') { + _encname = ir.getString(); + if (_encname == "default" || _encname == "none") + _encname.clear(); + } + ir.skipSpace(); + if (ir.peek() != '-') + _fontfname = ir.getString(); + if (!_fontfname.empty()) { + parseFilenameOptions(_fontfname); + } + ir.skipSpace(); + while (ir.peek() == '-') { + ir.get(); + char option = ir.get(); + if (!isprint(option)) + throw MapLineException("option character expected"); + ir.skipSpace(); + switch (option) { + case 's': // slant + if (!ir.parseDouble(_slant)) + throw_number_expected('s'); + break; + case 'e': // extend + if (!ir.parseDouble(_extend)) + throw_number_expected('e'); + break; + case 'b': // bold + if (!ir.parseDouble(_bold)) + throw_number_expected('b'); + break; + case 'r': //remap (deprecated) + break; + case 'i': // ttc index + if (!ir.parseInt(_fontindex, false)) + throw_number_expected('i', true); + break; + case 'p': // UCS plane + int dummy; + if (!ir.parseInt(dummy, false)) + throw_number_expected('p', true); + break; + case 'u': // to unicode + ir.getString(); + break; + case 'v': // stemV + int stemv; + if (!ir.parseInt(stemv, true)) + throw_number_expected('v', true); + break; + case 'm': // map single chars + ir.skipUntil("-"); + break; + case 'w': // writing mode (horizontal=0, vertical=1) + int vertical; + if (!ir.parseInt(vertical, false)) + throw_number_expected('w', true); + break; + default: + ostringstream oss; + oss << "invalid option: -" << option; + throw MapLineException(oss.str()); + } + ir.skipSpace(); + } +} + + +/** [:INDEX:][!]FONTNAME[/CSI][,VARIANT] */ +void MapLine::parseFilenameOptions (string fname) { + _fontfname = fname; + StringInputBuffer ib(fname); + BufferInputReader ir(ib); + if (ir.peek() == ':' && isdigit(ir.peek(1))) { // index given? + ir.get(); + _fontindex = ir.getInt(); // font index of file with multiple fonts + if (ir.peek() == ':') + ir.get(); + else + _fontindex = 0; + } + if (ir.peek() == '!') // no embedding + ir.get(); + + bool csi_given=false, style_given=false; + int pos; + if ((pos = ir.find('/')) >= 0) { // csi delimiter + csi_given = true; + _fontfname = ir.getString(pos); + } + else if ((pos = ir.find(',')) >= 0) { + style_given = true; + _fontfname = ir.getString(pos); + } + else + _fontfname = ir.getString(); + + if (csi_given) { + if ((pos = ir.find(',')) >= 0) { + style_given = true; + ir.getString(pos); // charcoll + } + else if (ir.eof()) + throw MapLineException("CSI specifier expected"); + else + ir.getString(); // charcoll + } + if (style_given) { + ir.get(); // skip ',' + if (ir.check("BoldItalic")) { + } + else if (ir.check("Bold")) { + } + else if (ir.check("Italic")) { + } + if (!ir.eof()) + throw MapLineException("invalid style given"); + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.h new file mode 100644 index 00000000000..87451dc912d --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MapLine.h @@ -0,0 +1,72 @@ +/************************************************************************* +** MapLine.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MAPLINE_H +#define MAPLINE_H + +#include +#include +#include "MessageException.h" + + +class InputReader; +class SubfontDefinition; + + +struct MapLineException : MessageException +{ + MapLineException (const std::string &msg) : MessageException(msg) {} +}; + + +class MapLine +{ + public: + MapLine (std::istream &is); + const std::string& texname () const {return _texname;} + const std::string& psname () const {return _psname;} + const std::string& fontfname () const {return _fontfname;} + const std::string& encname () const {return _encname;} + int fontindex () const {return _fontindex;} + double bold () const {return _bold;} + double slant () const {return _slant;} + double extend () const {return _extend;} + SubfontDefinition* sfd () const {return _sfd;} + + protected: + void init (); + bool isDVIPSFormat (const char *line) const; + void parse (const char *line); + void parseDVIPSLine (InputReader &ir); + void parseDVIPDFMLine (InputReader &ir); + void parseFilenameOptions (std::string opt); + + private: + std::string _texname; ///< TeX font name + std::string _psname; ///< PS font name + std::string _fontfname; ///< name of fontfile + std::string _encname; ///< name of encoding (without file suffix ".enc") + SubfontDefinition *_sfd; ///< subfont definition to be used + int _fontindex; ///< font index of file with multiple fonts (e.g. ttc files) + double _slant, _bold, _extend; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.cpp new file mode 100644 index 00000000000..6aba0d04bdd --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.cpp @@ -0,0 +1,465 @@ +/************************************************************************* +** Matrix.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "Calculator.h" +#include "Matrix.h" +#include "XMLString.h" + +using namespace std; + + + +/** Computes the determinant of a given matrix */ +double det (const Matrix &m) { + double sum=0; + for (int i=0; i < 3; ++i) { + sum += m._values[0][i] * m._values[1][(i+1)%3] * m._values[2][(i+2)%3] + - m._values[0][2-i] * m._values[1][(4-i)%3] * m._values[2][(3-i)%3]; + } + return sum; +} + + +/** Computes the determinant of the 2x2 submatrix of m where a given + * row and column were removed. + * @param[in] m base matrix + * @param[in] row row to remove + * @param[in] col column to remove */ +double det (const Matrix &m, int row, int col) { + int c1 = (col+1)%3, c2 = (col+2)%3; + int r1 = (row+1)%3, r2 = (row+2)%3; + if (c1 > c2) + swap(c1, c2); + if (r1 > r2) + swap(r1, r2); + return m._values[r1][c1] * m._values[r2][c2] + - m._values[r1][c2] * m._values[r2][c1]; +} + + +static inline double deg2rad (double deg) { + const double PI = acos(-1.0); + return PI*deg/180.0; +} + + +/** Creates a diagonal matrix ((d,0,0),(0,d,0),(0,0,d)). + * @param[in] d value of diagonal elements */ +Matrix::Matrix (double d) { + for (int i=0; i < 3; i++) + for (int j=0; j < 3; j++) + _values[i][j] = (i==j ? d : 0); +} + + +/** Creates the matrix ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). + * Expects that array v consists of 'size' elements. If size is less than 9, the + * remaining matrix components will be set to those of the identity matrix. + * @param[in] v array containing the matrix components + * @param[in] size size of array v */ +Matrix::Matrix (double v[], unsigned size) { + set(v, size); +} + + +/** Creates the matrix ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). + * If vector v has less than 9 elements, the remaining matrix components will be set to + * those of the identity matrix. + * @param[in] v array containing the matrix components + * @param[in] start use vector components start,...,start+8 */ +Matrix::Matrix (const std::vector &v, int start) { + set(v, start); +} + + +Matrix::Matrix (const string &cmds, Calculator &calc) { + parse(cmds, calc); +} + + +Matrix& Matrix::set (double v[], unsigned size) { + size = min(size, 9u); + for (unsigned i=0; i < size; i++) + _values[i/3][i%3] = v[i]; + for (unsigned i=size; i < 9; i++) + _values[i/3][i%3] = (i%4 ? 0 : 1); + return *this; +} + + +/** Set matrix values ((v0,v1,v2),(v3,v4,v5),(v6,v7,v8)). + * If vector v has less than 9 elements, the remaining matrix components will be set to + * those of the identity matrix. + * @param[in] v array containing the matrix components + * @param[in] start use vector components start,...,start+8 */ +Matrix& Matrix::set (const vector &v, int start) { + unsigned size = min((unsigned)v.size()-start, 9u); + for (unsigned i=0; i < size; i++) + _values[i/3][i%3] = v[i+start]; + for (unsigned i=size; i < 9; i++) + _values[i/3][i%3] = (i%4 ? 0 : 1); + return *this; +} + + +Matrix& Matrix::translate (double tx, double ty) { + if (tx != 0 || ty != 0) { + TranslationMatrix t(tx, ty); + rmultiply(t); + } + return *this; +} + + +Matrix& Matrix::scale (double sx, double sy) { + if (sx != 1 || sy != 1) { + ScalingMatrix s(sx, sy); + rmultiply(s); + } + return *this; +} + + +/** Multiplies this matrix by ((cos d, -sin d, 0), (sin d, cos d, 0), (0,0,1)) that + * describes an anti-clockwise rotation by d degrees. + * @param[in] deg rotation angle in degrees */ +Matrix& Matrix::rotate (double deg) { + RotationMatrix r(deg); + rmultiply(r); + return *this; +} + + +Matrix& Matrix::xskew (double deg) { + double t = tan(deg2rad(deg)); + if (t != 0) { + double v[] = {1, t}; + Matrix t(v, 2); + rmultiply(t); + } + return *this; +} + + +Matrix& Matrix::yskew (double deg) { + double t = tan(deg2rad(deg)); + if (t != 0) { + double v[] = {1, 0, 0, t}; + Matrix t(v, 4); + rmultiply(t); + } + return *this; +} + + +Matrix& Matrix::flip (bool haxis, double a) { + double s = 1; + if (haxis) // mirror at horizontal axis? + s = -1; + double v[] = {-s, 0, (haxis ? 0 : 2*a), 0, s, (haxis ? 2*a : 0), 0, 0, 1}; + Matrix t(v); + rmultiply(t); + return *this; +} + + +/** Swaps rows and columns of the matrix. */ +Matrix& Matrix::transpose () { + for (int i=0; i < 3; i++) + for (int j=i+1; j < 3; j++) + swap(_values[i][j], _values[j][i]); + return *this; +} + + +/** Multiplies this matrix M with matrix tm (tm is the factor on the left side): M := tm * M */ +Matrix& Matrix::lmultiply (const Matrix &tm) { + Matrix ret; + for (int i=0; i < 3; i++) + for (int j=0; j < 3; j++) + for (int k=0; k < 3; k++) + ret._values[i][j] += _values[i][k] * tm._values[k][j]; + return *this = ret; +} + + +/** Multiplies this matrix M with matrix tm (tm is the factor on the right side): M := M * tm */ +Matrix& Matrix::rmultiply (const Matrix &tm) { + Matrix ret; + for (int i=0; i < 3; i++) + for (int j=0; j < 3; j++) + for (int k=0; k < 3; k++) + ret._values[i][j] += tm._values[i][k] * _values[k][j]; + return *this = ret; +} + + +Matrix& Matrix::invert () { + Matrix ret; + if (double denom = det(*this)) { + for (int i=0; i < 3; ++i) { + for (int j=0; j < 3; ++j) { + ret._values[i][j] = det(*this, i, j)/denom; + if ((i+j)%2 != 0) + ret._values[i][j] *= -1; + } + } + return *this = ret; + } + throw exception(); +} + + +Matrix& Matrix::operator *= (double c) { + for (int i=0; i < 3; i++) + for (int j=0; j < 3; j++) + _values[i][j] *= c; + return *this; +} + + +DPair Matrix::operator * (const DPair &p) const { + double pp[] = {p.x(), p.y(), 1}; + double ret[]= {0, 0}; + for (int i=0; i < 2; i++) + for (int j=0; j < 3; j++) + ret[i] += _values[i][j] * pp[j]; + return DPair(ret[0], ret[1]); +} + + +/** Returns true if this matrix equals. Checks equality by comparing the matrix components. */ +bool Matrix::operator == (const Matrix &m) const { + for (int i=0; i < 2; i++) + for (int j=0; j < 3; j++) + if (_values[i][j] != m._values[i][j]) + return false; + return true; +} + + +/** Returns true if this matrix doesn't equal m. Checks inequality by comparing the matrix components. */ +bool Matrix::operator != (const Matrix &m) const { + for (int i=0; i < 2; i++) + for (int j=0; j < 3; j++) + if (_values[i][j] != m._values[i][j]) + return true; + return false; +} + + +/** Returns true if this matrix is the identity matrix ((1,0,0),(0,1,0),(0,0,1)). */ +bool Matrix::isIdentity() const { + for (int i=0; i < 2; i++) + for (int j=0; j < 3; j++) { + const double &v = _values[i][j]; + if ((i == j && v != 1) || (i != j && v != 0)) + return false; + } + return true; +} + + +/** Checks whether this matrix describes a plain translation (without any other transformations). + * If so, the parameters tx and ty are filled with the translation components. + * @param[out] tx horizontal translation + * @param[out] ty vertical translation + * @return true if matrix describes a pure translation */ +bool Matrix::isTranslation (double &tx, double &ty) const { + tx = _values[0][2]; + ty = _values[1][2]; + for (int i=0; i < 3; i++) + for (int j=0; j < 2; j++) { + const double &v = _values[i][j]; + if ((i == j && v != 1) || (i != j && v != 0)) + return false; + } + return _values[2][2] == 1; +} + + +/** Gets a parameter for the transformation command. + * @param[in] is parameter chars are read from this stream + * @param[in] calc parameters can be arithmetic expressions, so we need a calculator to evaluate them + * @param[in] def default value if parameter is optional + * @param[in] optional true if parameter is optional + * @param[in] leadingComma true if first non-blank must be a comma + * @return value of argument */ +static double getArgument (istream &is, Calculator &calc, double def, bool optional, bool leadingComma) { + while (isspace(is.peek())) + is.get(); + if (!optional && leadingComma && is.peek() != ',') + throw ParserException("',' expected"); + if (is.peek() == ',') { + is.get(); // skip comma + optional = false; // now we expect a parameter + } + string expr; + while (is && !isupper(is.peek()) && is.peek() != ',') + expr += is.get(); + if (expr.length() == 0) { + if (optional) + return def; + else + throw ParserException("parameter expected"); + } + return calc.eval(expr); +} + + +Matrix& Matrix::parse (istream &is, Calculator &calc) { + *this = Matrix(1); + while (is) { + while (isspace(is.peek())) + is.get(); + char cmd = is.get(); + switch (cmd) { + case 'T': { + double tx = getArgument(is, calc, 0, false, false); + double ty = getArgument(is, calc, 0, true, true); + translate(tx, ty); + break; + } + case 'S': { + double sx = getArgument(is, calc, 1, false, false); + double sy = getArgument(is, calc, sx, true, true ); + scale(sx, sy); + break; + } + case 'R': { + double a = getArgument(is, calc, 0, false, false); + double x = getArgument(is, calc, calc.getVariable("ux")+calc.getVariable("w")/2, true, true); + double y = getArgument(is, calc, calc.getVariable("uy")+calc.getVariable("h")/2, true, true); + translate(-x, -y); + rotate(a); + translate(x, y); + break; + } + case 'F': { + char c = is.get(); + if (c != 'H' && c != 'V') + throw ParserException("'H' or 'V' expected"); + double a = getArgument(is, calc, 0, false, false); + flip(c == 'H', a); + break; + } + case 'K': { + char c = is.get(); + if (c != 'X' && c != 'Y') + throw ParserException("transformation command 'K' must be followed by 'X' or 'Y'"); + double a = getArgument(is, calc, 0, false, false); + if (fabs(cos(deg2rad(a))) <= numeric_limits::epsilon()) { + ostringstream oss; + oss << "illegal skewing angle: " << a << " degrees"; + throw ParserException(oss.str()); + } + if (c == 'X') + xskew(a); + else + yskew(a); + break; + } + case 'M': { + double v[9]; + for (int i=0; i < 6; i++) + v[i] = getArgument(is, calc, i%4 ? 0 : 1, i!=0, i!=0); + // third row (0, 0, 1) + v[6] = v[7] = 0; + v[8] = 1; + Matrix tm(v); + rmultiply(tm); + break; + } + default: + ostringstream oss; + oss << "transformation command expected (found '" << cmd << "' instead)"; + throw ParserException(oss.str()); + } + } + return *this; +} + + +Matrix& Matrix::parse (const string &cmds, Calculator &calc) { + istringstream iss; + iss.str(cmds); + return parse(iss, calc); +} + + +/** Returns an SVG matrix expression that can be used in transform attributes. + * ((a,b,c),(d,e,f),(0,0,1)) => matrix(a d b e c f) */ +string Matrix::getSVG () const { + ostringstream oss; + oss << "matrix("; + for (int i=0; i < 3; i++) { + for (int j=0; j < 2; j++) { + if (i > 0 || j > 0) + oss << ' '; + oss << XMLString(_values[j][i]); + } + } + oss << ')'; + return oss.str(); +} + + +ostream& Matrix::write (ostream &os) const { + os << '('; + for (int i=0; i < 3; i++) { + os << '(' << _values[i][0]; + for (int j=1; j < 3; j++) + os << ',' << _values[i][j]; + os << ')'; + if (i < 2) + os << ','; + } + os << ')'; + return os; +} + + +////////////////////////////////////////////////////////////////// + + +TranslationMatrix::TranslationMatrix (double tx, double ty) { + double v[] = {1, 0, tx, 0, 1, ty}; + set(v, 6); +} + + +ScalingMatrix::ScalingMatrix (double sx, double sy) { + double v[] = {sx, 0, 0, 0, sy}; + set(v, 5); +} + + +RotationMatrix::RotationMatrix (double deg) { + double rad = deg2rad(deg); + double c = cos(rad); + double s = sin(rad); + double v[] = {c, -s, 0, s, c}; + set(v, 5); +} + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.h new file mode 100644 index 00000000000..d3a52439021 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Matrix.h @@ -0,0 +1,104 @@ +/************************************************************************* +** Matrix.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MATRIX_H +#define MATRIX_H + +#include +#include +#include +#include "MessageException.h" +#include "Pair.h" + + +struct ParserException : public MessageException +{ + ParserException (const std::string &msg) : MessageException(msg) {} +}; + +class Calculator; + +class Matrix +{ + friend double det (const Matrix &m); + friend double det (const Matrix &m, int row, int col); + + public: + Matrix (const std::string &cmds, Calculator &calc); + Matrix (double d=0); + Matrix (double v[], unsigned size=9); + Matrix (const std::vector &v, int start=0); + Matrix& set (double v[], unsigned size); + Matrix& set (const std::vector &v, int start=0); + double get (int row, int col) const {return _values[row][col];} + Matrix& transpose (); + Matrix& invert (); + Matrix& parse (std::istream &is, Calculator &c); + Matrix& parse (const std::string &cmds, Calculator &c); + Matrix& lmultiply (const Matrix &tm); + Matrix& rmultiply (const Matrix &tm); + Matrix& translate (double tx, double ty); + Matrix& scale (double sx, double sy); + Matrix& rotate (double deg); + Matrix& xskew (double deg); + Matrix& yskew (double deg); + Matrix& flip (bool h, double a); + Matrix& operator *= (double c); + DPair operator * (const DPair &p) const; + bool operator == (const Matrix &m) const; + bool operator != (const Matrix &m) const; + bool isIdentity() const; + bool isTranslation (double &tx, double &ty) const; + std::string getSVG () const; + std::ostream& write (std::ostream &os) const; + + private: + double _values[3][3]; // row x col +}; + + +struct TranslationMatrix : public Matrix +{ + TranslationMatrix (double tx, double ty); +}; + + +struct ScalingMatrix : public Matrix +{ + ScalingMatrix (double sx, double sy); +}; + + +struct RotationMatrix : public Matrix +{ + RotationMatrix (double deg); +}; + + +inline std::ostream& operator << (std::ostream &os, const Matrix &m) { + return m.write(os); +} + + +double det (const Matrix &m); +double det (const Matrix &m, int row, int col); + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.cpp new file mode 100644 index 00000000000..38407ad5f6d --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.cpp @@ -0,0 +1,273 @@ +/************************************************************************* +** Message.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include +#include "Message.h" +#include "Terminal.h" + +using namespace std; + +MessageStream::MessageStream () : _os(0), _nl(false), _col(1), _indent(0) { +} + + +MessageStream::MessageStream (std::ostream &os) + : _os(&os), _nl(true), _col(1), _indent(0) +{ + Terminal::init(os); +} + + +MessageStream::~MessageStream () { + if (_os && Message::COLORIZE) + Terminal::finish(*_os); +} + + +void MessageStream::putChar (const char c, ostream &os) { + switch (c) { + case '\r': + os << '\r'; + _nl = true; + _col = 1; + return; + case '\n': + if (!_nl) { + _col = 1; + _nl = true; + os << '\n'; + } + return; + default: + if (_nl) { + os << string(_indent, ' '); + _col += _indent; + } + else { + const int cols = Terminal::columns(); + if (cols > 0 && _col >= cols) { +#ifndef __WIN32__ + // move cursor to next line explicitly (not necessary in Windows/DOS terminal) + os << '\n'; +#endif + os << string(_indent, ' '); + _col = _indent+1; + } + else + _col++; + } + _nl = false; + if (!_nl || c != '\n') + os << c; + } +} + + +MessageStream& MessageStream::operator << (const char *str) { + if (_os && str) { + const char *first = str; + while (*first) { + const char *last = strchr(first, '\n'); + if (!last) + last = first+strlen(first)-1; +#ifndef __WIN32__ + // move cursor to next line explicitly (not necessary in Windows/DOS terminal) + const int cols = Terminal::columns(); + int len = last-first+1; + if (cols > 0 && _col+len > cols && _indent+len <= cols) + putChar('\n', *_os); +#endif + while (first <= last) + putChar(*first++, *_os); + first = last+1; + } + } + return *this; +} + + +MessageStream& MessageStream::operator << (const char &c) { + if (_os) + putChar(c, *_os); + return *this; +} + + +void MessageStream::indent (bool reset) { + if (reset) + _indent = 0; + _indent += 2; +} + + +void MessageStream::outdent (bool all) { + if (all) + _indent = 0; + else if (_indent > 0) + _indent -= 2; +} + + +void MessageStream::clearline () { + if (_os) { + int cols = Terminal::columns(); + *_os << '\r' << string(cols ? cols-1 : 79, ' ') << '\r'; + _nl = true; + _col = 1; + } +} + +static MessageStream nullStream; +static MessageStream messageStream(cerr); + + +////////////////////////////// + +// maximal verbosity +int Message::LEVEL = Message::MESSAGES | Message::WARNINGS | Message::ERRORS; +bool Message::COLORIZE = false; +bool Message::_initialized = false; +Message::Color Message::_classColors[9]; + + +/** Returns the stream for usual messages. */ +MessageStream& Message::mstream (bool prefix, MessageClass mclass) { + init(); + MessageStream *ms = (LEVEL & MESSAGES) ? &messageStream : &nullStream; + if (COLORIZE && ms && ms->os()) { + Terminal::fgcolor(_classColors[mclass].foreground, *ms->os()); + Terminal::bgcolor(_classColors[mclass].background, *ms->os()); + } + if (prefix) + *ms << "\nMESSAGE: "; + return *ms; +} + + +/** Returns the stream for warning messages. */ +MessageStream& Message::wstream (bool prefix) { + init(); + MessageStream *ms = (LEVEL & WARNINGS) ? &messageStream : &nullStream; + if (COLORIZE && ms && ms->os()) { + Terminal::fgcolor(_classColors[MC_WARNING].foreground, *ms->os()); + Terminal::bgcolor(_classColors[MC_WARNING].background, *ms->os()); + } + if (prefix) + *ms << "\nWARNING: "; + return *ms; +} + + +/** Returns the stream for error messages. */ +MessageStream& Message::estream (bool prefix) { + init(); + MessageStream *ms = (LEVEL & ERRORS) ? &messageStream : &nullStream; + if (COLORIZE && ms && ms->os()) { + Terminal::fgcolor(_classColors[MC_ERROR].foreground, *ms->os()); + Terminal::bgcolor(_classColors[MC_ERROR].background, *ms->os()); + } + if (prefix) + *ms << "\nERROR: "; + return *ms; +} + + +static bool colorchar2int (char colorchar, int *val) { + colorchar = tolower(colorchar); + if (colorchar >= '0' && colorchar <= '9') + *val = int(colorchar-'0'); + else if (colorchar >= 'a' && colorchar <= 'f') + *val = int(colorchar-'a'+10); + else if (colorchar == '*') + *val = -1; + else + return false; + return true; +} + + +/** Initializes the Message class. Sets the colors for each message set. + * The colors can be changed via environment variable DVISVGM_COLORS. Its + * value must be a sequence of color entries of the form gg:BF where the + * two-letter ID gg specifies a message set, B the hex digit of the + * background, and F the hex digit of the foreground/text color. + * Color codes: + * - 1: red, 2: green, 4: blue + * - 0-7: dark colors + * - 8-F: light colors + * - *: default color + * Example: num:01 sets page number messages to red on black background */ +void Message::init () { + if (_initialized || !Message::COLORIZE) + return; + + // set default message colors + _classColors[MC_ERROR] = Color(Terminal::RED, true); + _classColors[MC_WARNING] = Color(Terminal::YELLOW); + _classColors[MC_PAGE_NUMBER] = Color(Terminal::BLUE, true); + _classColors[MC_PAGE_SIZE] = Color(Terminal::MAGENTA); + _classColors[MC_PAGE_WRITTEN] = Color(Terminal::GREEN); + _classColors[MC_STATE] = Color(Terminal::CYAN); + _classColors[MC_TRACING] = Color(Terminal::BLUE); + _classColors[MC_PROGRESS] = Color(Terminal::MAGENTA); + + if (const char *color_str = getenv("DVISVGM_COLORS")) { + map classes; + classes["er"] = MC_ERROR; + classes["wn"] = MC_WARNING; + classes["pn"] = MC_PAGE_NUMBER; + classes["ps"] = MC_PAGE_SIZE; + classes["fw"] = MC_PAGE_WRITTEN; + classes["sm"] = MC_STATE; + classes["tr"] = MC_TRACING; + classes["pi"] = MC_PROGRESS; + const char *p=color_str; + + // skip leading whitespace + while (isspace(*p)) + ++p; + + // iterate over color assignments + while (strlen(p) >= 5) { + map::iterator it = classes.find(string(p, 2)); + if (it != classes.end() && p[2] == '=') { + int bgcolor, fgcolor; + if (colorchar2int(p[3], &bgcolor) && colorchar2int(p[4], &fgcolor)) { + _classColors[it->second].background = bgcolor; + _classColors[it->second].foreground = fgcolor; + } + } + p += 5; + + // skip trailing characters in a malformed entry + while (!isspace(*p) && *p != ':' && *p != ';') + ++p; + // skip separation characters + while (isspace(*p) || *p == ':' || *p == ';') + ++p; + } + } + _initialized = true; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.h new file mode 100644 index 00000000000..bc4a9ed016c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Message.h @@ -0,0 +1,114 @@ +/************************************************************************* +** Message.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MESSAGE_H +#define MESSAGE_H + +#include +#include +#include +#include +#include "Terminal.h" +#include "types.h" + + +class Message; + +class MessageStream +{ + friend class Message; + + public: + MessageStream (); + MessageStream (std::ostream &os); + ~MessageStream (); + + template + MessageStream& operator << (const T &obj) { + std::ostringstream oss; + oss << obj; + (*this) << oss.str(); + return *this; + } + + MessageStream& operator << (const char *str); + MessageStream& operator << (const char &c); + MessageStream& operator << (const std::string &str) {return (*this) << str.c_str();} + + void indent (int level) {_indent = std::max(0, level*2);} + void indent (bool reset=false); + void outdent (bool all=false); + void clearline (); + + protected: + void putChar (const char c, std::ostream &os); + std::ostream* os () {return _os;} + + private: + std::ostream *_os; + bool _nl; ///< true if previous character was a newline + int _col; ///< current terminal column + int _indent; ///< indentation width (number of columns/characters) +}; + + +class Message +{ + struct Color { + Color () : foreground(-1), background(-1) {} + Color (Int8 fgcolor) : foreground(fgcolor), background(-1) {} + Color (Int8 fgcolor, bool light) : foreground(fgcolor + (light ? 8 : 0)), background(-1) {} + Color (Int8 fgcolor, Int8 bgcolor) : foreground(fgcolor), background(bgcolor) {} + Int8 foreground; + Int8 background; + }; + + public: + enum MessageClass { + MC_ERROR, + MC_WARNING, + MC_MESSAGE, + MC_PAGE_NUMBER, + MC_PAGE_SIZE, + MC_PAGE_WRITTEN, + MC_STATE, + MC_TRACING, + MC_PROGRESS, + }; + + public: + static MessageStream& mstream (bool prefix=false, MessageClass mclass=MC_MESSAGE); + static MessageStream& estream (bool prefix=false); + static MessageStream& wstream (bool prefix=false); + + enum {ERRORS=1, WARNINGS=2, MESSAGES=4}; + static int LEVEL; + static bool COLORIZE; + + protected: + static void init (); + + + private: + static Color _classColors[]; + static bool _initialized; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MessageException.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MessageException.h new file mode 100644 index 00000000000..e6c4ace019f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MessageException.h @@ -0,0 +1,39 @@ +/************************************************************************* +** MessageException.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MESSAGEEXCEPTION_H +#define MESSAGEEXCEPTION_H + +#include +#include + + +class MessageException : public std::exception +{ + public: + MessageException (const std::string &msg) : _message(msg) {} + virtual ~MessageException () throw() {} + const char* what () const throw() {return _message.c_str();} + + private: + std::string _message; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.cpp new file mode 100644 index 00000000000..37e3b68f92f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.cpp @@ -0,0 +1,133 @@ +/************************************************************************* +** MetafontWrapper.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "FileSystem.h" +#include "FileFinder.h" +#include "Message.h" +#include "MetafontWrapper.h" +#include "Process.h" +#include "SignalHandler.h" +#include "macros.h" + +using namespace std; + + +MetafontWrapper::MetafontWrapper (const string &fname) : _fontname(fname) +{ +} + + +/** Calls Metafont and evaluates the logfile. If a gf file was successfully + * generated the dpi value is stripped from the filename + * (e.g. cmr10.600gf => cmr10.gf). This makes life easier... + * @param[in] mode Metafont mode, e.g. "ljfour" + * @param[in] mag magnification factor + * @return true on success */ +bool MetafontWrapper::call (const string &mode, double mag) { + if (!FileFinder::lookup(_fontname+".mf")) + return false; // mf file not available => no need to call the "slow" Metafont + FileSystem::remove(_fontname+".gf"); + +#ifdef __WIN32__ +#ifdef TEXLIVEWIN32 + const char *mfname = "mf-nowin.exe"; +#else + const char *mfname = "mf.exe"; +#endif + const char *cmd = FileFinder::lookup(mfname, false); + if (!cmd) { + Message::estream(true) << "can't run Metafont (" << mfname << " not found)\n"; + return false; + } +#else + const char *cmd = "mf"; +#endif + ostringstream oss; + oss << "\"\\mode=" << mode << ";" + "mag:=" << mag << ";" + "batchmode;" + "input " << _fontname << "\""; + Message::mstream(false, Message::MC_STATE) << "\nrunning Metafont for " << _fontname << '\n'; + Process mf_process(cmd, oss.str().c_str()); + mf_process.run(); + + // try to read Metafont's logfile and get name of created GF file + ifstream ifs((_fontname+".log").c_str()); + if (ifs) { + char buf[128]; + while (ifs) { + ifs.getline(buf, 128); + string line = buf; + if (line.substr(0, 15) == "! Interruption.") + SignalHandler::instance().trigger(true); + if (line.substr(0, 17) == "Output written on") { + size_t pos = line.find("gf ", 18+_fontname.length()); + if (pos != string::npos) { + string gfname = line.substr(18, pos-16); // GF filename found + FileSystem::rename(gfname, _fontname+".gf"); + } + break; + } + } + } + ifstream gf((_fontname+".gf").c_str()); + return gf; +} + + +/** Calls Metafont if output files (tfm and gf) don't already exist. + * @param[in] mode Metafont mode to be used (e.g. 'ljfour') + * @param[in] mag magnification factor + * @return true on success */ +bool MetafontWrapper::make (const string &mode, double mag) { + ifstream tfm((_fontname+".tfm").c_str()); + ifstream gf((_fontname+".gf").c_str()); + if (gf && tfm) // @@ distinguish between gf and tfm + return true; + return call(mode, mag); +} + + +bool MetafontWrapper::success () const { + ifstream tfm((_fontname+".tfm").c_str()); + ifstream gf((_fontname+".gf").c_str()); + return tfm && gf; +} + + +/** Remove all files created by a Metafont call (tfm, gf, log). + * @param[in] keepGF if true, GF files won't be removed */ +void MetafontWrapper::removeOutputFiles (bool keepGF) { + removeOutputFiles(_fontname, keepGF); +} + + +/** Remove all files created by a Metafont call for a given font (tfm, gf, log). + * @param[in] fontname name of font whose temporary files should be removed + * @param[in] keepGF if true, GF files will be kept */ +void MetafontWrapper::removeOutputFiles (const string &fontname, bool keepGF) { + const char *ext[] = {"gf", "tfm", "log", 0}; + for (const char **p = keepGF ? ext+2 : ext; *p; ++p) + FileSystem::remove(fontname + "." + *p); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.h new file mode 100644 index 00000000000..2a69654ff95 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MetafontWrapper.h @@ -0,0 +1,43 @@ +/************************************************************************* +** MetafontWrapper.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef METAFONTWRAPPER_H +#define METAFONTWRAPPER_H + +#include + + +struct FileFinder; + +class MetafontWrapper +{ + public: + MetafontWrapper (const std::string &fontname); + bool call (const std::string &mode, double mag); + bool make (const std::string &mode, double mag); + bool success () const; + void removeOutputFiles (bool keepGF=false); + static void removeOutputFiles (const std::string &fontname, bool keepGF=false); + + private: + std::string _fontname; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.cpp new file mode 100644 index 00000000000..18a36666f9a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.cpp @@ -0,0 +1,101 @@ +/************************************************************************* +** MiKTeXCom.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "MessageException.h" +#include "MiKTeXCom.h" +#include "macros.h" + +using namespace std; + + +MiKTeXCom::MiKTeXCom () : _session(0) { + if (FAILED(CoInitialize(0))) + throw MessageException("COM library could not be initialized\n"); +#ifdef _MSC_VER + HRESULT hres = _session.CreateInstance(L"MiKTeX.Session"); +#elif defined(__WIN64__) + HRESULT hres = CoCreateInstance(CLSID_MiKTeXSession2_9, 0, CLSCTX_LOCAL_SERVER, IID_ISession2, (void**)&_session); +#else + HRESULT hres = CoCreateInstance(CLSID_MiKTeXSession2_9, 0, CLSCTX_INPROC_SERVER, IID_ISession2, (void**)&_session); +#endif + if (FAILED(hres)) + throw MessageException("MiKTeX.Session could not be initialized"); +} + + +MiKTeXCom::~MiKTeXCom () { +#ifdef _MSC_VER + _session.Release(); +#else + _session->Release(); +#endif + _session = 0; // avoid automatic calling of Release() after CoUninitialize() + CoUninitialize(); +} + + +string MiKTeXCom::getVersion () { +#ifdef _MSC_VER + MiKTeXSetupInfo info = _session->GetMiKTeXSetupInfo(); +#else + MiKTeXSetupInfo info; + _session->GetMiKTeXSetupInfo(&info); +#endif + _bstr_t version = info.version; + return string(version); +} + + +string MiKTeXCom::getBinDir () { +#ifdef _MSC_VER + MiKTeXSetupInfo info = _session->GetMiKTeXSetupInfo(); +#else + MiKTeXSetupInfo info; + _session->GetMiKTeXSetupInfo(&info); +#endif + _bstr_t bindir = info.binDirectory; + return string(bindir); +} + + +const char* MiKTeXCom::findFile (const char *fname) { + try { + _bstr_t path; + static string ret; +#ifdef _MSC_VER + HRESULT hres = _session->FindFile(fname, path.GetAddress()); + bool found = (hres != 0); +#else + VARIANT_BOOL found_var; + _session->FindFile(_bstr_t(fname), path.GetAddress(), &found_var); + bool found = (found_var == VARIANT_TRUE); +#endif + if (found) { + ret = _bstr_t(path); + return ret.c_str(); + } + return 0; + } + catch (_com_error &e) { + throw MessageException((const char*)e.Description()); + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.h new file mode 100644 index 00000000000..3f387c8204b --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/MiKTeXCom.h @@ -0,0 +1,52 @@ +/************************************************************************* +** MiKTeXCom.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MIKTEXCOM_H +#define MIKTEXCOM_H + +#include + +#ifdef _MSC_VER +#import +using namespace MiKTeXSession2_9; +#else +#include "miktex209-session.h" +#endif + + +class MiKTeXCom +{ + public: + MiKTeXCom (); + ~MiKTeXCom (); + std::string getBinDir (); + std::string getVersion (); + const char* findFile (const char* fname); + + private: +#ifdef _MSC_VER + ISession2Ptr _session; +#else + ISession2 *_session; +#endif +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.cpp new file mode 100644 index 00000000000..e996ca24dea --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.cpp @@ -0,0 +1,45 @@ +/************************************************************************* +** NoPsSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "Message.h" +#include "NoPsSpecialHandler.h" + +using namespace std; + + +bool NoPsSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + _count++; + return true; +} + + +void NoPsSpecialHandler::dviEndPage (unsigned pageno) { + if (_count > 0) { + string suffix = (_count > 1 ? "s" : ""); + Message::wstream(true) << _count << " PostScript special" << suffix << " ignored. The resulting SVG might look wrong.\n"; + _count = 0; + } +} + + +const char** NoPsSpecialHandler::prefixes () const { + static const char *pfx[] = {"header=", "psfile=", "PSfile=", "ps:", "ps::", "!", "\"", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.h new file mode 100644 index 00000000000..e2f38302186 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/NoPsSpecialHandler.h @@ -0,0 +1,42 @@ +/************************************************************************* +** NoPsSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef NOPSSPECIALHANDLER_H +#define NOPSSPECIALHANDLER_H + +#include "SpecialHandler.h" + +class NoPsSpecialHandler : public SpecialHandler, public DVIEndPageListener +{ + public: + NoPsSpecialHandler () : _count(0) {} + bool process (const char *prefix, std::istream &is, SpecialActions *actions); + const char* name () const {return 0;} + const char* info () const {return 0;} + const char** prefixes () const; + + protected: + void dviEndPage (unsigned pageno); + + private: + unsigned _count; // number of PS specials skipped +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.cpp new file mode 100644 index 00000000000..f1fad9448d8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.cpp @@ -0,0 +1,324 @@ +/************************************************************************* +** PSInterpreter.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "FileFinder.h" +#include "InputReader.h" +#include "Message.h" +#include "PSInterpreter.h" +#include "SignalHandler.h" + +using namespace std; + + +const char *PSInterpreter::GSARGS[] = { + "gs", // dummy name + "-q", // be quiet, suppress gs banner + "-dSAFER", // disallow writing of files + "-dNODISPLAY", // we don't need a display device + "-dNOPAUSE", // keep going + "-dWRITESYSTEMDICT", // leave systemdict writable as some operators must be replaced + "-dNOPROMPT", +// "-dNOBIND", +}; + + +/** Constructs a new PSInterpreter object. + * @param[in] actions template methods to be executed after recognizing the corresponding PS operator. */ +PSInterpreter::PSInterpreter (PSActions *actions) + : _mode(PS_NONE), _actions(actions), _bytesToRead(0), _inError(false), _initialized(false) +{ +} + + +void PSInterpreter::init () { + if (!_initialized) { + _gs.init(sizeof(GSARGS)/sizeof(char*), GSARGS, this); + _gs.set_stdio(input, output, error); + _initialized = true; + // Before executing any random PS code redefine some operators and run + // initializing PS code. This cannot be done in the constructor because we + // need the completely initialized PSInterpreter object here. + execute(PSDEFS); + } +} + + +PSActions* PSInterpreter::setActions (PSActions *actions) { + PSActions *old_actions = _actions; + _actions = actions; + return old_actions; +} + + +/** Checks if the given status value returned by Ghostscript indicates an error. + * @param[in] status status value returned by Ghostscript after the execution of a PS snippet + * @throw PSException if the status value indicates a PostScript error */ +void PSInterpreter::checkStatus (int status) { + if (status < 0) { + _mode = PS_QUIT; + if (status < -100) + throw PSException("fatal error"); + if (_errorMessage.empty()) + throw PSException(_gs.error_name(status)); + throw PSException(_errorMessage); + } +} + + +/** Executes a chunk of PostScript code. + * @param[in] str buffer containing the code + * @param[in] len number of characters in buffer + * @param[in] flush If true, a final 'flush' is sent which forces the output buffer to be written immediately. + * @return true if the assigned number of bytes have been read */ +bool PSInterpreter::execute (const char *str, size_t len, bool flush) { + init(); + if (_mode == PS_QUIT) + return false; + + int status=0; + if (_mode == PS_NONE) { + _gs.run_string_begin(0, &status); + _mode = PS_RUNNING; + } + checkStatus(status); + + bool finished=false; + if (_bytesToRead > 0 && len >= _bytesToRead) { + len = _bytesToRead; + finished = true; + } + + // 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) { + SignalHandler::instance().check(); + size_t chunksize = min(len, (size_t)0xffff); + _gs.run_string_continue(p, chunksize, 0, &status); + p += chunksize; + len -= chunksize; + if (_bytesToRead > 0) + _bytesToRead -= chunksize; + if (status == -101) // e_Quit + _mode = PS_QUIT; + else + checkStatus(status); + } + if (flush) { + // force writing contents of output buffer + _gs.run_string_continue("\nflush ", 7, 0, &status); + } + return finished; +} + + +/** Executes a chunk of PostScript code read from a stream. The method returns on EOF. + * @param[in] is the input stream + * @return true if the assigned number of bytes have been read */ +bool PSInterpreter::execute (istream &is) { + char buf[4096]; + bool finished = false; + while (is && !is.eof() && !finished) { + is.read(buf, 4096); + finished = execute(buf, is.gcount(), false); + } + execute("\n", 1); + return finished; +} + + +/** This callback function handles input from stdin to Ghostscript. Currently not needed. + * @param[in] inst pointer to calling instance of PSInterpreter + * @param[in] buf takes the read characters + * @param[in] len size of buffer buf + * @return number of characters read */ +int GSDLLCALL PSInterpreter::input (void *inst, char *buf, int len) { + return 0; +} + + +/** This callback function handles output from Ghostscript to stdout. It looks for + * emitted commands staring with "dvi." and executes them by calling method callActions. + * Ghostscript sends the text in chunks by several calls of this function. + * Unfortunately, the PostScript specification wants error messages also to be sent to stdout + * instead of stderr. Thus, we must collect and concatenate the chunks until an evaluable text + * snippet is completely received. Furthermore, error messages have to be recognized and to be + * filtered out. + * @param[in] inst pointer to calling instance of PSInterpreter + * @param[in] buf contains the characters to be output + * @param[in] len number of characters in buf + * @return number of processed characters (equals 'len') */ +int GSDLLCALL PSInterpreter::output (void *inst, const char *buf, int len) { + PSInterpreter *self = static_cast(inst); + if (self && self->_actions) { + const size_t MAXLEN = 512; // maximal line length (longer lines are of no interest) + const char *end = buf+len-1; // last position of buf + for (const char *first=buf, *last=buf; first <= end; last++, first=last) { + // move first and last to begin and end of the next line, respectively + while (last < end && *last != '\n') + last++; + size_t linelength = last-first+1; + if (linelength > MAXLEN) // skip long lines since they don't contain any relevant information + continue; + + vector &linebuf = self->_linebuf; // just a shorter name... + if ((*last == '\n' || !self->active()) || self->_inError) { + if (linelength + linebuf.size() > 1) { // prefix "dvi." plus final newline + SplittedCharInputBuffer ib(linebuf.empty() ? 0 : &linebuf[0], linebuf.size(), first, linelength); + BufferInputReader in(ib); + if (self->_inError) + self->_errorMessage += string(first, linelength); + else { + in.skipSpace(); + if (in.check("Unrecoverable error: ")) { + self->_errorMessage.clear(); + while (!in.eof()) + self->_errorMessage += in.get(); + self->_inError = true; + } + else if (in.check("dvi.")) + self->callActions(in); + } + } + linebuf.clear(); + } + else { // no line end found => + // save remaining characters and prepend them to the next incoming chunk of characters + if (linebuf.size() + linelength > MAXLEN) + linebuf.clear(); // don't care for long lines + else { + size_t currsize = linebuf.size(); + linebuf.resize(currsize+linelength); + memcpy(&linebuf[currsize], first, linelength); + } + } + } + } + return len; +} + + +/** Converts a vector of strings to a vector of doubles. + * @param[in] str the strings to be converted + * @param[out] d the resulting doubles */ +static void str2double (const vector &str, vector &d) { + for (size_t i=0; i < str.size(); i++) { + istringstream iss(str[i]); + iss >> d[i]; + } +} + + +/** Evaluates a command emitted by Ghostscript and invokes the corresponding + * method of interface class PSActions. + * @param[in] in reader pointing to the next command */ +void PSInterpreter::callActions (InputReader &in) { + // array of currently supported operators (must be ascendingly sorted) + static const struct Operator { + const char *name; // name of operator + int pcount; // number of parameters (< 0 : variable number of parameters) + void (PSActions::*op)(vector &p); // operation handler + } operators [] = { + {"applyscalevals", 3, &PSActions::applyscalevals}, + {"clip", 0, &PSActions::clip}, + {"closepath", 0, &PSActions::closepath}, + {"curveto", 6, &PSActions::curveto}, + {"eoclip", 0, &PSActions::eoclip}, + {"eofill", 0, &PSActions::eofill}, + {"fill", 0, &PSActions::fill}, + {"grestore", 0, &PSActions::grestore}, + {"grestoreall", 0, &PSActions::grestoreall}, + {"gsave", 0, &PSActions::gsave}, + {"initclip", 0, &PSActions::initclip}, + {"lineto", 2, &PSActions::lineto}, + {"makepattern", -1, &PSActions::makepattern}, + {"moveto", 2, &PSActions::moveto}, + {"newpath", 0, &PSActions::newpath}, + {"querypos", 2, &PSActions::querypos}, + {"restore", 1, &PSActions::restore}, + {"rotate", 1, &PSActions::rotate}, + {"save", 1, &PSActions::save}, + {"scale", 2, &PSActions::scale}, + {"setcmykcolor", 4, &PSActions::setcmykcolor}, + {"setdash", -1, &PSActions::setdash}, + {"setgray", 1, &PSActions::setgray}, + {"sethsbcolor", 3, &PSActions::sethsbcolor}, + {"setlinecap", 1, &PSActions::setlinecap}, + {"setlinejoin", 1, &PSActions::setlinejoin}, + {"setlinewidth", 1, &PSActions::setlinewidth}, + {"setmatrix", 6, &PSActions::setmatrix}, + {"setmiterlimit", 1, &PSActions::setmiterlimit}, + {"setopacityalpha", 1, &PSActions::setopacityalpha}, + {"setpattern", -1, &PSActions::setpattern}, + {"setrgbcolor", 3, &PSActions::setrgbcolor}, + {"stroke", 0, &PSActions::stroke}, + {"translate", 2, &PSActions::translate}, + }; + if (_actions) { + in.skipSpace(); + // binary search + int first=0, last=sizeof(operators)/sizeof(Operator)-1; + while (first <= last) { + int mid = first+(last-first)/2; + int cmp = in.compare(operators[mid].name); + if (cmp > 0) + last = mid-1; + else if (cmp < 0) + first = mid+1; + else { + // collect parameters and call handler + vector params; + int pcount = operators[mid].pcount; + if (pcount < 0) { // variable number of parameters? + in.skipSpace(); + while (!in.eof()) { // read all available parameters + params.push_back(in.getString()); + in.skipSpace(); + } + } + else { // fixed number of parameters + for (int i=0; i < pcount; i++) { + in.skipSpace(); + params.push_back(in.getString()); + } + } + vector v(params.size()); + str2double(params, v); + (_actions->*operators[mid].op)(v); + _actions->executed(); + } + } + } +} + + +/** This callback function handles output from Ghostscript to stderr. + * @param[in] inst pointer to calling instance of PSInterpreter + * @param[in] buf contains the characters to be output + * @param[in] len number of chars in buf + * @return number of processed characters */ +int GSDLLCALL PSInterpreter::error (void *inst, const char *buf, int len) { + return len; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.h new file mode 100644 index 00000000000..4e46732a420 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSInterpreter.h @@ -0,0 +1,121 @@ +/************************************************************************* +** PSInterpreter.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PSINTERPRETER_H +#define PSINTERPRETER_H + +#include +#include +#include +#include +#include "Ghostscript.h" +#include "InputReader.h" +#include "MessageException.h" + + +struct PSException : public MessageException +{ + PSException (const std::string &msg) : MessageException(msg) {} +}; + + +/** This interface provides the template methods called by PSInterpreter when executing a PS snippet. + * Each method corresponds to a PostScript operator of the same name. */ +struct PSActions +{ + virtual ~PSActions () {} + virtual void applyscalevals (std::vector &p) =0; + virtual void clip (std::vector &p) =0; + virtual void closepath (std::vector &p) =0; + virtual void curveto (std::vector &p) =0; + virtual void eoclip (std::vector &p) =0; + virtual void eofill (std::vector &p) =0; + virtual void fill (std::vector &p) =0; + virtual void gsave (std::vector &p) =0; + virtual void grestore (std::vector &p) =0; + virtual void grestoreall (std::vector &p) =0; + virtual void initclip (std::vector &p) =0; + virtual void lineto (std::vector &p) =0; + virtual void makepattern (std::vector &p) =0; + virtual void moveto (std::vector &p) =0; + virtual void newpath (std::vector &p) =0; + virtual void querypos (std::vector &p) =0; + virtual void restore (std::vector &p) =0; + virtual void rotate (std::vector &p) =0; + virtual void save (std::vector &p) =0; + virtual void scale (std::vector &p) =0; + virtual void setcmykcolor (std::vector &cmyk) =0; + virtual void setdash (std::vector &p) =0; + virtual void setgray (std::vector &p) =0; + virtual void sethsbcolor (std::vector &hsb) =0; + virtual void setlinecap (std::vector &p) =0; + virtual void setlinejoin (std::vector &p) =0; + virtual void setlinewidth (std::vector &p) =0; + virtual void setmatrix (std::vector &p) =0; + virtual void setmiterlimit (std::vector &p) =0; + virtual void setopacityalpha (std::vector &p) =0; + virtual void setpattern (std::vector &p) =0; + virtual void setrgbcolor (std::vector &rgb) =0; + virtual void stroke (std::vector &p) =0; + virtual void translate (std::vector &p) =0; + virtual void executed () {} // triggered if one of the above PS operators has been executed +}; + + +/** This class provides methods to execute chunks of PostScript code and calls + * several template methods on invocation of selected PS operators (see PSActions). */ +class PSInterpreter +{ + enum Mode {PS_NONE, PS_RUNNING, PS_QUIT}; + + public: + PSInterpreter (PSActions *actions=0); + bool execute (const char *str, size_t len, bool flush=true); + bool execute (const char *str) {return execute(str, std::strlen(str));} + bool execute (const std::string &str) {return execute(str.c_str());} + bool execute (std::istream &is); + bool active () const {return _mode != PS_QUIT;} + void limit (size_t max_bytes) {_bytesToRead = max_bytes;} + PSActions* setActions (PSActions *actions); + + protected: + void init (); + // callback functions + static int GSDLLCALL input (void *inst, char *buf, int len); + static int GSDLLCALL output (void *inst, const char *buf, int len); + static int GSDLLCALL error (void *inst, const char *buf, int len); + + void checkStatus (int status); + void callActions (InputReader &cib); + + private: + Ghostscript _gs; + Mode _mode; ///< current execution mode + PSActions *_actions; ///< actions to be performed + size_t _bytesToRead; ///< if > 0, maximal number of bytes to be processed by following calls of execute() + std::vector _linebuf; + std::string _errorMessage; ///< text of error message + bool _inError; ///< true if scanning error message + bool _initialized; ///< true if PSInterpreter has been completely initialized + static const char *GSARGS[]; ///< parameters passed to Ghostscript + static const char *PSDEFS; ///< initial PostScript definitions +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.cpp new file mode 100644 index 00000000000..52fbf16c589 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.cpp @@ -0,0 +1,178 @@ +/************************************************************************* +** PSPattern.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "BoundingBox.h" +#include "PSPattern.h" +#include "SpecialActions.h" +#include "SVGTree.h" +#include "XMLNode.h" + +using namespace std; + + +string PSPattern::svgID () const { + return XMLString("pat")+XMLString(_id); +} + + +/** Appends the definition of this pattern to the "def" section of the SVG tree. */ +void PSPattern::apply (SpecialActions *actions) { + if (XMLElementNode *pattern = createPatternNode()) + actions->appendToDefs(pattern); +} + + +///////////////////////////////////////////////////////////////////////////// + +PSTilingPattern::PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) + : PSPattern(id), _bbox(bbox), _matrix(matrix), _xstep(xstep), _ystep(ystep), _groupNode(0) +{ + const double bp2pt = 72.27/72.0; // factor to convert bp to pt + _bbox.scale(bp2pt, bp2pt); + _xstep *= bp2pt; + _ystep *= bp2pt; + _groupNode = PSTilingPattern::createGroupNode(); +} + + +PSTilingPattern::~PSTilingPattern () { + delete _groupNode; +} + + +/** Creates a new pattern element representing the pattern defined in the PS code. */ +XMLElementNode* PSTilingPattern::createPatternNode () const { + if (!_groupNode) + return 0; + BoundingBox box(_bbox.minX(), _bbox.minY(), _bbox.minX()+_xstep, _bbox.minY()+_ystep); + XMLElementNode *pattern = new XMLElementNode("pattern"); + pattern->addAttribute("id", svgID()); + pattern->addAttribute("x", box.minX()); + pattern->addAttribute("y", box.minY()); + pattern->addAttribute("width", box.width()); + pattern->addAttribute("height", box.height()); + pattern->addAttribute("viewBox", box.toSVGViewBox()); + pattern->addAttribute("patternUnits", "userSpaceOnUse"); + if (!_matrix.isIdentity()) + pattern->addAttribute("patternTransform", _matrix.getSVG()); + if (_xstep < _bbox.width() || _ystep < _bbox.height()) { // overlapping tiles? + // disable clipping at the tile borders => tiles become "transparent" + pattern->addAttribute("overflow", "visible"); + } + if (XMLElementNode *clip=createClipNode()) + pattern->append(clip); + pattern->append(_groupNode); + return pattern; +} + + +/** Creates a new clip element restricting the drawing area to the + * dimensions given in the definition of the pattern. */ +XMLElementNode* PSTilingPattern::createClipNode() const { + XMLElementNode *clip = new XMLElementNode("clipPath"); + clip->addAttribute("id", "pc"+XMLString(psID())); + XMLElementNode *rect = new XMLElementNode("rect"); + rect->addAttribute("x", _bbox.minX()); + rect->addAttribute("y", _bbox.minY()); + rect->addAttribute("width", _bbox.width()); + rect->addAttribute("height", _bbox.height()); + clip->append(rect); + return clip; +} + + +/** Creates a new group element that contains all "drawing" elements that + * define the pattern graphic. */ +XMLElementNode* PSTilingPattern::createGroupNode () const { + // add all succeeding path elements to this group + XMLElementNode *group = new XMLElementNode("g"); + group->addAttribute("clip-path", XMLString("url(#pc")+XMLString(psID())+")"); + return group; +} + + +void PSTilingPattern::apply (SpecialActions *actions) { + PSPattern::apply(actions); + _groupNode = 0; +} + + +///////////////////////////////////////////////////////////////////////////// + +PSColoredTilingPattern::PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) + : PSTilingPattern(id, bbox, matrix, xstep, ystep) +{ +} + + +///////////////////////////////////////////////////////////////////////////// + +PSUncoloredTilingPattern::PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep) + : PSTilingPattern(id, bbox, matrix, xstep, ystep), _applied(false) +{ +} + + +PSUncoloredTilingPattern::~PSUncoloredTilingPattern () { + if (_applied) + setGroupNode(0); // prevent deleting the group node in the parent destructor +} + + +/** Returns an SVG id value that identifies this pattern with the current color applied. */ +string PSUncoloredTilingPattern::svgID () const { + ostringstream oss; + oss << PSPattern::svgID() << '-' << hex << _currentColor; + return oss.str(); +} + + +/** Appends the definition of this pattern with the current color applied + * to the "def" section of the SVG tree. */ +void PSUncoloredTilingPattern::apply (SpecialActions* actions) { + set::iterator it=_colors.find(_currentColor); + if (it == _colors.end()) { + if (_applied) + setGroupNode(static_cast(getGroupNode()->clone())); + // assign current color to the pattern graphic + vector colored_elems; + const char *attribs[] = {"fill", "stroke"}; + for (int i=0; i < 2; i++) { + getGroupNode()->findDescendants(0, attribs[i], colored_elems); + for (vector::iterator it=colored_elems.begin(); it != colored_elems.end(); ++it) + if (string((*it)->getAttributeValue(attribs[i])) != "none") + (*it)->addAttribute(attribs[i], _currentColor.rgbString()); + colored_elems.clear(); + } + PSPattern::apply(actions); + _colors.insert(_currentColor); + _applied = true; + } +} + + +XMLElementNode* PSUncoloredTilingPattern::createClipNode() const { + // only the first instance of this patterns get a clip element + if (_colors.empty()) + return PSTilingPattern::createClipNode(); + return 0; +} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.h new file mode 100644 index 00000000000..7e2848dea3b --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PSPattern.h @@ -0,0 +1,100 @@ +/************************************************************************* +** PSPattern.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PSPATTERN_H +#define PSPATTERN_H + +#include +#include +#include "BoundingBox.h" +#include "Color.h" +#include "Matrix.h" + + +struct SpecialActions; +class SVGTree; +class XMLElementNode; + +class PSPattern +{ + public: + virtual ~PSPattern () {} + virtual int psID () const {return _id;} + virtual std::string svgID () const; + virtual void apply (SpecialActions *actions); + + protected: + PSPattern (int id) : _id(id) {} + virtual XMLElementNode* createPatternNode () const =0; + + private: + int _id; ///< PostSCript ID of this pattern +}; + + +class PSTilingPattern : public PSPattern +{ + public: + ~PSTilingPattern (); + virtual XMLElementNode* getContainerNode () {return _groupNode;} + void apply (SpecialActions *actions); + + protected: + PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); + XMLElementNode* createPatternNode () const; + virtual XMLElementNode* createClipNode () const; + virtual XMLElementNode* createGroupNode () const; + virtual XMLElementNode* getGroupNode () const {return _groupNode;} + virtual void setGroupNode (XMLElementNode *node) {_groupNode = node;} + + private: + BoundingBox _bbox; ///< bounding box of the tile graphics + Matrix _matrix; ///< tile transformation + double _xstep, _ystep; ///< horizontal and vertical distance between neighboured tiles + XMLElementNode *_groupNode; ///< group containing the drawing elements +}; + + +class PSColoredTilingPattern : public PSTilingPattern +{ + public: + PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); +}; + + +class PSUncoloredTilingPattern : public PSTilingPattern +{ + public: + PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep); + ~PSUncoloredTilingPattern (); + std::string svgID () const; + void setColor (Color color) {_currentColor = color;} + void apply (SpecialActions *actions); + + protected: + XMLElementNode* createClipNode () const; + + private: + std::set _colors; ///< colors this pattern has already been drawn with + Color _currentColor; ///< current color to be applied + bool _applied; ///< has pattern with current group node already been applied to the SVG tree? +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.cpp new file mode 100644 index 00000000000..8a20a35d52b --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.cpp @@ -0,0 +1,135 @@ +/************************************************************************* +** PageRanges.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "InputBuffer.h" +#include "InputReader.h" +#include "PageRanges.h" + +#include "macros.h" + +using namespace std; + + +/** Analyzes a string describing a range sequence. + * Syntax: ([0-9]+(-[0-9]*)?)|(-[0-9]+)(,([0-9]+(-[0-9]*)?)|(-[0-9]+))* + * @param[in] str string to parse + * @param[in] max_page greatest allowed value + * @param[out] ranges the extracted range sequence + * @return true on success; false denotes a syntax error */ +bool PageRanges::parse (string str, int max_page) { + StringInputBuffer ib(str); + BufferInputReader ir(ib); + while (ir) { + int first=1; + int last=max_page; + ir.skipSpace(); + if (!isdigit(ir.peek()) && ir.peek() != '-') + return false; + + if (isdigit(ir.peek())) + first = ir.getInt(); + ir.skipSpace(); + if (ir.peek() == '-') { + while (ir.peek() == '-') + ir.get(); + ir.skipSpace(); + if (isdigit(ir.peek())) + last = ir.getInt(); + } + else + last = first; + ir.skipSpace(); + if (ir.peek() == ',') { + ir.get(); + if (ir.eof()) + return false; + } + else if (!ir.eof()) + return false; + if (first > last) + swap(first, last); + first = max(1, first); + last = max(first, last); + if (max_page > 0) { + first = min(first, max_page); + last = min(last, max_page); + } + insert(first, last); + } + return true; +} + + +/** Adds a page range to the range collection. + * @param[in] first first page of new range + * @param[in] last last page of new range */ +void PageRanges::insert (int first, int last) { + if (first > last) + swap(first, last); + Container::iterator it = _ranges.begin(); + while (it != _ranges.end() && first > it->first+1 && first > it->second+1) + ++it; + if (it == _ranges.end() || last < it->first-1 || first > it->second+1) + it = _ranges.insert(it, Range(first, last)); + else if ((first < it->first && last >= it->first-1) || (first <= it->second+1 && last > it->second)) { + it->first = min(it->first, first); + it->second = max(it->second, last); + } + // merge adjacent ranges + if (it != _ranges.end()) { + Container::iterator l = it; + Container::iterator r = it; + if (l == _ranges.begin()) + l = _ranges.end(); + else + --l; + ++r; + bool l_modified = false; + bool r_modified = false; + if (l != _ranges.end() && l->second >= it->first-1) { + l->first = min(l->first, it->first); + l->second = max(l->second, it->second); + l_modified = true; + } + if (r != _ranges.end() && r->first <= it->second+1) { + r->first = min(r->first, it->first); + r->second = max(r->second, it->second); + r_modified = true; + } + if (l_modified || r_modified) { + _ranges.erase(it); + if (l_modified && r_modified && l->second >= r->first-1) { + l->first = min(l->first, r->first); + l->second = max(l->second, r->second); + _ranges.erase(r); + } + } + } +} + + +/** Returns the number of pages. */ +size_t PageRanges::pages () const { + size_t sum=0; + for (ConstIterator it=_ranges.begin(); it != _ranges.end(); ++it) + sum += it->second - it->first + 1; + return sum; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.h new file mode 100644 index 00000000000..0e5cd58e5ff --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageRanges.h @@ -0,0 +1,49 @@ +/************************************************************************* +** PageRanges.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PAGERANGES_H +#define PAGERANGES_H + +#include +#include +#include + +class PageRanges +{ + public: + typedef std::pair Range; + typedef std::list Container; + typedef Container::iterator Iterator; + typedef Container::const_iterator ConstIterator; + + public: + bool parse (std::string str, int max_page=0); + void insert (int first, int last); + size_t pages () const; + size_t size () const {return _ranges.size();} + const Container& ranges () const {return _ranges;} + ConstIterator begin () const {return _ranges.begin();} + ConstIterator end () const {return _ranges.end();} + + private: + Container _ranges; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.cpp new file mode 100644 index 00000000000..7ff9eb42c0f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.cpp @@ -0,0 +1,156 @@ +/************************************************************************* +** PageSize.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "PageSize.h" + +using namespace std; + +// make sure tolower is a function (and not a macro) +// so that 'transform' can be applied +static int my_tolower (int c) { + return tolower(c); +} + + +/** Computes width and height of ISO/DIN An in millimeters. + * @param[in] n the A level (e.g. n=4 => DIN A4) + * @param[out] width contains the page width when function returns + * @param[out] height contains the page height when function returns */ +static void computeASize (int n, double &width, double &height) { + double sqrt2 = sqrt(2.0); + height = floor(1189.0/pow(sqrt2, n)+0.5); + width = floor(height/sqrt2+0.5); +} + + +/** Computes width and height of ISO/DIN Bn in millimeters. + * @param[in] n the B level (e.g. n=4 => DIN B4) + * @param[out] width contains the page width when function returns + * @param[out] height contains the page height when function returns */ +static void computeBSize (int n, double &width, double &height) { + double w, h; + computeASize(n, width, height); + computeASize(n-1, w, h); + width = floor(sqrt(width * w)+0.5); + height = floor(sqrt(height * h)+0.5); +} + + +/** Computes width and height of ISO/DIN Cn in millimeters. + * @param[in] n the C level (e.g. n=4 => DIN C4) + * @param[out] width contains the page width when function returns + * @param[out] height contains the page height when function returns */ +static void computeCSize (int n, double &width, double &height) { + double w, h; + computeASize(n, width, height); + computeBSize(n, w, h); + width = floor(sqrt(width * w)+0.5); + height = floor(sqrt(height * h)+0.5); +} + + +/** Computes width and height of ISO/DIN Dn in millimeters. + * @param[in] n the D level (e.g. n=4 => DIN D4) + * @param[out] width contains the page width when function returns + * @param[out] height contains the page height when function returns */ +static void computeDSize (int n, double &width, double &height) { + double w, h; + computeASize(n, width, height); + computeBSize(n+1, w, h); + width = floor(sqrt(width * w)+0.5); + height = floor(sqrt(height * h)+0.5); +} + + +/** Constructs a PageSize object of given size. + * @param[in] name specifies the page size, e.g. "A4" or "letter" */ +PageSize::PageSize (string name) : _width(0), _height(0) { + resize(name); +} + + +void PageSize::resize (double w, double h) { + _width = w; + _height = h; +} + +void PageSize::resize (string name) { + if (name.length() < 2) + throw PageSizeException("unknown page format: "+name); + + transform(name.begin(), name.end(), name.begin(), my_tolower); + // extract optional suffix + size_t pos = name.rfind("-"); + bool landscape = false; + if (pos != string::npos) { + string suffix = name.substr(pos); + name = name.substr(0, pos); + if (suffix == "-l" || suffix == "-landscape") + landscape = true; + else if (suffix != "-p" && suffix != "-portrait") + throw PageSizeException("invalid page format suffix: " + suffix); + } + + if (name == "invoice") { + _width = 140; + _height = 216; + } + else if (name == "executive") { + _width = 184; + _height = 267; + } + else if (name == "legal") { + _width = 216; + _height = 356; + } + else if (name == "letter") { + _width = 216; + _height = 279; + } + else if (name == "ledger") { + _width = 279; + _height = 432; + } + else if (isdigit(name[1]) && name.length() < 5) { // limit length of number to prevent arithmetic errors + istringstream iss(name.substr(1)); + int n; + iss >> n; + switch (name[0]) { + case 'a' : computeASize(n, _width, _height); break; + case 'b' : computeBSize(n, _width, _height); break; + case 'c' : computeCSize(n, _width, _height); break; + case 'd' : computeDSize(n, _width, _height); break; + default : throw PageSizeException("invalid page format: "+name); + } + } + if (_width == 0 || _height == 0) + throw PageSizeException("unknown page format: "+name); + if (landscape) + swap(_width, _height); + + const double ptpmm = 72.27/25.4; // TeX points per millimeter (72.27pt = 1in = 25.4mm) + _width *= ptpmm; + _height *= ptpmm; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.h new file mode 100644 index 00000000000..bb7a55c7cdc --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PageSize.h @@ -0,0 +1,48 @@ +/************************************************************************* +** PageSize.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PAGESIZE_H +#define PAGESIZE_H + +#include "MessageException.h" + +struct PageSizeException : public MessageException +{ + PageSizeException (const std::string &msg) : MessageException(msg) {} +}; + +class PageSize +{ + public: + PageSize (double w=0, double h=0) : _width(w), _height(h) {} + PageSize (std::string name); + void resize (std:: string name); + void resize (double w, double h); + double widthInPT () const {return _width;} + double heightInPT () const {return _height;} + double widthInMM () const {return _width*25.4/72.27;} + double heightInMM () const {return _height*25.4/72.27;} + bool valid () const {return _width > 0 && _height > 0;} + + private: + double _width, _height; // in pt +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Pair.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Pair.h new file mode 100644 index 00000000000..a3dc5a12af3 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Pair.h @@ -0,0 +1,79 @@ +/************************************************************************* +** Pair.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PAIR_H +#define PAIR_H + +#include +#include +#include "macros.h" +#include "types.h" + +template +class Pair +{ + public: + Pair (T x=0, T y=0) : _x(x), _y(y) {} + Pair operator += (const Pair &p) {_x += p._x; _y += p._y; return *this;} + Pair operator -= (const Pair &p) {_x -= p._x; _y -= p._y; return *this;} + Pair operator *= (T c) {_x *= c; _y *= c; return *this;} + Pair operator /= (T c) {_x /= c; _y /= c; return *this;} + Pair ortho () const {return Pair(-_y, _x);} + double length () const {return std::sqrt(_x*_x + _y*_y);} + bool operator == (const Pair &p) const {return _x == p._x && _y == p._y;} + bool operator != (const Pair &p) const {return _x != p._x || _y != p._y;} + T x () const {return _x;} + T y () const {return _y;} + void x (const T &xx) {_x = xx;} + void y (const T &yy) {_y = yy;} + std::ostream& write (std::ostream &os) const {return os << '(' << _x << ',' << _y << ')';} + + private: + T _x, _y; +}; + + +struct Pair32 : public Pair +{ + Pair32 (Int32 x=0, Int32 y=0) : Pair(x, y) {} + explicit Pair32 (double x, double y) : Pair(Int32(x+0.5), Int32(y+0.5)) {} + Pair32 (const Pair &p) : Pair(p) {} +// operator Pair () {return *this;} +}; + +typedef Pair DPair; + +template +IMPLEMENT_ARITHMETIC_OPERATOR(Pair, +) + +template +IMPLEMENT_ARITHMETIC_OPERATOR(Pair, -) + +template +IMPLEMENT_ARITHMETIC_OPERATOR2(Pair, T, *) + +template +IMPLEMENT_ARITHMETIC_OPERATOR2(Pair, T, /) + +template +IMPLEMENT_OUTPUT_OPERATOR(Pair) + +IMPLEMENT_ARITHMETIC_OPERATOR2(Pair32, Int32, *) +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.cpp new file mode 100644 index 00000000000..f3d8464704c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.cpp @@ -0,0 +1,76 @@ +/************************************************************************* +** PdfSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "InputReader.h" +#include "MapLine.h" +#include "PdfSpecialHandler.h" +#include "FontMap.h" +#include "Message.h" + +using namespace std; + + +PdfSpecialHandler::PdfSpecialHandler () : _maplineProcessed(false) +{ +} + + +bool PdfSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + if (!actions) + return true; + StreamInputReader ir(is); + ir.skipSpace(); + string cmd = ir.getWord(); + ir.skipSpace(); + if (cmd == "mapline" || cmd == "mapfile") { + // read mode selector ('+', '-', or '=') + char modechar = '+'; // default mode (append if new, do not replace existing mapping) + if (strchr("=+-", ir.peek())) // leading modifier given? + modechar = ir.get(); + else if (!_maplineProcessed) { // no modifier given? + // remove default map entries if this is the first mapline/mapfile special called + FontMap::instance().clear(); + } + + if (cmd == "mapline") { + try { + MapLine mapline(is); + FontMap::instance().apply(mapline, modechar); + } + catch (const MapLineException &ex) { + Message::wstream(true) << "pdf:mapline: " << ex.what() << '\n'; + } + } + else { // mapfile + string fname = ir.getString(); + if (!FontMap::instance().read(fname, modechar)) + Message::wstream(true) << "can't open map file " << fname << '\n'; + } + _maplineProcessed = true; + } + return true; +} + + +const char** PdfSpecialHandler::prefixes () const { + static const char *pfx[] = {"pdf:", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.h new file mode 100644 index 00000000000..43cdd1045de --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PdfSpecialHandler.h @@ -0,0 +1,39 @@ +/************************************************************************* +** PdfSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PDFSPECIALHANDLER_H +#define PDFSPECIALHANDLER_H + +#include "SpecialHandler.h" + +class PdfSpecialHandler : public SpecialHandler +{ + public: + PdfSpecialHandler (); + const char* info () const {return "pdfTeX font map specials";} + const char* name () const {return "pdf";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &is, SpecialActions *actions); + + private: + bool _maplineProcessed; ///< true if a mapline or mapfile special has already been processed +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.cpp new file mode 100644 index 00000000000..a76219e9846 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.cpp @@ -0,0 +1,142 @@ +/************************************************************************* +** Process.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifdef __WIN32__ +#include +#else +#include +#include +#include +#include +#endif + +#include +#include "FileSystem.h" +#include "Process.h" +#include "SignalHandler.h" +#include "macros.h" + +using namespace std; + +Process::Process (const string &cmd, const string ¶mstr) + : _cmd(cmd), _paramstr(paramstr) +{ +} + + +#ifndef __WIN32__ +/** Extracts whitespace-sparated parameters from a string. + * @param[in] paramstr the parameter string + * @param[out] params vector holding the extracted parameters */ +static void split_paramstr (string paramstr, vector ¶ms) { + size_t left=0, right=0; // index of first and last character of current parameter + char quote=0; // current quote character, 0=none + const size_t len = paramstr.length(); + while (left <= right && right < len) { + while (left < len && isspace(paramstr[left])) + ++left; + if (left < len && (paramstr[left] == '"' || paramstr[left] == '\'')) + quote = paramstr[left++]; + right = left; + while (right < len && (quote || !isspace(paramstr[right]))) { + if (quote && paramstr[right] == quote) { + quote=0; + break; + } + else + ++right; + } + if (right < len) + paramstr[right]=0; + if (left < len) + params.push_back(¶mstr[left]); + left = ++right; + } +} +#endif + + +/** Runs the process and waits until it's finished. + * @param[in] quiet if true, output to stdout/stderr is suppressed + * @return true if process terminated properly + * @throw SignalException if CTRL-C was pressed during execution */ +bool Process::run (bool quiet) { +#ifdef __WIN32__ + SECURITY_ATTRIBUTES sa; + ZeroMemory(&sa, sizeof(sa)); + sa.nLength = sizeof(sa); + sa.bInheritHandle = true; + + STARTUPINFO si; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES; + HANDLE devnull = CreateFile("nul", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + si.hStdOutput = quiet ? devnull : GetStdHandle(STD_OUTPUT_HANDLE); + PROCESS_INFORMATION pi; + ZeroMemory(&pi, sizeof(pi)); + + string cmdline = _cmd+" "+_paramstr; + CreateProcess(NULL, (LPSTR)cmdline.c_str(), NULL, NULL, true, 0, NULL, NULL, &si, &pi); + WaitForSingleObject(pi.hProcess, INFINITE); + DWORD exitcode = (DWORD)-1; + GetExitCodeProcess(pi.hProcess, &exitcode); + CloseHandle(devnull); + return exitcode == 0; +#else + pid_t pid = fork(); + if (pid == 0) { // child process + if (quiet) { + int devnull = open(FileSystem::DEVNULL, O_WRONLY); + if (devnull >= 0) { + dup2(devnull, STDOUT_FILENO); + dup2(devnull, STDERR_FILENO); + close(devnull); + } + } + vector params; + params.push_back(_cmd.c_str()); + split_paramstr(_paramstr, params); + params.push_back(0); // trailing NULL marks end + execvp(_cmd.c_str(), const_cast(¶ms[0])); + exit(1); + } + if (pid > 0) { // main process + int status; + for (;;) { + waitpid(pid, &status, WNOHANG); + if (WIFEXITED(status)) // child process exited normally + return WEXITSTATUS(status) == 0; + + try { + SignalHandler::instance().check(); + } + catch (SignalException &e) { // caught ctrl-c + kill(pid, SIGKILL); + throw; + } + } + } + return false; +#endif +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.h new file mode 100644 index 00000000000..973fabf2baf --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Process.h @@ -0,0 +1,41 @@ +/************************************************************************* +** Process.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PROCESS_H +#define PROCESS_H + +#include + +class Process +{ + public: + Process (const std::string &cmd, const std::string ¶mstr); + bool run (bool quiet=true); + + protected: + Process (const Process& orig) {} + + private: + std::string _cmd; + std::string _paramstr; +}; + +#endif + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.cpp new file mode 100644 index 00000000000..91020b9f28c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.cpp @@ -0,0 +1,806 @@ +/************************************************************************* +** PsSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "EPSFile.h" +#include "FileFinder.h" +#include "Ghostscript.h" +#include "Message.h" +#include "PSPattern.h" +#include "PsSpecialHandler.h" +#include "SpecialActions.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +static inline double str2double (const string &str) { + double ret; + istringstream iss(str); + iss >> ret; + return ret; +} + + +PsSpecialHandler::PsSpecialHandler () : _psi(this), _actions(0), _initialized(false), _xmlnode(0) +{ +} + + +PsSpecialHandler::~PsSpecialHandler () { + _psi.setActions(0); // ensure no further PS actions are performed + for (map::iterator it=_patterns.begin(); it != _patterns.end(); ++it) + delete it->second; +} + + +/** Initializes the PostScript handler. It's called by the first use of process(). The + * deferred initialization speeds up the conversion of DVI files that doesn't contain + * PS specials. */ +void PsSpecialHandler::initialize (SpecialActions *actions) { + if (!_initialized) { + // initial values of graphics state + _linewidth = 1; + _linecap = _linejoin = 0; + _miterlimit = 4; + _xmlnode = _savenode = 0; + _opacityalpha = 1; // fully opaque + _sx = _sy = _cos = 1.0; + _pattern = 0; + + // execute dvips prologue/header files + const char *headers[] = {"tex.pro", "texps.pro", "special.pro", /*"color.pro",*/ 0}; + for (const char **p=headers; *p; ++p) { + if (const char *path = FileFinder::lookup(*p, false)) { + ifstream ifs(path); + _psi.execute(ifs); + } + else + Message::wstream(true) << "PostScript header file " << *p << " not found\n"; + } + // push dictionary "TeXDict" with dvips definitions on dictionary stack + // and initialize basic dvips PostScript variables + ostringstream oss; + oss << " TeXDict begin 0 0 1000 72 72 () @start " + " 0 0 moveto "; + if (actions) { + float r, g, b; + actions->getColor().getRGB(r, g, b); + oss << r << ' ' << g << ' ' << b << " setrgbcolor "; + } + _psi.execute(oss.str()); + _initialized = true; + } +} + + +/** Move PS graphic position to current DVI location. */ +void PsSpecialHandler::moveToDVIPos () { + if (_actions) { + const double bp=72.0/72.27; // pt -> bp + const double x = _actions->getX()*bp; + const double y = _actions->getY()*bp; + ostringstream oss; + oss << '\n' << x << ' ' << y << " moveto "; + _psi.execute(oss.str()); + _currentpoint = DPair(x, y); + } +} + + +/** Executes a PS snippet and moves the DVI cursor to the current DVI position afterwards. + * It's just a shorthand function as this action sequence is required several times. + * @param[in] psi PS interpreter instance + * @param[in] is stream to read the PS code from + * @param[in] pos current PS graphic position + * @param[in] actions special actions */ +static void exec_and_syncpos (PSInterpreter &psi, istream &is, const DPair &pos, SpecialActions *actions) { + psi.execute(is); + psi.execute("\nquerypos "); // retrieve current PS position (stored in 'pos') + const double pt = 72.27/72.0; // bp -> pt + actions->setX(pos.x()*pt); + actions->setY(pos.y()*pt); +} + + +bool PsSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + if (!_initialized) + initialize(actions); + _actions = actions; + + if (*prefix == '"') { + // read and execute literal PostScript code (isolated by a wrapping save/restore pair) + moveToDVIPos(); + _psi.execute("\n@beginspecial @setspecial "); + _psi.execute(is); + _psi.execute("\n@endspecial "); + } + else if (*prefix == '!') { + // execute literal PostScript header + _psi.execute("\nTeXDict begin @defspecial "); + _psi.execute(is); + _psi.execute("\n@fedspecial end "); + } + else if (strcmp(prefix, "header=") == 0) { + // read and execute PS header files + string fname; + is >> fname; + if (const char *path = FileFinder::lookup(fname, false)) { + ifstream ifs(path); + _psi.execute(ifs); + } + else + Message::estream(true) << "PS header file '" << fname << "' not found"; + } + else if (strcmp(prefix, "psfile=") == 0 || strcmp(prefix, "PSfile=") == 0) { + if (_actions) { + StreamInputReader in(is); + string fname = in.getQuotedString(in.peek() == '"' ? '"' : 0); + map attr; + in.parseAttributes(attr); + psfile(fname, attr); + } + } + else if (strcmp(prefix, "ps::") == 0) { + _actions->finishLine(); // reset DVI position on next DVI command + if (is.peek() == '[') { + // collect characters inside the brackets + string code; + for (int i=0; i < 9 && is.peek() != ']' && !is.eof(); ++i) + code += is.get(); + if (is.peek() == ']') + code += is.get(); + + if (code == "[begin]" || code == "[nobreak]") { + moveToDVIPos(); + exec_and_syncpos(_psi, is, _currentpoint, _actions); + } + else { + // no move to DVI position here + if (code != "[end]") // PS array? + _psi.execute(code); + exec_and_syncpos(_psi, is, _currentpoint, _actions); + } + } + else { // ps:: behaves like ps::[end] + // no move to DVI position here + exec_and_syncpos(_psi, is, _currentpoint, _actions); + } + } + else { // ps: ... + _actions->finishLine(); + moveToDVIPos(); + StreamInputReader in(is); + if (in.check(" plotfile ")) { // ps: plotfile fname + string fname = in.getString(); + ifstream ifs(fname.c_str()); + if (ifs) + _psi.execute(ifs); + else + Message::wstream(true) << "file '" << fname << "' not found in ps: plotfile\n"; + } + else { + // ps: is almost identical to ps::[begin] but does + // a final repositioning to the current DVI location + exec_and_syncpos(_psi, is, _currentpoint, _actions); + moveToDVIPos(); + } + } + return true; +} + + +/** Handles psfile special. + * @param[in] fname EPS file to be included + * @param[in] attr attributes given with \special psfile */ +void PsSpecialHandler::psfile (const string &fname, const map &attr) { + EPSFile epsfile(fname); + istream &is = epsfile.istream(); + if (!is) + Message::wstream(true) << "file '" << fname << "' not found in special 'psfile'\n"; + else { + map::const_iterator it; + const double pt = 72.27/72.0; // bp -> pt + + // bounding box of EPS figure + double llx = (it = attr.find("llx")) != attr.end() ? str2double(it->second)*pt : 0; + double lly = (it = attr.find("lly")) != attr.end() ? str2double(it->second)*pt : 0; + double urx = (it = attr.find("urx")) != attr.end() ? str2double(it->second)*pt : 0; + double ury = (it = attr.find("ury")) != attr.end() ? str2double(it->second)*pt : 0; + + // desired width/height of resulting figure + double rwi = (it = attr.find("rwi")) != attr.end() ? str2double(it->second)/10.0*pt : -1; + double rhi = (it = attr.find("rhi")) != attr.end() ? str2double(it->second)/10.0*pt : -1; + if (rwi == 0 || rhi == 0 || urx-llx == 0 || ury-lly == 0) + return; + + // user transformations (default values chosen according to dvips manual) + double hoffset = (it = attr.find("hoffset")) != attr.end() ? str2double(it->second)*pt : 0; + double voffset = (it = attr.find("voffset")) != attr.end() ? str2double(it->second)*pt : 0; +// double hsize = (it = attr.find("hsize")) != attr.end() ? str2double(it->second) : 612; +// double vsize = (it = attr.find("vsize")) != attr.end() ? str2double(it->second) : 792; + double hscale = (it = attr.find("hscale")) != attr.end() ? str2double(it->second) : 100; + double vscale = (it = attr.find("vscale")) != attr.end() ? str2double(it->second) : 100; + double angle = (it = attr.find("angle")) != attr.end() ? str2double(it->second) : 0; + + Matrix m(1); + m.rotate(angle).scale(hscale/100, vscale/100).translate(hoffset, voffset); + BoundingBox bbox(llx, lly, urx, ury); + bbox.transform(m); + + double sx = rwi/bbox.width(); + double sy = rhi/bbox.height(); + if (sx < 0) sx = sy; + if (sy < 0) sy = sx; + if (sx < 0) sx = sy = 1.0; + + // save current DVI position (in pt units) + const double x = _actions->getX(); + const double y = _actions->getY(); + + // all following drawings are relative to (0,0) + _actions->setX(0); + _actions->setY(0); + moveToDVIPos(); + + _xmlnode = new XMLElementNode("g"); + _psi.execute("\n@beginspecial @setspecial "); // enter \special environment + _psi.limit(epsfile.pslength()); // limit the number of bytes to be processed + _psi.execute(is); // process EPS file + _psi.limit(0); // disable limitation + _psi.execute("\n@endspecial "); // leave special environment + if (!_xmlnode->empty()) { // has anything been drawn? + Matrix m(1); + m.rotate(angle).scale(hscale/100, vscale/100).translate(hoffset, voffset); + m.translate(-llx, lly); + m.scale(sx, sy); // resize image to width "rwi" and height "rhi" + m.translate(x, y); // move image to current DVI position + _xmlnode->addAttribute("transform", m.getSVG()); + _actions->appendToPage(_xmlnode); + } + else + delete _xmlnode; + _xmlnode = 0; + + // restore DVI position + _actions->setX(x); + _actions->setY(y); + moveToDVIPos(); + + // update bounding box + m.scale(sx, -sy); + m.translate(x, y); + bbox = BoundingBox(0, 0, fabs(urx-llx), fabs(ury-lly)); + bbox.transform(m); + _actions->embed(bbox); + } +} + +/////////////////////////////////////////////////////// + +void PsSpecialHandler::gsave (vector &p) { + _clipStack.dup(); +} + + +void PsSpecialHandler::grestore (vector &p) { + _clipStack.pop(); +} + + +void PsSpecialHandler::grestoreall (vector &p) { + _clipStack.pop(-1, true); +} + + +void PsSpecialHandler::save (vector &p) { + _clipStack.dup(static_cast(p[0])); +} + + +void PsSpecialHandler::restore (vector &p) { + _clipStack.pop(static_cast(p[0])); +} + + +void PsSpecialHandler::moveto (vector &p) { + _path.moveto(p[0], p[1]); +} + + +void PsSpecialHandler::lineto (vector &p) { + _path.lineto(p[0], p[1]); +} + + +void PsSpecialHandler::curveto (vector &p) { + _path.cubicto(p[0], p[1], p[2], p[3], p[4], p[5]); +} + + +void PsSpecialHandler::closepath (vector &p) { + _path.closepath(); +} + + +/** Draws the current path recorded by previously executed path commands (moveto, lineto,...). + * @param[in] p not used */ +void PsSpecialHandler::stroke (vector &p) { + if (!_path.empty() && _actions) { + BoundingBox bbox; + if (!_actions->getMatrix().isIdentity()) { + _path.transform(_actions->getMatrix()); + if (!_xmlnode) + bbox.transform(_actions->getMatrix()); + } + + const double pt = 72.27/72.0; // factor to convert bp -> pt + ScalingMatrix scale(pt, pt); + _path.transform(scale); + bbox.transform(scale); + + XMLElementNode *path=0; + Pair 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 = new XMLElementNode("circle"); + path->addAttribute("cx", x); + path->addAttribute("cy", y); + path->addAttribute("r", r); + path->addAttribute("fill", _actions->getColor().rgbString()); + bbox = BoundingBox(x-r, y-r, x+r, y+r); + } + } + else { + // compute bounding box + _path.computeBBox(bbox); + bbox.expand(_linewidth/2); + + ostringstream oss; + _path.writeSVG(oss); + path = new XMLElementNode("path"); + path->addAttribute("d", oss.str()); + path->addAttribute("stroke", _actions->getColor().rgbString()); + 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 (_opacityalpha < 1) + path->addAttribute("stroke-opacity", _opacityalpha); + if (!_dashpattern.empty()) { + ostringstream oss; + for (size_t i=0; i < _dashpattern.size(); i++) { + if (i > 0) + oss << ','; + oss << XMLString(_dashpattern[i]); + } + path->addAttribute("stroke-dasharray", oss.str()); + if (_dashoffset != 0) + path->addAttribute("stroke-dashoffset", _dashoffset); + } + } + if (path && _clipStack.top()) { + // assign clipping path and clip bounding box + path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")"); + BoundingBox clipbox; + _clipStack.top()->computeBBox(clipbox); + bbox.intersect(clipbox); + } + + if (_xmlnode) + _xmlnode->append(path); + else { + _actions->appendToPage(path); + _actions->embed(bbox); + } + _path.newpath(); + } +} + + +/** Draws a closed path filled with the current color. + * @param[in] p not used + * @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */ +void PsSpecialHandler::fill (vector &p, bool evenodd) { + if (!_path.empty() && _actions) { + // compute bounding box + BoundingBox bbox; + _path.computeBBox(bbox); + if (!_actions->getMatrix().isIdentity()) { + _path.transform(_actions->getMatrix()); + if (!_xmlnode) + bbox.transform(_actions->getMatrix()); + } + const double pt = 72.27/72.0; // factor to convert bp -> pt + ScalingMatrix scale(pt, pt); + _path.transform(scale); + bbox.transform(scale); + + ostringstream oss; + _path.writeSVG(oss); + XMLElementNode *path = new XMLElementNode("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().rgbString()); + if (_clipStack.top()) { + // assign clipping path and clip bounding box + path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")"); + BoundingBox clipbox; + _clipStack.top()->computeBBox(clipbox); + bbox.intersect(clipbox); + } + if (evenodd) // SVG default fill rule is "nonzero" algorithm + path->addAttribute("fill-rule", "evenodd"); + if (_opacityalpha < 1) + path->addAttribute("fill-opacity", _opacityalpha); + if (_xmlnode) + _xmlnode->append(path); + else { + _actions->appendToPage(path); + _actions->embed(bbox); + } + _path.newpath(); + } +} + + +/** Creates a Matrix object out of a given sequence of 6 double values. + * The given values must be arranged in PostScript matrix order. + * @param[in] v vector containing the matrix values + * @param[in] startindex vector index of first component + * @param[out] matrix the generated matrix */ +static void create_matrix (vector &v, int startindex, Matrix &matrix) { + // Ensure vector p has 6 elements. If necessary, add missing ones + // using corresponding values of the identity matrix. + if (v.size()-startindex < 6) { + v.resize(6+startindex); + for (int i=v.size()-startindex; i < 6; ++i) + v[i+startindex] = (i%3 ? 0 : 1); + } + // PS matrix [a b c d e f] equals ((a,b,0),(c,d,0),(e,f,1)). + // Since PS uses left multiplications, we must transpose and reorder + // the matrix to ((a,c,e),(b,d,f),(0,0,1)). This is done by the + // following swaps. + swap(v[startindex+1], v[startindex+2]); // => (a, c, b, d, e, f) + swap(v[startindex+2], v[startindex+4]); // => (a, c, e, d, b, f) + swap(v[startindex+3], v[startindex+4]); // => (a, c, e, b, d, f) + matrix.set(v, startindex); +} + + +/** Starts the definition of a new fill pattern. This operator + * expects 9 parameters for tiling patterns (see PS reference 4.9.2): + * @param[in] p the 9 values defining a tiling pattern (see PS reference 4.9.2): + * 0: pattern type (0:none, 1:tiling, 2:shading) + * 1: pattern ID + * 2-5: lower left and upper right coordinates of pattern box + * 6: horizontal distance of adjacent tiles + * 7: vertical distance of adjacent tiles + * 8: paint type (1: colored pattern, 2: uncolored pattern) + * 9-14: pattern matrix */ +void PsSpecialHandler::makepattern (vector &p) { + int pattern_type = static_cast(p[0]); + int id = static_cast(p[1]); + switch (pattern_type) { + case 0: + // pattern definition completed + if (_savenode) { + _xmlnode = _savenode; + _savenode = 0; + } + break; + case 1: { // tiling pattern + BoundingBox bbox(p[2], p[3], p[4], p[5]); + const double &xstep=p[6], &ystep=p[7]; // horizontal and vertical distance of adjacent tiles + int paint_type = static_cast(p[8]); + + Matrix matrix; // transformation matrix given together with pattern definition + create_matrix(p, 9, matrix); + matrix.rmultiply(_actions->getMatrix()); + + PSTilingPattern *pattern=0; + if (paint_type == 1) + pattern = new PSColoredTilingPattern(id, bbox, matrix, xstep, ystep); + else + pattern = new PSUncoloredTilingPattern(id, bbox, matrix, xstep, ystep); + _patterns[id] = pattern; + _savenode = _xmlnode; + _xmlnode = pattern->getContainerNode(); // insert the following SVG elements into this node + break; + } + case 2: { + // define a shading pattern + } + } +} + + +/** Selects a previously defined fill pattern. + * 0: pattern ID + * 1-3: (optional) RGB values for uncolored tiling patterns + * further parameters depend on the pattern type */ +void PsSpecialHandler::setpattern (vector &p) { + int pattern_id = p[0]; + Color color; + if (p.size() == 4) + color.set((float)p[1], (float)p[2], (float)p[3]); + map::iterator it = _patterns.find(pattern_id); + if (it == _patterns.end()) + _pattern = 0; + else { + if (PSUncoloredTilingPattern *pattern = dynamic_cast(it->second)) + pattern->setColor(color); + it->second->apply(_actions); + if (PSTilingPattern *pattern = dynamic_cast(it->second)) + _pattern = pattern; + else + _pattern = 0; + } +} + + +/** Clears the current clipping path. + * @param[in] p not used */ +void PsSpecialHandler::initclip (vector &p) { + _clipStack.push(); // push empty path +} + + +/** Assigns a new clipping path. + * @param[in] p not used + * @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */ +void PsSpecialHandler::clip (vector &p, bool evenodd) { + // when this method is called, _path contains the clipping path + if (!_path.empty() && _actions) { + if (!_actions->getMatrix().isIdentity()) + _path.transform(_actions->getMatrix()); + + const double pt = 72.27/72.0; // factor to convert bp -> pt + ScalingMatrix scale(pt, pt); + _path.transform(scale); + + + int oldID = _clipStack.topID(); + _clipStack.replace(_path); + int newID = _clipStack.topID(); + + ostringstream oss; + _path.writeSVG(oss); + XMLElementNode *path = new XMLElementNode("path"); + path->addAttribute("d", oss.str()); + if (evenodd) + path->addAttribute("clip-rule", "evenodd"); + + XMLElementNode *clip = new XMLElementNode("clipPath"); + clip->addAttribute("id", XMLString("clip")+XMLString(newID)); + if (oldID) + clip->addAttribute("clip-path", XMLString("url(#clip")+XMLString(oldID)+")"); + + clip->append(path); + _actions->appendToDefs(clip); + } +} + + +/** Clears current path */ +void PsSpecialHandler::newpath (vector &p) { + _path.newpath(); +} + + +void PsSpecialHandler::setmatrix (vector &p) { + if (_actions) { + Matrix m; + create_matrix(p, 0, m); + _actions->setMatrix(m); + } +} + + +// In contrast to SVG, PostScript transformations are applied in +// reverse order (M' = T*M). Thus, the transformation matrices must be +// left-multiplied in the following methods scale(), translate() and rotate(). + + +void PsSpecialHandler::scale (vector &p) { + if (_actions) { + Matrix m = _actions->getMatrix(); + ScalingMatrix s(p[0], p[1]); + m.lmultiply(s); + _actions->setMatrix(m); + } +} + + +void PsSpecialHandler::translate (vector &p) { + if (_actions) { + Matrix m = _actions->getMatrix(); + TranslationMatrix t(p[0], p[1]); + m.lmultiply(t); + _actions->setMatrix(m); + } +} + + +void PsSpecialHandler::rotate (vector &p) { + if (_actions) { + Matrix m = _actions->getMatrix(); + RotationMatrix r(p[0]); + m.lmultiply(r); + _actions->setMatrix(m); + } +} + + +void PsSpecialHandler::setgray (vector &p) { + _pattern = 0; + if (_actions) { + Color c; + c.setGray((float)p[0]); + _actions->setColor(c); + } +} + + +void PsSpecialHandler::setrgbcolor (vector &p) { + _pattern= 0; + if (_actions) + _actions->setColor(Color((float)p[0], (float)p[1], (float)p[2])); +} + + +void PsSpecialHandler::setcmykcolor (vector &p) { + _pattern = 0; + if (_actions) { + Color c; + c.setCMYK((float)p[0], (float)p[1], (float)p[2], (float)p[3]); + _actions->setColor(c); + } +} + + +void PsSpecialHandler::sethsbcolor (vector &p) { + _pattern = 0; + if (_actions) { + Color c; + c.setHSB((float)p[0], (float)p[1], (float)p[2]); + _actions->setColor(c); + } +} + + +/** Sets the dash parameters used for stroking. + * @param[in] p dash pattern array m1,...,mn plus trailing dash offset */ +void PsSpecialHandler::setdash (vector &p) { + _dashpattern.clear(); + for (size_t i=0; i < p.size()-1; i++) + _dashpattern.push_back(scale(p[i])); + _dashoffset = scale(p.back()); +} + + +/** This method is called by the PSInterpreter if an PS operator has been executed. */ +void PsSpecialHandler::executed () { + if (_actions) + _actions->progress("ps"); +} + +//////////////////////////////////////////// + +void PsSpecialHandler::ClippingStack::push () { + if (!_stack.empty()) + _stack.push(Entry(0, -1)); +} + + +void PsSpecialHandler::ClippingStack::push (const Path &path, int saveID) { + if (path.empty()) + _stack.push(Entry(0, saveID)); + else { + _paths.push_back(path); + _stack.push(Entry(_paths.size(), saveID)); + } +} + + +/** Pops a single or several elements from the clipping stack. + * The method distingushes between the following cases: + * 1) saveID < 0 and grestoreall == false: + * pop top element if it was pushed by gsave (its saveID is < 0 as well) + * 2) saveID < 0 and grestoreall == true + * repeat popping until stack is empty or the top element was pushed + * by save (its saveID is >= 0) + * 3) saveID >= 0: + * pop all elements until the saveID of the top element equals parameter saveID */ +void PsSpecialHandler::ClippingStack::pop (int saveID, bool grestoreall) { + if (!_stack.empty()) { + if (saveID < 0) { // grestore? + if (_stack.top().saveID < 0) // pushed by 'gsave'? + _stack.pop(); + // pop all further elements pushed by 'gsave' if grestoreall == true + while (grestoreall && !_stack.empty() && _stack.top().saveID < 0) + _stack.pop(); + } + else { + // pop elements pushed by 'gsave' + while (!_stack.empty() && _stack.top().saveID != saveID) + _stack.pop(); + // pop element pushed by 'save' + if (!_stack.empty()) + _stack.pop(); + } + } +} + + +/** Returns a pointer to the path on top of the stack, or 0 if the stack is empty. */ +PsSpecialHandler::Path* PsSpecialHandler::ClippingStack::top () { + return (!_stack.empty() && _stack.top().pathID) + ? &_paths[_stack.top().pathID-1] + : 0; +} + + +/** Pops all elements from the stack. */ +void PsSpecialHandler::ClippingStack::clear() { + _paths.clear(); + while (!_stack.empty()) + _stack.pop(); +} + + +/** Replaces the top element by a new one. + * @param[in] path new path to be on top of the stack */ +void PsSpecialHandler::ClippingStack::replace (const Path &path) { + if (_stack.empty()) + push(path, -1); + else { + _paths.push_back(path); + _stack.top().pathID = _paths.size(); + } +} + + +/** Duplicates the top element, i.e. the top element is pushed again. */ +void PsSpecialHandler::ClippingStack::dup (int saveID) { + _stack.push(_stack.empty() ? Entry(0, -1) : _stack.top()); + _stack.top().saveID = saveID; +} + + +const char** PsSpecialHandler::prefixes () const { + static const char *pfx[] = {"header=", "psfile=", "PSfile=", "ps:", "ps::", "!", "\"", 0}; + return pfx; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.h new file mode 100644 index 00000000000..afb9b3cfc36 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/PsSpecialHandler.h @@ -0,0 +1,140 @@ +/************************************************************************* +** PsSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef PSSPECIALHANDLER_H +#define PSSPECIALHANDLER_H + +#include +#include +#include +#include +#include "GraphicPath.h" +#include "PSInterpreter.h" +#include "SpecialHandler.h" +#include "PSPattern.h" + + +class PSPattern; +class XMLElementNode; + +class PsSpecialHandler : public SpecialHandler, protected PSActions +{ + typedef GraphicPath Path; + + class ClippingStack + { + public: + void push (); + void push (const Path &path, int saveID=-1); + void replace (const Path &path); + void dup (int saveID=-1); + void pop (int saveID=-1, bool grestore=false); + void clear (); + bool empty () {return _stack.empty();} + Path* top (); + int topID () {return _stack.empty() ? 0 : _stack.top().pathID;} + + private: + struct Entry { + int pathID; ///< index referencing a path of the pool + int saveID; ///< if >=0, path was pushed by 'save', and saveID holds the ID of the + Entry (int pid, int sid) : pathID(pid), saveID(sid) {} + }; + std::vector _paths; ///< pool of all clipping paths + std::stack _stack; + }; + + public: + PsSpecialHandler (); + ~PsSpecialHandler (); + const char* name () const {return "ps";} + const char* info () const {return "dvips PostScript specials";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &is, SpecialActions *actions); + + protected: + void initialize (SpecialActions *actions); + void moveToDVIPos (); + void psfile (const std::string &fname, const std::map &attr); + + /// scale given value by current PS scale factors + double scale (double v) const {return v*(_sx*_cos*_cos + _sy*(1-_cos*_cos));} + + void applyscalevals (std::vector &p) {_sx = p[0]; _sy = p[1]; _cos = p[2];} + void clip (std::vector &p) {clip(p, false);} + void clip (std::vector &p, bool evenodd); + void closepath (std::vector &p); + void curveto (std::vector &p); + void eoclip (std::vector &p) {clip(p, true);} + void eofill (std::vector &p) {fill(p, true);} + void fill (std::vector &p, bool evenodd); + void fill (std::vector &p) {fill(p, false);} + void grestore (std::vector &p); + void grestoreall (std::vector &p); + void gsave (std::vector &p); + void initclip (std::vector &p); + void lineto (std::vector &p); + void makepattern (std::vector &p); + void moveto (std::vector &p); + void newpath (std::vector &p); + void querypos (std::vector &p) {_currentpoint = DPair(p[0], p[1]);} + void restore (std::vector &p); + void rotate (std::vector &p); + void save (std::vector &p); + void scale (std::vector &p); + void setcmykcolor (std::vector &cmyk); + void setdash (std::vector &p); + void setgray (std::vector &p); + void sethsbcolor (std::vector &hsb); + void setlinecap (std::vector &p) {_linecap = UInt8(p[0]);} + void setlinejoin (std::vector &p) {_linejoin = UInt8(p[0]);} + void setlinewidth (std::vector &p) {_linewidth = p[0] ? scale(p[0])*1.00375 : 0.5;} + void setmatrix (std::vector &p); + void setmiterlimit (std::vector &p) {_miterlimit = p[0]*1.00375;} + void setopacityalpha (std::vector &p){_opacityalpha = p[0];} + void setpattern (std::vector &p); + void setrgbcolor (std::vector &rgb); + void stroke (std::vector &p); + void translate (std::vector &p); + void executed (); + + private: + PSInterpreter _psi; + SpecialActions *_actions; + bool _initialized; + XMLElementNode *_xmlnode; ///< if != 0, created SVG elements are appended to this node + XMLElementNode *_savenode; ///< pointer to temporaryly store _xmlnode + Path _path; + DPair _currentpoint; ///< current PS position in bp units + double _sx, _sy; ///< horizontal and vertical scale factors retrieved by operator "applyscalevals" + double _cos; ///< cosine of angle between (1,0) and transform(1,0) + double _linewidth; ///< current linewidth + double _miterlimit; ///< current miter limit + double _opacityalpha; ///< opacity level (0=fully transparent, ..., 1=opaque) + UInt8 _linecap : 2; ///< current line cap (0=butt, 1=round, 2=projecting square) + UInt8 _linejoin : 2; ///< current line join (0=miter, 1=round, 2=bevel) + double _dashoffset; ///< current dash offset + std::vector _dashpattern; + ClippingStack _clipStack; + std::map _patterns; + PSTilingPattern *_pattern; ///< current pattern +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGOutputBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGOutputBase.h new file mode 100644 index 00000000000..f53815c0a28 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGOutputBase.h @@ -0,0 +1,33 @@ +/************************************************************************* +** SVGOutputBase.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SVGOUTPUTBASE_H +#define SVGOUTPUTBASE_H + +#include +#include + +struct SVGOutputBase { + virtual ~SVGOutputBase () {} + virtual std::ostream& getPageStream (int page, int numPages) const =0; + virtual std::string filename (int page, int numPages) const =0; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.cpp new file mode 100644 index 00000000000..8d0719234ca --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.cpp @@ -0,0 +1,378 @@ +/************************************************************************* +** SVGTree.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "BoundingBox.h" +#include "DVIToSVG.h" +#include "Font.h" +#include "FontManager.h" +#include "SVGTree.h" +#include "XMLDocument.h" +#include "XMLDocTypeNode.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + + +// static class variables +bool SVGTree::CREATE_STYLE=true; +bool SVGTree::USE_FONTS=true; +bool SVGTree::CREATE_USE_ELEMENTS=false; + + +SVGTree::SVGTree () : _font(0), _color(Color::BLACK), _matrix(1) { + _xchanged = _ychanged = false; + _fontnum = 0; + reset(); +} + + +/** Clears the SVG tree and initializes the root element. */ +void SVGTree::reset () { + _doc.clear(); + _root = new XMLElementNode("svg"); + _root->addAttribute("version", "1.1"); + _root->addAttribute("xmlns", "http://www.w3.org/2000/svg"); + _root->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); + _doc.setRootNode(_root); + _doc.append(new XMLDocTypeNode("svg", "PUBLIC", + "\"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"")); + _page = _text = _span = _defs = 0; +} + + +/** Sets the bounding box of the document. + * @param[in] bbox bounding box in TeX point units */ +void SVGTree::setBBox (const BoundingBox &bbox) { + double bp = 72.0/72.27; // pt -> bp + ScalingMatrix scale(bp, bp); + BoundingBox scaled_box = bbox; + scaled_box.transform(scale); + _root->addAttribute("width", XMLString(scaled_box.width())+"pt"); + _root->addAttribute("height", XMLString(scaled_box.height())+"pt"); + _root->addAttribute("viewBox", scaled_box.toSVGViewBox()); +} + + +/** Starts a new page. + * @param[in] pageno number of new page */ +void SVGTree::newPage (int pageno) { + _page = new XMLElementNode("g"); + if (pageno >= 0) + _page->addAttribute("id", string("page")+XMLString(pageno)); + _root->append(_page); + _text = _span = 0; + while (!_pageContainerStack.empty()) + _pageContainerStack.pop(); +} + + +void SVGTree::appendToDefs (XMLNode *node) { + if (!_defs) { + _defs = new XMLElementNode("defs"); + _root->prepend(_defs); + } + _defs->append(node); +} + + +void SVGTree::appendToPage (XMLNode *node) { + if (_pageContainerStack.empty()) + _page->append(node); + else + _pageContainerStack.top()->append(node); +} + + +void SVGTree::prependToPage (XMLNode *node) { + if (_pageContainerStack.empty()) + _page->prepend(node); + else + _pageContainerStack.top()->prepend(node); +} + + +/** Appends a single charater to the current text node. If necessary, and depending on output mode + * and further output states, new XML elements (text, tspan, g, ...) are created. + * @param[in] c character to be added + * @param[in] x x coordinate + * @param[in] y y coordinate + * @param[in] font font to be used */ +void SVGTree::appendChar (int c, double x, double y, const Font &font) { + XMLElementNode *node=_span; + if (USE_FONTS) { + // changes of fonts and transformations require a new text element + if (!_text || _font.changed() || _matrix.changed()) { + newTextNode(x, y); + node = _text; + _color.changed(true); + } + if (_xchanged || _ychanged || (_color.changed() && _color.get() != Color::BLACK)) { + // if drawing position was explicitly changed, create a new tspan element + _span = new XMLElementNode("tspan"); + if (_xchanged) { + _span->addAttribute("x", x); + _xchanged = false; + } + if (_ychanged) { + _span->addAttribute("y", y); + _ychanged = false; + } + if (_color.get() != Color::BLACK) { + _span->addAttribute("fill", _color.get().rgbString()); + _color.changed(false); + } + _text->append(_span); + node = _span; + } + if (!node) { + if (!_text) + newTextNode(x, y); + node = _text; + } + node->append(XMLString(font.unicode(c), false)); + } + else { + if (_color.changed() || _matrix.changed()) { + bool set_color = (_color.changed() && _color.get() != Color::BLACK); + bool set_matrix = (_matrix.changed() && !_matrix.get().isIdentity()); + if (set_color || set_matrix) { + _span = new XMLElementNode("g"); + if (_color.get() != Color::BLACK) + _span->addAttribute("fill", _color.get().rgbString()); + if (!_matrix.get().isIdentity()) + _span->addAttribute("transform", _matrix.get().getSVG()); + appendToPage(_span); + node = _span; + _color.changed(false); + _matrix.changed(false); + } + else if (_color.get() == Color::BLACK && _matrix.get().isIdentity()) + node = _span = 0; + } + + if (!node) + node = _pageContainerStack.empty() ? _page : _pageContainerStack.top(); + if (CREATE_USE_ELEMENTS) { + ostringstream oss; + oss << "#g" << FontManager::instance().fontID(_font) << '-' << c; + XMLElementNode *use = new XMLElementNode("use"); + use->addAttribute("x", XMLString(x)); + use->addAttribute("y", XMLString(y)); + use->addAttribute("xlink:href", oss.str()); + node->append(use); + } + else { + Glyph glyph; + const PhysicalFont *font = dynamic_cast(_font.get()); + if (font && font->getGlyph(c, glyph)) { + double sx = font->scaledSize()/font->unitsPerEm(); + double sy = -sx; + ostringstream oss; + glyph.writeSVG(oss, sx, sy, x, y); + XMLElementNode *glyph_node = new XMLElementNode("path"); + glyph_node->addAttribute("d", oss.str()); + node->append(glyph_node); + } + } + } +} + + +/** Creates a new text element. This is a helper function used by appendChar(). + * @param[in] x current x coordinate + * @param[in] y current y coordinate */ +void SVGTree::newTextNode (double x, double y) { + _text = new XMLElementNode("text"); + _span = 0; // no tspan in text element yet + if (USE_FONTS) { + const Font *font = _font.get(); + if (CREATE_STYLE || !font) + _text->addAttribute("class", string("f")+XMLString(_fontnum)); + else { + _text->addAttribute("font-family", font->name()); + _text->addAttribute("font-size", font->scaledSize()); + } + } + _text->addAttribute("x", x); + _text->addAttribute("y", y); + if (!_matrix.get().isIdentity()) + _text->addAttribute("transform", _matrix.get().getSVG()); + appendToPage(_text); + _font.changed(false); + _matrix.changed(false); + _xchanged = false; + _ychanged = false; +} + + +void SVGTree::setFont (int num, const Font *font) { + _font.set(font); + _fontnum = num; +} + + +void SVGTree::transformPage (const Matrix *usermatrix) { + double bp = 72.0/72.27; // pt -> bp + ScalingMatrix matrix(bp, bp); + if (usermatrix) + matrix.rmultiply(*usermatrix); + if (!matrix.isIdentity()) + _page->addAttribute("transform", matrix.getSVG()); +} + + +/** Creates an SVG element for a single glyph. + * @param[in] c character number + * @param[in] font font to extract the glyph from + * @return pointer to element node if glyph exists, 0 otherwise */ +static XMLElementNode* createGlyphNode (int c, const PhysicalFont &font, GFGlyphTracer::Callback *cb) { + Glyph glyph; + if (!font.getGlyph(c, glyph, cb) || (!SVGTree::USE_FONTS && !SVGTree::CREATE_USE_ELEMENTS)) + return 0; + + double sx=1.0, sy=1.0; + double upem = font.unitsPerEm(); + XMLElementNode *glyph_node=0; + if (SVGTree::USE_FONTS) { + glyph_node = new XMLElementNode("glyph"); + glyph_node->addAttribute("unicode", XMLString(font.unicode(c), false)); + glyph_node->addAttribute("horiz-adv-x", XMLString(font.hAdvance(c))); + string name = font.glyphName(c); + if (!name.empty()) + glyph_node->addAttribute("glyph-name", name); + } + else { + ostringstream oss; + oss << 'g' << FontManager::instance().fontID(&font) << '-' << c; + glyph_node = new XMLElementNode("path"); + glyph_node->addAttribute("id", oss.str()); + sx = font.scaledSize()/upem; + sy = -sx; + } + ostringstream oss; + glyph.writeSVG(oss, sx, sy); + glyph_node->addAttribute("d", oss.str()); + return glyph_node; +} + + +void SVGTree::appendFontStyles (const set &fonts) { + if (CREATE_STYLE && USE_FONTS && !fonts.empty() && _defs) { + XMLElementNode *styleNode = new XMLElementNode("style"); + styleNode->addAttribute("type", "text/css"); + _root->insertAfter(styleNode, _defs); + typedef map SortMap; + SortMap sortmap; + FORALL(fonts, set::const_iterator, it) + if (!dynamic_cast(*it)) // skip virtual fonts + sortmap[FontManager::instance().fontID(*it)] = *it; + ostringstream style; + // add font style definitions in ascending order + FORALL(sortmap, SortMap::const_iterator, it) { + style << "text.f" << it->first << ' ' + << "{font-family:" << it->second->name() + << ";font-size:" << it->second->scaledSize() << "}\n"; + } + XMLCDataNode *cdata = new XMLCDataNode(style.str()); + styleNode->append(cdata); + } +} + + +/** Appends glyph definitions of a given font to the defs section of the SVG tree. + * @param[in] font font to be appended + * @param[in] chars codes of the characters whose glyph outlines should be appended */ +void SVGTree::append (const PhysicalFont &font, const set &chars, GFGlyphTracer::Callback *cb) { + if (chars.empty()) + return; + + if (USE_FONTS) { + XMLElementNode *fontNode = new XMLElementNode("font"); + string fontname = font.name(); + fontNode->addAttribute("id", fontname); + fontNode->addAttribute("horiz-adv-x", XMLString(font.hAdvance())); + appendToDefs(fontNode); + + XMLElementNode *faceNode = new XMLElementNode("font-face"); + faceNode->addAttribute("font-family", fontname); + faceNode->addAttribute("units-per-em", XMLString(font.unitsPerEm())); + if (font.type() != PhysicalFont::MF) { + faceNode->addAttribute("ascent", XMLString(font.ascent())); + faceNode->addAttribute("descent", XMLString(font.descent())); + } + fontNode->append(faceNode); + + // add required missing-glyph element + XMLElementNode *missing = new XMLElementNode("missing-glyph"); + missing->addAttribute("d", ""); + fontNode->append(missing); + FORALL(chars, set::const_iterator, i) + fontNode->append(createGlyphNode(*i, font, cb)); + } + else if (CREATE_USE_ELEMENTS && &font != font.uniqueFont()) { + // If the same character is used in various sizes, we don't want to embed the complete (lengthy) path + // descriptions multiple times. Because they would only differ by a scale factor, it's better to + // reference the already embedded path together with a transformation attribute and let the SVG renderer + // scale the glyphs properly. This is only necessary if we don't want to use font but path elements. + FORALL(chars, set::const_iterator, it) { + ostringstream oss; + XMLElementNode *use = new XMLElementNode("use"); + oss << 'g' << FontManager::instance().fontID(&font) << '-' << *it; + use->addAttribute("id", oss.str()); + oss.str(""); + oss << "#g" << FontManager::instance().fontID(font.uniqueFont()) << '-' << *it; + use->addAttribute("xlink:href", oss.str()); + double scale = font.scaledSize()/font.uniqueFont()->scaledSize(); + if (scale != 1.0) { + oss.str(""); + oss << "scale(" << scale << ')'; + use->addAttribute("transform", oss.str()); + } + appendToDefs(use); + } + } + else { + FORALL(chars, set::const_iterator, i) + appendToDefs(createGlyphNode(*i, font, cb)); + } +} + + +/** Pushes a new context element that will take all following nodes added to the page. */ +void SVGTree::pushContextElement (XMLElementNode *node) { + if (_pageContainerStack.empty()) + _page->append(node); + else + _pageContainerStack.top()->append(node); + _pageContainerStack.push(node); + _text = _span = 0; // ensure the creation of a new text element for the following characters added +} + + +/** Pops the current context element and restored the previous one. */ +void SVGTree::popContextElement () { + if (!_pageContainerStack.empty()) { + _pageContainerStack.pop(); + _text = _span = 0; // ensure the creation of a new text element for the following characters added + } +} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.h new file mode 100644 index 00000000000..0aa5f46499b --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SVGTree.h @@ -0,0 +1,108 @@ +/************************************************************************* +** SVGTree.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SVGTREE_H +#define SVGTREE_H + +#include +#include +#include +#include "Color.h" +#include "GFGlyphTracer.h" +#include "Matrix.h" +#include "XMLDocument.h" +#include "XMLNode.h" + +class BoundingBox; +class Color; +struct Font; +class Matrix; +class PhysicalFont; + +class SVGTree +{ + template + class Property { + public: + Property (const T &v) : _value(v), _changed(false) {} + + void set (const T &v) { + if (v != _value) { + _value = v; + _changed = true; + } + } + + const T& get () const {return _value;} + operator const T& () {return _value;} + bool changed () const {return _changed;} + void changed (bool c) {_changed = c;} + + private: + T _value; + bool _changed; + }; + + public: + SVGTree (); + void reset (); + void write (std::ostream &os) const {_doc.write(os);} + void newPage (int pageno); + void appendToDefs (XMLNode *node); + void appendToPage (XMLNode *node); + void prependToPage (XMLNode *node); + void appendToDoc (XMLNode *node) {_doc.append(node);} + void appendToRoot (XMLNode *node) {_root->append(node);} + void appendChar (int c, double x, double y, const Font &font); + void appendFontStyles (const std::set &fonts); + void append (const PhysicalFont &font, const std::set &chars, GFGlyphTracer::Callback *cb=0); + void pushContextElement (XMLElementNode *node); + void popContextElement (); + void setBBox (const BoundingBox &bbox); + void setFont (int id, const Font *font); + void setX (double x) {_xchanged = true;} + void setY (double y) {_ychanged = true;} + void setMatrix (const Matrix &m) {_matrix.set(m);} + void setColor (const Color &c) {_color.set(c);} + void transformPage (const Matrix *m); + const Color& getColor () const {return _color.get();} + const Matrix& getMatrix () const {return _matrix.get();} + XMLElementNode* rootNode () const {return _root;} + + public: + static bool USE_FONTS; ///< if true, create font references and don't draw paths directly + static bool CREATE_STYLE; ///< should and class attributes be used to reference fonts? + static bool CREATE_USE_ELEMENTS; ///< allow generation of elements? + + protected: + void newTextNode (double x, double y); + + private: + XMLDocument _doc; + XMLElementNode *_root, *_page, *_text, *_span, *_defs; + bool _xchanged, _ychanged; + Property _font; + Property _color; + Property _matrix; + int _fontnum; + std::stack _pageContainerStack; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.cpp new file mode 100644 index 00000000000..ffcd66165e0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.cpp @@ -0,0 +1,85 @@ +/************************************************************************* +** SignalHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "SignalHandler.h" + +using namespace std; + +bool SignalHandler::_break = false; + + +SignalHandler::~SignalHandler() { + stop(); +} + + +/** Returns the singleton handler object. */ +SignalHandler& SignalHandler::instance() { + static SignalHandler handler; + return handler; +} + + +/** Starts listening to CTRL-C signals. + * @return true if handler was activated. */ +bool SignalHandler::start () { + if (!_active) { + _break = false; + if (signal(SIGINT, SignalHandler::callback) != SIG_ERR) { + _active = true; + return true; + } + } + return false; +} + + +/** Stops listening for CTRL-C signals. */ +void SignalHandler::stop () { + if (_active) { + signal(SIGINT, SIG_DFL); + _active = false; + } +} + + +/** Checks for incoming signals and throws an exception if CTRL-C was caught. + * @throw SignalException */ +void SignalHandler::check() { + if (_break) + throw SignalException(); +} + + +void SignalHandler::trigger (bool notify) { + _break = true; + if (notify) + check(); +} + + +/** This function is called on CTRL-C signals. */ +void SignalHandler::callback (int) { + _break = true; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.h new file mode 100644 index 00000000000..e7473f567d8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SignalHandler.h @@ -0,0 +1,50 @@ +/************************************************************************* +** SignalHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SIGNALHANDLER_H +#define SIGNALHANDLER_H + +#include + +struct SignalException : public std::exception { +}; + + +class SignalHandler +{ + public: + ~SignalHandler (); + static SignalHandler& instance (); + bool start (); + void stop (); + void check (); + void trigger (bool notify); + bool active () const {return _active;} + + protected: + SignalHandler () : _active(false) {} + static void callback (int signal); + + private: + bool _active; ///< true if listening for signals + static bool _break; ///< true if signal has been caught +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialActions.h new file mode 100644 index 00000000000..81d57662df8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialActions.h @@ -0,0 +1,88 @@ +/************************************************************************* +** SpecialActions.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SPECIALACTIONS_H +#define SPECIALACTIONS_H + +#include +#include "BoundingBox.h" +#include "Color.h" +#include "Matrix.h" + + +struct XMLNode; +class XMLElementNode; + +struct SpecialActions +{ + virtual ~SpecialActions () {} + virtual double getX() const =0; + virtual double getY() const =0; + virtual void setX(double x) =0; + virtual void setY(double y) =0; + virtual void finishLine () =0; + virtual void setColor (const Color &color) =0; + virtual Color getColor () const =0; + virtual void setMatrix (const Matrix &m) =0; + virtual const Matrix& getMatrix () const =0; + virtual void setBgColor (const Color &color) =0; + virtual void appendToPage (XMLNode *node) =0; + virtual void appendToDefs (XMLNode *node) =0; + virtual void prependToPage (XMLNode *node) =0; + virtual void pushContextElement (XMLElementNode *node) =0; + virtual void popContextElement () =0; + virtual BoundingBox& bbox () =0; + virtual BoundingBox& bbox (const std::string &name, bool reset=false) =0; + virtual void embed (const BoundingBox &bbox) =0; + virtual void embed (const DPair &p, double r=0) =0; + virtual void progress (const char *id) {} +}; + + +class SpecialEmptyActions : public SpecialActions +{ + public: + double getX() const {return 0;} + double getY() const {return 0;} + void setX(double x) {} + void setY(double y) {} + void finishLine () {} + void setColor (const Color &color) {} + void setBgColor (const Color &color) {} + Color getColor () const {return 0;} + void setMatrix (const Matrix &m) {} + const Matrix& getMatrix () const {return _matrix;} + void appendToPage (XMLNode *node) {} + void appendToDefs (XMLNode *node) {} + void prependToPage (XMLNode *node) {} + void pushContextElement (XMLElementNode *node) {} + void popContextElement () {} + BoundingBox& bbox () {return _bbox;} + BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;} + void embed (const BoundingBox &bbox) {} + void embed (const DPair &p, double r=0) {} + + private: + BoundingBox _bbox; + Matrix _matrix; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialHandler.h new file mode 100644 index 00000000000..81aaf67eb7a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialHandler.h @@ -0,0 +1,65 @@ +/************************************************************************* +** SpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SPECIALHANDLER_H +#define SPECIALHANDLER_H + +#include +#include +#include "MessageException.h" + + +struct SpecialActions; +class SpecialManager; + + +struct SpecialException : public MessageException +{ + SpecialException (const std::string &msg) : MessageException(msg) {} +}; + + +struct DVIEndPageListener +{ + virtual ~DVIEndPageListener () {} + virtual void dviEndPage (unsigned pageno) =0; +}; + + +struct DVIPositionListener +{ + virtual ~DVIPositionListener () {} + virtual void dviMovedTo (double x, double y) =0; +}; + + +struct SpecialHandler +{ + friend class SpecialManager; + + virtual ~SpecialHandler () {} + virtual const char** prefixes () const=0; + virtual const char* info () const=0; + virtual const char* name () const=0; + virtual bool process (const char *prefix, std::istream &is, SpecialActions *actions)=0; +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.cpp new file mode 100644 index 00000000000..72c2a353b61 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.cpp @@ -0,0 +1,151 @@ +/************************************************************************* +** SpecialManager.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include "SpecialActions.h" +#include "SpecialManager.h" +#include "macros.h" + +using namespace std; + + +SpecialManager::~SpecialManager () { + unregisterHandlers(); +} + + +/** Remove all registered handlers. */ +void SpecialManager::unregisterHandlers () { + FORALL(_pool, vector::iterator, it) + delete *it; + _pool.clear(); + _handlers.clear(); + _endPageListeners.clear(); + _positionListeners.clear(); +} + + +/** Registers a single special handler. This method doesn't check if a + * handler of the same class is already registered. + * @param[in] pointer to handler to be registered */ +void SpecialManager::registerHandler (SpecialHandler *handler) { + if (handler) { + // get array of prefixes this handler is responsible for + _pool.push_back(handler); + for (const char **p=handler->prefixes(); *p; ++p) + _handlers[*p] = handler; + if (DVIEndPageListener *listener = dynamic_cast(handler)) + _endPageListeners.push_back(listener); + if (DVIPositionListener *listener = dynamic_cast(handler)) + _positionListeners.push_back(listener); + } +} + + +/** Registers several special handlers at once. + * If ignorelist == 0, all given handlers are registered. To exclude selected sets of + * specials, the corresponding names can be given separated by non alpha-numeric characters, + * e.g. "color, ps, em" or "color: ps em" etc. + * @param[in] handlers pointer to zero-terminated array of handlers to be registered + * @param[in] ignorelist list of special names to be ignored */ +void SpecialManager::registerHandlers (SpecialHandler **handlers, const char *ignorelist) { + if (handlers) { + string ign = ignorelist ? ignorelist : ""; + FORALL(ign, string::iterator, it) + if (!isalnum(*it)) + *it = '%'; + ign = "%"+ign+"%"; + + for (; *handlers; handlers++) { + if (!(*handlers)->name() || ign.find("%"+string((*handlers)->name())+"%") == string::npos) + registerHandler(*handlers); + else + delete *handlers; + } + } +} + + +/** Looks for an appropriate handler for a given special prefix. + * @param[in] prefix the special prefix, e.g. "color" or "em" + * @return in case of success: pointer to handler, 0 otherwise */ +SpecialHandler* SpecialManager::findHandler (const string &prefix) const { + ConstIterator it = _handlers.find(prefix); + if (it != _handlers.end()) + return it->second; + return 0; +} + + +/** Executes a special command. + * @param[in] special the special expression + * @param[in] actions actions the special handlers can perform + * @param[in] listener object that wants to be notified about the processing state + * @return true if the special could be processed successfully + * @throw SpecialException in case of errors during special processing */ +bool SpecialManager::process (const string &special, SpecialActions *actions, Listener *listener) const { + istringstream iss(special); + string prefix; + int c; + while (isalnum(c=iss.get())) + prefix += c; + if (ispunct(c)) // also add seperation character to identifying prefix + prefix += c; + if (prefix == "ps:" && iss.peek() == ':') + prefix += iss.get(); + if (SpecialHandler *handler = findHandler(prefix)) { + if (listener) + listener->beginSpecial(prefix.c_str()); + bool ret = handler->process(prefix.c_str(), iss, actions); + if (listener) + listener->endSpecial(prefix.c_str()); + return ret; + } + return false; +} + + +void SpecialManager::notifyEndPage (unsigned pageno) const { + FORALL(_endPageListeners, vector::const_iterator, it) + (*it)->dviEndPage(pageno); +} + + +void SpecialManager::notifyPositionChange (double x, double y) const { + FORALL(_positionListeners, vector::const_iterator, it) + (*it)->dviMovedTo(x, y); +} + + +void SpecialManager::writeHandlerInfo (ostream &os) const { + typedef map SortMap; + SortMap m; + FORALL(_handlers, ConstIterator, it) + if (it->second->name()) + m[it->second->name()] = it->second; + FORALL(m, SortMap::iterator, it) { + os << setw(10) << left << it->second->name() << ' '; + if (it->second->info()) + os << it->second->info(); + os << endl; + } +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.h new file mode 100644 index 00000000000..54b6df5dcd0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/SpecialManager.h @@ -0,0 +1,71 @@ +/************************************************************************* +** SpecialManager.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SPECIALMANAGER_H +#define SPECIALMANAGER_H + +#include +#include +#include +#include +#include "SpecialHandler.h" + +struct SpecialActions; + +class SpecialManager +{ + public: + struct Listener + { + virtual ~Listener () {} + virtual void beginSpecial (const char *prefix)=0; + virtual void endSpecial (const char *prefix)=0; + }; + + private: + typedef std::vector HandlerPool; + typedef std::map HandlerMap; + typedef HandlerMap::iterator Iterator; + typedef HandlerMap::const_iterator ConstIterator; + + public: + SpecialManager () {} + virtual ~SpecialManager (); + void registerHandler (SpecialHandler *handler); + void registerHandlers (SpecialHandler **handlers, const char *ignorelist); + void unregisterHandlers (); + bool process (const std::string &special, SpecialActions *actions, Listener *listener=0) const; + void notifyEndPage (unsigned pageno) const; + void notifyPositionChange (double x, double y) const; + void writeHandlerInfo (std::ostream &os) const; + + protected: + SpecialManager (const SpecialManager &) {} + void operator = (const SpecialManager &) {} + SpecialHandler* findHandler (const std::string &prefix) const; + + private: + HandlerPool _pool; ///< stores pointers to all handlers + HandlerMap _handlers; ///< pointers to handlers for corresponding prefixes + std::vector _endPageListeners; + std::vector _positionListeners; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.cpp new file mode 100644 index 00000000000..6e726e4016e --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.cpp @@ -0,0 +1,164 @@ +/************************************************************************* +** StreamReader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "CRC32.h" +#include "StreamReader.h" +#include "macros.h" + +using namespace std; + +StreamReader::StreamReader (istream &s) + : _is(&s) +{ +} + + +istream& StreamReader::replaceStream (istream &in) { + istream &ret = *_is; + _is = ∈ + return ret; +} + + +/** Reads an unsigned integer from assigned input stream. + * @param[in] bytes number of bytes to read (max. 4) + * @return read integer */ +UInt32 StreamReader::readUnsigned (int bytes) { + UInt32 ret = 0; + for (bytes--; bytes >= 0 && !_is->eof(); bytes--) { + UInt32 b = _is->get(); + ret |= b << (8*bytes); + } + return ret; +} + + +/** Reads an unsigned integer from assigned input stream and updates the CRC32 checksum. + * @param[in] bytes number of bytes to read (max. 4) + * @param[in,out] crc32 checksum to be updated + * @return read integer */ +UInt32 StreamReader::readUnsigned (int bytes, CRC32 &crc32) { + UInt32 ret = readUnsigned(bytes); + crc32.update(ret, bytes); + return ret; +} + + +/** Reads an signed integer from assigned input stream. + * @param[in] bytes number of bytes to read (max. 4) + * @return read integer */ +Int32 StreamReader::readSigned (int bytes) { + Int32 ret = _is->get(); + if (ret & 128) // negative value? + ret |= 0xffffff00; + for (bytes-=2; bytes >= 0 && !_is->eof(); bytes--) + ret = (ret << 8) | _is->get(); + return ret; +} + + +/** Reads an signed integer from assigned input stream and updates the CRC32 checksum. + * @param[in] bytes number of bytes to read (max. 4) + * @param[in,out] crc32 checksum to be updated + * @return read integer */ +Int32 StreamReader::readSigned (int bytes, CRC32 &crc32) { + Int32 ret = readSigned(bytes); + crc32.update(ret, bytes); + return ret; +} + + +/** Reads a string terminated by a 0-byte. */ +string StreamReader::readString () { + if (!_is) + throw StreamReaderException("no stream assigned"); + string ret; + while (!_is->eof() && _is->peek() > 0) + ret += _is->get(); + _is->get(); // skip 0-byte + return ret; +} + + +/** Reads a string terminated by a 0-byte and updates the CRC32 checksum. + * @param[in,out] crc32 checksum to be updated + * @param[in] finalZero consider final 0-byte in checksum + * @return the string read */ +string StreamReader::readString (CRC32 &crc32, bool finalZero) { + string ret = readString(); + crc32.update((const UInt8*)ret.c_str(), ret.length()); + if (finalZero) + crc32.update(0, 1); + return ret; +} + + +/** Reads a string of a given length. + * @param[in] length number of characters to read + * @return the string read */ +string StreamReader::readString (int length) { + if (!_is) + throw StreamReaderException("no stream assigned"); + char *buf = new char[length+1]; + if (length <= 0) + *buf = 0; + else { + _is->read(buf, length); // reads 'length' bytes + buf[length] = 0; + } + string ret = buf; + delete [] buf; + return ret; +} + + +/** Reads a string of a given length and updates the CRC32 checksum. + * @param[in] length number of characters to read + * @param[in,out] crc32 checksum to be updated + * @return the string read */ +string StreamReader::readString (int length, CRC32 &crc32) { + string ret = readString(length); + crc32.update(ret.c_str()); + return ret; +} + + +vector& StreamReader::readBytes (int n, vector &bytes) { + if (n > 0) + in().read((char*)&bytes[0], n); + return bytes; +} + + +vector& StreamReader::readBytes (int n, vector &bytes, CRC32 &crc32) { + readBytes(n, bytes); + crc32.update(&bytes[0], bytes.size()); + return bytes; +} + + +int StreamReader::readByte (CRC32 &crc32) { + int ret = readByte(); + if (ret >= 0) { + const UInt8 c = UInt8(ret & 0xff); + crc32.update(&c, 1); + } + return ret; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.h new file mode 100644 index 00000000000..3bb25dacca9 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamReader.h @@ -0,0 +1,65 @@ +/************************************************************************* +** StreamReader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef STREAMREADER_H +#define STREAMREADER_H + +#include +#include +#include +#include "MessageException.h" +#include "types.h" + +class CRC32; + +class StreamReader +{ + public: + StreamReader (std::istream &s); + virtual ~StreamReader () {} + std::istream& replaceStream (std::istream &s); + UInt32 readUnsigned (int n); + UInt32 readUnsigned (int n, CRC32 &crc32); + Int32 readSigned (int n); + Int32 readSigned (int n, CRC32 &crc32); + std::string readString (); + std::string readString (CRC32 &crc32, bool finalZero=false); + std::string readString (int length); + std::string readString (int length, CRC32 &crc32); + std::vector& readBytes (int n, std::vector &bytes); + std::vector& readBytes (int n, std::vector &bytes, CRC32 &crc32); + int readByte () {return _is->get();} + int readByte (CRC32 &crc32); + void seek (std::istream::streampos pos, std::ios::seekdir dir) {_is->seekg(pos, dir);} + + protected: + std::istream& in () {return *_is;} + + private: + std::istream *_is; +}; + + +struct StreamReaderException : public MessageException +{ + StreamReaderException (const std::string &msg) : MessageException(msg) {} +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.cpp new file mode 100644 index 00000000000..bdd378f9993 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.cpp @@ -0,0 +1,81 @@ +/************************************************************************* +** StreamWriter.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "CRC32.h" +#include "StreamWriter.h" + +using namespace std; + + +/** Writes an unsigned integer to the output stream. + * @param[in] val the value to write + * @param[in] n number of bytes to be considered */ +void StreamWriter::writeUnsigned (UInt32 val, int n) { + for (n--; n >= 0; n--) + _os.put((val >> (8*n)) & 0xff); +} + + +/** Writes a signed integer to the output stream. + * @param[in] val the value to write + * @param[in] n number of bytes to be considered */ +void StreamWriter::writeSigned (Int32 val, int n) { + writeUnsigned((UInt32)val, n); +} + + +/** Writes a signed integer to the output stream. + * @param[in] val the value to write + * @param[in] finalZero if true, a final 0-byte is appended */ +void StreamWriter::writeString (const string &str, bool finalZero) { + for (size_t i=0; i < str.length(); i++) + _os.put(str[i]); + if (finalZero) + _os.put(0); +} + + +/** Writes an unsigned integer to the output stream. + * @param[in] val the value to write + * @param[in] n number of bytes to be considered + * @param[in,out] crc32 checksum to be updated */ +void StreamWriter::writeUnsigned (UInt32 val, int n, CRC32 &crc32) { + writeUnsigned(val, n); + crc32.update(val, n); +} + + +/** Writes a signed integer to the output stream and updates the CRC32 checksum. + * @param[in] val the value to write + * @param[in] n number of bytes to be considered + * @param[in,out] crc32 checksum to be updated */ +void StreamWriter::writeSigned (Int32 val, int n, CRC32 &crc32) { + writeUnsigned((UInt32)val, n, crc32); +} + + +/** Writes a string to the output stream and updates the CRC32 checksum. + * @param[in] str the string to write + * @param[in,out] crc32 checksum to be updated + * @param[in] finalZero if true, a final 0-byte is appended */ +void StreamWriter::writeString (const std::string &str, CRC32 &crc32, bool finalZero) { + writeString(str, finalZero); + crc32.update((const UInt8*)str.c_str(), str.length() + (finalZero ? 1 : 0)); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.h new file mode 100644 index 00000000000..6217800dae6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/StreamWriter.h @@ -0,0 +1,46 @@ +/************************************************************************* +** StreamWriter.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef STREAMWRITER_H +#define STREAMWRITER_H + +#include +#include "types.h" + + +class CRC32; + +class StreamWriter +{ + public: + StreamWriter (std::ostream &os) : _os(os) {} + virtual ~StreamWriter () {} + void writeUnsigned (UInt32 val, int n); + void writeSigned (Int32 val, int n); + void writeString (const std::string &str, bool finalZero=false); + void writeUnsigned (UInt32 val, int n, CRC32 &crc32); + void writeSigned (Int32 val, int n, CRC32 &crc32); + void writeString (const std::string &str, CRC32 &crc32, bool finalZero=false); + + private: + std::ostream &_os; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.cpp new file mode 100644 index 00000000000..aa552d029f6 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.cpp @@ -0,0 +1,265 @@ +/************************************************************************* +** Subfont.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "FileFinder.h" +#include "Subfont.h" +#include "Message.h" + +using namespace std; + +// helper functions + +static int skip_mapping_data (istream &is); +static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &pos); + + +/** Constructs a new SubfontDefinition object. + * @param[in] name name of subfont definition + * @param[in] fpath path to corresponding .sfd file*/ +SubfontDefinition::SubfontDefinition (const string &name, const char *fpath) : _sfname(name) { + // read all subfont IDs from the .sfd file but skip the mapping data + ifstream is(fpath); + while (is) { + if (is.peek() == '#') // comment line? + is.ignore(numeric_limits::max(), '\n'); // => skip it + else if (isspace(is.peek())) + is.get(); + else { + string id; + while (is && !isspace(is.peek())) + id += is.get(); + if (!id.empty()) { + pair state = _subfonts.insert(pair(id, (Subfont*)0)); + if (state.second) // id was not present in map already + state.first->second = new Subfont(*this, state.first->first); + skip_mapping_data(is); + } + } + } +} + + +SubfontDefinition::~SubfontDefinition () { + for (Iterator it=_subfonts.begin(); it != _subfonts.end(); ++it) + delete it->second; +} + + +/** Looks for a subfont definition of the given name and returns the corresponding object. + * All objects are only created once for a given name and stored in an internal cache. + * @param[in] name name of subfont definition to lookup + * @return pointer to subfont definition object or 0 if it doesn't exist */ +SubfontDefinition* SubfontDefinition::lookup (const std::string &name) { + typedef map SFDMap; + static SFDMap sfdMap; + SFDMap::iterator it = sfdMap.find(name); + if (it != sfdMap.end()) + return it->second; + SubfontDefinition *sfd=0; + if (const char *path = FileFinder::lookup(name+".sfd", false)) { + sfd = new SubfontDefinition(name, path); + sfdMap[name] = sfd; + } + return sfd; +} + + +/** Returns the full path to the corresponding .sfd file or 0 if it can't be found. */ +const char* SubfontDefinition::path () const { + return FileFinder::lookup(filename(), false); +} + + +/** Returns the subfont with the given ID, or 0 if it doesn't exist. */ +Subfont* SubfontDefinition::subfont (const string &id) const { + ConstIterator it = _subfonts.find(id); + if (it != _subfonts.end()) + return it->second; + return 0; +} + + +/** Returns all subfonts defined in this SFD. */ +int SubfontDefinition::subfonts (vector &sfs) const { + for (ConstIterator it=_subfonts.begin(); it != _subfonts.end(); ++it) + sfs.push_back(it->second); + return sfs.size(); +} + +////////////////////////////////////////////////////////////////////// + +Subfont::~Subfont () { + delete [] _mapping; +} + + +/** Reads the character mappings for a given subfont ID. + * Format of subfont definition (sfd) files: + * sfd ::= (ID entries | '#' '\n')* + * ID ::= + * entries ::= (integer | integer ':' | integer '_' integer)* + * The mapping data for a subfont is given as a sequence of 256 16-bit values where + * value v at position c defines the (global) character code that is assigned to the + * local subfont character c. The sequence v,v+1,v+2,...,v+n can be abbreviated with + * v '_' v+n, e.g. 10_55. In order to continue the sequence at a different position, + * the syntax number ':' can be used. Example: 10: 5 6 7 assigns the values v=5, 6, 7 + * to c=10, 11 and 12, respectively. + * @return true if the data has been read successfully */ +bool Subfont::read () { + if (_mapping) // if there's already a mapping assigned, we're finished here + return true; + if (const char *p = _sfd.path()) { + ifstream is(p); + if (!is) + return false; + + int lineno=1; + while (is) { + if (is.peek() == '#' || is.peek() == '\n') { + is.ignore(numeric_limits::max(), '\n'); // skip comment and empty line + lineno++; + } + else if (isspace(is.peek())) + is.get(); + else { + string id; + while (is && !isspace(is.peek())) + id += is.get(); + if (id != _id) + lineno += skip_mapping_data(is); + else { + // build mapping array + _mapping = new UInt16[256]; + memset(_mapping, 0, 256*sizeof(UInt16)); + int pos=0; + char buf[1024]; + bool complete=false; + while (!complete) { + is.getline(buf, 1024); + complete = scan_line(buf, lineno, _mapping, _sfd.filename() ,pos); + } + return true; + } + } + } + } + return false; +} + + +/** Returns the global character code of the target font for a + * (local) character code of the subfont. + * @param[in] c local character code relative to the subfont + * @return character code of the target font */ +UInt16 Subfont::decode (unsigned char c) { + if (!_mapping && !read()) + return 0; + return _mapping[c]; +} + + +////////////////////////////////////////////////////////////////////// + + +/** Skips the mapping data of a subfont entry. + * @param[in] stream to read from + * @return number of lines skipped */ +static int skip_mapping_data (istream &is) { + char buf[1024]; + bool complete=false; + int lines=0; + while (is && !complete) { + is.getline(buf, 1024); + if (is.gcount() > 1) + lines++; + const char *p = buf+is.gcount()-2; + while (p >= buf && isspace(*p)) + p--; + complete = (p < buf || *p != '\\'); // line doesn't end with backslash + } + return lines; +} + + +/** Scans a single line of mapping data and stores the values in the given array. + * @param[in] line the line of text to be scanned + * @param[in] lineno line number used in exception messages + * @param[in,out] mapping the mapping data + * @param[in,out] offest position/index of next mapping value + * @return true if the line is the last one the current mapping sequence, i.e. the line doesn't end with a backslash */ +static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &offset) { + const char *p=line; + char *q; + for (; *p && isspace(*p); p++); + while (*p) { + if (*p == '\\') { + while (*++p) + if (!isspace(*p)) + throw SubfontException("unexpected backslash in mapping table", fname, lineno); + } + else { + long val1 = strtol(p, &q, 0); // first value of range + long val2; // last value of range + ostringstream oss; // output stream for exception messages + switch (*q) { + case ':': + if (val1 < 0 || val1 > 255) + throw SubfontException(oss << "offset value " << val1 << " out of range (0-255)", fname, lineno); + offset = val1; + val1 = -1; + q++; + break; + case '_': + p = q+1; + val2 = strtol(p, &q, 0); + if (val1 < 0 || val1 > 0xffffL) + throw SubfontException(oss << "table value " << val1 << " out of range", fname, lineno); + if (val2 < 0 || val2 > 0xffffL) + throw SubfontException(oss << "table value " << val2 << " out of range", fname, lineno); + if (p == q || (!isspace(*q) && *q != '\\' && *q)) + throw SubfontException(oss << "unexpected character '" << *q << "'", fname, lineno); + break; + default: + if (p == q || (!isspace(*q) && *q != '\\' && *q)) + throw SubfontException(oss << "unexpected character '" << *q << "'", fname, lineno); + if (val1 < 0 || val1 > 0xffffL) + throw SubfontException("invalid character code", fname, lineno); + val2 = val1; + } + if (val1 >= 0) { + if (val1 > val2 || offset+val2-val1 > 255) + throw SubfontException(oss << "invalid range in mapping table: " << hex << val1 << '_' << val2, fname, lineno); + for (long v=val1; v <= val2; v++) { + if (mapping[offset]) + throw SubfontException(oss << "mapping of character " << offset << " already defined", fname, lineno); + mapping[offset++] = static_cast(v); + } + } + for (p=q; *p && isspace(*p); p++); + } + } + for (p--; p >= line && isspace(*p); p--); + return p < line || *p != '\\'; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.h new file mode 100644 index 00000000000..b099bc76897 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Subfont.h @@ -0,0 +1,102 @@ +/************************************************************************* +** Subfont.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SUBFONT_H +#define SUBFONT_H + +#include +#include +#include +#include +#include +#include "MessageException.h" +#include "types.h" + + +class Subfont; + + +/** Represents a collection of subfont mappings as defined in a .sfd file, and + * encapsulates the evaluation of these files. */ +class SubfontDefinition +{ + typedef std::map Subfonts; + typedef Subfonts::iterator Iterator; + typedef Subfonts::const_iterator ConstIterator; + public: + ~SubfontDefinition (); + static SubfontDefinition* lookup (const std::string &name); +// int getIDs (std::vector &ids) const; + const std::string& name() const {return _sfname;} + std::string filename() const {return _sfname+".sfd";} + Subfont* subfont (const std::string &id) const; + int subfonts (std::vector &sfs) const; + const char* path () const; + + protected: + SubfontDefinition (const std::string &name, const char *fpath); + SubfontDefinition (const SubfontDefinition &sfd) {} + + private: + std::string _sfname; ///< name of subfont + Subfonts _subfonts; ///< all subfonts defined in the corresponding .sfd file +}; + + +/** Represents a single subfont mapping defined in a SubfontDefinition (.sfd file). */ +class Subfont +{ + friend class SubfontDefinition; + public: + ~Subfont(); + const std::string& id () const {return _id;} + UInt16 decode (unsigned char c); + + protected: + Subfont (SubfontDefinition &sfd, const std::string &id) : _sfd(sfd), _id(id), _mapping(0) {} + bool read (); + + private: + SubfontDefinition &_sfd; ///< SubfontDefinition where this Subfont belongs to + const std::string &_id; ///< id of this subfont as specified in the .sfd file + UInt16 *_mapping; ///< the character mapping table with 256 entries +}; + + +class SubfontException : public MessageException +{ + public: + SubfontException (const std::string &msg, const std::string &fname, int lineno=0) + : MessageException(msg), _fname(fname), _lineno(lineno) {} + + SubfontException (const std::ostream &oss, const std::string &fname, int lineno=0) + : MessageException(dynamic_cast(oss).str()), _fname(fname), _lineno(lineno) {} + + virtual ~SubfontException () throw() {} + + const char* filename () const {return _fname.c_str();} + int lineno () const {return _lineno;} + + private: + std::string _fname; + int _lineno; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.cpp new file mode 100644 index 00000000000..80c71ec7b4c --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.cpp @@ -0,0 +1,53 @@ +/************************************************************************* +** System.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "System.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined (HAVE_SYS_TIME_H) +#include +#elif defined (HAVE_SYS_TIMEB_H) +#include +#endif + + +using namespace std; + + +/** Returns timestamp (wall time) in seconds. */ +double System::time () { +#if defined (HAVE_SYS_TIME_H) + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec/1000000.0; +#elif defined (HAVE_SYS_TIMEB_H) + struct timeb tb; + ftime(&tb); + return tb.time + tb.millitm/1000.0; +#else + clock_t myclock = clock(); + return double(myclock)/CLOCKS_PER_SEC; +#endif +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.h new file mode 100644 index 00000000000..775d6358dd7 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/System.h @@ -0,0 +1,29 @@ +/************************************************************************* +** System.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +namespace System +{ + double time (); +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.cpp new file mode 100644 index 00000000000..596ed52e7ca --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.cpp @@ -0,0 +1,154 @@ +/************************************************************************* +** TFM.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "FileFinder.h" +#include "Message.h" +#include "StreamReader.h" +#include "TFM.h" + +using namespace std; + + +/** Reads a sequence of n TFM words (4 Bytes each). + * @param[in] is reads from this stream + * @param[out] v the read words + * @param[in] n number of words to be read */ +template +static void read_words (StreamReader &sr, vector &v, unsigned n) { + v.clear(); + v.resize(n); + for (unsigned i=0; i < n; i++) + v[i] = sr.readUnsigned(4); +} + + +/** Converts a TFM fix point value to double. */ +static double fix2double (FixWord fix) { + return double(fix)/(1 << 20); +} + + +TFM::TFM (istream &is) { + is.seekg(0); + StreamReader sr(is); + UInt16 lf = UInt16(sr.readUnsigned(2)); // length of entire file in 4 byte words + UInt16 lh = UInt16(sr.readUnsigned(2)); // length of header in 4 byte words + _firstChar= UInt16(sr.readUnsigned(2)); // smallest character code in font + _lastChar = UInt16(sr.readUnsigned(2)); // largest character code in font + UInt16 nw = UInt16(sr.readUnsigned(2)); // number of words in width table + UInt16 nh = UInt16(sr.readUnsigned(2)); // number of words in height table + UInt16 nd = UInt16(sr.readUnsigned(2)); // number of words in depth table + UInt16 ni = UInt16(sr.readUnsigned(2)); // number of words in italic corr. table + UInt16 nl = UInt16(sr.readUnsigned(2)); // number of words in lig/kern table + UInt16 nk = UInt16(sr.readUnsigned(2)); // number of words in kern table + UInt16 ne = UInt16(sr.readUnsigned(2)); // number of words in ext. char table + UInt16 np = UInt16(sr.readUnsigned(2)); // number of font parameter words + + if (6+lh+(_lastChar-_firstChar+1)+nw+nh+nd+ni+nl+nk+ne+np != lf) + throw FontMetricException("inconsistent length values"); + if (_firstChar >= _lastChar || _lastChar > 255 || ne > 256) + throw FontMetricException("character codes out of range"); + + readHeader(sr); + is.seekg(24+lh*4); // move to char info table + readTables(sr, nw, nh, nd, ni); +} + + +void TFM::readHeader (StreamReader &sr) { + _checksum = sr.readUnsigned(4); + _designSize = sr.readUnsigned(4); +} + + +void TFM::readTables (StreamReader &sr, int nw, int nh, int nd, int ni) { + read_words(sr, _charInfoTable, _lastChar-_firstChar+1); + read_words(sr, _widthTable, nw); + read_words(sr, _heightTable, nh); + read_words(sr, _depthTable, nd); + read_words(sr, _italicTable, ni); +} + + +/** Returns the design size of this font in TeX point units. */ +double TFM::getDesignSize () const { + return fix2double(_designSize); +} + + +/** Returns the index to the entry of the character info table that describes the metric of a given character. + * @param[in] c character whose index is retrieved + * @return table index for character c, or -1 if there's no entry */ +int TFM::charIndex (int c) const { + if (c < _firstChar || c > _lastChar || size_t(c-_firstChar) >= _charInfoTable.size()) + return -1; + return c-_firstChar; +} + + +// the char info word for each character consists of 4 bytes holding the following information: +// width index w, height index (h), depth index (d), italic correction index (it), +// tag (tg) and a remainder: +// +// byte 1 | byte 2 | byte 3 | byte 4 +// xxxxxxxx | xxxx xxxx | xxxxxx xx | xxxxxxxx +// w | h d | it tg | remainder + +/** Returns the width of char c in TeX point units. */ +double TFM::getCharWidth (int c) const { + int index = charIndex(c); + if (index < 0) + return 0; + index = (_charInfoTable[index] >> 24) & 0xFF; + return fix2double(_widthTable[index]) * fix2double(_designSize); +} + + +/** Returns the height of char c in TeX point units. */ +double TFM::getCharHeight (int c) const { + int index = charIndex(c); + if (index < 0) + return 0; + index = (_charInfoTable[index] >> 20) & 0x0F; + return fix2double(_heightTable[index]) * fix2double(_designSize); +} + + +/** Returns the depth of char c in TeX point units. */ +double TFM::getCharDepth (int c) const { + int index = charIndex(c); + if (index < 0) + return 0; + index = (_charInfoTable[index] >> 16) & 0x0F; + return fix2double(_depthTable[index]) * fix2double(_designSize); +} + + +/** Returns the italic correction of char c in TeX point units. */ +double TFM::getItalicCorr (int c) const { + int index = charIndex(c); + if (index < 0) + return 0; + index = (_charInfoTable[index] >> 10) & 0x3F; + return fix2double(_italicTable[index]) * fix2double(_designSize); +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.h new file mode 100644 index 00000000000..09fe68f6019 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TFM.h @@ -0,0 +1,65 @@ +/************************************************************************* +** TFM.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef TFM_H +#define TFM_H + +#include +#include +#include +#include "FontMetric.h" +#include "types.h" +#include "StreamReader.h" + +class StreamReader; + +class TFM : public FontMetric +{ + public: +// TFM (const char *fname); + TFM (std::istream &is); + double getDesignSize () const; + double getCharWidth (int c) const; + double getCharHeight (int c) const; + double getCharDepth (int c) const; + double getItalicCorr (int c) const; + UInt32 getChecksum () const {return _checksum;} + UInt16 firstChar () const {return _firstChar;} + UInt16 lastChar () const {return _lastChar;} + + protected: + TFM () : _checksum(0), _firstChar(0), _lastChar(0), _designSize(0) {} + void readHeader (StreamReader &sr); + void readTables (StreamReader &sr, int nw, int nh, int nd, int ni); + virtual int charIndex (int c) const; + void setCharRange (int firstchar, int lastchar) {_firstChar=firstchar; _lastChar=lastchar;} + + private: + UInt32 _checksum; + UInt16 _firstChar, _lastChar; + FixWord _designSize; ///< design size of the font in TeX points (7227 pt = 254 cm) + std::vector _charInfoTable; + std::vector _widthTable; ///< character widths in design size units + std::vector _heightTable; ///< character height in design size units + std::vector _depthTable; ///< character depth in design size units + std::vector _italicTable; ///< italic corrections in design size units +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.cpp new file mode 100644 index 00000000000..43deb73f448 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.cpp @@ -0,0 +1,211 @@ +/************************************************************************* +** Terminal.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "Terminal.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_TERMIOS_H +#include +#endif + +#ifdef GWINSZ_IN_SYS_IOCTL +#include +#endif + +#ifdef __WIN32__ +#include +#endif + +#include + + +using namespace std; + + +const int Terminal::RED = 1; +const int Terminal::GREEN = 2; +const int Terminal::BLUE = 4; + +const int Terminal::CYAN = GREEN|BLUE; +const int Terminal::YELLOW = RED|GREEN; +const int Terminal::MAGENTA = RED|BLUE; +const int Terminal::WHITE = RED|GREEN|BLUE; +const int Terminal::DEFAULT = -1; +const int Terminal::BLACK = 0; + +#ifdef __WIN32__ +int Terminal::_defaultColor; +int Terminal::_cursorHeight; +#endif + +int Terminal::_fgcolor = Terminal::DEFAULT; +int Terminal::_bgcolor = Terminal::DEFAULT; + + +/** Initializes the terminal. This method should be called before any of the others. + * @param[in,out] os terminal output stream (currently unused) */ +void Terminal::init (ostream &os) { +#ifdef __WIN32__ + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + if (h != INVALID_HANDLE_VALUE) { + CONSOLE_SCREEN_BUFFER_INFO buffer_info; + GetConsoleScreenBufferInfo(h, &buffer_info); + _defaultColor = (buffer_info.wAttributes & 0xff); + CONSOLE_CURSOR_INFO cursor_info; + GetConsoleCursorInfo(h, &cursor_info); + _cursorHeight = cursor_info.dwSize; + } +#endif +} + + +/** Finishes the terminal output. Should be called after last terminal action. + * @param[in,out] os terminal output stream */ +void Terminal::finish (ostream &os) { + fgcolor(DEFAULT, os); + bgcolor(DEFAULT, os); + cursor(true); +} + + +/** Returns the number of terminal columns (number of characters per row). + * If it's not possible to retrieve information about the terminal size, 0 is returned. */ +int Terminal::columns () { +#if defined(TIOCGWINSZ) + struct winsize ws; + if (ioctl(fileno(stderr), TIOCGWINSZ, &ws) < 0) + return 0; + return ws.ws_col; +#elif defined(__WIN32__) + CONSOLE_SCREEN_BUFFER_INFO info; + if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &info)) + return 0; + return info.dwSize.X; +#else + return 0; +#endif +} + + +/** Returns the number of terminal rows. + * If it's not possible to retrieve information about the terminal size, 0 is returned. */ +int Terminal::rows () { +#if defined(TIOCGWINSZ) + struct winsize ws; + if (ioctl(fileno(stderr), TIOCGWINSZ, &ws) < 0) + return 0; + return ws.ws_row; +#elif defined(__WIN32__) + CONSOLE_SCREEN_BUFFER_INFO info; + if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &info)) + return 0; + return info.dwSize.Y; +#else + return 0; +#endif +} + + +/** Sets the foreground color. + * @param[in] color color code + * @param[in] os terminal output stream */ +void Terminal::fgcolor (int color, ostream &os) { + _fgcolor = color; + +#ifdef __WIN32__ + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + if (h != INVALID_HANDLE_VALUE) { + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo(h, &info); + if (_fgcolor == DEFAULT) + color = _defaultColor & 0x0f; + else { + // swap red and blue bits + color = (color & 0x0a) | ((color & 1) << 2) | ((color & 4) >> 2); + } + color = (info.wAttributes & 0xf0) | (color & 0x0f); + SetConsoleTextAttribute(h, (DWORD)color); + } +#else + bool light = false; + if (color != DEFAULT && color > 7) { + light = true; + color %= 8; + } + if (color == DEFAULT) { + os << "\x1B[0m"; + if (_bgcolor != DEFAULT) + bgcolor(_bgcolor, os); + } + else + os << "\x1B[" << (light ? '1': '0') << ';' << (30+(color & 0x07)) << 'm'; +#endif +} + + +/** Sets the background color. + * @param[in] color color code + * @param[in] os terminal output stream */ +void Terminal::bgcolor (int color, ostream &os) { + _bgcolor = color; +#ifdef __WIN32__ + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + if (h != INVALID_HANDLE_VALUE) { + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo(h, &info); + if (_bgcolor == DEFAULT) + color = (_defaultColor & 0xf0) >> 4; + else { + // swap red and blue bits + color = (color & 0x0a) | ((color & 1) << 2) | ((color & 4) >> 2); + } + color = (info.wAttributes & 0x0f) | ((color & 0x0f) << 4); + SetConsoleTextAttribute(h, (DWORD)color); + } +#else + if (color != DEFAULT && color > 7) + color %= 8; + if (color == DEFAULT) { + os << "\x1B[0m"; + if (_fgcolor != DEFAULT) + fgcolor(_fgcolor, os); + } + else + os << "\x1B[" << (40+(color & 0x07)) << 'm'; +#endif +} + + +/** Disables or enables the console cursor + * @param[in] visible if false, the cursor is disabled, and enabled otherwise */ +void Terminal::cursor (bool visible) { +#ifdef __WIN32__ + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + if (h != INVALID_HANDLE_VALUE) { + CONSOLE_CURSOR_INFO cursor_info; + cursor_info.bVisible = visible; + cursor_info.dwSize = _cursorHeight; + SetConsoleCursorInfo(h, &cursor_info); + } +#endif +} \ No newline at end of file diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.h new file mode 100644 index 00000000000..0a876272c91 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/Terminal.h @@ -0,0 +1,58 @@ +/************************************************************************* +** Terminal.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef TERMINAL_H +#define TERMINAL_H + +#include + +class Terminal +{ + public: + static const int DEFAULT; + static const int BLACK; + static const int RED; + static const int GREEN; + static const int BLUE; + static const int CYAN; + static const int YELLOW; + static const int MAGENTA; + static const int WHITE; + + public: + static void init (std::ostream &os); + static void finish (std::ostream &os); + static int columns (); + static int rows (); + static void fgcolor (int color, std::ostream &os); + static void bgcolor (int color, std::ostream &os); + static void cursor (bool visible); + + private: + static int _fgcolor; ///< current foreground color + static int _bgcolor; ///< current background color + +#ifdef __WIN32__ + static int _defaultColor; + static int _cursorHeight; ///< current height of the cursor in percent +#endif +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.cpp new file mode 100644 index 00000000000..f44b89277b7 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.cpp @@ -0,0 +1,323 @@ +/************************************************************************* +** TpicSpecialHandler.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include "Color.h" +#include "InputBuffer.h" +#include "InputReader.h" +#include "SpecialActions.h" +#include "TpicSpecialHandler.h" +#include "XMLNode.h" +#include "XMLString.h" +#include "types.h" + +using namespace std; + + +TpicSpecialHandler::TpicSpecialHandler () { + reset(); +} + + +void TpicSpecialHandler::dviEndPage (unsigned pageno) { + reset(); +} + + +void TpicSpecialHandler::reset () { + _points.clear(); + _penwidth = 1.0; + _fill = -1.0; // no fill +} + + +/** Creates SVG elements that draw lines through the recorded points. + * @param[in] stroke if true, the (out)line is drawn (in black) + * @param[in] fill if true, enclosed area is filled with current color + * @param[in] ddist dash/dot distance of line in TeX point units + * (0:solid line, >0:dashed line, <0:dotted line) */ +void TpicSpecialHandler::drawLines (bool stroke, bool fill, double ddist, SpecialActions *actions) { + if (actions && !_points.empty()) { + XMLElementNode *elem=0; + if (_points.size() == 1) { + const DPair &p = _points.back(); + elem = new XMLElementNode("circle"); + elem->addAttribute("cx", p.x()+actions->getX()); + elem->addAttribute("cy", p.y()+actions->getY()); + elem->addAttribute("r", _penwidth/2.0); + actions->embed(p, _penwidth/2.0); + } + else { + if (_points.size() == 2 || (!fill && _points.front() != _points.back())) { + elem = new XMLElementNode("polyline"); + elem->addAttribute("fill", "none"); + elem->addAttribute("stroke-linecap", "round"); + } + else { + if (_points.front() == _points.back()) + _points.pop_back(); + if (_fill < 0) + _fill = 1; + Color color = actions->getColor(); + color *= _fill; + elem = new XMLElementNode("polygon"); + elem->addAttribute("fill", fill ? color.rgbString() : "none"); + } + ostringstream oss; + FORALL(_points, vector::iterator, it) { + if (it != _points.begin()) + oss << ' '; + double x = it->x()+actions->getX(); + double y = it->y()+actions->getY(); + oss << XMLString(x) << ',' << XMLString(y); + actions->embed(DPair(x, y)); + } + elem->addAttribute("points", oss.str()); + if (stroke) { // draw outline? + elem->addAttribute("stroke", "black"); + elem->addAttribute("stroke-width", XMLString(_penwidth)); + } + } + if (ddist > 0) + elem->addAttribute("stroke-dasharray", XMLString(ddist)); + else if (ddist < 0) + elem->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist)); + actions->appendToPage(elem); + } + reset(); +} + + +/** Stroke a quadratic spline through the midpoints of the lines defined by + * the previously recorded points. The spline starts with a straight line + * from the first point to the mid-point of the first line. The spline ends + * with a straight line from the mid-point of the last line to the last point. + * If ddist=0, the spline is stroked solid. Otherwise ddist denotes the length + * of the dashes and the gaps inbetween. + * @param[in] ddist length of dashes and gaps */ +void TpicSpecialHandler::drawSplines (double ddist, SpecialActions *actions) { + if (actions && !_points.empty()) { + const size_t size = _points.size(); + if (size < 3) + drawLines(true, false, ddist, actions); + else { + double x = actions->getX(); + double y = actions->getY(); + DPair p(x,y); + ostringstream oss; + oss << 'M' << XMLString(x+_points[0].x()) << ',' << XMLString(y+_points[0].y()); + DPair mid = p+_points[0]+(_points[1]-_points[0])/2.0; + oss << 'L' << XMLString(mid.x()) << ',' << XMLString(mid.y()); + actions->embed(p+_points[0]); + for (size_t i=1; i < size-1; i++) { + const DPair p0 = p+_points[i-1]; + const DPair p1 = p+_points[i]; + const DPair p2 = p+_points[i+1]; + mid = p1+(p2-p1)/2.0; + oss << 'Q' << XMLString(p1.x()) << ',' << XMLString(p1.y()) + << ' ' << XMLString(mid.x()) << ',' << XMLString(mid.y()); + actions->embed(mid); + actions->embed((p0+p1*6.0+p2)/8.0, _penwidth); + } + if (_points[0] == _points[size-1]) // closed path? + oss << 'Z'; + else { + oss << 'L' << XMLString(x+_points[size-1].x()) << ',' << XMLString(y+_points[size-1].y()); + actions->embed(p+_points[size-1]); + } + + Color color = actions->getColor(); + color *= _fill; + XMLElementNode *path = new XMLElementNode("path"); + if (_fill >= 0) { + if (_points[0] != _points[size-1]) + oss << 'Z'; + path->addAttribute("fill", color.rgbString()); + } + else + path->addAttribute("fill", "none"); + + path->addAttribute("d", oss.str()); + path->addAttribute("stroke", actions->getColor().rgbString()); + path->addAttribute("stroke-width", XMLString(_penwidth)); + if (ddist > 0) + path->addAttribute("stroke-dasharray", XMLString(ddist)); + else if (ddist < 0) + path->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist)); + actions->appendToPage(path); + } + } + reset(); +} + + +/** Draws an elliptical arc. + * @param[in] cx x-coordinate of arc center + * @param[in] cy y-coordinate of arc center + * @param[in] rx length of horizonal semi-axis + * @param[in] ry length of vertical semi-axis + * @param[in] angle1 starting angle (clockwise) relative to x-axis + * @param[in] angle2 ending angle (clockwise) relative to x-axis */ +void TpicSpecialHandler::drawArc (double cx, double cy, double rx, double ry, double angle1, double angle2, SpecialActions *actions) { + if (actions) { + const double PI2 = 4*asin(1.0); + angle1 *= -1; + angle2 *= -1; + if (fabs(angle1) > PI2) { + int n = (int)(angle1/PI2); + angle1 = angle1 - n*PI2; + angle2 = angle2 - n*PI2; + } + + double x = cx + actions->getX(); + double y = cy + actions->getY(); + XMLElementNode *elem=0; + if (fabs(angle1-angle2) >= PI2) { // closed ellipse? + elem = new XMLElementNode("ellipse"); + elem->addAttribute("cx", XMLString(x)); + elem->addAttribute("cy", XMLString(y)); + elem->addAttribute("rx", XMLString(rx)); + elem->addAttribute("ry", XMLString(ry)); + } + else { + if (angle1 < 0) + angle1 = PI2+angle1; + if (angle2 < 0) + angle2 = PI2+angle2; + elem = new XMLElementNode("path"); + int large_arg = fabs(angle1-angle2) > PI2/2 ? 0 : 1; + int sweep_flag = angle1 > angle2 ? 0 : 1; + if (angle1 > angle2) { + large_arg = 1-large_arg; + sweep_flag = 1-sweep_flag; + } + ostringstream oss; + oss << 'M' << XMLString(x+rx*cos(angle1)) << ',' << XMLString(y+ry*sin(-angle1)) + << 'A' << XMLString(rx) << ',' << XMLString(ry) + << " 0 " + << large_arg << ' ' << sweep_flag << ' ' + << XMLString(x+rx*cos(angle2)) << ',' << XMLString(y-ry*sin(angle2)); + if (_fill >= 0) + oss << 'Z'; + elem->addAttribute("d", oss.str()); + } + elem->addAttribute("stroke-width", _penwidth); + elem->addAttribute("stroke", actions->getColor().rgbString()); + elem->addAttribute("stroke-linecap", "round"); + elem->addAttribute("fill", "none"); + if (_fill >= 0) { + Color color=actions->getColor(); + color *= _fill; + elem->addAttribute("fill", color.rgbString()); + } + else + elem->addAttribute("fill", "none"); + actions->appendToPage(elem); + actions->embed(BoundingBox(cx-rx, cy-ry, cx+rx, cy+ry)); + } + reset(); +} + + +#define cmd_id(c1,c2) ((c1 << 8) | c2) + +bool TpicSpecialHandler::process (const char *prefix, istream &is, SpecialActions *actions) { + if (!prefix || strlen(prefix) != 2) + return false; + + const double PT=0.07227; // factor for milli-inch to TeX points + StreamInputBuffer ib(is); + BufferInputReader in(ib); + switch (cmd_id(prefix[0], prefix[1])) { + case cmd_id('p','n'): // set pen width in milli-inches + _penwidth = in.getDouble()*PT; + break; + case cmd_id('b','k'): // set fill color to black + _fill = 0; + break; + case cmd_id('w','h'): // set fill color to white + _fill = 1; + break; + case cmd_id('s','h'): // set fill color to given gray level + in.skipSpace(); + _fill = in.eof() ? 0.5 : max(0.0, min(1.0, in.getDouble())); + break; + case cmd_id('t','x'): // set fill pattern + break; + case cmd_id('p','a'): { // add point to path + double x=in.getDouble()*PT; + double y=in.getDouble()*PT; + _points.push_back(DPair(x,y)); + break; + } + case cmd_id('f','p'): // draw solid lines through recorded points; close and fill path if fill color was defined + drawLines(true, _fill >= 0, 0, actions); + break; + case cmd_id('i','p'): // don't draw outlines but close the recorded path and fill the resulting polygon + drawLines(false, true, 0, actions); + break; + case cmd_id('d','a'): // as fp but draw dashed lines + drawLines(true, _fill >= 0, in.getDouble()*72.27, actions); + break; + case cmd_id('d','t'): // as fp but draw dotted lines + drawLines(true, _fill >= 0, -in.getDouble()*72.27, actions); + break; + case cmd_id('s','p'): { // draw quadratic splines through recorded points + double ddist = in.getDouble(); + drawSplines(ddist, actions); + break; + } + case cmd_id('a','r'): { // draw elliptical arc + double cx = in.getDouble()*PT; + double cy = in.getDouble()*PT; + double rx = in.getDouble()*PT; + double ry = in.getDouble()*PT; + double a1 = in.getDouble(); + double a2 = in.getDouble(); + drawArc(cx, cy, rx, ry, a1, a2, actions); + break; + } + case cmd_id('i','a'): { // fill elliptical arc + double cx = in.getDouble()*PT; + double cy = in.getDouble()*PT; + double rx = in.getDouble()*PT; + double ry = in.getDouble()*PT; + double a1 = in.getDouble(); + double a2 = in.getDouble(); + if (_fill < 0) + _fill = 1; + drawArc(cx, cy, rx, ry, a1, a2, actions); + if (_fill < 0) + _fill = -1; + break; + } + default: + return false; + } + return true; +} + + +const char** TpicSpecialHandler::prefixes () const { + static const char *pfx[] = {"ar", "bk", "da", "dt", "fp", "ia", "ip", "pa", "pn", "sh", "sp", "tx", "wh", 0}; + return pfx; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.h new file mode 100644 index 00000000000..e055e2e0a69 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/TpicSpecialHandler.h @@ -0,0 +1,50 @@ +/************************************************************************* +** TpicSpecialHandler.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef TPICSPECIALHANDLER_H +#define TPICSPECIALHANDLER_H + +#include +#include "Pair.h" +#include "SpecialHandler.h" + +class TpicSpecialHandler : public SpecialHandler, public DVIEndPageListener +{ + public: + TpicSpecialHandler (); + const char* info () const {return "TPIC specials";} + const char* name () const {return "tpic";} + const char** prefixes () const; + bool process (const char *prefix, std::istream &is, SpecialActions *actions); + + protected: + void dviEndPage (unsigned pageno); + void reset (); + void drawLines (bool stroke, bool fill, double ddist, SpecialActions *actions); + void drawSplines (double ddist, SpecialActions *actions); + void drawArc (double cx, double cy, double rx, double ry, double angle1, double angle2, SpecialActions *actions); + + private: + double _penwidth; ///< pen width in TeX point units + double _fill; ///< fill intensity [0,1]; if < 0, we don't fill anything + std::vector _points; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFActions.h new file mode 100644 index 00000000000..ba25639b337 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFActions.h @@ -0,0 +1,38 @@ +/************************************************************************* +** VFActions.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef VFACTIONS_H +#define VFACTIONS_H + +#include +#include +#include "types.h" + + +struct VFActions +{ + virtual ~VFActions () {} + virtual void preamble (std::string comment, UInt32 checksum, double dsize) {} + virtual void postamble () {} + virtual void defineVFFont (UInt32 fontnum, std::string path, std::string name, UInt32 checksum, double dsize, double ssize) {} + virtual void defineVFChar (UInt32 c, std::vector *dvi) {} +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.cpp new file mode 100644 index 00000000000..5980a63054a --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.cpp @@ -0,0 +1,190 @@ +/************************************************************************* +** VFReader.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include "Font.h" +#include "VFActions.h" +#include "VFReader.h" +#include "macros.h" + +using namespace std; + + +/** Converts a TFM fix point value to double. */ +inline static double fix2double (FixWord fix) { + return double(fix)/(1 << 20); +} + + +VFReader::VFReader (istream &is) + : StreamReader(is), _actions(0), _designSize(0) { +} + + +VFReader::~VFReader () { +} + + +VFActions* VFReader::replaceActions (VFActions *a) { + VFActions *ret = _actions; + _actions = a; + return ret; +} + + +/** Reads a single VF command from the current position of the input stream and calls the + * corresponding cmdFOO method. The execution can be influenced by a function of type ApproveOpcode. + * It takes an opcode and returns true if the command is supposed to be executed. + * @param[in] approve function to approve invocation of the action assigned to command + * @return opcode of the executed command */ +int VFReader::executeCommand (ApproveAction approve) { + int opcode = in().get(); + if (!in() || opcode < 0) // at end of file + throw VFException("invalid file"); + + bool approved = !approve || approve(opcode); + VFActions *actions = _actions; + if (!approved) + replaceActions(0); // disable actions + + if (opcode <= 241) // short character definition? + cmdShortChar(opcode); + else if (opcode >= 243 && opcode <= 246) // font definition? + cmdFontDef(opcode-243+1); + else { + switch (opcode) { + case 242: cmdLongChar(); break; // long character definition + case 247: cmdPre(); break; // preamble + case 248: cmdPost(); break; // postamble + default : { // invalid opcode + replaceActions(actions); // reenable actions + ostringstream oss; + oss << "undefined VF command (opcode " << opcode << ')'; + throw VFException(oss.str()); + } + } + } + replaceActions(actions); // reenable actions + return opcode; +} + + +bool VFReader::executeAll () { + in().clear(); // reset all status bits + if (!in()) + return false; + in().seekg(0); // move file pointer to first byte of the input stream + while (!in().eof() && executeCommand() != 248); // stop reading after post (248) + return true; +} + + +/// Returns true if op indicates the preamble or a font definition +static bool is_pre_or_fontdef (int op) {return op > 242;} +static bool is_chardef (int op) {return op < 243;} + + +bool VFReader::executePreambleAndFontDefs () { + in().clear(); + if (!in()) + return false; + in().seekg(0); // move file pointer to first byte of the input stream + while (!in().eof() && executeCommand(is_pre_or_fontdef) > 242); // stop reading after last font definition + return true; +} + + +bool VFReader::executeCharDefs () { + in().clear(); + if (!in()) + return false; + in().seekg(0); + while (!in().eof() && executeCommand(is_chardef) < 243); // stop reading after last char definition + return true; +} + +////////////////////////////////////////////////////////////////////////////// + +/** Reads and executes DVI preamble command. */ +void VFReader::cmdPre () { + UInt32 i = readUnsigned(1); // identification number (should be 2) + UInt32 k = readUnsigned(1); // length of following comment + string cmt = readString(k); // comment + UInt32 cs = readUnsigned(4); // check sum to be compared with TFM cecksum + UInt32 ds = readUnsigned(4); // design size (same as TFM design size) (fix_word) + _designSize = fix2double(ds); + if (i != 202) + throw VFException("invalid identification value in preamble"); + if (_actions) + _actions->preamble(cmt, cs, ds); +} + + +void VFReader::cmdPost () { + while ((readUnsigned(1)) == 248); // skip fill bytes + if (_actions) + _actions->postamble(); +} + + +void VFReader::cmdLongChar () { + UInt32 pl = readUnsigned(4); // packet length (length of DVI subroutine) + if (_actions) { + UInt32 cc = readUnsigned(4); // character code + readUnsigned(4); // character width from corresponding TFM file + vector *dvi = new vector(pl); // DVI subroutine + readBytes(pl, *dvi); + _actions->defineVFChar(cc, dvi); // call template method for user actions + } + else + in().seekg(8+pl, ios::cur); // skip remaining char definition bytes +} + + +/** Reads and executes short_char_x command. + * @param[in] pl packet length (length of DVI subroutine) */ +void VFReader::cmdShortChar (int pl) { + if (_actions) { + UInt32 cc = readUnsigned(1); // character code + readUnsigned(3); // character width from corresponding TFM file + vector *dvi = new vector(pl); // DVI subroutine + readBytes(pl, *dvi); + _actions->defineVFChar(cc, dvi); // call template method for user actions + } + else + in().seekg(4+pl, ios::cur); // skip char definition bytes +} + + +void VFReader::cmdFontDef (int len) { + UInt32 fontnum = readUnsigned(len); // font number + UInt32 checksum = readUnsigned(4); // font checksum (to be compared with corresponding TFM checksum) + UInt32 ssize = readUnsigned(4); // scaled size of font relative to design size (fix_word) + UInt32 dsize = readUnsigned(4); // design size of font (same as TFM design size) (fix_word) + UInt32 pathlen = readUnsigned(1); // length of font path + UInt32 namelen = readUnsigned(1); // length of font name + string fontpath = readString(pathlen); + string fontname = readString(namelen); + if (_actions) { + double ss = fix2double(ssize); + double ds = fix2double(dsize); + _actions->defineVFFont(fontnum, fontpath, fontname, checksum, ds, ss*_designSize); + } +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.h new file mode 100644 index 00000000000..25689dec2c8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VFReader.h @@ -0,0 +1,65 @@ +/************************************************************************* +** VFReader.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef VFREADER_H +#define VFREADER_H + +#include "MessageException.h" +#include "StreamReader.h" +#include "types.h" + + +struct VFException : public MessageException +{ + VFException (const std::string &msg) : MessageException(msg) {} +}; + + +struct VFActions; + + +class VFReader : public StreamReader +{ + typedef bool (*ApproveAction)(int); + public: + VFReader (std::istream &is); + virtual ~VFReader (); + VFActions* replaceActions (VFActions *a); + bool executeAll (); + bool executePreambleAndFontDefs (); + bool executeCharDefs (); + + protected: + int executeCommand (ApproveAction approve=0); + + // the following methods represent the VF commands + // they are called by executeCommand and should not be used directly + void cmdPre (); + void cmdPost (); + void cmdShortChar (int pl); + void cmdLongChar (); + void cmdFontDef (int len); + + private: + VFActions *_actions; ///< actions to execute when reading a VF command + double _designSize; ///< design size of currently read VF +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VectorStream.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VectorStream.h new file mode 100644 index 00000000000..e57dad43ad1 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/VectorStream.h @@ -0,0 +1,46 @@ +/************************************************************************* +** VectorStream.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef VECTORSTREAM_H +#define VECTORSTREAM_H + +#include +#include + + +template +struct VectorStreamBuffer : public std::streambuf +{ + VectorStreamBuffer (std::vector &source) { + setg((char*)&source[0], (char*)&source[0], (char*)&source[0]+source.size()); + } +}; + + +template +class VectorInputStream : public std::istream +{ + public: + VectorInputStream (std::vector &source) : std::istream(&_buf), _buf(source) {} + private: + VectorStreamBuffer _buf; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocTypeNode.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocTypeNode.h new file mode 100644 index 00000000000..ad1cd0f3b38 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocTypeNode.h @@ -0,0 +1,41 @@ +/************************************************************************* +** XMLDocTypeNode.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef XMLDOCTYPENODE_H +#define XMLDOCTYPENODE_H + +#include "XMLNode.h" + +class XMLDocTypeNode : public XMLDeclarationNode +{ + public: + XMLDocTypeNode (const std::string &rootName, const std::string &type, const std::string ¶m) + : XMLDeclarationNode("DOCTYPE", rootName + " " + type + " " + param) {} +}; + + +class XMLEntityNode : public XMLDeclarationNode +{ + public: + XMLEntityNode (const std::string &n, const std::string &v) + : XMLDeclarationNode("ENTITY", n + " " + v) {} +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.cpp new file mode 100644 index 00000000000..5b6e3b1354f --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.cpp @@ -0,0 +1,100 @@ +/************************************************************************* +** XMLDocument.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "macros.h" +#include "XMLDocument.h" + +using namespace std; + +XMLDocument::XMLDocument (XMLElementNode *root) + : _rootElement(root), _emitted(false) +{ +} + + +XMLDocument::~XMLDocument () { + clear(); +} + + +void XMLDocument::clear () { + delete _rootElement; + _rootElement = 0; + FORALL(_nodes, list::iterator, i) + delete *i; + _nodes.clear(); +} + + +void XMLDocument::append (XMLNode *node) { + if (!node) + return; + XMLElementNode *newRoot = dynamic_cast(node); + if (newRoot) { // there can only be one root element node in the document + delete _rootElement; // so if there is already one... + _rootElement = newRoot; // ...we replace it + } + else + _nodes.push_back(node); +} + + +void XMLDocument::setRootNode (XMLElementNode *root) { + delete _rootElement; + _rootElement = root; +} + + +ostream& XMLDocument::write (ostream &os) const { + if (_rootElement) { // no root element => no output + os << "\n"; + FORALL(_nodes, list::const_iterator, i) + (*i)->write(os); + _rootElement->write(os); + } + return os; +} + +/** Writes a part of the XML document to the given output stream and removes + * the completely written nodes. The output stops when a stop node is reached + * (this node won't be printed at all). If a node was only partly emitted, i.e. + * its child was the stop node, a further call of emit will continue the output. + * @param[in] os stream to which the output is written + * @param[in] stopElement node where emitting stops (if 0 the whole tree will be emitted) + * @return true if node was completely emitted */ +bool XMLDocument::emit (ostream& os, XMLNode *stopNode) { + if (_rootElement) { // no root element => no output + if (!_emitted) { + os << "\n"; + _emitted = true; + } + FORALL(_nodes, list::iterator, i) { + if ((*i)->emit(os, stopNode)) { + list::iterator it = i++; // prevent i from being invalidated... + _nodes.erase(it); // ... by erase + --i; // @@ what happens if i points to first child? + } + else + return false; + } + return _rootElement->emit(os, stopNode); + } + return true; +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.h new file mode 100644 index 00000000000..31cf9dea303 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLDocument.h @@ -0,0 +1,44 @@ +/************************************************************************* +** XMLDocument.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef XMLDOCUMENT_H +#define XMLDOCUMENT_H + +#include "XMLNode.h" + +class XMLDocument +{ + public: + XMLDocument (XMLElementNode *root=0); + ~XMLDocument (); + void clear (); + void append (XMLNode *node); + void setRootNode (XMLElementNode *root); + const XMLElementNode* getRootElement () const {return _rootElement;} + std::ostream& write (std::ostream &os) const; + bool emit (std::ostream& os, XMLNode *stopNode); + + private: + std::list _nodes; + XMLElementNode *_rootElement; + bool _emitted; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.cpp new file mode 100644 index 00000000000..d69b4a9b049 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.cpp @@ -0,0 +1,343 @@ +/************************************************************************* +** XMLNode.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "macros.h" +#include "XMLNode.h" +#include "XMLString.h" + +using namespace std; + +bool XMLNode::emit (ostream &os, XMLNode *stopNode) { + if (this == stopNode) + return false; + write(os); + return true; +} + + +XMLElementNode::XMLElementNode (const string &n) : _name(n), _emitted(false) { +} + + +XMLElementNode::XMLElementNode (const XMLElementNode &node) + : _name(node._name), _attributes(node._attributes), _emitted(false) +{ + FORALL(node._children, ChildList::const_iterator, it) + _children.push_back((*it)->clone()); +} + + +XMLElementNode::~XMLElementNode () { + FORALL(_children, ChildList::iterator, i) + delete *i; +} + + +void XMLElementNode::addAttribute (const string &name, const string &value) { + _attributes[name] = value; +} + + +void XMLElementNode::addAttribute (const string &name, double value) { + _attributes[name] = XMLString(value); +} + + +void XMLElementNode::append (XMLNode *child) { + if (!child) + return; + XMLTextNode *textNode1 = dynamic_cast(child); + if (!textNode1 || _children.empty()) + _children.push_back(child); + else { + if (XMLTextNode *textNode2 = dynamic_cast(_children.back())) + textNode2->append(textNode1); // merge two consecutive text nodes + else + _children.push_back(child); + } +} + + +void XMLElementNode::append (const string &str) { + if (_children.empty() || !dynamic_cast(_children.back())) + _children.push_back(new XMLTextNode(str)); + else + static_cast(_children.back())->append(str); +} + + +void XMLElementNode::prepend (XMLNode *child) { + if (!child) + return; + XMLTextNode *textNode1 = dynamic_cast(child); + if (!textNode1 || _children.empty()) + _children.push_front(child); + else { + if (XMLTextNode *textNode2 = dynamic_cast(_children.back())) + textNode2->prepend(textNode1); // merge two consecutive text nodes + else + _children.push_front(child); + } +} + + +/** Inserts a new child node before a given child node already present. The latter + * will be the following sibling of the node to be inserted. If there's no such + * node present, nothing is inserted. + * @param[in] child node to be inserted + * @param[in] sibling following sibling of 'child' + * @return true on success */ +bool XMLElementNode::insertBefore (XMLNode *child, XMLNode *sibling) { + ChildList::iterator it = _children.begin(); + while (it != _children.end() && *it != sibling) + ++it; + if (it != _children.end()) { + _children.insert(it, child); + return true; + } + return false; +} + + +/** Inserts a new child node after a given child node already present. The latter + * will be the preceding sibling of the node to be inserted. If there's no such + * node present, nothing is inserted. + * @param[in] child node to be inserted + * @param[in] sibling preceding sibling of 'child' + * @return true on success */ +bool XMLElementNode::insertAfter (XMLNode *child, XMLNode *sibling) { + ChildList::iterator it = _children.begin(); + while (it != _children.end() && *it != sibling) + ++it; + if (it != _children.end()) { + _children.insert(++it, child); + return true; + } + return false; +} + + +/** Finds all descendant elements of a given name and given attribute. + * @param[in] name name of elements to find + * @param[in] attr_name name of attribute to find + * @param[out] descendants all elements found + * @return true if at least one element was found */ +bool XMLElementNode::findDescendants (const char *name, const char *attr_name, vector &descendants) { + FORALL(_children, ChildList::iterator, it) { + if (XMLElementNode *elem = dynamic_cast(*it)) { + if ((!name || elem->getName() == name) && (!attr_name || elem->hasAttribute(attr_name))) + descendants.push_back(elem); + elem->findDescendants(name, attr_name, descendants); + } + } + return !descendants.empty(); +} + + +ostream& XMLElementNode::write (ostream &os) const { + os << '<' << _name; + FORALL(_attributes, AttribMap::const_iterator, i) + os << ' ' << i->first << "='" << i->second << '\''; + if (_children.empty()) + os << "/>\n"; + else { + os << '>'; + if (dynamic_cast(_children.front())) + os << '\n'; + FORALL(_children, ChildList::const_iterator, i) + (*i)->write(os); + os << "\n"; + } + return os; +} + + +/** Writes a part of the XML tree to the given output stream and removes + * the completely written nodes. The output stops when a stop node is reached + * (this node won't be printed at all). If a node was only partly emitted, i.e. + * its child was the stop node, a further call of emit will continue the output. + * @param[in] os stream to which the output is sent to + * @param[in] stopElement node where emitting stops (if 0 the whole tree will be emitted) + * @return true if node was emitted completely */ +bool XMLElementNode::emit (ostream &os, XMLNode *stopNode) { + if (this == stopNode) + return false; + + if (!_emitted) { + os << '<' << _name; + FORALL(_attributes, AttribMap::iterator, i) + os << ' ' << i->first << "='" << i->second << '\''; + if (_children.empty()) + os << "/>\n"; + else { + os << '>'; + if (dynamic_cast(_children.front())) + os << '\n'; + } + + _emitted = true; + } + if (!_children.empty()) { + FORALL(_children, ChildList::iterator, i) { + if ((*i)->emit(os, stopNode)) { + ChildList::iterator it = i++; // prevent i from being invalidated... + _children.erase(it); // ... by erase + --i; // @@ what happens if i points to first child? + } + else + return false; + } + os << "\n"; + } + return true; +} + + +/** Returns true if this element has an attribute of given name. */ +bool XMLElementNode::hasAttribute (const string &name) const { + return _attributes.find(name) != _attributes.end(); +} + + +/** Returns the value of an attribute. + * @param[in] name name of attribute + * @return attribute value or 0 if attribute doesn't exist */ +const char* XMLElementNode::getAttributeValue(const std::string& name) const { + AttribMap::const_iterator it = _attributes.find(name); + if (it != _attributes.end()) + return it->second.c_str(); + return 0; +} + + +////////////////////// + +void XMLTextNode::append (XMLNode *node) { + if (XMLTextNode *tn = dynamic_cast(node)) + append(tn); + else + delete node; +} + + +void XMLTextNode::append (XMLTextNode *node) { + if (node) + _text += node->_text; + delete node; +} + + +void XMLTextNode::append (const string &str) { + _text += str; +} + + +void XMLTextNode::prepend (XMLNode *node) { + if (XMLTextNode *tn = dynamic_cast(node)) + prepend(tn); + else + delete node; +} + + +////////////////////// + +XMLDeclarationNode::XMLDeclarationNode (const string &n, const string &p) + : _name(n), _params(p), _emitted(false) +{ +} + + +XMLDeclarationNode::XMLDeclarationNode (const XMLDeclarationNode &node) + : _name(node._name), _params(node._params), _emitted(false) +{ + FORALL(node._children, list::const_iterator, it) + _children.push_back(new XMLDeclarationNode(**it)); +} + + +XMLDeclarationNode::~XMLDeclarationNode () { + FORALL(_children, list::iterator, i) + delete *i; +} + + +/** Appends another declaration node to this one. + * @param[in] child child to append, must be of type XMLDeclarationNode */ +void XMLDeclarationNode::append (XMLNode *child) { + if (XMLDeclarationNode *decl_node = dynamic_cast(child)) + _children.push_back(decl_node); + else + delete child; +} + + +ostream& XMLDeclarationNode::write (ostream &os) const { + os << "\n"; + else { + os << "[\n"; + FORALL(_children, list::const_iterator, i) + (*i)->write(os); + os << "]>\n"; + } + return os; +} + + +bool XMLDeclarationNode::emit (ostream &os, XMLNode *stopNode) { + if (this == stopNode) + return false; + + if (!_emitted) { + os << "\n"; + else + os << "[\n"; + _emitted = true; + } + if (!_children.empty()) { + FORALL(_children, list::iterator, i) { + if ((*i)->emit(os, stopNode)) { + list::iterator it = i++; // prevent i from being invalidated... + _children.erase(it); // ... by erase + --i; // @@ what happens if i points to first child? + } + else + return false; + } + os << "]>\n"; + } + return true; + +} + +////////////////////// + +ostream& XMLCDataNode::write (ostream &os) const { + os << "\n"; + return os; +} + + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.h new file mode 100644 index 00000000000..324bea068aa --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLNode.h @@ -0,0 +1,134 @@ +/************************************************************************* +** XMLNode.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef XMLNODE_H +#define XMLNODE_H + +#include +#include +#include +#include + +#include "SpecialActions.h" + + +struct XMLNode +{ + virtual ~XMLNode () {} + virtual XMLNode* clone () const =0; + virtual std::ostream& write (std::ostream &os) const =0; + virtual bool emit (std::ostream &os, XMLNode *stopElement); + virtual void append (XMLNode *child) {} + virtual void prepend (XMLNode *child) {} +}; + + +class XMLElementNode : public XMLNode +{ + typedef std::map AttribMap; + typedef std::list ChildList; + public: + XMLElementNode (const std::string &name); + XMLElementNode (const XMLElementNode &node); + ~XMLElementNode (); + XMLNode* clone () const {return new XMLElementNode(*this);} + void addAttribute (const std::string &name, const std::string &value); + void addAttribute (const std::string &name, double value); + void append (XMLNode *child); + void append (const std::string &str); + void prepend (XMLNode *child); + bool insertAfter (XMLNode *child, XMLNode *sibling); + bool insertBefore (XMLNode *child, XMLNode *sibling); + bool hasAttribute (const std::string &name) const; + const char* getAttributeValue (const std::string &name) const; + bool findDescendants (const char *name, const char *attr_name, std::vector &descendants); + std::ostream& write (std::ostream &os) const; + bool emit (std::ostream &os, XMLNode *stopElement); + bool empty () const {return _children.empty();} + const std::list& children () const {return _children;} + const std::string& getName () const {return _name;} + + private: + std::string _name; // element name (...) + AttribMap _attributes; + ChildList _children; // child nodes + bool _emitted; // true if node has been (partly) emitted +}; + + +class XMLTextNode : public XMLNode +{ + public: + XMLTextNode (const std::string &str) : _text(str) {} + XMLNode* clone () const {return new XMLTextNode(*this);} + void append (XMLNode *node); + void append (XMLTextNode *node); + void append (const std::string &str); + void prepend (XMLNode *child); + std::ostream& write (std::ostream &os) const {return os << _text;} + + private: + std::string _text; +}; + + +class XMLCommentNode : public XMLNode +{ + public: + XMLCommentNode (const std::string &str) : _text(str) {} + XMLNode* clone () const {return new XMLCommentNode(*this);} + std::ostream& write (std::ostream &os) const {return os << "\n";} + + private: + std::string _text; +}; + + +class XMLDeclarationNode : public XMLNode +{ + public: + XMLDeclarationNode (const std::string &n, const std::string &p); + XMLDeclarationNode (const XMLDeclarationNode &node); + ~XMLDeclarationNode (); + XMLNode* clone () const {return new XMLDeclarationNode(*this);} + void append (XMLNode *child); + std::ostream& write (std::ostream &os) const; + bool emit (std::ostream &os, XMLNode *stopElement); + + private: + std::string _name; + std::string _params; + std::list _children; + bool _emitted; +}; + + +class XMLCDataNode : public XMLNode +{ + public: + XMLCDataNode (const std::string &d) : _data(d) {} + XMLNode* clone () const {return new XMLCDataNode(*this);} + std::ostream& write (std::ostream &os) const; + + private: + std::string _data; +}; + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.cpp new file mode 100644 index 00000000000..326eaf89bdf --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.cpp @@ -0,0 +1,134 @@ +/************************************************************************* +** XMLString.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include "macros.h" +#include "XMLString.h" + +using namespace std; + +int XMLString::DECIMAL_PLACES = 0; + +static string translate (unsigned c) { + switch (c) { + case '<' : return "<"; + case '&' : return "&"; + case '"' : return """; + case '\'': return "'"; + } + ostringstream oss; + if (c >= 32 && c <= 126) + oss << char(c); + else + oss <<"&#" << unsigned(c) << ';'; + return oss.str(); +} + + +#if 0 +/** Returns the number of pre-decimal places of a given floating point value. */ +static int predecimal_places (double x) { + int n = abs(static_cast(x)); + int ret = (n == 0 ? 0 : 1); + while (n >= 10) { + ret++; + n /= 10; + } + return ret; +} +#endif + + +/** Rounds a floating point value to a given number of decimal places. + * @param[in] x number to round + * @param[in] n number of decimal places (must be between 1 and 6) + * @return rounded value */ +static inline double round (double x, long n) { + const long pow10[] = {10L, 100L, 1000L, 10000L, 100000L, 1000000L}; + n--; + return floor(x*pow10[n]+0.5)/pow10[n]; +} + + +XMLString::XMLString (const string &str, bool plain) { + if (plain) + *this = str; + else { + FORALL(str, string::const_iterator, i) + *this += translate(*i); + } +} + + +XMLString::XMLString (const char *str, bool plain) { + if (str) { + if (plain) + *this = str; + else { + while (*str) + *this += translate(*str++); + } + } +} + + +XMLString::XMLString (int n, bool cast) { + if (cast) { + stringstream ss; + ss << n; + ss >> *this; + } + else + *this += translate(n); +} + + +XMLString::XMLString (double x) { + stringstream ss; + if (DECIMAL_PLACES > 0) + x = round(x, DECIMAL_PLACES); + ss << x; + ss >> *this; +} + + +/* +ostream& XMLString::write (ostream &os) const { + const string *self = static_cast(this); + FORALL(*self, string::const_iterator, i) { + unsigned char c = *i; + switch (c) { + case '<' : os << "<"; break; + case '&' : os << "&"; break; + case '"' : os << """; break; + case '\'': os << "'"; break; + default : + if (c >= 32 && c <= 126) + os << c; + else + os << "&#" << int(c) << ';'; + } + } + return os; +} +*/ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.h new file mode 100644 index 00000000000..b1496b4a503 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/XMLString.h @@ -0,0 +1,40 @@ +/************************************************************************* +** XMLString.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef XMLSTRING_H +#define XMLSTRING_H + +#include + + +class XMLString : public std::string +{ + public: + XMLString () : std::string() {} + XMLString (const char *str, bool plain=false); + XMLString (const std::string &str, bool plain=false); + XMLString (int n, bool cast=true); + XMLString (double x); + + static int DECIMAL_PLACES; ///< number of decimal places applied to floating point values (0-6) +}; + + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/dvisvgm.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/dvisvgm.cpp new file mode 100644 index 00000000000..1ed18e007fb --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/dvisvgm.cpp @@ -0,0 +1,447 @@ +/************************************************************************* +** dvisvgm.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "gzstream.h" +#include "CommandLine.h" +#include "DVIToSVG.h" +#include "DVIToSVGActions.h" +#include "EPSToSVG.h" +#include "FileFinder.h" +#include "FilePath.h" +#include "FileSystem.h" +#include "Font.h" +#include "FontCache.h" +#include "FontEngine.h" +#include "FontMap.h" +#include "Ghostscript.h" +#include "HtmlSpecialHandler.h" +#include "InputReader.h" +#include "Message.h" +#include "PageSize.h" +#include "SignalHandler.h" +#include "SpecialManager.h" +#include "SVGOutputBase.h" +#include "System.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#include "PSInterpreter.h" +#endif +#ifndef TARGET_SYSTEM +#define TARGET_SYSTEM "" +#endif + +#ifdef __MSVC__ +#include +#else +extern "C" { +#include +} +#endif + +using namespace std; + +class SVGOutput : public SVGOutputBase +{ + public: + SVGOutput (const char *base=0, string pattern="", int zip_level=0) + : _path(base ? base : ""), + _pattern(pattern), + _stdout(base == 0), + _zipLevel(zip_level), + _page(-1), + _os(0) {} + + + ~SVGOutput () { + delete _os; + } + + + /** Returns an output stream for the given page. + * @param[in] page number of current page + * @param[in] numPages total number of pages in the DVI file + * @return output stream for the given page */ + ostream& getPageStream (int page, int numPages) const { + string fname = filename(page, numPages); + if (fname.empty()) { + delete _os; + _os = 0; + return cout; + } + if (page == _page) + return *_os; + + _page = page; + delete _os; + + if (_zipLevel > 0) + _os = new ogzstream(fname.c_str(), _zipLevel); + else + _os = new ofstream(fname.c_str()); + if (!_os || !*_os) { + delete _os; + _os = 0; + throw MessageException("can't open file "+fname+" for writing"); + } + return *_os; + } + + + /** Returns the name of the SVG file containing the given page. + * @param[in] page number of page */ + string filename (int page, int numPages) const { + if (_stdout) + return ""; + string fname = _pattern; + if (fname.empty()) + fname = numPages > 1 ? "%f-%p" : "%f"; + else if (numPages > 1 && fname.find("%p") == string::npos) + fname += FileSystem::isDirectory(fname.c_str()) ? "/%f-%p" : "-%p"; + + // replace pattern variables by their actual values + // %f: basename of the DVI file + // %p: current page number + ostringstream oss; + oss << setfill('0') << setw(max(2, int(1+log10((double)numPages)))) << page; + size_t pos=0; + while ((pos = fname.find('%', pos)) != string::npos && pos < fname.length()-1) { + switch (fname[pos+1]) { + case 'f': fname.replace(pos, 2, _path.basename()); pos += _path.basename().length(); break; + case 'p': fname.replace(pos, 2, oss.str()); pos += oss.str().length(); break; + default : ++pos; + } + } + FilePath outpath(fname, true); + if (outpath.suffix().empty()) + outpath.suffix(_zipLevel > 0 ? "svgz" : "svg"); + string apath = outpath.absolute(); + string rpath = outpath.relative(); + return apath.length() < rpath.length() ? apath : rpath; + } + + private: + FilePath _path; + string _pattern; + bool _stdout; + int _zipLevel; + mutable int _page; // number of current page being written + mutable ostream *_os; +}; + +//////////////////////////////////////////////////////////////////////////////// + +static void show_help (const CommandLine &cmd) { + cout << PACKAGE_STRING "\n\n"; + cmd.help(cmd.help_arg()); + cout << "\nCopyright (C) 2005-2013 Martin Gieseking \n\n"; +} + + +static string remove_path (string fname) { + fname = FileSystem::adaptPathSeperators(fname); + size_t slashpos = fname.rfind('/'); + if (slashpos == string::npos) + return fname; + return fname.substr(slashpos+1); +} + + +static string ensure_suffix (string fname, const string &suffix) { + size_t dotpos = remove_path(fname).rfind('.'); + if (dotpos == string::npos) + fname += "."+suffix; + return fname; +} + + +static string get_transformation_string (const CommandLine &args) { + ostringstream oss; + if (args.rotate_given()) + oss << 'R' << args.rotate_arg() << ",w/2,h/2"; + if (args.translate_given()) + oss << 'T' << args.translate_arg(); + if (args.scale_given()) + oss << 'S' << args.scale_arg(); + if (args.transform_given()) + oss << args.transform_arg(); + return oss.str(); +} + + +static void set_libgs (CommandLine &args) { +#if !defined(DISABLE_GS) && !defined(HAVE_LIBGS) + if (args.libgs_given()) + Ghostscript::LIBGS_NAME = args.libgs_arg(); + else if (getenv("LIBGS")) + Ghostscript::LIBGS_NAME = getenv("LIBGS"); +#ifdef MIKTEX + else { +#ifdef __WIN64__ + const char *gsdll = "mgsdll64.dll"; +#else + const char *gsdll = "mgsdll32.dll"; +#endif + // try to lookup the Ghostscript DLL coming with MiKTeX + if (const char *gsdll_path = FileFinder::lookup(gsdll)) + Ghostscript::LIBGS_NAME = gsdll_path; + } +#endif +#endif +} + + +static bool set_cache_dir (const CommandLine &args) { + if (args.cache_given() && !args.cache_arg().empty()) { + if (args.cache_arg() == "none") + PhysicalFont::CACHE_PATH = 0; + else if (FileSystem::exists(args.cache_arg().c_str())) + PhysicalFont::CACHE_PATH = args.cache_arg().c_str(); + else + Message::wstream(true) << "cache directory '" << args.cache_arg() << "' does not exist (caching disabled)\n"; + } + else { + if (const char *userdir = FileSystem::userdir()) { + static string path = userdir; + path += "/.dvisvgm"; + path = FileSystem::adaptPathSeperators(path); + const string cachepath = path+"/cache"; + if (!FileSystem::exists(cachepath.c_str())) { + if (!FileSystem::exists(path.c_str())) + FileSystem::mkdir(cachepath.c_str()); + else { + FileSystem::mkdir(cachepath.c_str()); + // move existing cache files from former location to new one + vector files; + FileSystem::collect(path.c_str(), files); + FORALL(files, vector::iterator, it) { + if (it->at(0) == 'f' && it->length() > 4 && it->substr(it->length()-4, 4) == ".fgd") { + const char *fname = it->c_str()+1; + FileSystem::copy(path+"/"+fname, cachepath+"/"+fname, true); + } + } + } + } + path = cachepath; + PhysicalFont::CACHE_PATH = path.c_str(); + } + if (args.cache_given() && args.cache_arg().empty()) { + cout << "cache directory: " << (PhysicalFont::CACHE_PATH ? PhysicalFont::CACHE_PATH : "(none)") << '\n'; + FontCache::fontinfo(PhysicalFont::CACHE_PATH, cout, true); + return false; + } + } + return true; +} + + +static bool check_bbox (const string &bboxstr) { + const char *formats[] = {"none", "min", "dvi", 0}; + for (const char **p=formats; *p; ++p) + if (bboxstr == *p) + return true; + if (isalpha(bboxstr[0])) { + try { + PageSize size(bboxstr); + return true; + } + catch (const PageSizeException &e) { + Message::estream(true) << "invalid bounding box format '" << bboxstr << "'\n"; + return false; + } + } + try { + BoundingBox bbox; + bbox.set(bboxstr); + return true; + } + catch (const MessageException &e) { + Message::estream(true) << e.what() << '\n'; + return false; + } +} + + +static void print_version (bool extended) { + ostringstream oss; + oss << PACKAGE_STRING; + if (extended) { + if (strlen(TARGET_SYSTEM) > 0) + oss << " (" TARGET_SYSTEM ")"; + oss << "\n" << string(oss.str().length()-1, '-') << "\n" + "freetype: " << FontEngine::version() << "\n"; + + string gsver; + Ghostscript gs; + gsver = gs.revision(true); + if (!gsver.empty()) + oss << "Ghostscript: " << gsver + "\n"; + oss << +#ifdef MIKTEX + "MiKTeX: " << FileFinder::version() << "\n" +#else + "kpathsea: " << FileFinder::version() << "\n" +#endif + "potrace: " << (strchr(potrace_version(), ' ') ? strchr(potrace_version(), ' ')+1 : "unknown") << "\n" + "zlib: " << zlibVersion(); + } + cout << oss.str() << endl; +} + + +static void init_fontmap (const CommandLine &args) { + const char *mapseq = args.fontmap_given() ? args.fontmap_arg().c_str() : 0; + bool additional = mapseq && strchr("+-=", *mapseq); + if (!mapseq || additional) { + const char *mapfiles[] = {"ps2pk.map", "dvipdfm.map", "psfonts.map", 0}; + bool found = false; + for (const char **p=mapfiles; *p && !found; p++) + found = FontMap::instance().read(*p); + if (!found) + Message::wstream(true) << "none of the default map files could be found"; + } + if (mapseq) + FontMap::instance().read(mapseq); +} + + +int main (int argc, char *argv[]) { + CommandLine args; + args.parse(argc, argv); + if (args.error()) + return 1; + + Message::COLORIZE = args.color_given(); + + try { + FileFinder::init(argv[0], "dvisvgm", !args.no_mktexmf_given()); + } + catch (MessageException &e) { + Message::estream(true) << e.what() << '\n'; + return 0; + } + + set_libgs(args); + if (args.version_given()) { + print_version(args.version_arg()); + return 0; + } + if (args.list_specials_given()) { + SVGOutput out; + DVIToSVG dvisvg(cin, out); + if (const SpecialManager *sm = dvisvg.setProcessSpecials()) + sm->writeHandlerInfo(cout); + return 0; + } + + if (!set_cache_dir(args)) + return 0; + + if (argc == 1 || args.help_given()) { + show_help(args); + return 0; + } + + if (argc > 1 && args.numFiles() < 1) { + Message::estream(true) << "no input file given\n"; + return 1; + } + + if (args.stdout_given() && args.zip_given()) { + Message::estream(true) << "writing SVGZ files to stdout is not supported\n"; + return 1; + } + + if (!check_bbox(args.bbox_arg())) + return 1; + + if (args.progress_given()) { + DVIReader::COMPUTE_PAGE_LENGTH = args.progress_given(); + DVIToSVGActions::PROGRESSBAR_DELAY = args.progress_arg(); + } + SVGTree::CREATE_STYLE = !args.no_styles_given(); + SVGTree::USE_FONTS = !args.no_fonts_given(); + SVGTree::CREATE_USE_ELEMENTS = args.no_fonts_arg() < 1; + DVIToSVGActions::EXACT_BBOX = args.exact_given(); + DVIToSVG::TRACE_MODE = args.trace_all_given() ? (args.trace_all_arg() ? 'a' : 'm') : 0; + Message::LEVEL = args.verbosity_arg(); + PhysicalFont::KEEP_TEMP_FILES = args.keep_given(); + PhysicalFont::METAFONT_MAG = args.mag_arg(); + XMLString::DECIMAL_PLACES = max(0, min(6, args.precision_arg())); + HtmlSpecialHandler::LINK_MARKER = + args.linkmark_arg() == "line" ? HtmlSpecialHandler::LM_LINE : + args.linkmark_arg() == "box" ? HtmlSpecialHandler::LM_BOX : HtmlSpecialHandler::LM_NONE; + + double start_time = System::time(); + string inputfile = ensure_suffix(args.file(0), args.eps_given() ? "eps" : "dvi"); + ifstream ifs(inputfile.c_str(), ios_base::binary|ios_base::in); + if (!ifs) { + Message::estream(true) << "can't open file '" << inputfile << "' for reading\n"; + return 0; + } + try { + SVGOutput out(args.stdout_given() ? 0 : inputfile.c_str(), args.output_arg(), args.zip_given() ? args.zip_arg() : 0); + SignalHandler::instance().start(); + if (args.eps_given()) { + EPSToSVG eps2svg(inputfile, out); + eps2svg.convert(); + Message::mstream().indent(0); + Message::mstream(false, Message::MC_PAGE_NUMBER) + << "file converted in " << (System::time()-start_time) << " seconds\n"; + } + else { + DVIToSVG dvi2svg(ifs, out); + const char *ignore_specials = args.no_specials_given() ? (args.no_specials_arg().empty() ? "*" : args.no_specials_arg().c_str()) : 0; + dvi2svg.setProcessSpecials(ignore_specials, true); + dvi2svg.setTransformation(get_transformation_string(args)); + dvi2svg.setPageSize(args.bbox_arg()); + + init_fontmap(args); + pair pageinfo; + dvi2svg.convert(args.page_arg(), &pageinfo); + Message::mstream().indent(0); + Message::mstream(false, Message::MC_PAGE_NUMBER) << "\n" << pageinfo.first << " of " << pageinfo.second << " page"; + if (pageinfo.second > 1) + Message::mstream(false, Message::MC_PAGE_NUMBER) << 's'; + Message::mstream(false, Message::MC_PAGE_NUMBER) << " converted in " << (System::time()-start_time) << " seconds\n"; + } + } + catch (DVIException &e) { + Message::estream() << "\nDVI error: " << e.what() << '\n'; + } + catch (PSException &e) { + Message::estream() << "\nPostScript error: " << e.what() << '\n'; + } + catch (SignalException &e) { + Message::wstream(true) << "execution interrupted by user\n"; + } + catch (MessageException &e) { + Message::estream(true) << e.what() << '\n'; + } + FileFinder::finish(); + return 0; +} + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.cpp new file mode 100644 index 00000000000..2893c299891 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.cpp @@ -0,0 +1,172 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.C +// Revision : $Revision: 1.3 $ +// Revision_date : $Date: 2006/01/05 16:22:35 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#include "gzstream.h" +#include +#include // for memcpy + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +const int gzstreambuf::bufferSize = 47+256; // size of data buff + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See header file for user classes. +// ---------------------------------------------------------------------------- + +// -------------------------------------- +// class gzstreambuf: +// -------------------------------------- + +gzstreambuf* gzstreambuf::open(const char* name, int compression_level, int open_mode) { + if ( is_open()) + return (gzstreambuf*)0; + mode = open_mode; + // no append nor read/write mode + if ((mode & std::ios::ate) || (mode & std::ios::app) + || ((mode & std::ios::in) && (mode & std::ios::out))) + return (gzstreambuf*)0; + if (compression_level < 1) + compression_level = 1; + else if (compression_level > 9) + compression_level = 9; + char fmode[10]; + char* fmodeptr = fmode; + if ( mode & std::ios::in) + *fmodeptr++ = 'r'; + else if ( mode & std::ios::out) + *fmodeptr++ = 'w'; + *fmodeptr++ = 'b'; + *fmodeptr++ = '0'+compression_level; + *fmodeptr = '\0'; + file = gzopen( name, fmode); + if (file == 0) + return (gzstreambuf*)0; + opened = 1; + return this; +} + +gzstreambuf * gzstreambuf::close() { + if ( is_open()) { + sync(); + opened = 0; + if ( gzclose( file) == Z_OK) + return this; + } + return (gzstreambuf*)0; +} + +int gzstreambuf::underflow() { // used for input buffer only + if ( gptr() && ( gptr() < egptr())) + return * reinterpret_cast( gptr()); + + if ( ! (mode & std::ios::in) || ! opened) + return EOF; + // Josuttis' implementation of inbuf + int n_putback = gptr() - eback(); + if ( n_putback > 4) + n_putback = 4; + memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback); + + int num = gzread( file, buffer+4, bufferSize-4); + if (num <= 0) // ERROR or EOF + return EOF; + + // reset buffer pointers + setg( buffer + (4 - n_putback), // beginning of putback area + buffer + 4, // read position + buffer + 4 + num); // end of buffer + + // return next character + return * reinterpret_cast( gptr()); +} + +int gzstreambuf::flush_buffer() { + // Separate the writing of the buffer from overflow() and + // sync() operation. + int w = pptr() - pbase(); + if ( gzwrite( file, pbase(), w) != w) + return EOF; + pbump( -w); + return w; +} + +int gzstreambuf::overflow( int c) { // used for output buffer only + if ( ! ( mode & std::ios::out) || ! opened) + return EOF; + if (c != EOF) { + *pptr() = c; + pbump(1); + } + if ( flush_buffer() == EOF) + return EOF; + return c; +} + +int gzstreambuf::sync() { + // Changed to use flush_buffer() instead of overflow( EOF) + // which caused improper behavior with std::endl and flush(), + // bug reported by Vincent Ricard. + if ( pptr() && pptr() > pbase()) { + if ( flush_buffer() == EOF) + return -1; + } + return 0; +} + +// -------------------------------------- +// class gzstreambase: +// -------------------------------------- + +gzstreambase::gzstreambase( const char* name, int compression_level, int mode) { + init( &buf); + open( name, compression_level, mode); +} + +gzstreambase::~gzstreambase() { + buf.close(); +} + +void gzstreambase::open( const char* name, int compression_level, int open_mode) { + if ( ! buf.open( name, compression_level, open_mode)) + clear( rdstate() | std::ios::badbit); +} + +void gzstreambase::close() { + if ( buf.is_open()) + if ( ! buf.close()) + clear( rdstate() | std::ios::badbit); +} + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +// ============================================================================ +// EOF // diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.h new file mode 100644 index 00000000000..60f38c4fac7 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/gzstream.h @@ -0,0 +1,121 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.h +// Revision : $Revision: 1.3 $ +// Revision_date : $Date: 2006/01/05 16:22:35 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#ifndef GZSTREAM_H +#define GZSTREAM_H 1 + +// standard C++ with new header file names and std:: namespace +#include +#include +#include + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See below for user classes. +// ---------------------------------------------------------------------------- + +class gzstreambuf : public std::streambuf { +private: + static const int bufferSize; // size of data buff + // totals 512 bytes under g++ for igzstream at the end. + + gzFile file; // file handle for compressed file + char buffer[47+256]; // data buffer + char opened; // open/close state of stream + int mode; // I/O mode + + int flush_buffer(); +public: + gzstreambuf() : opened(0) { + setp( buffer, buffer + (bufferSize-1)); + setg( buffer + 4, // beginning of putback area + buffer + 4, // read position + buffer + 4); // end position + // ASSERT: both input & output capabilities will not be used together + } + int is_open() { return opened; } + gzstreambuf* open(const char* name, int compression_level, int open_mode); + gzstreambuf* close(); + ~gzstreambuf() { close(); } + + virtual int overflow( int c = EOF); + virtual int underflow(); + virtual int sync(); +}; + +class gzstreambase : virtual public std::ios { +protected: + gzstreambuf buf; +public: + gzstreambase() { init(&buf); } + gzstreambase( const char* name, int compression_level, int open_mode); + ~gzstreambase(); + void open( const char* name, int compression_level, int open_mode); + void close(); + gzstreambuf* rdbuf() { return &buf; } +}; + +// ---------------------------------------------------------------------------- +// User classes. Use igzstream and ogzstream analogously to ifstream and +// ofstream respectively. They read and write files based on the gz* +// function interface of the zlib. Files are compatible with gzip compression. +// ---------------------------------------------------------------------------- + +class igzstream : public gzstreambase, public std::istream { +public: + igzstream() : std::istream( &buf) {} + igzstream( const char* name, int compression_level, int open_mode = std::ios::in) + : gzstreambase(name, compression_level, open_mode), std::istream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int compression_level, int open_mode = std::ios::in) { + gzstreambase::open( name, compression_level, open_mode); + } +}; + +class ogzstream : public gzstreambase, public std::ostream { +public: + ogzstream() : std::ostream( &buf) {} + ogzstream( const char* name, int compression_level, int mode = std::ios::out) + : gzstreambase(name, compression_level, mode), std::ostream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int compression_level, int open_mode = std::ios::out) { + gzstreambase::open(name, compression_level, open_mode); + } +}; + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +#endif // GZSTREAM_H +// ============================================================================ +// EOF // + diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/iapi.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/iapi.h new file mode 100644 index 00000000000..8e29d938d03 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/iapi.h @@ -0,0 +1,300 @@ +/* Copyright (C) 2001-2006 Artifex Software, Inc. + All Rights Reserved. + + This software is provided AS-IS with no warranty, either express or + implied. + + This software is distributed under license and may not be copied, modified + or distributed except as expressly authorized under the terms of that + license. Refer to licensing information at http://www.artifex.com/ + or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, + San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. +*/ + +/* $Id: iapi.h 9043 2008-08-28 22:48:19Z giles $ */ + +/* + * Public API for Ghostscript interpreter + * for use both as DLL and for static linking. + * + * Should work for Windows, OS/2, Linux, Mac. + * + * DLL exported functions should be as similar as possible to imain.c + * You will need to include "ierrors.h". + * + * Current problems: + * 1. Ghostscript does not support multiple instances. + * 2. Global variables in gs_main_instance_default() + * and gsapi_instance_counter + */ + +/* Exported functions may need different prefix + * GSDLLEXPORT marks functions as exported + * GSDLLAPI is the calling convention used on functions exported + * by Ghostscript + * GSDLLCALL is used on callback functions called by Ghostscript + * When you include this header file in the caller, you may + * need to change the definitions by defining these + * before including this header file. + * Make sure you get the calling convention correct, otherwise your + * program will crash either during callbacks or soon after returning + * due to stack corruption. + */ + +#ifndef iapi_INCLUDED +# define iapi_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WINDOWS_) || defined(__WINDOWS__) +# ifndef _Windows +# define _Windows +# endif +#endif + +#ifdef _Windows +# ifndef GSDLLEXPORT +# define GSDLLEXPORT __declspec(dllexport) +# endif +# ifndef GSDLLAPI +# define GSDLLAPI __stdcall +# endif +# ifndef GSDLLCALL +# define GSDLLCALL __stdcall +# endif +#endif /* _Windows */ + +#if defined(OS2) && defined(__IBMC__) +# ifndef GSDLLAPI +# define GSDLLAPI _System +# endif +# ifndef GSDLLCALL +# define GSDLLCALL _System +# endif +#endif /* OS2 && __IBMC */ + +#ifdef __MACOS__ +# pragma export on +#endif + +#ifndef GSDLLEXPORT +# define GSDLLEXPORT +#endif +#ifndef GSDLLAPI +# define GSDLLAPI +#endif +#ifndef GSDLLCALL +# define GSDLLCALL +#endif + +#if defined(__IBMC__) +# define GSDLLAPIPTR * GSDLLAPI +# define GSDLLCALLPTR * GSDLLCALL +#else +# define GSDLLAPIPTR GSDLLAPI * +# define GSDLLCALLPTR GSDLLCALL * +#endif + +#ifndef display_callback_DEFINED +# define display_callback_DEFINED +typedef struct display_callback_s display_callback; +#endif + +typedef struct gsapi_revision_s { + const char *product; + const char *copyright; + long revision; + long revisiondate; +} gsapi_revision_t; + + +/* Get version numbers and strings. + * This is safe to call at any time. + * You should call this first to make sure that the correct version + * of the Ghostscript is being used. + * pr is a pointer to a revision structure. + * len is the size of this structure in bytes. + * Returns 0 if OK, or if len too small (additional parameters + * have been added to the structure) it will return the required + * size of the structure. + */ +GSDLLEXPORT int GSDLLAPI +gsapi_revision(gsapi_revision_t *pr, int len); + +/* + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * Ghostscript supports only one instance. + * The current implementation uses a global static instance + * counter to make sure that only a single instance is used. + * If you try to create two instances, the second attempt + * will return < 0 and set pinstance to NULL. + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ +/* Create a new instance of Ghostscript. + * This instance is passed to most other API functions. + * The caller_handle will be provided to callback functions. + */ + +GSDLLEXPORT int GSDLLAPI +gsapi_new_instance(void **pinstance, void *caller_handle); + +/* + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * Ghostscript supports only one instance. + * The current implementation uses a global static instance + * counter to make sure that only a single instance is used. + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ +/* Destroy an instance of Ghostscript + * Before you call this, Ghostscript must have finished. + * If Ghostscript has been initialised, you must call gsapi_exit() + * before gsapi_delete_instance. + */ +GSDLLEXPORT void GSDLLAPI +gsapi_delete_instance(void *instance); + +/* Set the callback functions for stdio + * The stdin callback function should return the number of + * characters read, 0 for EOF, or -1 for error. + * The stdout and stderr callback functions should return + * the number of characters written. + * If a callback address is NULL, the real stdio will be used. + */ +GSDLLEXPORT int GSDLLAPI +gsapi_set_stdio(void *instance, + int (GSDLLCALLPTR stdin_fn)(void *caller_handle, char *buf, int len), + int (GSDLLCALLPTR stdout_fn)(void *caller_handle, const char *str, int len), + int (GSDLLCALLPTR stderr_fn)(void *caller_handle, const char *str, int len)); + +/* Set the callback function for polling. + * This is used for handling window events or cooperative + * multitasking. This function will only be called if + * Ghostscript was compiled with CHECK_INTERRUPTS + * as described in gpcheck.h. + * The polling function should return 0 if all is well, + * and negative if it wants ghostscript to abort. + * The polling function must be fast. + */ +GSDLLEXPORT int GSDLLAPI gsapi_set_poll(void *instance, + int (GSDLLCALLPTR poll_fn)(void *caller_handle)); + +/* Set the display device callback structure. + * If the display device is used, this must be called + * after gsapi_new_instance() and before gsapi_init_with_args(). + * See gdevdisp.h for more details. + */ +GSDLLEXPORT int GSDLLAPI gsapi_set_display_callback( + void *instance, display_callback *callback); + + +/* Initialise the interpreter. + * This calls gs_main_init_with_args() in imainarg.c + * 1. If quit or EOF occur during gsapi_init_with_args(), + * the return value will be e_Quit. This is not an error. + * You must call gsapi_exit() and must not call any other + * gsapi_XXX functions. + * 2. If usage info should be displayed, the return value will be e_Info + * which is not an error. Do not call gsapi_exit(). + * 3. Under normal conditions this returns 0. You would then + * call one or more gsapi_run_*() functions and then finish + * with gsapi_exit(). + */ +GSDLLEXPORT int GSDLLAPI gsapi_init_with_args(void *instance, + int argc, char **argv); + +/* + * The gsapi_run_* functions are like gs_main_run_* except + * that the error_object is omitted. + * If these functions return <= -100, either quit or a fatal + * error has occured. You then call gsapi_exit() next. + * The only exception is gsapi_run_string_continue() + * which will return e_NeedInput if all is well. + */ + +GSDLLEXPORT int GSDLLAPI +gsapi_run_string_begin(void *instance, + int user_errors, int *pexit_code); + +GSDLLEXPORT int GSDLLAPI +gsapi_run_string_continue(void *instance, + const char *str, unsigned int length, int user_errors, int *pexit_code); + +GSDLLEXPORT int GSDLLAPI +gsapi_run_string_end(void *instance, + int user_errors, int *pexit_code); + +GSDLLEXPORT int GSDLLAPI +gsapi_run_string_with_length(void *instance, + const char *str, unsigned int length, int user_errors, int *pexit_code); + +GSDLLEXPORT int GSDLLAPI +gsapi_run_string(void *instance, + const char *str, int user_errors, int *pexit_code); + +GSDLLEXPORT int GSDLLAPI +gsapi_run_file(void *instance, + const char *file_name, int user_errors, int *pexit_code); + + +/* Exit the interpreter. + * This must be called on shutdown if gsapi_init_with_args() + * has been called, and just before gsapi_delete_instance(). + */ +GSDLLEXPORT int GSDLLAPI +gsapi_exit(void *instance); + +/* Visual Tracer */ +/* This function is only for debug purpose clients */ +struct vd_trace_interface_s; +GSDLLEXPORT void GSDLLAPI +gsapi_set_visual_tracer(struct vd_trace_interface_s *I); + + +/* function prototypes */ +typedef int (GSDLLAPIPTR PFN_gsapi_revision)( + gsapi_revision_t *pr, int len); +typedef int (GSDLLAPIPTR PFN_gsapi_new_instance)( + void **pinstance, void *caller_handle); +typedef void (GSDLLAPIPTR PFN_gsapi_delete_instance)( + void *instance); +typedef int (GSDLLAPIPTR PFN_gsapi_set_stdio)(void *instance, + int (GSDLLCALLPTR stdin_fn)(void *caller_handle, char *buf, int len), + int (GSDLLCALLPTR stdout_fn)(void *caller_handle, const char *str, int len), + int (GSDLLCALLPTR stderr_fn)(void *caller_handle, const char *str, int len)); +typedef int (GSDLLAPIPTR PFN_gsapi_set_poll)(void *instance, + int(GSDLLCALLPTR poll_fn)(void *caller_handle)); +typedef int (GSDLLAPIPTR PFN_gsapi_set_display_callback)( + void *instance, display_callback *callback); +typedef int (GSDLLAPIPTR PFN_gsapi_init_with_args)( + void *instance, int argc, char **argv); +typedef int (GSDLLAPIPTR PFN_gsapi_run_string_begin)( + void *instance, int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_run_string_continue)( + void *instance, const char *str, unsigned int length, + int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_run_string_end)( + void *instance, int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_run_string_with_length)( + void *instance, const char *str, unsigned int length, + int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_run_string)( + void *instance, const char *str, + int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_run_file)(void *instance, + const char *file_name, int user_errors, int *pexit_code); +typedef int (GSDLLAPIPTR PFN_gsapi_exit)(void *instance); +typedef void (GSDLLAPIPTR PFN_gsapi_set_visual_tracer) + (struct vd_trace_interface_s *I); + + +#ifdef __MACOS__ +#pragma export off +#endif + +#ifdef __cplusplus +} /* extern 'C' protection */ +#endif + +#endif /* iapi_INCLUDED */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ierrors.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ierrors.h new file mode 100644 index 00000000000..3184341177e --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/ierrors.h @@ -0,0 +1,153 @@ +/* Copyright (C) 2001-2006 Artifex Software, Inc. + All Rights Reserved. + + This software is provided AS-IS with no warranty, either express or + implied. + + This software is distributed under license and may not be copied, modified + or distributed except as expressly authorized under the terms of that + license. Refer to licensing information at http://www.artifex.com/ + or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, + San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. +*/ + +/* $Id: ierrors.h 8022 2007-06-05 22:23:38Z giles $ */ +/* Definition of error codes */ + +#ifndef ierrors_INCLUDED +# define ierrors_INCLUDED + +/* + * DO NOT USE THIS FILE IN THE GRAPHICS LIBRARY. + * THIS FILE IS PART OF THE POSTSCRIPT INTERPRETER. + * USE gserrors.h IN THE LIBRARY. + */ + +/* + * A procedure that may return an error always returns + * a non-negative value (zero, unless otherwise noted) for success, + * or negative for failure. + * We use ints rather than an enum to avoid a lot of casting. + */ + +/* Define the error name table */ +extern const char *const gs_error_names[]; + + /* ------ PostScript Level 1 errors ------ */ + +#define e_unknownerror (-1) /* unknown error */ +#define e_dictfull (-2) +#define e_dictstackoverflow (-3) +#define e_dictstackunderflow (-4) +#define e_execstackoverflow (-5) +#define e_interrupt (-6) +#define e_invalidaccess (-7) +#define e_invalidexit (-8) +#define e_invalidfileaccess (-9) +#define e_invalidfont (-10) +#define e_invalidrestore (-11) +#define e_ioerror (-12) +#define e_limitcheck (-13) +#define e_nocurrentpoint (-14) +#define e_rangecheck (-15) +#define e_stackoverflow (-16) +#define e_stackunderflow (-17) +#define e_syntaxerror (-18) +#define e_timeout (-19) +#define e_typecheck (-20) +#define e_undefined (-21) +#define e_undefinedfilename (-22) +#define e_undefinedresult (-23) +#define e_unmatchedmark (-24) +#define e_VMerror (-25) /* must be the last Level 1 error */ + +#define LEVEL1_ERROR_NAMES\ + "unknownerror", "dictfull", "dictstackoverflow", "dictstackunderflow",\ + "execstackoverflow", "interrupt", "invalidaccess", "invalidexit",\ + "invalidfileaccess", "invalidfont", "invalidrestore", "ioerror",\ + "limitcheck", "nocurrentpoint", "rangecheck", "stackoverflow",\ + "stackunderflow", "syntaxerror", "timeout", "typecheck", "undefined",\ + "undefinedfilename", "undefinedresult", "unmatchedmark", "VMerror" + + /* ------ Additional Level 2 errors (also in DPS) ------ */ + +#define e_configurationerror (-26) +#define e_undefinedresource (-27) +#define e_unregistered (-28) + +#define LEVEL2_ERROR_NAMES\ + "configurationerror", "undefinedresource", "unregistered" + + /* ------ Additional DPS errors ------ */ + +#define e_invalidcontext (-29) +/* invalidid is for the NeXT DPS extension. */ +#define e_invalidid (-30) + +#define DPS_ERROR_NAMES\ + "invalidcontext", "invalidid" + +#define ERROR_NAMES\ + LEVEL1_ERROR_NAMES, LEVEL2_ERROR_NAMES, DPS_ERROR_NAMES + + /* ------ Pseudo-errors used internally ------ */ + +/* + * Internal code for a fatal error. + * gs_interpret also returns this for a .quit with a positive exit code. + */ +#define e_Fatal (-100) + +/* + * Internal code for the .quit operator. + * The real quit code is an integer on the operand stack. + * gs_interpret returns this only for a .quit with a zero exit code. + */ +#define e_Quit (-101) + +/* + * Internal code for a normal exit from the interpreter. + * Do not use outside of interp.c. + */ +#define e_InterpreterExit (-102) + +/* + * Internal code that indicates that a procedure has been stored in the + * remap_proc of the graphics state, and should be called before retrying + * the current token. This is used for color remapping involving a call + * back into the interpreter -- inelegant, but effective. + */ +#define e_RemapColor (-103) + +/* + * Internal code to indicate we have underflowed the top block + * of the e-stack. + */ +#define e_ExecStackUnderflow (-104) + +/* + * Internal code for the vmreclaim operator with a positive operand. + * We need to handle this as an error because otherwise the interpreter + * won't reload enough of its state when the operator returns. + */ +#define e_VMreclaim (-105) + +/* + * Internal code for requesting more input from run_string. + */ +#define e_NeedInput (-106) + +/* + * Internal code for a normal exit when usage info is displayed. + * This allows Window versions of Ghostscript to pause until + * the message can be read. + */ +#define e_Info (-110) + +/* + * Define which error codes require re-executing the current object. + */ +#define ERROR_IS_INTERRUPT(ecode)\ + ((ecode) == e_interrupt || (ecode) == e_timeout) + +#endif /* ierrors_INCLUDED */ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/macros.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/macros.h new file mode 100644 index 00000000000..8935b9babe9 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/macros.h @@ -0,0 +1,42 @@ +/************************************************************************* +** macros.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef MACROS_H +#define MACROS_H + +#define FORALL(container, itertype, itervar) \ + for (itertype itervar=(container).begin(); itervar != (container).end(); ++itervar) + +#define IMPLEMENT_ARITHMETIC_OPERATOR(class, op) \ + inline class operator op (class a, const class &b) { \ + return a op##= b; \ + } + +#define IMPLEMENT_ARITHMETIC_OPERATOR2(class, scalar, op) \ + inline class operator op (class a, scalar b) { \ + return a op##= b; \ + } + +#define IMPLEMENT_OUTPUT_OPERATOR(class) \ + inline std::ostream& operator << (std::ostream &os, class obj) { \ + return obj.write(os); \ + } + +#endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/options.xml b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/options.xml new file mode 100644 index 00000000000..ea0a6f6db95 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/options.xml @@ -0,0 +1,151 @@ + + + + + + + dvisvgm + [options] dvifile + -E [options] epsfile + This program converts DVI files, as created by TeX/LaTeX, to\nthe XML-based scalable vector graphics format SVG. + + +
+ + + +
+
+ + + + + + + + +
+
+ + + + +
+
+ + + + + + + + +
+
+ + + + + + +
+
+
+ diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/psdefs.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/psdefs.cpp new file mode 100644 index 00000000000..259105a3529 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/psdefs.cpp @@ -0,0 +1,84 @@ +/************************************************************************* +** psdefs.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#include "PSInterpreter.h" + +const char *PSInterpreter::PSDEFS = +"3 dict dup begin/Install{matrix setmatrix}def/HWResolution[72 72]def/PageSize[10" +"000 10000]def end setpagedevice/@dodraw true store/@patcnt 0 store/@SD systemdic" +"t def/@UD userdict def true setglobal @SD/:save @SD/save get put @SD/:restore @S" +"D/restore get put @SD/:gsave @SD/gsave get put @SD/:grestore @SD/grestore get pu" +"t @SD/:grestoreall @SD/grestoreall get put @SD/:stroke @SD/stroke get put @SD/:f" +"ill @SD/fill get put @SD/:eofill @SD/eofill get put @SD/:clip @SD/clip get put @" +"SD/:eoclip @SD/eoclip get put @SD/:charpath @SD/charpath get put @SD/:show @SD/s" +"how get put @SD/.setopacityalpha known not{@SD/.setopacityalpha{pop}put}if @SD/p" +"rval{dup type/stringtype eq{print}{30 string cvs print}ifelse}put @SD/prseq{-1 1" +"{-1 roll prval( )print}for(\\n)print}put @SD/prcmd{( )exch(\\ndvi.)3{print}repea" +"t prseq}put @SD/cvxall{{cvx}forall}put @SD/defpr{[exch[/copy @SD]cvxall 5 -1 rol" +"l dup 6 1 roll[/get/exec]cvxall 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 1 roll du" +"p length string cvs/prcmd cvx]cvx def}put @SD/querypos{{currentpoint}stopped{$er" +"ror/newerror false put}{2(querypos)prcmd}ifelse}put @SD/applyscalevals{1 0 trans" +"form 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 0 1 trans" +"form 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 1 0 trans" +"form dup mul exch dup dup mul 3 -1 roll add sqrt div 3(applyscalevals)prcmd}def " +"@SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)prcmd}{0(closepath)prcmd}p" +"athforall}put @SD/charpath{/@dodraw false store :charpath/@dodraw true store}put" +" @SD/show{@dodraw{dup :gsave true charpath eofill :grestore :show}if}put @SD/str" +"oke{@dodraw{0(newpath)prcmd prpath 0(stroke)prcmd newpath}{:stroke}ifelse}put @S" +"D/fill{@dodraw{0(newpath)prcmd prpath 0(fill)prcmd newpath}{:fill}ifelse}put @SD" +"/eofill{@dodraw{0(newpath)prcmd prpath 0(eofill)prcmd newpath}{:eofill}ifelse}pu" +"t @SD/clip{:clip 0(newpath)prcmd prpath 0(clip)prcmd}put @SD/eoclip{:eoclip 0(ne" +"wpath)prcmd prpath 0(eoclip)prcmd}put @SD/bop{pop pop}put/@rect{4 -2 roll moveto" +" exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def/@rectcc" +"{4 -2 roll moveto 2 copy 0 lt exch 0 lt xor{dup 0 exch rlineto exch 0 rlineto ne" +"g 0 exch rlineto}{exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto}ifelse cl" +"osepath}bind def @SD/rectclip{newpath dup type/arraytype eq{aload length 4 idiv{" +"@rectcc}repeat}{@rectcc}ifelse clip newpath}put @SD/rectfill{gsave newpath dup t" +"ype/arraytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifelse fill grestor" +"e}put @SD/rectstroke{gsave newpath dup type/arraytype eq{aload length 4 idiv{@re" +"ct}repeat}{@rect}ifelse stroke grestore}put false setglobal @SD readonly pop/ini" +"tclip 0 defpr/sysexec{@SD exch get exec}def/adddot{dup length 1 add string dup 0" +" 46 put dup 3 -1 roll 1 exch putinterval}def/setlinewidth{dup/setlinewidth sysex" +"ec applyscalevals 1(setlinewidth)prcmd}def/setlinecap 1 defpr/setlinejoin 1 defp" +"r/setmiterlimit 1 defpr/setdash{mark 3 1 roll 2 copy/setdash sysexec applyscalev" +"als exch aload length 1 add -1 roll counttomark(setdash)prcmd pop}def/setgstate{" +"currentlinewidth 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentl" +"inejoin 1(setlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd currentrgbco" +"lor 3(setrgbcolor)prcmd 6 array currentmatrix aload pop 6(setmatrix)prcmd curren" +"tdash mark 3 1 roll exch aload length 1 add -1 roll counttomark(setdash)prcmd po" +"p}def/save{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)prcmd" +"}def/restore{:restore setgstate @UD/@saveID known{@UD begin @saveID end}{0}ifels" +"e 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore setgstate 0(grestore)prcm" +"d}def/grestoreall{:grestoreall setstate 0(grestoreall)prcmd}def/rotate{dup type/" +"arraytype ne{dup 1(rotate)prcmd}if/rotate sysexec}def/scale{dup type/arraytype n" +"e{2 copy 2(scale)prcmd}if/scale sysexec}def/translate{dup type/arraytype ne{2 co" +"py 2(translate)prcmd}if/translate sysexec}def/setmatrix{dup/setmatrix sysexec al" +"oad pop 6(setmatrix)prcmd}def/initmatrix{matrix setmatrix}def/concat{matrix curr" +"entmatrix matrix concatmatrix setmatrix}def/makepattern{gsave <>" +" begin dup/XUID[1000000 @patcnt]put mx/makepattern sysexec dup dup begin Pattern" +"Type @patcnt BBox aload pop XStep YStep PaintType mx aload pop 15(makepattern)pr" +"cmd newpath matrix setmatrix PaintProc 0 1(makepattern)prcmd end/@patcnt @patcnt" +" 1 add store end grestore}def/setpattern{begin PatternType 1 eq{PaintType 1 eq{X" +"UID aload pop exch pop 1}{:gsave[currentcolorspace aload length -1 roll pop]setc" +"olorspace/setcolor sysexec XUID aload pop exch pop currentrgbcolor :grestore 4}i" +"felse(setpattern)prcmd}{/setpattern sysexec}ifelse end}def/setcolor{dup type/dic" +"ttype eq{setpattern}{/setcolor sysexec}ifelse}def/setgray 1 defpr/setcmykcolor 4" +" defpr/sethsbcolor 3 defpr/setrgbcolor 3 defpr/.setopacityalpha{dup/.setopacitya" +"lpha sysexec 1(setopacityalpha)prcmd}def "; diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.3/src/types.h b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/types.h new file mode 100644 index 00000000000..c22d0e1bf47 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.3/src/types.h @@ -0,0 +1,84 @@ +/************************************************************************* +** types.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2013 Martin Gieseking ** +** ** +** 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 . ** +*************************************************************************/ + +#ifndef TYPES_H +#define TYPES_H + +namespace internal { + template + class ERROR_inttype_not_available + { + ERROR_inttype_not_available(); + }; + + template + struct select + { + typedef A T; + }; + + template + struct select + { + typedef B T; + }; +} + + +// Retrieves a signed integer type with sizeof(T) == BYTES +template +struct int_t +{ + typedef typename internal::select >::T>::T>::T>::T>::T T; +}; + + +// Retrieves an unsigned integer type with sizeof(T) == BYTES +template +struct int_t +{ + typedef typename internal::select >::T>::T>::T>::T>::T T; +}; + + +// Machine independent definition of sized integer types +typedef int_t<1, true>::T Int8; +typedef int_t<2, true>::T Int16; +typedef int_t<4, true>::T Int32; +typedef int_t<8, true>::T Int64; +typedef int_t<1, false>::T UInt8; +typedef int_t<2, false>::T UInt16; +typedef int_t<4, false>::T UInt32; +typedef int_t<8, false>::T UInt64; + +typedef Int32 FixWord; +typedef UInt32 ScaledInt; + +#endif diff --git a/Build/source/texk/dvisvgm/version.ac b/Build/source/texk/dvisvgm/version.ac index cb3a960a68a..1793998a023 100644 --- a/Build/source/texk/dvisvgm/version.ac +++ b/Build/source/texk/dvisvgm/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current dvisvgm version -m4_define([dvisvgm_version], [1.2.2]) +m4_define([dvisvgm_version], [1.3]) -- cgit v1.2.3