aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/src/main.cpp
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-09-30 20:37:32 +0200
committerjaseg <git@jaseg.de>2021-09-30 20:37:49 +0200
commit2616cf46ff2005d36ff0481f602d7cb1bfebc8ea (patch)
tree6f1807253392c9281f7be9cde3082059cd558161 /svg-flatten/src/main.cpp
parentbc54e8233f614a905884c75ed70b15daef156ac9 (diff)
downloadgerbolyze-2616cf46ff2005d36ff0481f602d7cb1bfebc8ea.tar.gz
gerbolyze-2616cf46ff2005d36ff0481f602d7cb1bfebc8ea.tar.bz2
gerbolyze-2616cf46ff2005d36ff0481f602d7cb1bfebc8ea.zip
svg-flatten: Add forwarding logic for usvg font optionsv2.2.4
Diffstat (limited to 'svg-flatten/src/main.cpp')
-rw-r--r--svg-flatten/src/main.cpp53
1 files changed, 43 insertions, 10 deletions
diff --git a/svg-flatten/src/main.cpp b/svg-flatten/src/main.cpp
index e259881..817ba67 100644
--- a/svg-flatten/src/main.cpp
+++ b/svg-flatten/src/main.cpp
@@ -5,6 +5,7 @@
#include <iostream>
#include <iomanip>
#include <fstream>
+#include <vector>
#include <algorithm>
#include <string>
#include <argagg.hpp>
@@ -120,16 +121,26 @@ int main(int argc, char **argv) {
{"skip_usvg", {"--no-usvg"},
"Do not preprocess input using usvg (do not use unless you know *exactly* what you're doing)",
0},
- {"usvg_dpi", {"--usvg-dpi"},
- "Passed through to usvg's --dpi, in case the input file has different ideas of DPI than usvg has.",
- 1},
{"scale", {"--scale"},
"Scale input svg lengths by this factor (-o gerber only).",
1},
{"exclude_groups", {"-e", "--exclude-groups"},
"Comma-separated list of group IDs to exclude from export. Takes precedence over --only-groups.",
1},
-
+ /* Forwarded USVG options */
+ {"usvg-dpi", {"--usvg-dpi"},
+ "Passed through to usvg's --dpi, in case the input file has different ideas of DPI than usvg has.",
+ 1},
+ {"usvg-font-family", {"--usvg-font-family"}, "", 1},
+ {"usvg-font-size", {"--usvg-font-size"}, "", 1},
+ {"usvg-serif-family", {"--usvg-serif-family"}, "", 1},
+ {"usvg-sans-serif-family", {"--usvg-sans-serif-family"}, "", 1},
+ {"usvg-cursive-family", {"--usvg-cursive-family"}, "", 1},
+ {"usvg-fantasy-family", {"--usvg-fantasy-family"}, "", 1},
+ {"usvg-monospace-family", {"--usvg-monospace-family"}, "", 1},
+ {"usvg-use-font-file", {"--usvg-use-font-file"}, "", 1},
+ {"usvg-use-fonts-dir", {"--usvg-use-fonts-dir"}, "", 1},
+ {"usvg-skip-system-fonts", {"--usvg-skip-system-fonts"}, "", 0},
}};
@@ -366,15 +377,37 @@ int main(int argc, char **argv) {
frob = barf;
} else {
+#ifndef NOFORK
//cerr << "calling usvg on " << barf << " and " << frob << endl;
- int dpi = 96;
- if (args["usvg_dpi"]) {
- dpi = args["usvg_dpi"].as<int>();
+ vector<string> command_line = {"--keep-named-groups"};
+
+ string options[] = {
+ "usvg-dpi",
+ "usvg-font-family",
+ "usvg-font-size",
+ "usvg-serif-family",
+ "usvg-sans-serif-family",
+ "usvg-cursive-family",
+ "usvg-fantasy-family",
+ "usvg-monospace-family",
+ "usvg-use-font-file",
+ "usvg-use-fonts-dir",
+ };
+
+ for (string &opt : options) {
+ if (args[opt.c_str()]) {
+ command_line.push_back("--" + opt.substr(5));
+ command_line.push_back(args[opt.c_str()]);
+ }
+ }
+
+ if (args["usvg-skip-system-fonts"]) {
+ command_line.push_back("--skip-system-fonts");
}
- string dpi_str = to_string(dpi);
+
+ command_line.push_back(barf);
+ command_line.push_back(frob);
-#ifndef NOFORK
- const char *command_line[] = {nullptr, "--keep-named-groups", "--dpi", dpi_str.c_str(), barf.c_str(), frob.c_str(), nullptr};
if (run_cargo_command("usvg", command_line, "USVG")) {
return EXIT_FAILURE;
}