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
124 | strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1] > 200 // adjust for baseline
\r
125 | strokesArray[i][6] - strokesArray[i][4] < this.kAdjustKakatoRangeY[k + 1] // for thin box
\r
127 strokesArray[i][2] += (3 - k) * 100;
\r
133 return strokesArray;
\r
135 Kage.prototype.adjustKakato = adjustKakato;
\r
137 function drawStrokesArray(polygons, strokesArray){
\r
138 for(var i = 0; i < strokesArray.length; i++){
\r
139 dfDrawFont(this, polygons,
\r
140 strokesArray[i][0],
\r
141 strokesArray[i][1],
\r
142 strokesArray[i][2],
\r
143 strokesArray[i][3],
\r
144 strokesArray[i][4],
\r
145 strokesArray[i][5],
\r
146 strokesArray[i][6],
\r
147 strokesArray[i][7],
\r
148 strokesArray[i][8],
\r
149 strokesArray[i][9],
\r
150 strokesArray[i][10]);
\r
153 Kage.prototype.drawStrokesArray = drawStrokesArray;
\r
155 function drawGlyph(polygons, glyph){ // void
\r
156 // [glyph] : [stroke]$[stroke]$.....
\r
157 // [stroke] : [column]:[column]:.....
\r
158 var strokes = glyph.split("$");
\r
159 for(var i = 0; i < strokes.length; i++){
\r
160 var columns = strokes[i].split(":");
\r
161 if(Math.floor(columns[0]) != 99){
\r
162 dfDrawFont(this, polygons,
\r
163 Math.floor(columns[0]),
\r
164 Math.floor(columns[1]), Math.floor(columns[2]),
\r
165 Math.floor(columns[3]), Math.floor(columns[4]),
\r
166 Math.floor(columns[5]), Math.floor(columns[6]),
\r
167 Math.floor(columns[7]), Math.floor(columns[8]),
\r
168 Math.floor(columns[9]), Math.floor(columns[10]));
\r
170 var buhin = this.kBuhin.search(columns[7]);
\r
172 this.drawBuhin(polygons, buhin,
\r
173 Math.floor(columns[3]),
\r
174 Math.floor(columns[4]),
\r
175 Math.floor(columns[5]),
\r
176 Math.floor(columns[6]));
\r
181 Kage.prototype.drawGlyph = drawGlyph;
\r
183 function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void
\r
184 var strokes = glyph.split("$");
\r
185 for(var i = 0; i < strokes.length; i++){
\r
186 var columns = strokes[i].split(":");
\r
187 if(Math.floor(columns[0]) != 99){
\r
188 dfDrawFont(this, polygons,
\r
189 Math.floor(columns[0]),
\r
190 Math.floor(columns[1]),
\r
191 Math.floor(columns[2]),
\r
192 x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
\r
193 y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
\r
194 x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
\r
195 y1 + Math.floor(columns[6]) * (y2 - y1) / 200,
\r
196 x1 + Math.floor(columns[7]) * (x2 - x1) / 200,
\r
197 y1 + Math.floor(columns[8]) * (y2 - y1) / 200,
\r
198 x1 + Math.floor(columns[9]) * (x2 - x1) / 200,
\r
199 y1 + Math.floor(columns[10]) * (y2 - y1) / 200);
\r
201 var buhin = this.kBuhin.search(columns[7]);
\r
203 this.drawBuhin(polygons, buhin,
\r
204 x1 + Math.floor(columns[3]) * (x2 - x1) / 200,
\r
205 y1 + Math.floor(columns[4]) * (y2 - y1) / 200,
\r
206 x1 + Math.floor(columns[5]) * (x2 - x1) / 200,
\r
207 y1 + Math.floor(columns[6]) * (y2 - y1) / 200);
\r
212 Kage.prototype.drawBuhin = drawBuhin;
\r
215 Kage.prototype.kMincho = 0;
\r
216 Kage.prototype.kGothic = 1;
\r
217 this.kShotai = this.kMincho;
\r
222 this.kMinWidthY = 1.2;
\r
223 this.kMinWidthT = 3.6;
\r
225 this.kKakato = 1.8;
\r
226 this.kL2RDfatten = 1.1;
\r
228 this.kUseCurve = 0;
\r
230 this.kAdjustKakatoL = ([8, 5, 3, 1]); // for KAKATO adjustment 000,100,200,300
\r
231 this.kAdjustKakatoR = ([4, 3, 2, 1]); // for KAKATO adjustment 000,100,200,300
\r
232 this.kAdjustKakatoRangeX = 12; // check area width
\r
233 this.kAdjustKakatoRangeY = ([1, 11, 14, 18]); // 3 steps of checking
\r
234 this.kAdjustKakatoStep = 3; // number of steps
\r
236 this.kAdjustUrokoX = ([14, 12, 9, 7]); // for UROKO adjustment 000,100,200,300
\r
237 this.kAdjustUrokoY = ([7, 6, 5, 4]); // for UROKO adjustment 000,100,200,300
\r
238 this.kAdjustUrokoLength = ([13, 21, 30]); // length for checking
\r
239 this.kAdjustUrokoLengthStep = 3; // number of steps
\r
240 this.kAdjustUrokoLine = ([13, 15, 18]); // check for crossing. corresponds to length
\r
242 this.kMinWidthY = 2;
\r
243 this.kMinWidthT = 6;
\r
246 this.kL2RDfatten = 1.1;
\r
248 this.kUseCurve = 0;
\r
250 this.kAdjustKakatoL = ([14, 9, 5, 2]); // for KAKATO adjustment 000,100,200,300
\r
251 this.kAdjustKakatoR = ([8, 6, 4, 2]); // for KAKATO adjustment 000,100,200,300
\r
252 this.kAdjustKakatoRangeX = 20; // check area width
\r
253 this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // 3 steps of checking
\r
254 this.kAdjustKakatoStep = 3; // number of steps
\r
256 this.kAdjustUrokoX = ([24, 20, 16, 12]); // for UROKO adjustment 000,100,200,300
\r
257 this.kAdjustUrokoY = ([12, 11, 9, 8]); // for UROKO adjustment 000,100,200,300
\r
258 this.kAdjustUrokoLength = ([22, 36, 50]); // length for checking
\r
259 this.kAdjustUrokoLengthStep = 3; // number of steps
\r
260 this.kAdjustUrokoLine = ([22, 26, 30]); // check for crossing. corresponds to length
\r
263 this.kBuhin = new Buhin();
\r