[Sie-announce] SIEコード [2225] SVGFontに関する修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 12月 17日 (金) 23:34:55 JST


Revision: 2225
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2225
Author:   dhrname
Date:     2010-12-17 23:34:55 +0900 (Fri, 17 Dec 2010)

Log Message:
-----------
SVGFontに関する修正

Modified Paths:
--------------
    branches/06x/066/org/w3c/dom/svg.js

Modified: branches/06x/066/org/w3c/dom/svg.js
===================================================================
--- branches/06x/066/org/w3c/dom/svg.js	2010-12-16 13:51:55 UTC (rev 2224)
+++ branches/06x/066/org/w3c/dom/svg.js	2010-12-17 14:34:55 UTC (rev 2225)
@@ -5199,7 +5199,7 @@
         for (var i=0,tli=textElements.length;i<tli;++i) {
           var ti = textElements[i], style = tar.ownerDocument.defaultView.getComputedStyle(ti, '');
           if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
-            NAIBU._noie_createFont(ti, tar);
+            NAIBU._noie_createFont(ti, tar, true);
           }
         }
         evt = tar = svg = curt = textElments = svgns = null;
@@ -5273,7 +5273,7 @@
     for (var i=0,tli=textElements.length;i<tli;++i) {
       var ti = textElements[i], style = tar.ownerDocument.defaultView.getComputedStyle(ti, '');
       if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
-        NAIBU._noie_createFont(ti, tar._instance);
+        NAIBU._noie_createFont(ti, tar._instance, true);
       }
     }
     tar.ownerDocument.documentElement.__isExternalFont = 1;
@@ -5428,18 +5428,18 @@
     for (var i=0,tli=textElements.length;i<tli;++i) {
       var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
       if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
-        NAIBU._noie_createFont(ti, font);
+        NAIBU._noie_createFont(ti, font, true);
       }
     }
   }
   doc = data = null;
 };
-NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font) {
+NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''), svgns = "http://www.w3.org/2000/svg";
   //isTategakiは縦書きならば真
   var isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"), horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x";
   var node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph");
-  var em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttribute("units-per-em") || 0);
+  var em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttribute("units-per-em") || 1000);
   var advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ); //字幅の設定
   var dx = parseFloat(ti.getAttributeNS(null, "x") || 0), fontSize = parseFloat(style.getPropertyValue("font-size")), dy = parseFloat(ti.getAttributeNS(null, "y") || 0), fe = fontSize / em;
   var ds = false, npdlist = ["fill",
@@ -5453,12 +5453,15 @@
   "stroke-opacity",
   "opacity",
   "cursor"];
+  if (isMSIE) {
+    /*IEのみ、font-sizeは自動で調整されているものを使った方がよい*/
+    fontSize = parseFloat(ti._tar.style.fontSize);
+    fe = fontSize / em;
+  }
   if (/a/[-1] === 'a') { //Firefoxならば
     ds = true;
-  } else {
-    if (isTategaki) {
-      ds = true;
-    }
+  } else if (isMSIE || isTategaki) {
+    ds = true;
   }
   if (ds){
      while(node) {
@@ -5489,7 +5492,7 @@
           if (advanceX[i] !== void 0) { //配列に含まれていれば
             var path = ti.ownerDocument.createElementNS(svgns, "path");
             //advance、すなわち字幅の長さ分、ずらしていく
-            var matrix = ti.ownerDocument.createSVGMatrix();
+            var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
             matrix.a = fe;
             matrix.d = -fe;
             for (var j=0;j<npdlist.length;++j){
@@ -5521,11 +5524,11 @@
         }
         adv = advanceX = glyphData = null;
       } else {
-        NAIBU._noie_createFont(node, font);
+        NAIBU._noie_createFont(node, font, isMSIE);
       }
       node = node.nextSibling;
     }
-    ti.style.setProperty("opacity", "0", null);
+    ti.setAttributeNS(null, "opacity", "0");
   }
   data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = null;
 };




Sie-announce メーリングリストの案内
Back to archive index