svnno****@sourc*****
svnno****@sourc*****
2009年 10月 20日 (火) 23:41:52 JST
Revision: 1351
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1351
Author: dhrname
Date: 2009-10-20 23:41:52 +0900 (Tue, 20 Oct 2009)
Log Message:
-----------
FirefoxとOperaにはDOMParser方式のtext2svg機能を採用した
Modified Paths:
--------------
branches/05x/052/sie.js
Modified: branches/05x/052/sie.js
===================================================================
--- branches/05x/052/sie.js 2009-10-20 12:45:30 UTC (rev 1350)
+++ branches/05x/052/sie.js 2009-10-20 14:41:52 UTC (rev 1351)
@@ -1847,13 +1847,18 @@
//Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。(必須ではない)
function textToSVG( /*string*/ source, /*float*/ w, /*float*/ h) {
- var data = 'data:image/svg+xml;charset=utf-8,' + unescapeUTF16(escape(source));
- var ob = document.createElement("object");
- ob.setAttribute("data",data);
- ob.setAttribute("width",w);
- ob.setAttribute("height",h);
- ob.setAttribute("type","image/svg+xml");
- return ob;
+ if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
+ var data = 'data:image/svg+xml;charset=utf-8,' + unescapeUTF16(escape(source));
+ var ob = document.createElement("object");
+ ob.setAttribute("data",data);
+ ob.setAttribute("width",w);
+ ob.setAttribute("height",h);
+ ob.setAttribute("type","image/svg+xml");
+ return ob;
+ } else {
+ var doc = (new DOMParser()).parseFromString(source, "text/xml");
+ return (document.importNode(doc.documentElement, true));
+ }
}
//XMLHttpRequestオブジェクトの作成