Added adjust KAKATO function.
authorKoichi KAMICHI <kamichi@fonts.jp>
Mon, 25 Aug 2008 12:03:30 +0000 (12:03 +0000)
committerKoichi KAMICHI <kamichi@fonts.jp>
Mon, 25 Aug 2008 12:03:30 +0000 (12:03 +0000)
engine/kage.js
engine/kagecd.js
engine/kagedf.js
engine/polygons.js
engine/test.js

index 16f2856..b2d9710 100755 (executable)
-function Kage(){\r
-  // method\r
-  function makeGlyph(polygons, target){ // void\r
-    var buhin = this.kBuhin.search(target);\r
-    if(buhin != ""){\r
-      this.drawGlyph(polygons, buhin);\r
-    }\r
-  }\r
-  Kage.prototype.makeGlyph = makeGlyph;\r
-\r
-  function drawGlyph(polygons, glyph){ // void\r
-    // [glyph] : [stroke]$[stroke]$.....\r
-    // [stroke] : [column]:[column]:.....\r
-    var strokes = glyph.split("$");\r
-    for(var i = 0; i < strokes.length; i++){\r
-      var columns = strokes[i].split(":");\r
-      if(Math.floor(columns[0]) != 99){\r
-       dfDrawFont(this, polygons,\r
-                  Math.floor(columns[0]),\r
-                  Math.floor(columns[1]), Math.floor(columns[2]),\r
-                  Math.floor(columns[3]), Math.floor(columns[4]),\r
-                  Math.floor(columns[5]), Math.floor(columns[6]),\r
-                  Math.floor(columns[7]), Math.floor(columns[8]),\r
-                  Math.floor(columns[9]), Math.floor(columns[10]));\r
-      } else {\r
-       var buhin = this.kBuhin.search(columns[7]);\r
-       if(buhin != ""){\r
-         this.drawBuhin(polygons, buhin,\r
-                        Math.floor(columns[3]),\r
-                        Math.floor(columns[4]),\r
-                        Math.floor(columns[5]),\r
-                        Math.floor(columns[6]));\r
-       }\r
-      }\r
-    }\r
-  }\r
-  Kage.prototype.drawGlyph = drawGlyph;\r
-  \r
-  function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void\r
-    var strokes = glyph.split("$");\r
-    for(var i = 0; i < strokes.length; i++){\r
-      var columns = strokes[i].split(":");\r
-      if(Math.floor(columns[0]) != 99){\r
-       dfDrawFont(this, polygons,\r
-                  Math.floor(columns[0]),\r
-                  Math.floor(columns[1]),\r
-                  Math.floor(columns[2]),\r
-                  x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
-                  y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
-                  x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
-                  y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
-                  x1 + Math.floor(columns[7]) * (x2 - x1) / 200,\r
-                  y1 + Math.floor(columns[8]) * (y2 - y1) / 200,\r
-                  x1 + Math.floor(columns[9]) * (x2 - x1) / 200,\r
-                  y1 + Math.floor(columns[10]) * (y2 - y1) / 200);\r
-      } else {\r
-       var buhin = this.kBuhin.search(columns[7]);\r
-       if(buhin != ""){\r
-         this.drawBuhin(polygons, buhin,\r
-                        x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
-                        y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
-                        x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
-                        y1 + Math.floor(columns[6]) * (y2 - y1) / 200);\r
-       }\r
-      }\r
-    }\r
-  }\r
-  Kage.prototype.drawBuhin = drawBuhin;\r
-  \r
-  //properties\r
-  Kage.prototype.kMincho = 0;\r
-  Kage.prototype.kGothic = 1;\r
-  this.kShotai = this.kMincho;\r
-  this.kMage = 10;\r
-  this.kRate = 100;\r
-  this.kMinWidthY = 2;\r
-  this.kMinWidthT = 6;\r
-  this.kWidth = 5;\r
-  this.kKakato = 3;\r
-  //has KAKATO = 2, no KAKATO = 1\r
-  this.kL2RDfatten = 1.1;\r
-  this.kBuhin = new Buhin();\r
-  \r
-  return this;\r
-}\r
+function Kage(){
+  // method
+  function makeGlyph(polygons, buhin){ // void
+    var glyphData = this.kBuhin.search(buhin);
+    if(glyphData != ""){
+      this.drawStrokesArray(polygons, this.adjustKakato(this.getEachStrokes(glyphData)));
+    }
+  }
+  Kage.prototype.makeGlyph = makeGlyph;
+  
+  function getEachStrokes(glyphData){ // strokes array
+    var strokesArray = new Array();
+    var strokes = glyphData.split("$");
+    for(var i = 0; i < strokes.length; i++){
+      var columns = strokes[i].split(":");
+      if(Math.floor(columns[0]) != 99){
+        strokesArray.push([
+          Math.floor(columns[0]),
+          Math.floor(columns[1]),
+          Math.floor(columns[2]),
+          Math.floor(columns[3]),
+          Math.floor(columns[4]),
+          Math.floor(columns[5]),
+          Math.floor(columns[6]),
+          Math.floor(columns[7]),
+          Math.floor(columns[8]),
+          Math.floor(columns[9]),
+          Math.floor(columns[10])
+          ]);
+      } else {
+        var buhin = this.kBuhin.search(columns[7]);
+        if(buhin != ""){
+          strokesArray = strokesArray.concat(this.getEachStrokesOfBuhin(buhin,
+                                                  Math.floor(columns[3]),
+                                                  Math.floor(columns[4]),
+                                                  Math.floor(columns[5]),
+                                                  Math.floor(columns[6]))
+                            );
+        }
+      }
+    }
+    return strokesArray;
+  }
+  Kage.prototype.getEachStrokes = getEachStrokes;
+  
+  function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2){
+    var temp = this.getEachStrokes(buhin);
+    var result = new Array();
+    for(var i = 0; i < temp.length; i++){
+      result.push([temp[i][0],
+                   temp[i][1],
+                   temp[i][2],
+                   x1 + temp[i][3] * (x2 - x1) / 200,
+                   y1 + temp[i][4] * (y2 - y1) / 200,
+                   x1 + temp[i][5] * (x2 - x1) / 200,
+                   y1 + temp[i][6] * (y2 - y1) / 200,
+                   x1 + temp[i][7] * (x2 - x1) / 200,
+                   y1 + temp[i][8] * (y2 - y1) / 200,
+                   x1 + temp[i][9] * (x2 - x1) / 200,
+                   y1 + temp[i][10] * (y2 - y1) / 200]);
+    }
+    return result;
+  }
+  Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin;
+  
+  function adjustKakato(strokesArray){ // strokesArray
+    for(var i = 0; i < strokesArray.length; i++){
+      if(strokesArray[i][0] == 1 &&
+         (strokesArray[i][2] == 13 || strokesArray[i][2] == 23)){
+        for(var k = 0; k < this.kAdjustKakatoStep; k++){
+          var crossing = 0;
+          for(var j = 0; j < strokesArray.length && !crossing; j++){
+            if(i == j){ continue; }
+            switch(strokesArray[j][0]){
+            case 0:
+            case 8:
+            case 9:
+              break;
+            case 6:
+            case 7:
+              if(!crossing && isCross(strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[j][9],
+                         strokesArray[j][10],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[j][9],
+                         strokesArray[j][10],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[j][9],
+                         strokesArray[j][10],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[j][9],
+                         strokesArray[j][10],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+            case 2:
+            case 12:
+            case 3:
+              if(!crossing && isCross(strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[j][7],
+                         strokesArray[j][8],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+            default:
+              if(!crossing && isCross(strokesArray[j][3],
+                         strokesArray[j][4],
+                         strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][3],
+                         strokesArray[j][4],
+                         strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][3],
+                         strokesArray[j][4],
+                         strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+              if(!crossing && isCross(strokesArray[j][3],
+                         strokesArray[j][4],
+                         strokesArray[j][5],
+                         strokesArray[j][6],
+                         strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1],
+                         strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
+                         strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){
+                crossing++;
+              }
+            }
+          }
+          if(crossing){
+            strokesArray[i][2] += (3 - k) * 100;
+            k = Infinity;
+          }
+        }
+      }
+    }
+    return strokesArray;
+  }
+  Kage.prototype.adjustKakato = adjustKakato;
+  
+  function drawStrokesArray(polygons, strokesArray){
+    for(var i = 0; i < strokesArray.length; i++){
+      dfDrawFont(this, polygons,
+                 strokesArray[i][0],
+                 strokesArray[i][1],
+                 strokesArray[i][2],
+                 strokesArray[i][3],
+                 strokesArray[i][4],
+                 strokesArray[i][5],
+                 strokesArray[i][6],
+                 strokesArray[i][7],
+                 strokesArray[i][8],
+                 strokesArray[i][9],
+                 strokesArray[i][10]);
+    }
+  }
+  Kage.prototype.drawStrokesArray = drawStrokesArray;
+  
+  function drawGlyph(polygons, glyph){ // void
+    // [glyph] : [stroke]$[stroke]$.....
+    // [stroke] : [column]:[column]:.....
+    var strokes = glyph.split("$");
+    for(var i = 0; i < strokes.length; i++){
+      var columns = strokes[i].split(":");
+      if(Math.floor(columns[0]) != 99){
+        dfDrawFont(this, polygons,
+                   Math.floor(columns[0]),
+                   Math.floor(columns[1]), Math.floor(columns[2]),
+                   Math.floor(columns[3]), Math.floor(columns[4]),
+                   Math.floor(columns[5]), Math.floor(columns[6]),
+                   Math.floor(columns[7]), Math.floor(columns[8]),
+                   Math.floor(columns[9]), Math.floor(columns[10]));
+      } else {
+        var buhin = this.kBuhin.search(columns[7]);
+        if(buhin != ""){
+          this.drawBuhin(polygons, buhin,
+                         Math.floor(columns[3]),
+                         Math.floor(columns[4]),
+                         Math.floor(columns[5]),
+                         Math.floor(columns[6]));
+        }
+      }
+    }
+  }
+  Kage.prototype.drawGlyph = drawGlyph;
+  
+  function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void
+    var strokes = glyph.split("$");
+    for(var i = 0; i < strokes.length; i++){
+      var columns = strokes[i].split(":");
+      if(Math.floor(columns[0]) != 99){
+        dfDrawFont(this, polygons,
+                   Math.floor(columns[0]),
+                   Math.floor(columns[1]),
+                   Math.floor(columns[2]),
+                   x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
+                   y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
+                   x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
+                   y1 + Math.floor(columns[6]) * (y2 - y1) / 200,
+                   x1 + Math.floor(columns[7]) * (x2 - x1) / 200,
+                   y1 + Math.floor(columns[8]) * (y2 - y1) / 200,
+                   x1 + Math.floor(columns[9]) * (x2 - x1) / 200,
+                   y1 + Math.floor(columns[10]) * (y2 - y1) / 200);
+      } else {
+        var buhin = this.kBuhin.search(columns[7]);
+        if(buhin != ""){
+          this.drawBuhin(polygons, buhin,
+                         x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
+                         y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
+                         x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
+                         y1 + Math.floor(columns[6]) * (y2 - y1) / 200);
+        }
+      }
+    }
+  }
+  Kage.prototype.drawBuhin = drawBuhin;
+  
+  //properties
+  Kage.prototype.kMincho = 0;
+  Kage.prototype.kGothic = 1;
+  this.kShotai = this.kMincho;
+  this.kMage = 10;
+  this.kRate = 100;
+  this.kMinWidthY = 2;
+  this.kMinWidthT = 6;
+  this.kWidth = 5;
+  this.kAdjustKakatoL = ([14, 9, 5, 2]); // 調整済みカカト用
+  this.kAdjustKakatoR = ([8, 6, 4, 2]); // 調整済みカカト用
+  this.kAdjustKakatoRangeX = 20; // 影響判定矩形の大きさ
+  this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // 影響判定矩形の大きさ
+  this.kAdjustKakatoStep = 3; // 影響判定矩形の段階
+  this.kKakato = 3;
+  this.kL2RDfatten = 1.1;
+  this.kBuhin = new Buhin();
+  
+  return this;
+}
index d98915b..aec3dca 100755 (executable)
@@ -9,6 +9,7 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){
   var deltad;\r
   var XX, XY, YX, YY;\r
   var poly, poly2;\r
+       var hosomi;\r
   \r
   if(kage.kShotai == kage.kMincho){ // mincho\r
     switch(a1){\r
@@ -76,6 +77,11 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){
       y4 = y4 + delta * Math.sin(rad) * v;\r
     }\r
     \r
+               hosomi = 0.5;\r
+               if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){\r
+                       hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50);\r
+               }\r
+\r
     poly = new Polygon();\r
     poly2 = new Polygon();\r
     for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
@@ -103,9 +109,20 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){
         ib = kage.kMinWidthT;\r
       }\r
       \r
-      if(a1 == 7){ deltad = Math.sqrt(t); }\r
-      else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }\r
+      if(a1 == 7 && a2 == 0){ // L2RD: fatten\r
+        deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;\r
+                       }\r
+      else if(a1 == 7){\r
+                               deltad = Math.pow(t, hosomi);\r
+                       }\r
+                       else if(a2 == 7){\r
+                               deltad = Math.pow(1.0 - t, hosomi);\r
+                       }\r
       else{ deltad = 1; }\r
+\r
+                       if(deltad < 0.15){\r
+                               deltad = 0.15;\r
+                       }\r
       ia = ia * deltad;\r
       ib = ib * deltad;\r
       \r
@@ -472,6 +489,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
   var deltad;\r
   var XX, XY, YX, YY;\r
   var poly, poly2;\r
+       var hosomi;\r
   \r
   if(kage.kShotai == kage.kMincho){ // mincho\r
     switch(a1){\r
@@ -540,6 +558,11 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
       x3 = x3 + delta * Math.cos(rad) * v;\r
       y3 = y3 + delta * Math.sin(rad) * v;\r
     }\r
+\r
+               hosomi = 0.5;\r
+               if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){\r
+                       hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50);\r
+               }\r
     \r
     poly = new Polygon();\r
     poly2 = new Polygon();\r
@@ -570,10 +593,20 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
         ib = kage.kMinWidthT;\r
       }\r
       \r
-      if(a1 == 7 && a2 == 0){ deltad = Math.sqrt(t) * kage.kL2RDfatten; } //L2RD: fatten\r
-      else if(a1 == 7){ deltad = Math.sqrt(t); }\r
-      else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }\r
+      if(a1 == 7 && a2 == 0){ // L2RD: fatten\r
+                                       deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;\r
+                       }\r
+      else if(a1 == 7){\r
+                               deltad = Math.pow(t, hosomi);\r
+                       }\r
+                       else if(a2 == 7){\r
+                               deltad = Math.pow(1.0 - t, hosomi);\r
+                       }\r
       else{ deltad = 1; }\r
+\r
+                       if(deltad < 0.15){\r
+                               deltad = 0.15;\r
+                       }\r
       ia = ia * deltad;\r
       ib = ib * deltad;\r
       \r
@@ -937,7 +970,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
 function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){\r
   var rad;\r
   var v, x1, y1, x2, y2;\r
-  var a1, a2;\r
+  var a1, a2, opt1, opt2;\r
   var XX, XY, YX, YY;\r
   var poly;\r
   \r
@@ -946,8 +979,10 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
     y1 = ty1;\r
     x2 = tx2;\r
     y2 = ty2;\r
-    a1 = ta1;\r
-    a2 = ta2;\r
+    a1 = ta1 % 100;\r
+    a2 = ta2 % 100;\r
+    opt1 = Math.floor(ta1 / 100);\r
+    opt2 = Math.floor(ta2 / 100);\r
     \r
     if(x1 == x2){ //if TATE stroke, use y-axis\r
       poly = new Polygon(4);\r
@@ -988,12 +1023,12 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
         poly.set(1, x2 + kage.kMinWidthT, y2);\r
         break;\r
       case 13:\r
-        poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato + kage.kMinWidthT);\r
-        poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato);\r
+        poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kAdjustKakatoL[opt2] + kage.kMinWidthT);\r
+        poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kAdjustKakatoL[opt2]);\r
         break;\r
       case 23:\r
-        poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT);\r
-        poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5);\r
+        poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kAdjustKakatoR[opt2] + kage.kMinWidthT);\r
+        poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kAdjustKakatoR[opt2]);\r
         break;\r
       case 32:\r
         poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthY);\r
@@ -1028,7 +1063,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
         poly.push(x2, y2 + kage.kMinWidthT);\r
         poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);\r
         poly.push(x2 + kage.kMinWidthT, y2);\r
-       poly.reverse(); // for fill-rule\r
+        poly.reverse(); // for fill-rule\r
         polygons.push(poly);\r
       }\r
     }\r
@@ -1188,17 +1223,17 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
           poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
           break;\r
         case 13:\r
-          poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.cos(rad) * v,\r
-                   y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.sin(rad) * v);\r
-          poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.cos(rad) * v,\r
-                   y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.sin(rad) * v);\r
+          poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoL[opt2] * Math.cos(rad) * v,\r
+                   y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoL[opt2] * Math.sin(rad) * v);\r
+          poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoL[opt2] + kage.kMinWidthT) * Math.cos(rad) * v,\r
+                   y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoL[opt2] + kage.kMinWidthT) * Math.sin(rad) * v);\r
           break;\r
         case 23:\r
-          poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.cos(rad) * v,\r
-                   y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.sin(rad) * v);\r
+          poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoR[opt2] * Math.cos(rad) * v,\r
+                   y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoR[opt2] * Math.sin(rad) * v);\r
           poly.set(2,\r
-                   x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.cos(rad) * v,\r
-                   y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.sin(rad) * v);\r
+                   x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoR[opt2] + kage.kMinWidthT) * Math.cos(rad) * v,\r
+                   y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoR[opt2] + kage.kMinWidthT) * Math.sin(rad) * v);\r
           break;\r
         case 32:\r
           poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,\r
index 934b85c..2ec6052 100755 (executable)
@@ -1,7 +1,7 @@
 function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){\r
   var tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4, v;\r
   var rad;\r
-  \r
+       \r
   if(kage.kShotai == kage.kMincho){\r
     switch(a1 % 100){ // ... no need to divide\r
     case 0:\r
@@ -144,7 +144,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){
       cdDrawLine(kage, polygons, x3, y3, x4, y4, 6, a3);\r
       break;\r
     case 13:\r
-rate = 6;\r
+      rate = 6;\r
       if(a3 == 5){\r
         if(x1 == x2){\r
           if(y1 < y2){ v = 1; } else{ v = -1; }\r
index dd3582a..5e3c8b8 100755 (executable)
@@ -1,95 +1,95 @@
 function Polygons(){\r
-               // method\r
-               function push(polygon){ // void\r
-                               // only a simple check\r
-                               var minx = 200;\r
-                               var maxx = 0;\r
-                               var miny = 200;\r
-                               var maxy = 0;\r
-                               var error = 0;\r
-                               for(var i = 0; i < polygon.array.length; i++){\r
-                                               if(polygon.array[i].x < minx){\r
-                                                               minx = polygon.array[i].x;\r
-                                               }\r
-                                               if(polygon.array[i].x > maxx){\r
-                                                               maxx = polygon.array[i].x;\r
-                                               }\r
-                                               if(polygon.array[i].y < miny){\r
-                                                               miny = polygon.array[i].y;\r
-                                               }\r
-                                               if(polygon.array[i].y > maxy){\r
-                                                               maxy = polygon.array[i].y;\r
-                                               }\r
-                                               if(isNaN(polygon.array[i].x) || isNaN(polygon.array[i].y)){\r
-                                                               error++;\r
-                                               }\r
-                               }\r
-                               if(error == 0 && minx != maxx && miny != maxy && polygon.array.length >= 3){\r
-                                               var newArray = new Array();\r
-                                               newArray.push(polygon.array.shift());\r
-                                               while(polygon.array.length != 0){\r
-                                                               var temp = polygon.array.shift();\r
-                                                               if(newArray[newArray.length - 1].x != temp.x ||\r
-                                                                        newArray[newArray.length - 1].y != temp.y){\r
-                                                                               newArray.push(temp);\r
-                                                               }\r
-                                               }\r
-                                               if(newArray.length >= 3){\r
-                                                               polygon.array = newArray;\r
-                                                               this.array.push(polygon);\r
-                                               }\r
-                               }\r
-               }\r
-               Polygons.prototype.push = push;\r
-               \r
-               function generateSVG(){ // string\r
-                               var buffer = "";\r
-                               buffer += "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" baseProfile=\"full\" viewBox=\"0 0 199 199\">\n";\r
-                               buffer += "<g fill=\"black\">\n";\r
-                               for(var i = 0; i < this.array.length; i++){\r
-                                               buffer += "<polygon points=\"";\r
-                                               for(var j = 0; j < this.array[i].array.length; j++){\r
-                                                               buffer += this.array[i].array[j].x + "," + this.array[i].array[j].y + " ";\r
-                                               }\r
-                                               buffer += "\" />\n";\r
-                               }\r
-                               buffer += "</g>\n";\r
-                               buffer += "</svg>\n";\r
-                               return buffer;\r
-               }\r
-               Polygons.prototype.generateSVG = generateSVG;\r
-               \r
-    function generateEPS(){ // string\r
-                               var buffer = "";\r
-                               buffer += "%!PS-Adobe-3.0 EPSF-3.0\n";\r
-                               buffer += "%%BoundingBox: 0 -208 1024 816\n";\r
-                               buffer += "%%Pages: 0\n";\r
-                               buffer += "%%Title: Kanji glyph\n";\r
-                               buffer += "%%Creator: GlyphWiki powered by KAGE system\n";\r
-                               buffer += "%%CreationDate: " + new Date() + "\n";\r
-                               buffer += "%%EndComments\n";\r
-                               buffer += "%%EndProlog\n";\r
-                               buffer += "newpath\n";\r
-                               \r
-                               for(var i = 0; i < this.array.length; i++){\r
-                                               for(var j = 0; j < this.array[i].array.length; j++){\r
-                                                               buffer += (this.array[i].array[j].x * 5) + " " + (1000 - this.array[i].array[j].y * 5 - 200) + " ";\r
-                                                               if(j == 0){\r
-                                                                               buffer += "moveto\n";\r
-                                                               } else {\r
-                                                                               buffer += "lineto\n";\r
-                                                               }\r
-                                               }\r
-                                               buffer += "closepath\n";\r
-                               }\r
-                               buffer += "fill\n";\r
-                               buffer += "%%EOF\n";\r
-                               return buffer;\r
+  // method\r
+  function push(polygon){ // void\r
+    // only a simple check\r
+    var minx = 200;\r
+    var maxx = 0;\r
+    var miny = 200;\r
+    var maxy = 0;\r
+    var error = 0;\r
+    for(var i = 0; i < polygon.array.length; i++){\r
+      if(polygon.array[i].x < minx){\r
+        minx = polygon.array[i].x;\r
+      }\r
+      if(polygon.array[i].x > maxx){\r
+        maxx = polygon.array[i].x;\r
+      }\r
+      if(polygon.array[i].y < miny){\r
+        miny = polygon.array[i].y;\r
+      }\r
+      if(polygon.array[i].y > maxy){\r
+        maxy = polygon.array[i].y;\r
+      }\r
+      if(isNaN(polygon.array[i].x) || isNaN(polygon.array[i].y)){\r
+        error++;\r
+      }\r
     }\r
-    Polygons.prototype.generateEPS = generateEPS;\r
-               \r
-               // property\r
-               this.array = new Array();\r
-               \r
-               return this;\r
+    if(error == 0 && minx != maxx && miny != maxy && polygon.array.length >= 3){\r
+      var newArray = new Array();\r
+      newArray.push(polygon.array.shift());\r
+      while(polygon.array.length != 0){\r
+        var temp = polygon.array.shift();\r
+        if(newArray[newArray.length - 1].x != temp.x ||\r
+           newArray[newArray.length - 1].y != temp.y){\r
+          newArray.push(temp);\r
+        }\r
+      }\r
+      if(newArray.length >= 3){\r
+        polygon.array = newArray;\r
+        this.array.push(polygon);\r
+      }\r
+    }\r
+  }\r
+  Polygons.prototype.push = push;\r
+  \r
+  function generateSVG(){ // string\r
+    var buffer = "";\r
+    buffer += "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" baseProfile=\"full\" viewBox=\"0 0 199 199\">\n";\r
+    buffer += "<g fill=\"black\">\n";\r
+    for(var i = 0; i < this.array.length; i++){\r
+      buffer += "<polygon points=\"";\r
+      for(var j = 0; j < this.array[i].array.length; j++){\r
+        buffer += this.array[i].array[j].x + "," + this.array[i].array[j].y + " ";\r
+      }\r
+      buffer += "\" />\n";\r
+    }\r
+    buffer += "</g>\n";\r
+    buffer += "</svg>\n";\r
+    return buffer;\r
+  }\r
+  Polygons.prototype.generateSVG = generateSVG;\r
+  \r
+  function generateEPS(){ // string\r
+    var buffer = "";\r
+    buffer += "%!PS-Adobe-3.0 EPSF-3.0\n";\r
+    buffer += "%%BoundingBox: 0 -208 1024 816\n";\r
+    buffer += "%%Pages: 0\n";\r
+    buffer += "%%Title: Kanji glyph\n";\r
+    buffer += "%%Creator: GlyphWiki powered by KAGE system\n";\r
+    buffer += "%%CreationDate: " + new Date() + "\n";\r
+    buffer += "%%EndComments\n";\r
+    buffer += "%%EndProlog\n";\r
+    buffer += "newpath\n";\r
+    \r
+    for(var i = 0; i < this.array.length; i++){\r
+      for(var j = 0; j < this.array[i].array.length; j++){\r
+        buffer += (this.array[i].array[j].x * 5) + " " + (1000 - this.array[i].array[j].y * 5 - 200) + " ";\r
+        if(j == 0){\r
+          buffer += "moveto\n";\r
+        } else {\r
+          buffer += "lineto\n";\r
+        }\r
+      }\r
+      buffer += "closepath\n";\r
+    }\r
+    buffer += "fill\n";\r
+    buffer += "%%EOF\n";\r
+    return buffer;\r
+  }\r
+  Polygons.prototype.generateEPS = generateEPS;\r
+  \r
+  // property\r
+  this.array = new Array();\r
+  \r
+  return this;\r
 }\r
index a0c1372..fa9a5f7 100644 (file)
@@ -8,6 +8,7 @@ load("buhin.js");
 load("kage.js");
 load("kagecd.js");
 load("kagedf.js");
+load("2d.js");
 
 kage = new Kage();
 polygons = new Polygons();