在draw2d中使用Canvas 的setZoom function来扩大,缩小画布进而放大,缩小画布上的图形大小。(Zoom in/Zoom Out功能)。
图形类型Circle, Rectangle的放大,缩小都还正常,
但是 在Chrome浏览器下Label 的缩小功能却存在着label 的文本缩小时反而会变大的状况。
具体的测试方式如下:
1. 没有给label 特别设定font size。 看上去字体默认大小是10px.
2. Zoom out(缩小)画布时, 文本的字体看上去反而变大了,其他图形都是正常的。
( 放大:canvas.setZoom(0.95, false);
缩小:canvas.setZoom(1.05, false);)
3. 试试其他浏览器, 在 Firefox是正常的。
<a style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" xlink:title="8g High-sensitivity R-Touch support" id="ui-id-5"> <text style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: start; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-family: Arial; " x="0" y="7" text-anchor="start" font="10px "Arial"" stroke="none" fill="#ffffff" title="8g High-sensitivity R-Touch support" transform="matrix(1,0,0,1,5007,4846.5)" stroke-width="1"> <tspan style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" dy="3.5">Label Text</tspan> </text> </a>产生的就是a 标签下包含一个text 标签, text 标签下包含一个tspan标签。
<!-- Create By oscar999 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script src="raphael.js" type="text/javascript" charset="utf-8"></script> </head> <body> <input type="button" value="Change Viewbox Big" onclick="setTestViewBox('big')"> <input type="button" value="Change Viewbox Small" onclick="setTestViewBox('small')"> <script> var paper = Raphael(10,50,620,400); var circle = paper.circle(50,40,10); var t = paper.text(100, 100, "Raphaël kicks butt!"); circle.attr("fill","#f00"); var i=2; var sOldTyle=""; function setTestViewBox(stype) { if(sOldTyle!=stype) { sOldTyle = stype; i=1; } if(stype=="big") { paper.setViewBox(0, 0, 620/i, 400/i); }else{ paper.setViewBox(0, 0, 620*i, 400*i); } i++; } </script> </body> </html>
<text style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-family: Arial;" x="100" y="100" text-anchor="middle" font="10px "Arial"" stroke="none" fill="#000000" stroke-width="1"> <tspan style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" dy="3.5">Raphaël kicks butt!</tspan> </text>和draw2d是类似的。
结果是失败了。
实际上,在未安装链接文章方式设置CSS之前,查看最终产生的CSS, 已经有包含这个设置了。
text, tspan, tref {
}