summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/CommandLine.hpp
blob: c4a215b301d8f99470ea23003457e655adc24bec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// 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.
// Copyright (C) 2016-2021 Martin Gieseking <martin.gieseking@uos.de>

#ifndef COMMANDLINE_HPP
#define COMMANDLINE_HPP

#include <config.h>
#include <array>
#include <vector>
#include "CLCommandLine.hpp"

using CL::Option;
using CL::TypedOption;

class CommandLine : public CL::CommandLine {
	public:
		CommandLine () : CL::CommandLine(
			"This program converts DVI files, as created by TeX/LaTeX, as well as\nEPS and PDF files to the XML-based scalable vector graphics format SVG.",
			"[options] dvifile\n--eps [options] epsfile\n--pdf [options] pdffile",
			"Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de>"
		) {}

		CommandLine (int argc, char **argv) : CommandLine() {
			parse(argc, argv);
		}

		// option variables
		TypedOption<std::string, Option::ArgMode::REQUIRED> bboxOpt {"bbox", 'b', "size", "min", "set size of bounding box"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> bitmapFormatOpt {"bitmap-format", 'B', "fmt", "jpeg", "set format used to embed PS/EPS bitmaps"};
		TypedOption<std::string, Option::ArgMode::OPTIONAL> cacheOpt {"cache", 'C', "dir", "set/print path of cache directory"};
		Option clipjoinOpt {"clipjoin", 'j', "compute intersection of clipping paths"};
		Option colorOpt {"color", '\0', "colorize messages"};
		Option colornamesOpt {"colornames", '\0', "prefer color names to RGB values if possible"};
		Option commentsOpt {"comments", '\0', "add comments with additional information"};
		Option epsOpt {"eps", 'E', "convert EPS file to SVG"};
		Option exactBboxOpt {"exact-bbox", 'e', "compute exact glyph bounding boxes"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> fontFormatOpt {"font-format", 'f', "format", "svg", "set file format of embedded fonts"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> fontmapOpt {"fontmap", 'm', "filenames", "evaluate (additional) font map files"};
		Option gradOverlapOpt {"grad-overlap", '\0', "create overlapping color gradient segments"};
		TypedOption<int, Option::ArgMode::REQUIRED> gradSegmentsOpt {"grad-segments", '\0', "number", 20, "number of color gradient segments per row"};
		TypedOption<double, Option::ArgMode::REQUIRED> gradSimplifyOpt {"grad-simplify", '\0', "delta", 0.05, "reduce level of detail for small segments"};
		TypedOption<int, Option::ArgMode::OPTIONAL> helpOpt {"help", 'h', "mode", 0, "print this summary of options and exit"};
		Option keepOpt {"keep", '\0', "keep temporary files"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> libgsOpt {"libgs", '\0', "filename", "set name of Ghostscript shared library"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> linkmarkOpt {"linkmark", 'L', "style", "box", "select how to mark hyperlinked areas"};
		Option listSpecialsOpt {"list-specials", 'l', "print supported special sets and exit"};
		TypedOption<double, Option::ArgMode::REQUIRED> magOpt {"mag", 'M', "factor", 4, "magnification of Metafont output"};
		TypedOption<int, Option::ArgMode::OPTIONAL> noFontsOpt {"no-fonts", 'n', "variant", 0, "draw glyphs by using path elements"};
		Option noMergeOpt {"no-merge", '\0', "don't merge adjacent text elements"};
		Option noMktexmfOpt {"no-mktexmf", '\0', "don't try to create missing fonts"};
		TypedOption<std::string, Option::ArgMode::OPTIONAL> noSpecialsOpt {"no-specials", 'S', "prefixes", "don't process [selected] specials"};
		Option noStylesOpt {"no-styles", '\0', "don't use CSS styles to reference fonts"};
		TypedOption<std::string, Option::ArgMode::OPTIONAL> optimizeOpt {"optimize", 'O', "modules", "all", "perform several SVG optimizations"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> outputOpt {"output", 'o', "pattern", "set name pattern of output files"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> pageOpt {"page", 'p', "ranges", "1", "choose page(s) to convert"};
		TypedOption<std::string, Option::ArgMode::OPTIONAL> pageHashesOpt {"page-hashes", 'H', "params", "xxh64", "activate usage of page hashes"};
		Option pdfOpt {"pdf", 'P', "convert PDF file to SVG"};
		TypedOption<int, Option::ArgMode::REQUIRED> precisionOpt {"precision", 'd', "number", 0, "set number of decimal points (0-6)"};
		TypedOption<double, Option::ArgMode::OPTIONAL> progressOpt {"progress", '\0', "delay", 0.5, "enable progress indicator"};
		Option relativeOpt {"relative", 'R', "create relative path commands"};
		TypedOption<double, Option::ArgMode::REQUIRED> rotateOpt {"rotate", 'r', "angle", "rotate page content clockwise"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> scaleOpt {"scale", 'c', "sx[,sy]", "scale page content"};
		Option stdinOpt {"stdin", '\0', "read input file from stdin"};
		Option stdoutOpt {"stdout", 's', "write SVG output to stdout"};
		TypedOption<std::string, Option::ArgMode::OPTIONAL> tmpdirOpt {"tmpdir", '\0', "path", "set/print the directory for temporary files"};
		TypedOption<bool, Option::ArgMode::OPTIONAL> traceAllOpt {"trace-all", 'a', "retrace", false, "trace all glyphs of bitmap fonts"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> transformOpt {"transform", 'T', "commands", "transform page content"};
		TypedOption<std::string, Option::ArgMode::REQUIRED> translateOpt {"translate", 't', "tx[,ty]", "shift page content"};
		TypedOption<unsigned, Option::ArgMode::REQUIRED> verbosityOpt {"verbosity", 'v', "level", 7, "set verbosity level (0-7)"};
		TypedOption<bool, Option::ArgMode::OPTIONAL> versionOpt {"version", 'V', "extended", false, "print version and exit"};
		TypedOption<int, Option::ArgMode::OPTIONAL> zipOpt {"zip", 'z', "level", 9, "create compressed .svgz file"};
		TypedOption<double, Option::ArgMode::REQUIRED> zoomOpt {"zoom", 'Z', "factor", 1.0, "zoom page content"};

	protected:
		std::vector<OptSectPair>& options () const override {return _options;}
		const char* section (size_t n) const override {return n < _sections.size() ? _sections[n] : nullptr;}

	private:
		std::array<const char*, 5> _sections {{
			"Input options",
			"SVG output options",
			"SVG transformations",
			"Processing options",
			"Message options",
		}};

		mutable std::vector<OptSectPair> _options = {
			{&pageOpt, 0},
			{&fontmapOpt, 0},
#if !defined(DISABLE_GS)
			{&epsOpt, 0},
#endif
#if !defined(DISABLE_GS)
			{&pdfOpt, 0},
#endif
			{&stdinOpt, 0},
			{&bboxOpt, 1},
#if !defined(DISABLE_GS)
			{&bitmapFormatOpt, 1},
#endif
#if !defined(DISABLE_GS)
			{&clipjoinOpt, 1},
#endif
			{&colornamesOpt, 1},
			{&commentsOpt, 1},
#if !defined(DISABLE_WOFF)
			{&fontFormatOpt, 1},
#endif
#if !defined(DISABLE_GS)
			{&gradOverlapOpt, 1},
#endif
#if !defined(DISABLE_GS)
			{&gradSegmentsOpt, 1},
#endif
#if !defined(DISABLE_GS)
			{&gradSimplifyOpt, 1},
#endif
			{&linkmarkOpt, 1},
			{&optimizeOpt, 1},
			{&outputOpt, 1},
			{&precisionOpt, 1},
			{&relativeOpt, 1},
			{&stdoutOpt, 1},
			{&tmpdirOpt, 1},
			{&noFontsOpt, 1},
			{&noMergeOpt, 1},
			{&noStylesOpt, 1},
			{&zipOpt, 1},
			{&rotateOpt, 2},
			{&scaleOpt, 2},
			{&translateOpt, 2},
			{&transformOpt, 2},
			{&zoomOpt, 2},
			{&cacheOpt, 3},
			{&exactBboxOpt, 3},
			{&keepOpt, 3},
#if !defined(HAVE_LIBGS) && !defined(DISABLE_GS)
			{&libgsOpt, 3},
#endif
			{&magOpt, 3},
			{&noMktexmfOpt, 3},
			{&noSpecialsOpt, 3},
			{&pageHashesOpt, 3},
			{&traceAllOpt, 3},
			{&colorOpt, 4},
			{&helpOpt, 4},
			{&listSpecialsOpt, 4},
			{&progressOpt, 4},
			{&verbosityOpt, 4},
			{&versionOpt, 4},
		};
};

#endif