summaryrefslogtreecommitdiff
path: root/dviware
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-01-31 03:01:43 +0000
committerNorbert Preining <norbert@preining.info>2023-01-31 03:01:43 +0000
commit7c33483242d8e20f8f809e76ec9a3406db2dbfab (patch)
treea6b1f262cb5d0ec3041fddac57b41ed134c1e9ed /dviware
parent326add29024271cbd541ac55448e616e833ae5fa (diff)
CTAN sync 202301310301
Diffstat (limited to 'dviware')
-rw-r--r--dviware/dvisvgm/Makefile.in2
-rw-r--r--dviware/dvisvgm/NEWS6
-rw-r--r--dviware/dvisvgm/aminclude_static.am2
-rwxr-xr-xdviware/dvisvgm/configure20
-rw-r--r--dviware/dvisvgm/configure.ac2
-rw-r--r--dviware/dvisvgm/doc/dvisvgm.14
-rw-r--r--dviware/dvisvgm/src/Bezier.hpp4
-rw-r--r--dviware/dvisvgm/src/FontManager.cpp8
-rw-r--r--dviware/dvisvgm/src/FontManager.hpp3
-rw-r--r--dviware/dvisvgm/src/PDFHandler.cpp42
-rw-r--r--dviware/dvisvgm/src/PDFHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/RangeMap.cpp2
-rw-r--r--dviware/dvisvgm/src/fonts/Base14Fonts.cpp5
-rw-r--r--dviware/dvisvgm/src/fonts/Base14Fonts.hpp2
14 files changed, 54 insertions, 50 deletions
diff --git a/dviware/dvisvgm/Makefile.in b/dviware/dvisvgm/Makefile.in
index db990b1fd5..ac9b736303 100644
--- a/dviware/dvisvgm/Makefile.in
+++ b/dviware/dvisvgm/Makefile.in
@@ -15,7 +15,7 @@
@SET_MAKE@
# aminclude_static.am generated automatically by Autoconf
-# from AX_AM_MACROS_STATIC on Tue Jan 10 14:41:23 CET 2023
+# from AX_AM_MACROS_STATIC on Mon Jan 30 08:25:52 CET 2023
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
diff --git a/dviware/dvisvgm/NEWS b/dviware/dvisvgm/NEWS
index d1f6981d0b..73e94d8cac 100644
--- a/dviware/dvisvgm/NEWS
+++ b/dviware/dvisvgm/NEWS
@@ -1,3 +1,9 @@
+dvisvgm-3.0.2 (2023-01-30)
+- fixed computation of font sizes in new PDF handler (GH issue #220)
+- fixed viewBox coordinates determined by new PDF handler (GH issue #223)
+- improved detection of font names used in PDF files (GH issue #224)
+- minor code improvements
+
dvisvgm-3.0.1 (2023-01-10)
- added support for the 64-bit GS library in TeX Live
(patch sent by Akira Kakuto)
diff --git a/dviware/dvisvgm/aminclude_static.am b/dviware/dvisvgm/aminclude_static.am
index da2bc19bda..fa78c284ab 100644
--- a/dviware/dvisvgm/aminclude_static.am
+++ b/dviware/dvisvgm/aminclude_static.am
@@ -1,6 +1,6 @@
# aminclude_static.am generated automatically by Autoconf
-# from AX_AM_MACROS_STATIC on Tue Jan 10 14:41:23 CET 2023
+# from AX_AM_MACROS_STATIC on Mon Jan 30 08:25:52 CET 2023
# Code coverage
diff --git a/dviware/dvisvgm/configure b/dviware/dvisvgm/configure
index 3bd0835d9b..fe4f59ca6b 100755
--- a/dviware/dvisvgm/configure
+++ b/dviware/dvisvgm/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for dvisvgm 3.0.1.
+# Generated by GNU Autoconf 2.71 for dvisvgm 3.0.2.
#
# Report bugs to <martin.gieseking@uos.de>.
#
@@ -621,8 +621,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dvisvgm'
PACKAGE_TARNAME='dvisvgm'
-PACKAGE_VERSION='3.0.1'
-PACKAGE_STRING='dvisvgm 3.0.1'
+PACKAGE_VERSION='3.0.2'
+PACKAGE_STRING='dvisvgm 3.0.2'
PACKAGE_BUGREPORT='martin.gieseking@uos.de'
PACKAGE_URL=''
@@ -1441,7 +1441,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 3.0.1 to adapt to many kinds of systems.
+\`configure' configures dvisvgm 3.0.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1512,7 +1512,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvisvgm 3.0.1:";;
+ short | recursive ) echo "Configuration of dvisvgm 3.0.2:";;
esac
cat <<\_ACEOF
@@ -1661,7 +1661,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvisvgm configure 3.0.1
+dvisvgm configure 3.0.2
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2141,7 +2141,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 $as_me 3.0.1, which was
+It was created by dvisvgm $as_me 3.0.2, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@@ -3712,7 +3712,7 @@ fi
# Define the identity of the package.
PACKAGE='dvisvgm'
- VERSION='3.0.1'
+ VERSION='3.0.2'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -21365,7 +21365,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 $as_me 3.0.1, which was
+This file was extended by dvisvgm $as_me 3.0.2, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21433,7 +21433,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-dvisvgm config.status 3.0.1
+dvisvgm config.status 3.0.2
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
diff --git a/dviware/dvisvgm/configure.ac b/dviware/dvisvgm/configure.ac
index 7fa9e9b18f..27e1e2ec39 100644
--- a/dviware/dvisvgm/configure.ac
+++ b/dviware/dvisvgm/configure.ac
@@ -4,7 +4,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([dvisvgm],[3.0.1],[martin.gieseking@uos.de])
+AC_INIT([dvisvgm],[3.0.2],[martin.gieseking@uos.de])
DATE="January 2023"
AC_CONFIG_SRCDIR(src)
AC_CONFIG_HEADERS([config.h])
diff --git a/dviware/dvisvgm/doc/dvisvgm.1 b/dviware/dvisvgm/doc/dvisvgm.1
index 06705cef77..dc17575416 100644
--- a/dviware/dvisvgm/doc/dvisvgm.1
+++ b/dviware/dvisvgm/doc/dvisvgm.1
@@ -4,10 +4,10 @@
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 2022-10-14
.\" Manual: dvisvgm Manual
-.\" Source: dvisvgm 3.0.1
+.\" Source: dvisvgm 3.0.2
.\" Language: English
.\"
-.TH "DVISVGM" "1" "2022\-10\-14" "dvisvgm 3\&.0\&.1" "dvisvgm Manual"
+.TH "DVISVGM" "1" "2022\-10\-14" "dvisvgm 3\&.0\&.2" "dvisvgm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
diff --git a/dviware/dvisvgm/src/Bezier.hpp b/dviware/dvisvgm/src/Bezier.hpp
index 9036bfcd55..f79180ccb1 100644
--- a/dviware/dvisvgm/src/Bezier.hpp
+++ b/dviware/dvisvgm/src/Bezier.hpp
@@ -32,7 +32,7 @@ class QuadBezier {
QuadBezier ();
QuadBezier (const DPair &p0, const DPair &p1, const DPair &p2);
void setPoints (const DPair &p0, const DPair &p1, const DPair &p2);
- constexpr const DPair& point (int i) const {return _points[i];}
+ const DPair& point (int i) const {return _points[i];}
DPair valueAt (double t) const;
DPair derivativeAt (double t) const;
double arclen (double t=1.0) const;
@@ -57,7 +57,7 @@ class CubicBezier {
void subdivide (double t, CubicBezier *bezier1, CubicBezier *bezier2) const;
CubicBezier& transform (const Matrix &matrix);
int approximate (double delta, std::vector<DPair> &p, std::vector<double> *t=nullptr) const;
- constexpr const DPair& point (int i) const {return _points[i];}
+ const DPair& point (int i) const {return _points[i];}
int reduceDegree (double delta, std::vector<DPair> &p) const;
std::vector<QuadBezier> toQuadBeziers (double delta, std::vector<double> *startParams=nullptr) const;
BoundingBox getBBox () const;
diff --git a/dviware/dvisvgm/src/FontManager.cpp b/dviware/dvisvgm/src/FontManager.cpp
index 7eeaadeb9d..bc6f88d322 100644
--- a/dviware/dvisvgm/src/FontManager.cpp
+++ b/dviware/dvisvgm/src/FontManager.cpp
@@ -325,18 +325,18 @@ int FontManager::registerFont (uint32_t fontnum, const string &filename, int fon
/** Registers a native font that is referenced by its name instead of a DVI font number.
* @param[in] fname filename/path of the font file
+ * @param[in] fontname font name used if the font file doesn't provide one
* @param[in] ptsize font size in PS points
* return global ID assigned to the font */
-int FontManager::registerFont (const std::string &fname, double ptsize) {
+int FontManager::registerFont (const string &fname, string fontname, double ptsize) {
if (fname.empty())
return -1;
- string fontname;
if (fname.size() > 6 && fname.substr(0,6) == "sys://") {
fontname = fname.substr(6);
if (!find_base14_font(fontname))
return -1;
}
- else if (!FileSystem::exists(fname) || (fontname = FontEngine::instance().getPSName(fname)).empty())
+ else if (!FileSystem::exists(fname) || (fontname.empty() && (fontname = FontEngine::instance().getPSName(fname)).empty()))
return -1;
int id = fontID(fontname, ptsize);
if (id >= 0)
@@ -345,7 +345,7 @@ int FontManager::registerFont (const std::string &fname, double ptsize) {
id = fontID(fontname);
if (id < 0) {
nativeFont = util::make_unique<NativeFontImpl>(fname, fontname, ptsize);
- _name2id.emplace(std::move(fontname), _fonts.size());
+ _name2id.emplace(std::move(fontname), int(_fonts.size()));
}
else {
auto *nf = font_cast<NativeFont*>(getFontById(id));
diff --git a/dviware/dvisvgm/src/FontManager.hpp b/dviware/dvisvgm/src/FontManager.hpp
index eeaa1949de..503813a86d 100644
--- a/dviware/dvisvgm/src/FontManager.hpp
+++ b/dviware/dvisvgm/src/FontManager.hpp
@@ -57,8 +57,7 @@ class FontManager {
int registerFont (uint32_t fontnum, const std::string &fontname, uint32_t checksum, double dsize, double scale);
int registerFont (uint32_t fontnum, const std::string &fname, double ptsize, const FontStyle &style, Color color);
int registerFont (uint32_t fontnum, const std::string &fname, int fontIndex, double ptsize, const FontStyle &style, Color color);
-// int registerFont (const std::string &fname, int fontIndex, double ptsize, const FontStyle &style, Color color);
- int registerFont (const std::string &fname, double ptsize);
+ int registerFont (const std::string &fname, std::string fontname, double ptsize);
Font* getFont (int n) const;
Font* getFont (const std::string &name) const;
Font* getFont (const std::string &name, double ptsize);
diff --git a/dviware/dvisvgm/src/PDFHandler.cpp b/dviware/dvisvgm/src/PDFHandler.cpp
index 9703124e2c..ba88e69852 100644
--- a/dviware/dvisvgm/src/PDFHandler.cpp
+++ b/dviware/dvisvgm/src/PDFHandler.cpp
@@ -139,19 +139,6 @@ string PDFHandler::mutoolVersion () {
}
-/** Returns the bounding box of a selected PDF page. */
-BoundingBox PDFHandler::bbox (string &fname, int pageno) {
- BoundingBox bbox;
- string arraystr = mtShow(fname, "pages/" + to_string(pageno) + "/MediaBox");
- if (arraystr.substr(0, 4) == "null")
- arraystr = mtShow(fname, "pages/" + to_string(pageno) + "/Parent/MediaBox");
- auto vec = parse_pdf_array<double>(arraystr);
- if (vec.size() == 4)
- bbox = BoundingBox(vec[0], vec[1], vec[2], vec[3]);
- return bbox;
-}
-
-
/** Converts a single page of a PDF file to SVG. If no context element is given,
* the SVG page contents are added to a page group element of the SVG tree.
* Otherwise, they are added to the context element which is not inserted into
@@ -220,15 +207,12 @@ void PDFHandler::finishFile () {
void PDFHandler::initPage (int pageno, unique_ptr<SVGElement> context) {
_pageno = pageno;
- _bbox = bbox(_fname, pageno);
- if (context) {
+ if (!context)
+ _svg->newPage(_pageno);
+ else {
_context = context.get();
_svg->pushPageContext(std::move(context));
}
- else {
- _svg->newPage(_pageno);
- _svg->setBBox(_bbox);
- }
// collect sequence of images referenced on current page
collectObjects();
_imgSeq.clear();
@@ -287,7 +271,8 @@ void PDFHandler::elementClosed (XMLElement *trcElement) {
struct Handler {
const char *name;
void (PDFHandler::*func)(XMLElement*);
- } handlers[9] = {
+ } handlers[10] = {
+ {"page", &PDFHandler::doPage},
{"stroke_path", &PDFHandler::doStrokePath},
{"fill_path", &PDFHandler::doFillPath},
{"fill_image", &PDFHandler::doFillImage},
@@ -309,6 +294,13 @@ void PDFHandler::elementClosed (XMLElement *trcElement) {
}
+void PDFHandler::doPage (XMLElement *trcPageElement) {
+ auto vec = parse_attr_value<vector<double>>(trcPageElement, "mediabox");
+ if (vec.size() == 4)
+ _bbox = BoundingBox(vec[0], vec[1], vec[2], vec[3]);
+}
+
+
/** Returns a color object from color data given in the trace XML.
* @param[in] colorspace currently supported: DeviceGray, DeviceRGB, DeviceCMYK
* @param[in] value color components depending on color space */
@@ -645,8 +637,9 @@ void PDFHandler::doFillText (XMLElement *trcFillTextElement) {
filename = it->second.fname;
if (filename.empty())
filename = "sys://"+fontname;
- double ptsize = abs(trm[0]);
- int fontID = FontManager::instance().registerFont(filename, ptsize);
+ double ptsize = matrix_extent({trm[0], trm[1], 0, trm[2], trm[3]});
+ ptsize = round(10*ptsize)/10;
+ int fontID = FontManager::instance().registerFont(filename, fontname, ptsize);
if (fontID >= 0) {
auto font = font_cast<NativeFont*>(FontManager::instance().getFontById(fontID));
if (font != _currentFont) {
@@ -789,7 +782,6 @@ void PDFHandler::collectObjects () {
_objDict = parse_pdf_dict<ObjID>(mtShow("pages/" + to_string(_pageno) + "/Resources/XObject"));
// replace referenced font IDs by actual IDs used for extracted fonts
for (auto &entry : _objDict) {
- string objtype = mtShow(to_string(entry.second.num)+"/Type", SearchPattern(R"(/(\w+))", "$1"));
// store filenames of non-font object in object map
auto fnameIt = _extractedFiles.find(entry.second.num);
entry.second.fname = fnameIt != _extractedFiles.end() ? tmpdir+fnameIt->second : "";
@@ -798,6 +790,10 @@ void PDFHandler::collectObjects () {
if (entry.second.substr(0, 5) == "font-") {
string filepath = tmpdir+entry.second; // path to font file
string fontname = strip_subset_prefix(FontEngine::instance().getPSName(filepath));
+ // If the extracted font file doesn't contain a font name,
+ // try to get it from the corresponding PDF object.
+ if (fontname.empty())
+ fontname = mtShow(to_string(entry.first)+"/FontName", SearchPattern(R"(/(\w+))", "$1"));
_objDict.emplace(fontname, ObjID(entry.first, 0, filepath));
}
}
diff --git a/dviware/dvisvgm/src/PDFHandler.hpp b/dviware/dvisvgm/src/PDFHandler.hpp
index fd34ce0568..3400a1d69d 100644
--- a/dviware/dvisvgm/src/PDFHandler.hpp
+++ b/dviware/dvisvgm/src/PDFHandler.hpp
@@ -57,7 +57,6 @@ class PDFHandler {
const BoundingBox& bbox () const {return _bbox;}
std::unique_ptr<SVGElement> convert (const std::string &fname, int pageno, std::unique_ptr<SVGElement> context=nullptr);
static std::string mutoolVersion ();
- static BoundingBox bbox (std::string &fname, int pageno);
static bool available () {return !mutoolVersion().empty();}
protected:
@@ -77,6 +76,7 @@ class PDFHandler {
void collectObjects ();
void elementOpened (XMLElement *trcElement);
void elementClosed (XMLElement *trcElement);
+ void doPage (XMLElement *trcPageElement);
void doClipPath (XMLElement *trcClipPathElement);
void doClipStrokePath (XMLElement *trcClipStrokePathElement);
void doClipText (XMLElement *trcClipTextElement);
diff --git a/dviware/dvisvgm/src/RangeMap.cpp b/dviware/dvisvgm/src/RangeMap.cpp
index bac95b3093..11489113f3 100644
--- a/dviware/dvisvgm/src/RangeMap.cpp
+++ b/dviware/dvisvgm/src/RangeMap.cpp
@@ -179,7 +179,7 @@ uint32_t RangeMap::valueAt (uint32_t c) const {
/** Returns the number of values mapped. */
size_t RangeMap::numValues () const {
- return std::accumulate(_ranges.begin(), _ranges.end(), 0, [](size_t sum, const Range &range) {
+ return std::accumulate(_ranges.begin(), _ranges.end(), size_t(0), [](size_t sum, const Range &range) {
return sum+range.max()-range.min()+1;
});
}
diff --git a/dviware/dvisvgm/src/fonts/Base14Fonts.cpp b/dviware/dvisvgm/src/fonts/Base14Fonts.cpp
index 07f4850bc1..6f316ffca9 100644
--- a/dviware/dvisvgm/src/fonts/Base14Fonts.cpp
+++ b/dviware/dvisvgm/src/fonts/Base14Fonts.cpp
@@ -2,7 +2,7 @@
** Base14Fonts.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2022 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -38,6 +38,9 @@ extern const MemoryFontData NimbusSans_Italic_cff;
extern const MemoryFontData NimbusSans_Regular_cff;
extern const MemoryFontData StandardSymbolsPS_cff;
+/** Returns the CFF font data for a given name of a Base 14 font.
+ * If 'fontname' doesn't specify one of the 14 PDF base fonts,
+ * the function returns nullptr. */
const MemoryFontData* find_base14_font (const string &fontname) {
struct FontData {
const char *name;
diff --git a/dviware/dvisvgm/src/fonts/Base14Fonts.hpp b/dviware/dvisvgm/src/fonts/Base14Fonts.hpp
index 4e410fdc61..8746f593d6 100644
--- a/dviware/dvisvgm/src/fonts/Base14Fonts.hpp
+++ b/dviware/dvisvgm/src/fonts/Base14Fonts.hpp
@@ -2,7 +2,7 @@
** Base14Fonts.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2022 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **