SourceForge: dvisvgm/dvisvgm: changeset 359:b27591bd60cc
fixed path scaling issue in PS handler
authorMartin Gieseking <mgieseki@users.sourceforge.net>
Fri Nov 06 22:57:31 2009 +0100 (2 weeks ago)
changeset 359b27591bd60cc
parent 358742dc459a53e
child 3601a7811edd130
fixed path scaling issue in PS handler
NEWS
src/PsSpecialHandler.cpp
     1.1 --- a/NEWS	Fri Nov 06 21:08:36 2009 +0100
     1.2 +++ b/NEWS	Fri Nov 06 22:57:31 2009 +0100
     1.3 @@ -1,6 +1,7 @@
     1.4  dvisvgm-0.8.7
     1.5  - fixed bounding box issue concerning italic corrections
     1.6  - PS handler: zero-length paths are now drawn as dots
     1.7 +- PS handler: fixed a path positioning issue
     1.8  - added macro {?nl} to be used with special dvisvgm:raw
     1.9  
    1.10  dvisvgm-0.8.6
     2.1 --- a/src/PsSpecialHandler.cpp	Fri Nov 06 21:08:36 2009 +0100
     2.2 +++ b/src/PsSpecialHandler.cpp	Fri Nov 06 22:57:31 2009 +0100
     2.3 @@ -286,12 +286,19 @@
     2.4   *  @param[in] p not used */
     2.5  void PsSpecialHandler::stroke (vector<double> &p) {
     2.6  	if (!_path.empty() && _actions) {
     2.7 +		BoundingBox bbox;
     2.8 +		if (!_actions->getMatrix().isIdentity()) {
     2.9 +			_path.transform(_actions->getMatrix());
    2.10 +			if (!_xmlnode)
    2.11 +				bbox.transform(_actions->getMatrix());
    2.12 +		}
    2.13 +
    2.14  		const double pt = 72.27/72.0;  // factor to convert bp -> pt
    2.15  		ScalingMatrix scale(pt, pt);
    2.16  		_path.transform(scale);
    2.17 +		bbox.transform(scale);
    2.18  
    2.19  		XMLElementNode *path=0;
    2.20 -		BoundingBox bbox;
    2.21  		Pair<double> point;
    2.22  		if (_path.isDot(point)) {  // zero-length path?
    2.23  			if (_linecap == 1) {     // round line ends?  => draw dot
    2.24 @@ -310,11 +317,6 @@
    2.25  			// compute bounding box
    2.26  			_path.computeBBox(bbox);
    2.27  			bbox.expand(_linewidth/2);
    2.28 -			if (!_actions->getMatrix().isIdentity()) {
    2.29 -				_path.transform(_actions->getMatrix());
    2.30 -				if (!_xmlnode)
    2.31 -					bbox.transform(_actions->getMatrix());
    2.32 -			}
    2.33  
    2.34  			ostringstream oss;
    2.35  			_path.writeSVG(oss);
    2.36 @@ -366,10 +368,6 @@
    2.37   *  @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */
    2.38  void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
    2.39  	if (!_path.empty() && _actions) {
    2.40 -		const double pt = 72.27/72.0;  // factor to convert bp -> pt
    2.41 -		ScalingMatrix scale(pt, pt);
    2.42 -		_path.transform(scale);
    2.43 -
    2.44  		// compute bounding box
    2.45  		BoundingBox bbox;
    2.46  		_path.computeBBox(bbox);
    2.47 @@ -379,6 +377,11 @@
    2.48  				bbox.transform(_actions->getMatrix());
    2.49  		}
    2.50  
    2.51 +		const double pt = 72.27/72.0;  // factor to convert bp -> pt
    2.52 +		ScalingMatrix scale(pt, pt);
    2.53 +		_path.transform(scale);
    2.54 +		bbox.transform(scale);
    2.55 +
    2.56  		ostringstream oss;
    2.57  		_path.writeSVG(oss);
    2.58  		XMLElementNode *path = new XMLElementNode("path");
    2.59 @@ -418,12 +421,13 @@
    2.60  void PsSpecialHandler::clip (vector<double> &p, bool evenodd) {
    2.61  	// when this method is called, _path contains the clipping path
    2.62  	if (!_path.empty() && _actions) {
    2.63 +		if (!_actions->getMatrix().isIdentity())
    2.64 +			_path.transform(_actions->getMatrix());
    2.65 +
    2.66  		const double pt = 72.27/72.0;  // factor to convert bp -> pt
    2.67  		ScalingMatrix scale(pt, pt);
    2.68  		_path.transform(scale);
    2.69  
    2.70 -		if (!_actions->getMatrix().isIdentity())
    2.71 -			_path.transform(_actions->getMatrix());
    2.72  
    2.73  		int oldID = _clipStack.topID();
    2.74  		_clipStack.replace(_path);