EXTRA_DIST = doc src
-# Strip the XML prologue from an Inkscape document to produce
-# something that can be included directly into an HTML5 document.
-day.svg: src/day.svg
- @XMLLINT@ -xpath "/*" $< > $@
+# List of element IDs that we use in the HTML document.
+PRECIOUS_IDS = \
+ bus \
+ city \
+ citycopy \
+ codebg \
+ codetext \
+ clouds \
+ cloudscopy \
+ destination \
+ origin \
+ origindest \
+ train \
+ tram \
+ trees \
+ treescopy \
+ serviceid \
+ servicename \
+ sky \
+ ticket \
+ ticketbg \
+ ticketdate \
+ tickettime \
+ zone
+
+SCOUR = @SCOUR@ --enable-id-stripping \
+ --enable-comment-stripping \
+ --remove-descriptive-elements \
+ --no-renderer-workaround \
+ --no-line-breaks \
+ --error-on-flowtext
+
+# Optimize the favicon just like we do the tableau.
+favicon.min.svg: favicon.svg
+ $(SCOUR) $< > $@
+
+# Optimize our SVG once using XSL, to catch a few things
+# that "scour" misses.
+tableau.min.svg: tableau.svg svgclean.xsl
+ @XSLTPROC@ svgclean.xsl $< > $@
+
+# Optimize our SVG again, and remove its XML prologue so that it can
+# be included directly into the HTML document.
+tableau.min.min.svg: tableau.min.svg
+ $(SCOUR) --protect-ids-list=$$(echo $(PRECIOUS_IDS) | tr ' ' ',') \
+ --strip-xml-prolog \
+ $< > $@
+
+# Use FontForge to convert the sfd source files to woff2.
+.sfd.woff2:
+ @FONTFORGE@ -script sfd2woff.ff $<
# Base64-encode a woff2 (web open font format 2.0) file. We use this
# to embed fonts directly into the CSS that requires them.
-CharmBypass-Regular.base64: src/CharmBypass-Regular.woff2
+.woff2.base64:
@BASE64@ -w0 $< > $@
-CharmBypass-Bold.base64: src/CharmBypass-Bold.woff2
+
+# Same with the favicon SVG.
+.svg.base64:
@BASE64@ -w0 $< > $@
# Build index.html by substituting the contents of a few (single
-# line!) files into @PLACEHOLDERS@ within src/index.html.in. If you
-# put tildes in src/day.svg this will probably break, so please don't
-# do that.
-index.html: src/index.html.in day.svg CharmBypass-Regular.base64 CharmBypass-Bold.base64
+# line!) files into @PLACEHOLDERS@ within index.html.in. If you put
+# tildes in tableau.svg this will probably break, so please don't do
+# that.
+index.html: index.html.in tableau.min.min.svg CharmBypass-Regular.base64 CharmBypass-Bold.base64 favicon.base64
+
sed -e "s~@CBPREGULAR@~$$(cat CharmBypass-Regular.base64)~" \
-e "s~@CBPBOLD@~$$(cat CharmBypass-Bold.base64)~" \
- -e "s~@SVGDATA@~$$(cat day.svg)~" \
+ -e "s~@FAVICON@~$$(cat favicon.base64)~" \
+ -e "s~@SVGDATA@~$$(cat tableau.min.min.svg)~" \
$< > $@
# If you really want to, we support installing index.html
# Automake doesn't understand our wacky build process so we have to
# tell it which files are produced by running "make"
-CLEANFILES = $(dist_pkgdata_DATA) CharmBypass-Regular.base64 CharmBypass-Bold.base64 day.svg
+CLEANFILES = $(dist_pkgdata_DATA) \
+ CharmBypass-Regular.base64 \
+ CharmBypass-Bold.base64 \
+ favicon.min.svg \
+ tableau.min.svg \
+ tableau.min.min.svg