# HG changeset patch # User wycc # Date 1302497679 -28800 # Node ID b12c513212af6df809a65268339fc105c5652485 # Parent 4be04f29fa708af7d7a8df7672e9369712ca656e A prelimanary support for the SVG 1.2 flowRoot style text support. This is useless unless the region is rectangle. sort the scenes by layer and start attribute. diff -r 4be04f29fa70 -r b12c513212af nodejs/svg.js --- a/nodejs/svg.js Mon Apr 11 12:52:09 2011 +0800 +++ b/nodejs/svg.js Mon Apr 11 12:54:39 2011 +0800 @@ -78,10 +78,34 @@ this.parseGroup(accu,coord,'root_coord',nodes[k]); } } + + this.sortScene(); } +loadSVG.prototype.sortScene=function() +{ + for(i=0;i b.layer) return 1; + if (a.layer < b.layer) return -1; + if (a.start > b.start) return 1; + if (a.start < b.start) return -1; + return 0; + }); + sys.puts("scenes"); + for(i=0;i nx) + coord.center.x = nx; + var ny = coord[3]*tcoord.text_x+coord[4]*tcoord.text_y+coord[5]; + if (coord.center.y > ny) + coord.center.y = ny; + this._set_bbox(n, tcoord); + + make_mbnames(this.mb_rt, n, tcoord); +} + loadSVG.prototype.parseText=function(accu,coord,id, n) { var nodes = n.childNodes(); @@ -826,6 +925,11 @@ n.coord = tcoord; this._check_duplicate_src(n,tcoord); + tcoord.sx = 1; + tcoord.sy = 1; + tcoord.r = 0; + tcoord.tx = 0; + tcoord.ty = 0; if (n.attr('x')) { var nx = coord[0]*x+coord[1]*y+coord[2]; if (coord.center.x > nx) @@ -836,6 +940,7 @@ if (coord.center.y > ny) coord.center.y = ny; } + style = parse_style(n); var nodes = n.childNodes(); var k; @@ -1076,7 +1181,12 @@ } else { n.coord.isuse = false; } - var attr = n.attr('duplicate-src'); + + // A workaround, should be removed. + var attr = n.attr('saved_id'); + if (attr) return; + + attr = n.attr('duplicate-src'); if (attr == null) { sys.puts("no duplicated" + n); return; @@ -1088,6 +1198,7 @@ } this.mb_rt.mbnames[id].target = coord; coord.refid = this.mb_rt.mbnames[id].id; + sys.puts("set the refid of "+id+" to be "+coord.refid); } catch(e) { sys.puts("id "+id+" is not defined"); } @@ -1106,6 +1217,7 @@ n.coord = coord; coord.node = n; + n.layer = root.id; this._check_duplicate_src(n,coord); coord.center= new Object(); @@ -1142,6 +1254,8 @@ this.parsePath(accu,coord, id, nodes[k]); } else if (c == "text") { this.parseText(accu,coord, id, nodes[k]); + } else if (c == "flowRoot") { + this.parseFlowRoot(accu, coord, id, nodes[k]); } else if (c == "rect") { this.parseRect(accu_matrix,coord, id, nodes[k]); } else if (c == "image") {