--- SvgExporterPG-orig.js 2011-09-15 23:11:40.000000000 +0200 +++ SvgExporterPG.js 2011-09-30 12:02:31.182972504 +0200 @@ -384,32 +384,29 @@ continuous = true; } if (!continuous) { - //p.scale(this.getPatternFactor()); - p.scale(1/this.scale); + // dash and gap lengths are to be proportional to line weight + // beware: line weight unit is 100 times the current unit + // beware: the viewer scales lengths differently from weight + p.scale(this.weight / 100 / this.scale); var num = p.getNumDashes(); - var str = ""; + var str = []; for ( var i = 0; i < num; ++i) { var len = Math.abs(p.getDashLengthAt(i)); - // see FS#192: - //len = this.convert(len); - str += "" + len; - if (i < num - 1) { - str += ","; - } - } - additionalStyles += "stroke-dasharray:" + str; - - // does more harm than good -// if (isShape(this.shape)) { -// var length = this.shape.getLength(); -// if (isNaN(this.offset)) { -// this.offset = this.getPatternOffset(length, p); -// } else { -// var num = Math.ceil(this.offset / p.getPatternLength()); - // this.offset -= num * p.getPatternLength(); - // } - // additionalStyles += ";stroke-dashoffset:" + this.offset; - // } + str.push(len); + } + additionalStyles += "stroke-dasharray:" + str.join(","); + + // center dash-array + if (isShape(this.shape) && isFinite(this.shape.getLength())) { + var length = this.shape.getLength(); + if (isNaN(this.offset)) { + this.offset = -this.getPatternOffset(length, p); + } else { + var num = Math.ceil(this.offset / p.getPatternLength()); + this.offset -= num * p.getPatternLength(); + } + additionalStyles += ";stroke-dashoffset:" + this.offset; + } } SvgExporter.prototype.writeStyleAttribute.call(this, additionalStyles); @@ -428,9 +425,11 @@ // dimension entity: export text: this.writeEntityComment(entity); this.text = entity.getTextData(); -// var angle = this.text.getAngle(); -// var offset = RVector.createPolar(this.text.getHeight()/2, angle + Math.PI/2); -// this.text.move(offset); + var angle = this.text.getAngle(); + if (angle !== 0) { + var offset = RVector.createPolar(0, angle); + this.text.move(offset); + } this.textColor = entity.getColor(); this.exportText(); this.text = undefined;