chiark / gitweb /
Plumb usvg options from a file src/USVG_DEFAULT_ARGS.txt
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 May 2022 19:27:04 +0000 (20:27 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 May 2022 19:42:15 +0000 (20:42 +0100)
Rather than the Makefile.  This will let us make the default arguments
available to Rust code.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
src/USVG_DEFAULT_ARGS.txt [new file with mode: 0644]
usvg-processor

index b354ed6732459ac974b93c3ad0ce515e795c25c9..54e61d97bf1fa4ef8d38116f95b018dc02f70a51 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,8 +39,6 @@ BUNDLED_SOURCES += $(BUNDLED_SOURCES_FILES)
 
 TARGET_DIR ?= target
 
-USVG_OPTIONS = "--sans-serif-family=DejaVu Sans"
-
 WASM_BINDGEN = $(TARGET_DIR)/debug/wasm-bindgen
 WASM_BINDGEN_OPTIONS =                                         \
        --remove-name-section --remove-producers-section        \
@@ -343,7 +341,7 @@ bundled-sources::
 #---------- svg processing ----------
 
 LIBRARIES ?= $(basename $(wildcard library/*.toml))
-USVG_DEP = stamp/cargo.usvg
+USVG_DEP = stamp/cargo.usvg src/USVG_DEFAULT_ARGS.txt
 
 include $(addsuffix /files.make, $(LIBRARIES))
 
diff --git a/src/USVG_DEFAULT_ARGS.txt b/src/USVG_DEFAULT_ARGS.txt
new file mode 100644 (file)
index 0000000..755206d
--- /dev/null
@@ -0,0 +1,5 @@
+# One argument per line
+# Lines starting with #, and empty lines, are ignored
+
+--sans-serif-family
+DejaVu Sans
index 58f3042a8a5d3ba3fef4374d2c6e9b938788cfd7..41db5d3fa57ed2d1e6db962ae64174161780755d 100755 (executable)
@@ -26,7 +26,17 @@ sub add_lic () {
 add_lic();
 
 flush STDOUT or die $!;
-my $cmd = "$usvg - -c";
+my $cmd = "$usvg";
+
+open OPTS, "src/USVG_DEFAULT_ARGS.txt" or die $!;
+while (<OPTS>) {
+  s/^\s*$//; s/\s*$//;
+  next unless m/^[^#]/;
+  $cmd .= " '$_'";
+}
+
+$cmd .= " - -c";
+
 my $cmd_m = "$cmd <$in >$out.tmp";
 print STDERR "+ $cmd_m\n";