--- SvgExporter.js~ 2011-08-19 15:58:00.000000000 +0200 +++ SvgExporter.js 2011-08-27 14:40:46.989516955 +0200 @@ -276,8 +276,8 @@ for ( var c = 0; c < path.getElementCount(); ++c) { // move to, line to, curve to, curve to, data var type = path.getTypeAt(c); - var x = path.getXAt(c); // data point x - var y = path.getYAt(c); // data point y + var x = this.convert(path.getXAt(c)); // data point x + var y = this.convert(path.getYAt(c)); // data point y if (type == QPainterPath.MoveToElement) { str += "M%1,%2 ".arg(x).arg(y); } else if (type == QPainterPath.LineToElement) { @@ -605,7 +605,7 @@ width = RUnit.convert(this.weight / 100.0, RS.Millimeter, this.doc .getUnit()); } - return this.convert(width); + return width; }; SvgExporter.prototype.writeStyleAttribute = function(additionalStyles) { --- SvgExporterPG.js~ 2011-08-19 15:58:00.000000000 +0200 +++ SvgExporterPG.js 2011-08-27 14:40:48.049517131 +0200 @@ -186,15 +186,15 @@ var pos = this.convert(point.getPosition()); - // export as circles + // export as circles, do not double convert Position if (this.pointsAsCircles) { - var circle = new RCircle(pos, this.circleRadius); + var circle = new RCircle(point.getPosition(), this.convert(this.circleRadius)); this.exportCircle(circle); return; } // export as crosses - var s = this.crossSize / 2; + var s = this.convert(this.crossSize / 2); var p0 = pos.operator_add(new RVector(-s, 0)); var p1 = pos.operator_add(new RVector(s, 0)); var p2 = pos.operator_add(new RVector(0, -s)); @@ -302,12 +302,29 @@ var y = this.convert(pos.y) * -1; this.writeAttribute("y", y); var h = this.text.getTextHeight(); - // this.writeAttribute("dy", h / 2); - this.writeAttribute("dy", h); + if (this.text.getVAlign() == RS.VAlignTop) { + this.writeAttribute("dy", this.convert(h)); + } else if (this.text.getVAlign() == RS.VAlignMiddle) { + this.writeAttribute("dy", this.convert(h / 2)); + } else if (this.text.getVAlign() == RS.VAlignBase) { + this.writeAttribute("dy", 0); + } else if (this.text.getVAlign() == RS.VAlignBottom) { + this.writeAttribute("dy", 0); + } this.writeFontAttributes(); var a = 360 - RMath.rad2deg(this.text.getAngle()); this.writeAttribute("transform", "scale(1,-1) rotate(" + a + " " + x + "," + y + ")"); + if (this.text.getHAlign() == RS.HAlignLeft + || this.text.getHAlign() == RS.HAlignAlign + || this.text.getHAlign() == RS.HAlignFit) { + this.writeAttribute("text-anchor", "start"); + } else if (this.text.getHAlign() == RS.HAlignRight) { + this.writeAttribute("text-anchor", "end"); + } else if (this.text.getHAlign() == RS.HAlignCenter + || this.text.getHAlign() == RS.HAlignMid) { + this.writeAttribute("text-anchor", "middle"); + } this.exportLineText(this.text.getPlainText()); this.writeEndElement("text"); // }; @@ -319,13 +336,19 @@ SvgExporterPG.prototype.writeFontAttributes = function() { this.writeAttribute("font-family", this.text.getFontName()); - var h = this.text.getTextHeight(); + var h = this.convert(this.text.getTextHeight()); + if (this.text.isBold()) { + this.writeAttribute("font-weight", "bold"); + } + if (this.text.isItalic()) { + this.writeAttribute("font-style", "italic"); + } // this.writeAttribute("font-size", h); this.writeAttribute("font-size", h * 1.4); // why 1.4? // this.writeAttribute("line-height", this.text.getLineSpacingFactor() * 1.1); this.writeAttribute("line-height", this.text.getLineSpacingFactor() * 1.1); var c = this.textColor; - this.writeAttribute("fill", c.name()); + this.writeAttribute("fill", this.getColorName(c)); }; SvgExporterPG.prototype.writeStyleAttribute = function(additionalStyles) { @@ -351,7 +374,6 @@ var str = ""; for ( var i = 0; i < num; ++i) { var len = Math.abs(p.getDashLengthAt(i)); - len = this.convert(len); str += "" + len; if (i < num - 1) { str += ","; @@ -384,14 +406,6 @@ this.exportText(); this.text = undefined; return; - } else if (isFunction(entity.getTextData)) { - // dimension entity: export text: - this.writeEntityComment(entity); - this.text = entity.getTextData(); - this.textColor = entity.getColor(); - this.exportText(); - this.text = undefined; - return; } // other entities without text: