summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-02-24 03:00:45 +0000
committerNorbert Preining <norbert@preining.info>2022-02-24 03:00:45 +0000
commitdc88afec77f198ebb8774f9c87146f2985e8f156 (patch)
treec2ffe8156173930a3f167b2cdeeb4fc1cd66a6b3 /dviware/dvisvgm/src
parentd529109bf475e3f1e220ce0e980e104b1a7e3c6b (diff)
CTAN sync 202202240300
Diffstat (limited to 'dviware/dvisvgm/src')
-rw-r--r--dviware/dvisvgm/src/BoundingBox.cpp2
-rw-r--r--dviware/dvisvgm/src/BoundingBox.hpp2
-rw-r--r--dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/PSPattern.cpp2
-rw-r--r--dviware/dvisvgm/src/PsSpecialHandler.cpp21
-rw-r--r--dviware/dvisvgm/src/SVGTree.cpp2
6 files changed, 18 insertions, 13 deletions
diff --git a/dviware/dvisvgm/src/BoundingBox.cpp b/dviware/dvisvgm/src/BoundingBox.cpp
index 7276d717da..d79848f8f9 100644
--- a/dviware/dvisvgm/src/BoundingBox.cpp
+++ b/dviware/dvisvgm/src/BoundingBox.cpp
@@ -246,7 +246,7 @@ void BoundingBox::transform (const Matrix &tm) {
}
-string BoundingBox::toSVGViewBox () const {
+string BoundingBox::svgViewBoxString () const {
ostringstream oss;
oss << XMLString(_ulx) << ' ' << XMLString(_uly) << ' ' << XMLString(width()) << ' ' << XMLString(height());
return oss.str();
diff --git a/dviware/dvisvgm/src/BoundingBox.hpp b/dviware/dvisvgm/src/BoundingBox.hpp
index 339bc7eb41..e9ffe2c946 100644
--- a/dviware/dvisvgm/src/BoundingBox.hpp
+++ b/dviware/dvisvgm/src/BoundingBox.hpp
@@ -76,7 +76,7 @@ class BoundingBox {
bool operator != (const BoundingBox &bbox) const {return !(*this == bbox);}
void scale (double sx, double sy);
void transform (const Matrix &tm);
- std::string toSVGViewBox () const;
+ std::string svgViewBoxString () const;
std::ostream& write (std::ostream &os) const;
std::unique_ptr<XMLElement> createSVGRect () const;
diff --git a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
index 9a38ef9b3b..077e030776 100644
--- a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
@@ -162,7 +162,7 @@ static void expand_constants (string &str, SpecialActions &actions) {
++endpos;
if (str[endpos] == '}') {
BoundingBox &box=actions.bbox(str.substr(pos+7, endpos-pos-7));
- str.replace(pos, endpos-pos+1, box.toSVGViewBox());
+ str.replace(pos, endpos-pos+1, box.svgViewBoxString());
}
else
repl_bbox = false;
diff --git a/dviware/dvisvgm/src/PSPattern.cpp b/dviware/dvisvgm/src/PSPattern.cpp
index 3232c88bbe..cbb4f10807 100644
--- a/dviware/dvisvgm/src/PSPattern.cpp
+++ b/dviware/dvisvgm/src/PSPattern.cpp
@@ -71,7 +71,7 @@ unique_ptr<XMLElement> PSTilingPattern::createPatternNode () const {
pattern->addAttribute("y", box.minY());
pattern->addAttribute("width", box.width());
pattern->addAttribute("height", box.height());
- pattern->addAttribute("viewBox", box.toSVGViewBox());
+ pattern->addAttribute("viewBox", box.svgViewBoxString());
pattern->addAttribute("patternUnits", "userSpaceOnUse");
if (!_matrix.isIdentity())
pattern->addAttribute("patternTransform", _matrix.toSVG());
diff --git a/dviware/dvisvgm/src/PsSpecialHandler.cpp b/dviware/dvisvgm/src/PsSpecialHandler.cpp
index 66514d1b08..ff853c72ee 100644
--- a/dviware/dvisvgm/src/PsSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PsSpecialHandler.cpp
@@ -422,12 +422,18 @@ unique_ptr<SVGElement> PsSpecialHandler::createImageNode (FileType type, const s
node->addAttribute("xlink:href", href);
}
else { // PostScript or PDF
- // clip image to its bounding box if flag 'clip' is given
- string rectclip;
- if (clip)
- rectclip = to_string(bbox.minX())+" "+to_string(bbox.minY())+" "+to_string(bbox.width())+" "+to_string(bbox.height())+" rectclip";
-
- node = util::make_unique<SVGElement>("g"); // put SVG nodes created from the EPS/PDF file in this group
+ if (!clip)
+ node = util::make_unique<SVGElement>("g");
+ else {
+ // clip image to its bounding box if flag 'clip' is given
+ node = util::make_unique<SVGElement>("svg");
+ node->addAttribute("overflow", "hidden");
+ node->addAttribute("x", bbox.minX());
+ node->addAttribute("y", bbox.minY());
+ node->addAttribute("width", bbox.width());
+ node->addAttribute("height", bbox.height());
+ node->addAttribute("viewBox", bbox.svgViewBoxString());
+ }
_xmlnode = node.get();
_psi.execute(
"\n@beginspecial @setspecial" // enter special environment
@@ -435,8 +441,7 @@ unique_ptr<SVGElement> PsSpecialHandler::createImageNode (FileType type, const s
"/@imgbase("+image_base_path(*_actions)+")store " // path and basename of image files
"matrix setmatrix" // don't apply outer PS transformations
"/FirstPage "+to_string(pageno)+" def" // set number of first page to convert (PDF only)
- "/LastPage "+to_string(pageno)+" def " // set number of last page to convert (PDF only)
- +rectclip+ // clip to bounding box (if requexted by attribute 'clip')
+ "/LastPage "+to_string(pageno)+" def" // set number of last page to convert (PDF only)
"(" + pathstr + ")run " // execute file content
"@endspecial\n" // leave special environment
);
diff --git a/dviware/dvisvgm/src/SVGTree.cpp b/dviware/dvisvgm/src/SVGTree.cpp
index 8463ef08f1..f4cd9a85ef 100644
--- a/dviware/dvisvgm/src/SVGTree.cpp
+++ b/dviware/dvisvgm/src/SVGTree.cpp
@@ -72,7 +72,7 @@ void SVGTree::setBBox (const BoundingBox &bbox) {
_root->addAttribute("width", XMLString(bbox.width()*ZOOM_FACTOR)+"pt");
_root->addAttribute("height", XMLString(bbox.height()*ZOOM_FACTOR)+"pt");
}
- _root->addAttribute("viewBox", bbox.toSVGViewBox());
+ _root->addAttribute("viewBox", bbox.svgViewBoxString());
}