3 function makeGlyph(polygons, buhin){ // void
\r
4 var glyphData = this.kBuhin.search(buhin);
\r
6 this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko(this.adjustKakato(this.getEachStrokes(glyphData)))));
\r
9 Kage.prototype.makeGlyph = makeGlyph;
\r
11 function getEachStrokes(glyphData){ // strokes array
\r
12 var strokesArray = new Array();
\r
13 var strokes = glyphData.split("$");
\r
14 for(var i = 0; i < strokes.length; i++){
\r
15 var columns = strokes[i].split(":");
\r
16 if(Math.floor(columns[0]) != 99){
\r
18 Math.floor(columns[0]),
\r
19 Math.floor(columns[1]),
\r
20 Math.floor(columns[2]),
\r
21 Math.floor(columns[3]),
\r
22 Math.floor(columns[4]),
\r
23 Math.floor(columns[5]),
\r
24 Math.floor(columns[6]),
\r
25 Math.floor(columns[7]),
\r
26 Math.floor(columns[8]),
\r
27 Math.floor(columns[9]),
\r
28 Math.floor(columns[10])
\r
31 var buhin = this.kBuhin.search(columns[7]);
\r
33 strokesArray = strokesArray.concat(this.getEachStrokesOfBuhin(buhin,
\r
34 Math.floor(columns[3]),
\r
35 Math.floor(columns[4]),
\r
36 Math.floor(columns[5]),
\r
37 Math.floor(columns[6]))
\r
42 return strokesArray;
\r
44 Kage.prototype.getEachStrokes = getEachStrokes;
\r
46 function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2){
\r
47 var temp = this.getEachStrokes(buhin);
\r
48 var result = new Array();
\r
49 for(var i = 0; i < temp.length; i++){
\r
50 result.push([temp[i][0],
\r
53 x1 + temp[i][3] * (x2 - x1) / 200,
\r
54 y1 + temp[i][4] * (y2 - y1) / 200,
\r
55 x1 + temp[i][5] * (x2 - x1) / 200,
\r
56 y1 + temp[i][6] * (y2 - y1) / 200,
\r
57 x1 + temp[i][7] * (x2 - x1) / 200,
\r
58 y1 + temp[i][8] * (y2 - y1) / 200,
\r
59 x1 + temp[i][9] * (x2 - x1) / 200,
\r
60 y1 + temp[i][10] * (y2 - y1) / 200]);
\r
64 Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin;
\r
66 function adjustUroko(strokesArray){ // strokesArray
\r
67 for(var i = 0; i < strokesArray.length; i++){
\r
68 if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0){ // no operation for TATE
\r
69 for(var k = 0; k < this.kAdjustUrokoLengthStep; k++){
\r
71 if(strokesArray[i][4] == strokesArray[i][6]){ // YOKO
\r
72 tx = strokesArray[i][5] - this.kAdjustUrokoLine[k];
\r
73 ty = strokesArray[i][6] - 0.5;
\r
74 tlen = strokesArray[i][5] - strokesArray[i][3];
\r
76 var rad = Math.atan((strokesArray[i][6] - strokesArray[i][4]) / (strokesArray[i][5] - strokesArray[i][3]));
\r
77 tx = strokesArray[i][5] - this.kAdjustUrokoLine[k] * Math.cos(rad) - 0.5 * Math.sin(rad);
\r
78 ty = strokesArray[i][6] - this.kAdjustUrokoLine[k] * Math.sin(rad) - 0.5 * Math.cos(rad);
\r
79 tlen = Math.sqrt((strokesArray[i][6] - strokesArray[i][4]) * (strokesArray[i][6] - strokesArray[i][4]) +
\r
80 (strokesArray[i][5] - strokesArray[i][3]) * (strokesArray[i][5] - strokesArray[i][3]));
\r
82 if(tlen < this.kAdjustUrokoLength[k] ||
\r
83 isCrossWithOthers(strokesArray, i, tx, ty, strokesArray[i][5], strokesArray[i][6])
\r
85 strokesArray[i][2] += (this.kAdjustUrokoLengthStep - k) * 100;
\r
91 return strokesArray;
\r
93 Kage.prototype.adjustUroko = adjustUroko;
\r
95 function adjustKirikuchi(strokesArray){ // strokesArray
\r
96 for(var i = 0; i < strokesArray.length; i++){
\r
97 if(strokesArray[i][0] == 2 && strokesArray[i][1] == 32 &&
\r
98 strokesArray[i][3] > strokesArray[i][5] &&
\r
99 strokesArray[i][4] < strokesArray[i][6]){
\r
100 for(var j = 0; j < strokesArray.length; j++){ // no need to skip when i == j
\r
101 if(strokesArray[j][0] == 1 &&
\r
102 strokesArray[j][3] < strokesArray[i][3] && strokesArray[j][5] > strokesArray[i][3] &&
\r
103 strokesArray[j][4] == strokesArray[i][4] && strokesArray[j][4] == strokesArray[j][6]){
\r
104 strokesArray[i][1] = 132;
\r
105 j = strokesArray.length;
\r
110 return strokesArray;
\r
112 Kage.prototype.adjustKirikuchi = adjustKirikuchi;
\r
114 function adjustKakato(strokesArray){ // strokesArray
\r
115 for(var i = 0; i < strokesArray.length; i++){
\r
116 if(strokesArray[i][0] == 1 &&
\r
117 (strokesArray[i][2] == 13 || strokesArray[i][2] == 23)){
\r
118 for(var k = 0; k < this.kAdjustKakatoStep; k++){
\r
119 if(isCrossBoxWithOthers(strokesArray, i,
\r
120 strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,
\r
121 strokesArray[i][6] + this.kAdjustKakatoRangeY[k],
\r
122 strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,
\r
123 strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])
\r
125 strokesArray[i][2] += (3 - k) * 100;
\r
131 return strokesArray;
\r
133 Kage.prototype.adjustKakato = adjustKakato;
\r
135 function drawStrokesArray(polygons, strokesArray){
\r
136 for(var i = 0; i < strokesArray.length; i++){
\r
137 dfDrawFont(this, polygons,
\r
138 strokesArray[i][0],
\r
139 strokesArray[i][1],
\r
140 strokesArray[i][2],
\r
141 strokesArray[i][3],
\r
142 strokesArray[i][4],
\r
143 strokesArray[i][5],
\r
144 strokesArray[i][6],
\r
145 strokesArray[i][7],
\r
146 strokesArray[i][8],
\r
147 strokesArray[i][9],
\r
148 strokesArray[i][10]);
\r
151 Kage.prototype.drawStrokesArray = drawStrokesArray;
\r
153 function drawGlyph(polygons, glyph){ // void
\r
154 // [glyph] : [stroke]$[stroke]$.....
\r
155 // [stroke] : [column]:[column]:.....
\r
156 var strokes = glyph.split("$");
\r
157 for(var i = 0; i < strokes.length; i++){
\r
158 var columns = strokes[i].split(":");
\r
159 if(Math.floor(columns[0]) != 99){
\r
160 dfDrawFont(this, polygons,
\r
161 Math.floor(columns[0]),
\r
162 Math.floor(columns[1]), Math.floor(columns[2]),
\r
163 Math.floor(columns[3]), Math.floor(columns[4]),
\r
164 Math.floor(columns[5]), Math.floor(columns[6]),
\r
165 Math.floor(columns[7]), Math.floor(columns[8]),
\r
166 Math.floor(columns[9]), Math.floor(columns[10]));
\r
168 var buhin = this.kBuhin.search(columns[7]);
\r
170 this.drawBuhin(polygons, buhin,
\r
171 Math.floor(columns[3]),
\r
172 Math.floor(columns[4]),
\r
173 Math.floor(columns[5]),
\r
174 Math.floor(columns[6]));
\r
179 Kage.prototype.drawGlyph = drawGlyph;
\r
181 function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void
\r
182 var strokes = glyph.split("$");
\r
183 for(var i = 0; i < strokes.length; i++){
\r
184 var columns = strokes[i].split(":");
\r
185 if(Math.floor(columns[0]) != 99){
\r
186 dfDrawFont(this, polygons,
\r
187 Math.floor(columns[0]),
\r
188 Math.floor(columns[1]),
\r
189 Math.floor(columns[2]),
\r
190 x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
\r
191 y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
\r
192 x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
\r
193 y1 + Math.floor(columns[6]) * (y2 - y1) / 200,
\r
194 x1 + Math.floor(columns[7]) * (x2 - x1) / 200,
\r
195 y1 + Math.floor(columns[8]) * (y2 - y1) / 200,
\r
196 x1 + Math.floor(columns[9]) * (x2 - x1) / 200,
\r
197 y1 + Math.floor(columns[10]) * (y2 - y1) / 200);
\r
199 var buhin = this.kBuhin.search(columns[7]);
\r
201 this.drawBuhin(polygons, buhin,
\r
202 x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
\r
203 y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
\r
204 x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
\r
205 y1 + Math.floor(columns[6]) * (y2 - y1) / 200);
\r
210 Kage.prototype.drawBuhin = drawBuhin;
\r
213 Kage.prototype.kMincho = 0;
\r
214 Kage.prototype.kGothic = 1;
\r
215 this.kShotai = this.kMincho;
\r
219 this.kMinWidthY = 2;
\r
220 this.kMinWidthT = 6;
\r
223 this.kL2RDfatten = 1.1;
\r
225 this.kUseCurve = 0;
\r
227 this.kAdjustKakatoL = ([14, 9, 5, 2]); // for KAKATO adjustment 000,100,200,300
\r
228 this.kAdjustKakatoR = ([8, 6, 4, 2]); // for KAKATO adjustment 000,100,200,300
\r
229 this.kAdjustKakatoRangeX = 20; // check area width
\r
230 this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // 3 steps of checking
\r
231 this.kAdjustKakatoStep = 3; // number of steps
\r
233 this.kAdjustUrokoX = ([24, 20, 16, 12]); // for UROKO adjustment 000,100,200,300
\r
234 this.kAdjustUrokoY = ([12, 11, 9, 8]); // for UROKO adjustment 000,100,200,300
\r
235 this.kAdjustUrokoLength = ([22, 36, 50]); // length for checking
\r
236 this.kAdjustUrokoLengthStep = 3; // number of steps
\r
237 this.kAdjustUrokoLine = ([22, 26, 30]); // check for crossing. corresponds to length
\r
239 this.kBuhin = new Buhin();
\r