summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp
index eb09cc0b8a3..75d83f2b4b6 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp
@@ -267,6 +267,11 @@ bool PsSpecialHandler::process (const string &prefix, istream &is, SpecialAction
* @param[in] fname EPS/PDF file to be included
* @param[in] attr attributes given with psfile/pdffile special */
void PsSpecialHandler::imgfile (FileType filetype, const string &fname, const unordered_map<string,string> &attr) {
+ // prevent warning about missing image file "/dev/null" which is
+ // added by option "psfixbb" of the preview package
+ if (fname == "/dev/null")
+ return;
+
const char *filepath = FileFinder::instance().lookup(fname, false);
if (!filepath && FileSystem::exists(fname))
filepath = fname.c_str();
@@ -398,31 +403,19 @@ static bool transform_box_extents (const Matrix &matrix, double &w, double &h, d
void PsSpecialHandler::dviEndPage (unsigned, SpecialActions &actions) {
BoundingBox bbox;
if (_previewFilter.getBoundingBox(bbox)) { // is there any data written by preview package?
- double w = max(0.0, _previewFilter.width());
- double h = max(0.0, _previewFilter.height());
- double d = max(0.0, _previewFilter.depth());
+ double w=0, h=0, d=0;
if (actions.getBBoxFormatString() == "preview" || actions.getBBoxFormatString() == "min") {
if (actions.getBBoxFormatString() == "preview") {
+ w = max(0.0, _previewFilter.width());
+ h = max(0.0, _previewFilter.height());
+ d = max(0.0, _previewFilter.depth());
actions.bbox() = bbox;
Message::mstream() << "\napplying bounding box set by";
}
else {
- // compute height, depth and width depending on the
- // tight bounding box derived from the objects on the page
- double y0 = bbox.maxY()-h; // y coordinate of the baseline
- h = actions.bbox().maxY()-y0;
- if (h < 0) {
- h = 0;
- d = actions.bbox().height();
- }
- else {
- d = y0-actions.bbox().minY();
- if (d < 0) {
- h = actions.bbox().height();
- d = 0;
- }
- }
w = actions.bbox().width();
+ h = max(0.0, -actions.bbox().minY());
+ d = max(0.0, actions.bbox().maxY());
Message::mstream() << "\ncomputing extents based on data set by";
}
Message::mstream() << " preview package (version " << _previewFilter.version() << ")\n";
@@ -442,28 +435,28 @@ void PsSpecialHandler::dviEndPage (unsigned, SpecialActions &actions) {
"height=" << XMLString(h*bp2pt) << "pt, "
"depth=" << XMLString(d*bp2pt) << "pt\n";
}
- }
#if 0
- XMLElementNode *rect = new XMLElementNode("rect");
- rect->addAttribute("x", actions.bbox().minX());
- rect->addAttribute("y", actions.bbox().minY());
- rect->addAttribute("width", w);
- rect->addAttribute("height", h+d);
- rect->addAttribute("fill", "none");
- rect->addAttribute("stroke", "red");
- rect->addAttribute("stroke-width", "0.5");
- actions.appendToPage(rect);
- if (d > 0) {
- XMLElementNode *line = new XMLElementNode("line");
- line->addAttribute("x1", actions.bbox().minX());
- line->addAttribute("y1", actions.bbox().minY()+h);
- line->addAttribute("x2", actions.bbox().maxX());
- line->addAttribute("y2", actions.bbox().minY()+h);
- line->addAttribute("stroke", "blue");
- line->addAttribute("stroke-width", "0.5");
- actions.appendToPage(line);
- }
+ auto rect = util::make_unique<XMLElementNode>("rect");
+ rect->addAttribute("x", actions.bbox().minX());
+ rect->addAttribute("y", actions.bbox().minY());
+ rect->addAttribute("width", w);
+ rect->addAttribute("height", h+d);
+ rect->addAttribute("fill", "none");
+ rect->addAttribute("stroke", "red");
+ rect->addAttribute("stroke-width", "0.1");
+ actions.appendToPage(std::move(rect));
+ if (d > 0) {
+ auto line = util::make_unique<XMLElementNode>("line");
+ line->addAttribute("x1", actions.bbox().minX());
+ line->addAttribute("y1", actions.bbox().minY()+h);
+ line->addAttribute("x2", actions.bbox().maxX());
+ line->addAttribute("y2", actions.bbox().minY()+h);
+ line->addAttribute("stroke", "blue");
+ line->addAttribute("stroke-width", "0.1");
+ actions.appendToPage(std::move(line));
+ }
#endif
+ }
}
// close dictionary TeXDict and execute end-hook if defined
if (_psSection == PS_BODY) {