From 54288872a1eb5c36a5d8b6fbcc9cafb1f38cefad Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 9 Sep 2019 14:44:19 +0200 Subject: Bug 674005 - Crop png formula environnment problem for HTML output `divips -E` does not always return the correct bounding box. The program `ps2epsi` returns a good bounding box. - don't use the `-E` with `dvips` - convert the file from `dvips` with `ps2epsi` to an encapsulated postscript file --- src/formula.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/formula.cpp b/src/formula.cpp index 1c5042e..534f56a 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -118,11 +118,12 @@ void FormulaList::generateBitmaps(const char *path) int pageNum=*pagePtr; msg("Generating image form_%d.png for formula\n",pageNum); char dviArgs[4096]; + char psArgs[4096]; QCString formBase; formBase.sprintf("_form%d",pageNum); // run dvips to convert the page with number pageIndex to an - // encapsulated postscript. - sprintf(dviArgs,"-q -D 600 -E -n 1 -p %d -o %s.eps _formulas.dvi", + // postscript file. + sprintf(dviArgs,"-q -D 600 -n 1 -p %d -o %s_tmp.ps _formulas.dvi", pageIndex,formBase.data()); portable_sysTimerStart(); if (portable_system("dvips",dviArgs)!=0) @@ -133,6 +134,18 @@ void FormulaList::generateBitmaps(const char *path) return; } portable_sysTimerStop(); + // run ps2epsi to convert to an encapsulated postscript file with + // boundingbox (dvips with -E has some problems here). + sprintf(psArgs,"%s_tmp.ps %s.eps",formBase.data(),formBase.data()); + portable_sysTimerStart(); + if (portable_system("ps2epsi",psArgs)!=0) + { + err("Problems running ps2epsi. Check your installation!\n"); + portable_sysTimerStop(); + QDir::setCurrent(oldDir); + return; + } + portable_sysTimerStop(); // now we read the generated postscript file to extract the bounding box QFileInfo fi(formBase+".eps"); if (fi.exists()) @@ -282,6 +295,7 @@ void FormulaList::generateBitmaps(const char *path) f.close(); } // remove intermediate image files + thisDir.remove(formBase+"_tmp.ps"); thisDir.remove(formBase+".eps"); thisDir.remove(formBase+".pnm"); thisDir.remove(formBase+".ps"); -- cgit v0.12