From 263d098fe32f82fef6cb0ccb75a89862b9b4200a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 21 Mar 2020 22:04:56 +0000 Subject: dvisvgm 2.9.1 git-svn-id: svn://tug.org/texlive/trunk@54456 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvisvgm/configure | 22 +++++------ Build/source/texk/dvisvgm/dvisvgm-src/ChangeLog | 46 ++++++++++++++++++++++ Build/source/texk/dvisvgm/dvisvgm-src/NEWS | 9 +++++ Build/source/texk/dvisvgm/dvisvgm-src/configure.ac | 2 +- .../texk/dvisvgm/dvisvgm-src/doc/Makefile.am | 6 ++- .../texk/dvisvgm/dvisvgm-src/doc/Makefile.in | 6 ++- .../dvisvgm/dvisvgm-src/doc/conf-dblatex-pdf.xsl | 7 ++-- .../source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.1 | 25 +++++++----- .../texk/dvisvgm/dvisvgm-src/doc/dvisvgm.txt.in | 13 +++--- .../dvisvgm-src/doc/generate-dvisvgm-sty.xsl | 1 + .../dvisvgm/dvisvgm-src/doc/tweak-dblatex-tex.py | 18 +++++++++ .../texk/dvisvgm/dvisvgm-src/src/Calculator.cpp | 1 + .../dvisvgm-src/src/DvisvgmSpecialHandler.cpp | 33 +++++++++++++++- .../source/texk/dvisvgm/dvisvgm-src/src/Matrix.cpp | 2 +- .../texk/dvisvgm/dvisvgm-src/src/NumericRanges.hpp | 9 ++--- .../texk/dvisvgm/dvisvgm-src/src/PageRanges.cpp | 1 - .../texk/dvisvgm/dvisvgm-src/src/PageRanges.hpp | 5 +-- .../dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp | 22 +++++++---- .../dvisvgm-src/tests/DvisvgmSpecialTest.cpp | 27 +++++++------ Build/source/texk/dvisvgm/version.ac | 2 +- 20 files changed, 190 insertions(+), 67 deletions(-) create mode 100644 Build/source/texk/dvisvgm/dvisvgm-src/doc/tweak-dblatex-tex.py (limited to 'Build/source/texk/dvisvgm') diff --git a/Build/source/texk/dvisvgm/configure b/Build/source/texk/dvisvgm/configure index 0fee4f52b97..3592a2666fd 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 (TeX Live) 2.9. +# Generated by GNU Autoconf 2.69 for dvisvgm (TeX Live) 2.9.1. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dvisvgm (TeX Live)' PACKAGE_TARNAME='dvisvgm--tex-live-' -PACKAGE_VERSION='2.9' -PACKAGE_STRING='dvisvgm (TeX Live) 2.9' +PACKAGE_VERSION='2.9.1' +PACKAGE_STRING='dvisvgm (TeX Live) 2.9.1' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1391,7 +1391,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 (TeX Live) 2.9 to adapt to many kinds of systems. +\`configure' configures dvisvgm (TeX Live) 2.9.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1462,7 +1462,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvisvgm (TeX Live) 2.9:";; + short | recursive ) echo "Configuration of dvisvgm (TeX Live) 2.9.1:";; esac cat <<\_ACEOF @@ -1594,7 +1594,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvisvgm (TeX Live) configure 2.9 +dvisvgm (TeX Live) configure 2.9.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2462,7 +2462,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 (TeX Live) $as_me 2.9, which was +It was created by dvisvgm (TeX Live) $as_me 2.9.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -8214,7 +8214,7 @@ fi # Define the identity of the package. PACKAGE='dvisvgm--tex-live-' - VERSION='2.9' + VERSION='2.9.1' cat >>confdefs.h <<_ACEOF @@ -20212,7 +20212,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -dvisvgm (TeX Live) config.lt 2.9 +dvisvgm (TeX Live) config.lt 2.9.1 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -23517,7 +23517,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 (TeX Live) $as_me 2.9, which was +This file was extended by dvisvgm (TeX Live) $as_me 2.9.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23583,7 +23583,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 (TeX Live) config.status 2.9 +dvisvgm (TeX Live) config.status 2.9.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/ChangeLog b/Build/source/texk/dvisvgm/dvisvgm-src/ChangeLog index 9b23cf074be..725017aba85 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/ChangeLog +++ b/Build/source/texk/dvisvgm/dvisvgm-src/ChangeLog @@ -1,3 +1,49 @@ +2020-03-21 Martin Gieseking + + * src/Matrix.cpp: + fixed parsing of "scale(s)" +fixes #131 + + * .appveyor.yml, .travis.yml, configure.ac, doc/dvisvgm.1, src/Doxyfile, + src/version.hpp: + set version to 2.9.1 + + * NEWS: + updated NEWS + +2020-03-20 Martin Gieseking + + * src/Calculator.cpp, tests/CalculatorTest.cpp: + calculator: allow to omit '*' before '(' + +2020-03-19 Martin Gieseking + + * doc/dvisvgm.1, doc/dvisvgm.txt.in, src/DvisvgmSpecialHandler.cpp, + tests/DvisvgmSpecialTest.cpp: + added macro {?(expr)} to enable math expressions in raw specials +closes + #130 + +2020-03-17 Martin Gieseking + + * doc/Makefile.am, doc/conf-dblatex-pdf.xsl, doc/dvisvgm.txt.in, + doc/generate-dvisvgm-sty.xsl, doc/tweak-dblatex-tex.py: + optimize line breaks and code blocks in pdf manpage + +2020-03-16 Martin Gieseking + + * doc/conf-dblatex-pdf.xsl: + small font changes in pdf version of manual page +- changed body font to + Source Serif Pro +- scaled monospace font by 0.9 + + * src/PageRanges.cpp, src/PageRanges.hpp: + removed redundant #includes + + * src/NumericRanges.hpp: + replaced explicit iterator type with auto + 2020-03-13 Martin Gieseking * NEWS: diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/NEWS b/Build/source/texk/dvisvgm/dvisvgm-src/NEWS index 0f58739ca22..e898c38bd3d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/NEWS +++ b/Build/source/texk/dvisvgm/dvisvgm-src/NEWS @@ -1,3 +1,12 @@ +dvisvgm-2.9.1 (2020-03-21) +- added macro {?(expr)} to enable the evaluation of math expressions in + raw SVG fragments (GH #130) +- multiplication operator "*" preceding an opening parentheses can now be + omitted in math expressions +- fixed the evaluation of transformation command "scale(c)" which is now + correctly treated as "scale(c, c)" (GH #131) +- minor layout optimizations of the PDF manual page + dvisvgm-2.9 (2020-03-13) - added processing of PS operators 'image' and 'colorimage' to embed bitmaps present in PS/PDF data into the generated SVG diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/configure.ac b/Build/source/texk/dvisvgm/dvisvgm-src/configure.ac index 532bc087952..783d2709a8d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/configure.ac +++ b/Build/source/texk/dvisvgm/dvisvgm-src/configure.ac @@ -4,7 +4,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([dvisvgm],[2.9],[martin.gieseking@uos.de]) +AC_INIT([dvisvgm],[2.9.1],[martin.gieseking@uos.de]) DATE="March 2020" AC_CONFIG_SRCDIR(src) AC_CONFIG_HEADERS([config.h]) diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.am index fdbc24e1cec..92c7d25efd7 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.am +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.am @@ -15,6 +15,7 @@ EXTRA_DIST = $(man_MANS) \ dvisvgm.txt.in \ generate-dvisvgm-sty.xsl \ tweak-dblatex-pdf.xsl \ + tweak-dblatex-tex.py \ tweak-db-refentry.xsl if BUILD_MANPAGE @@ -22,6 +23,7 @@ if BUILD_MANPAGE CONF_DBLATEX_MAN = $(dvisvgm_srcdir)/doc/conf-dblatex-man.xsl CONF_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/conf-dblatex-pdf.xsl TWEAK_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/tweak-dblatex-pdf.xsl +TWEAK_DBLATEX_TEX = $(dvisvgm_srcdir)/doc/tweak-dblatex-tex.py TWEAK_DB_ARTICLE = $(dvisvgm_srcdir)/doc/tweak-db-article.xsl TWEAK_DB_REFENTRY = $(dvisvgm_srcdir)/doc/tweak-db-refentry.xsl GEN_DBLATEX_STY = $(dvisvgm_srcdir)/doc/generate-dvisvgm-sty.xsl @@ -31,10 +33,10 @@ DB_VARS = man.endnotes.list.enabled=0 man.endnotes.are.numbered=0 man.authors.se dvisvgm.1: dvisvgm-man.xml $(CONF_DBLATEX_MAN) xmlto -m $(CONF_DBLATEX_MAN) $(addprefix --stringparam , $(DB_VARS)) man $< -dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF) +dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF) $(TWEAK_DBLATEX_TEX) mv $< $<.tmp xsltproc -o $< $(TWEAK_DBLATEX_PDF) $<.tmp - dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) $< + dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) -r plugin:$(basename $(TWEAK_DBLATEX_TEX)) $< mv $<.tmp $< mv $(basename $<).pdf $@ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.in index 35bceae1d1f..8568648c65a 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/Makefile.in @@ -325,11 +325,13 @@ EXTRA_DIST = $(man_MANS) \ dvisvgm.txt.in \ generate-dvisvgm-sty.xsl \ tweak-dblatex-pdf.xsl \ + tweak-dblatex-tex.py \ tweak-db-refentry.xsl @BUILD_MANPAGE_TRUE@CONF_DBLATEX_MAN = $(dvisvgm_srcdir)/doc/conf-dblatex-man.xsl @BUILD_MANPAGE_TRUE@CONF_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/conf-dblatex-pdf.xsl @BUILD_MANPAGE_TRUE@TWEAK_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/tweak-dblatex-pdf.xsl +@BUILD_MANPAGE_TRUE@TWEAK_DBLATEX_TEX = $(dvisvgm_srcdir)/doc/tweak-dblatex-tex.py @BUILD_MANPAGE_TRUE@TWEAK_DB_ARTICLE = $(dvisvgm_srcdir)/doc/tweak-db-article.xsl @BUILD_MANPAGE_TRUE@TWEAK_DB_REFENTRY = $(dvisvgm_srcdir)/doc/tweak-db-refentry.xsl @BUILD_MANPAGE_TRUE@GEN_DBLATEX_STY = $(dvisvgm_srcdir)/doc/generate-dvisvgm-sty.xsl @@ -583,10 +585,10 @@ uninstall-man: uninstall-man1 @BUILD_MANPAGE_TRUE@dvisvgm.1: dvisvgm-man.xml $(CONF_DBLATEX_MAN) @BUILD_MANPAGE_TRUE@ xmlto -m $(CONF_DBLATEX_MAN) $(addprefix --stringparam , $(DB_VARS)) man $< -@BUILD_MANPAGE_TRUE@dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF) +@BUILD_MANPAGE_TRUE@dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF) $(TWEAK_DBLATEX_TEX) @BUILD_MANPAGE_TRUE@ mv $< $<.tmp @BUILD_MANPAGE_TRUE@ xsltproc -o $< $(TWEAK_DBLATEX_PDF) $<.tmp -@BUILD_MANPAGE_TRUE@ dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) $< +@BUILD_MANPAGE_TRUE@ dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) -r plugin:$(basename $(TWEAK_DBLATEX_TEX)) $< @BUILD_MANPAGE_TRUE@ mv $<.tmp $< @BUILD_MANPAGE_TRUE@ mv $(basename $<).pdf $@ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/conf-dblatex-pdf.xsl b/Build/source/texk/dvisvgm/dvisvgm-src/doc/conf-dblatex-pdf.xsl index 321bc0f4fb3..bb3bd93b632 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/conf-dblatex-pdf.xsl +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/conf-dblatex-pdf.xsl @@ -3,15 +3,16 @@ - \setmainfont{Source Sans Pro} + \setmainfont{Source Serif Pro} \setsansfont{Source Sans Pro} - \setmonofont{Source Code Pro} + \setmonofont[Scale=0.9]{Source Code Pro} 0 0 caution note + tabular 0 1 @@ -55,7 +56,7 @@ \phantomsection\pdfbookmark[3]{ - + diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.1 b/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.1 index 43fd7e11269..67cc037d26d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.1 +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.1 @@ -2,12 +2,12 @@ .\" Title: dvisvgm .\" Author: Martin Gieseking .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 2020-03-08 +.\" Date: 2020-03-19 .\" Manual: dvisvgm Manual -.\" Source: dvisvgm 2.9 +.\" Source: dvisvgm 2.9.1 .\" Language: English .\" -.TH "DVISVGM" "1" "2020\-03\-08" "dvisvgm 2\&.9" "dvisvgm Manual" +.TH "DVISVGM" "1" "2020\-03\-19" "dvisvgm 2\&.9\&.1" "dvisvgm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -329,7 +329,7 @@ or to the font format, e\&.g\&. \fB\-\-font\-format=woff,autohint\fR or -\fB\-\-font\-format=woff,ah\fR\&. +\fB\-\-fwoff,ah\fR\&. .sp Option \fB\-\-font\-format\fR @@ -1177,9 +1177,9 @@ dvisvgm offers its own small set of specials\&. The following list gives a brief \fBdvisvgm:raw\fR \fItext\fR .RS 4 Adds an arbitrary sequence of XML nodes to the page section of the SVG document\&. dvisvgm checks syntax and proper nesting of the inserted elements but does not perform any validation, thus the user has to ensure that the resulting SVG is still valid\&. Opening and closing tags may be distributed among different -\fBraw\fR -specials\&. The tags themselves can also be split but must be continued with the immediatly following -\fBraw\fR +\fIraw\fR +specials\&. The tags themselves can also be split but must be continued with the immediately following +\fIraw\fR special\&. Both syntactically incorrect and wrongly nested tags lead to error messages\&. Parameter \fItext\fR may also contain the expressions @@ -1191,9 +1191,16 @@ that expand to the current \fIx\fR or \fIy\fR -coordinate, the current color, and current transformation matrix, respectively\&. Furthermore, +coordinate, the current color, and current transformation matrix, respectively\&. Character sequence \fB{?nl}\fR -expands to a newline character\&. +expands to a newline character\&. Finally, constructions of the form +\fB{?(\fR\fB\fIexpr\fR\fR\fB)}\fR +enable the evaluation of mathematical expressions which may consist of basic arithmetic operations including modulo\&. Like above, the variables +\fIx\fR +and +\fIy\fR +represent the current coordinates\&. Example: +\fB{?(\-10*(x+2y)\-5)}\fR\&. .RE .PP \fBdvisvgm:rawdef\fR \fItext\fR diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.txt.in b/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.txt.in index 7afc9138b98..2b51b57c32d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.txt.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/dvisvgm.txt.in @@ -22,7 +22,7 @@ Martin Gieseking <@PACKAGE_BUGREPORT@> :man source: dvisvgm :man version: @VERSION@ :man manual: dvisvgm Manual -:revdate: 2020-03-08 09:20 +0100 +:revdate: 2020-03-19 22:06 +0100 Name ---- @@ -224,7 +224,7 @@ version 1 and 2). By default, dvisvgm creates unhinted fonts that might look bad on low-resolution devices. In order to improve the display quality, the generated TrueType, WOFF, or WOFF2 fonts can be autohinted. The autohinter is enabled by appending +,autohint+ or +,ah+ to the font format, -e.g. +--font-format=woff,autohint+ or +--font-format=woff,ah+. +e.g. +--font-format=woff,autohint+ or +--fwoff,ah+. + Option *--font-format* is only available if dvisvgm was built with WOFF support enabled. @@ -722,12 +722,15 @@ dvisvgm offers its own small set of specials. The following list gives a brief o *dvisvgm:raw* 'text';; Adds an arbitrary sequence of XML nodes to the page section of the SVG document. dvisvgm checks syntax and proper nesting of the inserted elements but does not perform any validation, thus the user has to ensure - that the resulting SVG is still valid. Opening and closing tags may be distributed among different +raw+ - specials. The tags themselves can also be split but must be continued with the immediatly following +raw+ + that the resulting SVG is still valid. Opening and closing tags may be distributed among different 'raw' + specials. The tags themselves can also be split but must be continued with the immediately following 'raw' special. Both syntactically incorrect and wrongly nested tags lead to error messages. Parameter 'text' may also contain the expressions *{?x}*, *{?y}*, *{?color}*, and *{?matrix}* that expand to the current 'x' or 'y' coordinate, the current color, and current transformation matrix, respectively. - Furthermore, *{?nl}* expands to a newline character. + Character sequence *{?nl}* expands to a newline character. Finally, constructions of the form *{?(__expr__)}* + enable the evaluation of mathematical expressions which may consist of basic arithmetic operations including + modulo. Like above, the variables 'x' and 'y' represent the current coordinates. + Example: +{?(-10*(x+2y)-5)}+. *dvisvgm:rawdef* 'text';; This command is similar to *dvisvgm:raw*, but puts the XML nodes into the section of the SVG document diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/generate-dvisvgm-sty.xsl b/Build/source/texk/dvisvgm/dvisvgm-src/doc/generate-dvisvgm-sty.xsl index bdb279da99f..7a3ae6a7705 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/doc/generate-dvisvgm-sty.xsl +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/generate-dvisvgm-sty.xsl @@ -7,6 +7,7 @@ \ProvidesPackage{dvisvgm}[2015/02/04 dvisvgm DocBook style] \RequirePackageWithOptions{docbook} \RequirePackage[english]{babel} +\RequirePackage[shortcuts]{extdash} \RequirePackage{underscore} \renewcommand*{\arraystretch}{-0.4} \AtBeginDocument{% diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/doc/tweak-dblatex-tex.py b/Build/source/texk/dvisvgm/dvisvgm-src/doc/tweak-dblatex-tex.py new file mode 100644 index 00000000000..3f34d94e654 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-src/doc/tweak-dblatex-tex.py @@ -0,0 +1,18 @@ +import re +import os + +def main (latex_file, stdout): + latex_file_old = latex_file+"-old" + os.rename(latex_file, latex_file_old) + os.remove(os.path.splitext(latex_file)[0]+".pdf") + with open(latex_file, "w") as outfile: + with open(latex_file_old) as infile: + lines = infile.readlines() + for line in lines: + if re.match(r'(.*\\def)|(.*\\href)', line) == None: + line = re.sub(r'([a-zA-Z0-9]+)/', r'\1\slash{}', line) + line = re.sub(r'-{}-{}', r'\=/\=/', line) + line = re.sub(r'([^a-zA-Z0-9])-{}', r'\1\=/', line) + print >>outfile, line.rstrip() + os.remove(latex_file_old) + return 0 diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp index c5dc00df4d3..0fdcf0f2fa3 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp @@ -71,6 +71,7 @@ double Calculator::term (istream &is, bool skip) { // term: for (;;) switch (lookAhead(is)) { case '*': left *= prim(is, true); break; // prim '*' prim => $1 * $3 + case '(': left *= prim(is, false); break; // prim '*' prim => $1 * $3 case '/': { // prim '/' prim => $1 / $3 double denom = prim(is, true); if (denom == 0) diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/DvisvgmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/DvisvgmSpecialHandler.cpp index b2af27d6363..1f331659f03 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/DvisvgmSpecialHandler.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/DvisvgmSpecialHandler.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "Calculator.hpp" #include "DvisvgmSpecialHandler.hpp" #include "InputBuffer.hpp" #include "InputReader.hpp" @@ -190,6 +191,35 @@ static void expand_constants (string &str, SpecialActions &actions) { } +/** Evaluates substrings of the form {?(expr)} where 'expr' is a math expression, + * and replaces the substring by the computed value. + * @param[in,out] str string to scan for expressions */ +static void evaluate_expressions (string &str, SpecialActions &actions) { + size_t left = str.find("{?("); // start position of expression macro + while (left != string::npos) { + size_t right = str.find(")}", left+2); // end position of expression macro + if (right == string::npos) + break; + Calculator calc; + calc.setVariable("x", actions.getX()); + calc.setVariable("y", actions.getY()); + string expr = str.substr(left+3, right-left-3); // math expression to evaluate + if (util::normalize_space(expr).empty()) // no expression given, e.g. {?( )} + str.erase(left, right-left+2); // => replace with empty string + else { + try { + double val = calc.eval(expr); + str.replace(left, right-left+2, XMLString(val)); + } + catch (CalculatorException &e) { + throw SpecialException(string(e.what())+" in '{?("+expr+")}'"); + } + } + left = str.find("{?(", right+1); // find next expression macro + } +} + + /** Processes raw SVG fragments from the input stream. The SVG data must represent * a single or multiple syntactically complete XML parts, like opening/closing tags, * comments, or CDATA blocks. These must not be split and distributed over several @@ -199,6 +229,7 @@ void DvisvgmSpecialHandler::processRaw (InputReader &ir, SpecialActions &actions if (_nestingLevel == 0) { string xml = ir.getLine(); if (!xml.empty()) { + evaluate_expressions(xml, actions); expand_constants(xml, actions); _pageParser.parse(xml, actions); } @@ -536,4 +567,4 @@ void DvisvgmSpecialHandler::XMLParser::flush (SpecialActions &actions) { tags.resize(tags.length()-2); throw SpecialException("missing closing tags: "+tags); } -} \ No newline at end of file +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Matrix.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Matrix.cpp index 75d571877a9..d0dcb2124d2 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Matrix.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Matrix.cpp @@ -538,7 +538,7 @@ Matrix Matrix::parseSVGTransform (const string &transform) { } else if (parse_transform_cmd(iss, "scale", 1, 2, params)) { if (params.size() == 1) - params.push_back(1); + params.push_back(params[0]); if (ne(params[0], 1) || ne(params[1], 1)) matrix.rmultiply(ScalingMatrix(params[0], params[1])); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/NumericRanges.hpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/NumericRanges.hpp index a6ee109568e..1669f7ddce2 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/NumericRanges.hpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/NumericRanges.hpp @@ -26,8 +26,7 @@ #include template -class NumericRanges -{ +class NumericRanges { public: using Range = std::pair; using Container = std::list; @@ -54,7 +53,7 @@ template void NumericRanges::addRange (T first, T last) { if (first > last) std::swap(first, last); - typename Container::iterator it = _ranges.begin(); + auto 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) @@ -65,8 +64,8 @@ void NumericRanges::addRange (T first, T last) { } // merge adjacent ranges if (it != _ranges.end()) { - typename Container::iterator l = it; - typename Container::iterator r = it; + auto l = it; + auto r = it; if (l == _ranges.begin()) l = _ranges.end(); else diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.cpp index a08ad4aa542..2623d2ef468 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.cpp @@ -18,7 +18,6 @@ ** along with this program; if not, see . ** *************************************************************************/ -#include #include "InputBuffer.hpp" #include "InputReader.hpp" #include "PageRanges.hpp" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.hpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.hpp index e6909b9cd18..555338449a2 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.hpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PageRanges.hpp @@ -21,13 +21,10 @@ #ifndef PAGERANGES_HPP #define PAGERANGES_HPP -#include #include -#include #include "NumericRanges.hpp" -class PageRanges : public NumericRanges -{ +class PageRanges : public NumericRanges { public: bool parse (const std::string &str, int max_page=0); size_t numberOfPages () const; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp index 28ebf342b83..af79a4c8e1c 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp @@ -25,14 +25,19 @@ 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); + 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)"), 14); + EXPECT_EQ(calc.eval("(1+2)(3+4)"), 21); + EXPECT_EQ(calc.eval("-(1+2)(3+4)"), -21); + EXPECT_EQ(calc.eval("(1+2)-(3+4)"), -4); + EXPECT_EQ(calc.eval("-2+3+4"), 5); + EXPECT_EQ(calc.eval("3/2"), 1.5); + EXPECT_EQ(calc.eval("3%2"), 1); + EXPECT_EQ(calc.eval("-(4)"), -4); } @@ -47,6 +52,7 @@ TEST(CalculatorTest, variables) { calc.setVariable("b", 3); EXPECT_EQ(calc.eval("a+b"), 5); EXPECT_EQ(calc.eval("2a+2b"), 10); + EXPECT_EQ(calc.eval("2a(1+2b)"), 28); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/DvisvgmSpecialTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/DvisvgmSpecialTest.cpp index 829b4ca5ad8..b8e67403aeb 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/DvisvgmSpecialTest.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/DvisvgmSpecialTest.cpp @@ -27,13 +27,14 @@ using namespace std; + class MyDvisvgmSpecialHandler : public DvisvgmSpecialHandler { public: void finishPreprocessing () {dviPreprocessingFinished();} - void finishPage () {dviEndPage(0, emptyActions);} + void finishPage () {dviEndPage(0, _actions);} protected: - EmptySpecialActions emptyActions; + EmptySpecialActions _actions; }; @@ -42,8 +43,8 @@ class DvisvgmSpecialTest : public ::testing::Test { class ActionsRecorder : public EmptySpecialActions { public: void embed (const BoundingBox &bb) override {bbox.embed(bb);} - double getX () const override {return 0;} - double getY () const override {return 0;} + double getX () const override {return -42;} + double getY () const override {return 14;} bool defsEquals (const string &str) const {return defsString() == str;} bool pageEquals (const string &str) const {return pageString() == str;} bool bboxEquals (const string &str) const {return bbox.toSVGViewBox() == str;} @@ -86,15 +87,15 @@ TEST_F(DvisvgmSpecialTest, basic) { TEST_F(DvisvgmSpecialTest, rawText) { - istringstream iss("raw first{?nl}"); + istringstream iss("raw first{?nl}{?x},{?y}"); handler.process("", iss, recorder); EXPECT_TRUE(recorder.defsEquals("")); - EXPECT_TRUE(recorder.pageEquals("first\n")) << recorder.pageString(); + EXPECT_TRUE(recorder.pageEquals("first\n-42,14")) << recorder.pageString(); - iss.clear(); iss.str("raw \t second {?bbox dummy} \t"); + iss.clear(); iss.str("raw \t ;{?(-x+2*y-5)}second {?bbox dummy} \t"); handler.process("", iss, recorder); EXPECT_TRUE(recorder.defsEquals("")); - EXPECT_TRUE(recorder.pageEquals("first\nsecond 0 0 0 0")) << recorder.pageString(); + EXPECT_TRUE(recorder.pageEquals("first\n-42,14;65second 0 0 0 0")) << recorder.pageString(); } @@ -313,13 +314,13 @@ TEST_F(DvisvgmSpecialTest, processImg) { std::istringstream iss("img 72.27 72.27 test.png"); handler.process("", iss, recorder); EXPECT_TRUE(recorder.defsEquals("")); - EXPECT_TRUE(recorder.pageEquals("")) << recorder.pageString(); + EXPECT_TRUE(recorder.pageEquals("")) << recorder.pageString(); recorder.clear(); iss.clear(); iss.str("img 10bp 20bp test2.png"); handler.process("", iss, recorder); - EXPECT_TRUE(recorder.pageEquals("")) << recorder.pageString(); + EXPECT_TRUE(recorder.pageEquals("")) << recorder.pageString(); } @@ -340,19 +341,19 @@ TEST_F(DvisvgmSpecialTest, processBBox) { iss.clear(); iss.str("bbox 72.27 72.27"); handler.process("", iss, recorder); - EXPECT_TRUE(recorder.bboxEquals("0 -72 72 72")); + EXPECT_TRUE(recorder.bboxEquals("-42 -58 72 72")); recorder.clear(); iss.clear(); iss.str("bbox 72bp 72bp"); handler.process("", iss, recorder); - EXPECT_TRUE(recorder.bboxEquals("0 -72 72 72")); + EXPECT_TRUE(recorder.bboxEquals("-42 -58 72 72")); recorder.clear(); iss.clear(); iss.str("bbox rel 72.27 72.27"); handler.process("", iss, recorder); - EXPECT_TRUE(recorder.bboxEquals("0 -72 72 72")); + EXPECT_TRUE(recorder.bboxEquals("-42 -58 72 72")); recorder.clear(); iss.clear(); diff --git a/Build/source/texk/dvisvgm/version.ac b/Build/source/texk/dvisvgm/version.ac index a087e4671c0..b3c2057f1ee 100644 --- a/Build/source/texk/dvisvgm/version.ac +++ b/Build/source/texk/dvisvgm/version.ac @@ -9,4 +9,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current dvisvgm version -m4_define([dvisvgm_version], [2.9]) +m4_define([dvisvgm_version], [2.9.1]) -- cgit v1.2.3