Skip to content

Commit

Permalink
Bug 674005 - Crop png formula environnment problem for HTML output
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
albert-github committed Sep 9, 2019
1 parent 81da20f commit 5428887
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/formula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 5428887

Please sign in to comment.