[Sie-announce] SIEコード [2026] 1, tspan要素の処理を追加

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 9月 28日 (火) 23:31:36 JST


Revision: 2026
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2026
Author:   dhrname
Date:     2010-09-28 23:31:36 +0900 (Tue, 28 Sep 2010)

Log Message:
-----------
1, tspan要素の処理を追加
2, 文字列の微妙な位置設定をカーニングとして設定

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

Modified: branches/06x/061/org/w3c/dom/svg.js
===================================================================
--- branches/06x/061/org/w3c/dom/svg.js	2010-09-27 13:35:57 UTC (rev 2025)
+++ branches/06x/061/org/w3c/dom/svg.js	2010-09-28 14:31:36 UTC (rev 2026)
@@ -3292,7 +3292,26 @@
       } else {
         var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
       }
-      var kern = "fijltI.,:;'-", akern = "1a bcdeghknopqsuvxyz";
+      if (tar.localName === "tspan") {
+        /*現在のテキスト位置を、前のノードによって、
+         *変更する(tspan要素のみ)
+         */
+        var tpt = tar, d = 0;
+        while (tpt.previousSibling) {
+          if (tpt.previousSibling.nodeType === Node.TEXT_NODE) {
+            d += tpt.length;
+          } else if (tpt.previousSibling.localName === "tspan") {
+            d += tpt.getNumberOfChars();
+          }
+          tpt = tpt.previousSibling;
+        }
+        if (isYokogaki) {
+          x = tp.getSubStringLength(0, d);
+        } else {
+          y = tp.getSubStringLength(0, d);
+        }
+      }
+      var kern = "f ijltIr.,:;'-\"()", akern = "1234567890abcdeghknopquvxyz";
       if (isYokogaki) {
         y += fontSize * 0.2;
       } else {
@@ -3348,15 +3367,15 @@
               //カーニングを求めて、字の幅を文字ごとに調整する
               var tdc = ti.data.charAt(i);
               if (kern.indexOf(tdc) > -1) {
-                alm = fontSize * 0.7;
-              } else if ((tdc === "r") || (tdc === "s")){
-                alm = fontSize * 0.6;
-              } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G")){
+                alm = fontSize * 0.68;
+              } else if (tdc === "s"){
+                alm = fontSize * 0.52;
+              } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
                 alm = fontSize * 0.2;
               } else if (akern.indexOf(tdc) > -1){
-                alm = fontSize * 0.55;
+                alm = fontSize * 0.45;
               } else {
-                alm = fontSize * 0.35;
+                alm = fontSize * 0.3;
               }
               var tcca = tdc.charCodeAt(0);
               if ((12288 <= tcca) && (tcca <= 65533)) {
@@ -3379,7 +3398,7 @@
             ++n;
           }
         } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firtChild) {
-          this._list.concat(ti._list);
+          tar._list.concat(ti._list);
           n += ti.getNumberOfChars();
         }
         ti = ti.nextSibling;
@@ -3620,7 +3639,9 @@
         tar._tar.style.cursor = cursor;
       }
       var vis = style.getPropertyValue("visibility");
-      tar._tar.style.visibility = vis;
+      if (!!!vis._n) {
+        tar._tar.style.visibility = vis;
+      }
       var isRect = true;
       if (ttp.lastChild) {
         if (ttp.lastChild.nodeName !== "rect") {




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