8 void generateGlyphByIDS(const KGString *in, KGString *out, int flag){
11 //pass this method if 'in' is not UCS parts
12 if((in->str)[0] != 'u'){
13 generateGlyph(in, out);
16 //pass this method if 'in' is place-variant-flag defined
17 if(in->len < 5 && 7 < in->len){
18 generateGlyph(in, out);
22 tmp1 = kg_string_new(in->str);
23 tmp2 = kg_string_new(in->str);
26 if(1 <= flag && flag <= 7){
27 if(tmp1->len != 7) kg_string_append(tmp1, "-");
28 if(flag == 1) kg_string_append(tmp1, "01");
29 else if(flag == 2) kg_string_append(tmp1, "02");
30 else if(flag == 3) kg_string_append(tmp1, "03");
31 else if(flag == 4) kg_string_append(tmp1, "04");
32 else if(flag == 5) kg_string_append(tmp1, "05");
33 else if(flag == 6) kg_string_append(tmp1, "06");
36 generateGlyph(tmp1, out);
37 if(out->len != 0) return;
38 generateGlyph(tmp2, out);
39 if(out->len != 0) return;
43 void generateGlyph(const KGString *in, KGString *out){
45 tmp = kg_string_new("");
46 kg_string_set_size(out, 0);
49 searchPartsData(in, tmp);
51 tmp = CalcSizes(tmp, 1);
52 out = kg_string_assign(out, tmp->str);
57 searchAliasData(in, tmp);
59 generateGlyph(tmp, out);
60 if(out->len == 0) return;
61 //save to cache ... not yet
68 if(out->len == 0) return;
69 //save to cache ... not yet
74 void doCombine(const KGString *in, KGString *out){
75 KGString *partIDS1, *partIDS2, *partIDS3;
76 KGString *partStroke1, *partStroke2, *partStroke3;
79 partIDS1 = kg_string_new("");
80 partIDS2 = kg_string_new("");
81 partIDS3 = kg_string_new("");
82 partStroke1 = kg_string_new("");
83 partStroke2 = kg_string_new("");
84 partStroke3 = kg_string_new("");
86 kg_string_set_size(out, 0);
89 if(strncmp(in->str, "u2ff", 4) != 0) return;
90 //switch by combine types
93 divideInto2(in, partIDS1, partIDS3);
94 if(partIDS1->len == 0) return;
96 generateGlyphByIDS(partIDS1, partStroke1, 1);
97 if(partStroke1->len == 0) return;
98 partStroke1 = CalcSizes(partStroke1, 0);
99 generateGlyphByIDS(partIDS3, partStroke3, 2);
100 if(partStroke3->len == 0) return;
101 partStroke3 = CalcSizes(partStroke3, 0);
104 divideInto2(in, partIDS1, partIDS3);
105 if(partIDS1->len == 0) return;
107 generateGlyphByIDS(partIDS1, partStroke1, 3);
108 if(partStroke1->len == 0) return;
109 partStroke1 = CalcSizes(partStroke1, 0);
110 generateGlyphByIDS(partIDS3, partStroke3, 4);
111 if(partStroke3->len == 0) return;
112 partStroke3 = CalcSizes(partStroke3, 0);
114 case '4': //full surround
115 case '5': //surround from above
116 case '6': //surround from below
117 case '7': //surround from left
118 case '8': //surround from upper left
119 case '9': //surround from upper right
120 case 'a': //surround from lower left
121 //case 'b': //overlaid (not supported)
122 divideInto2(in, partIDS1, partIDS3);
123 if(partIDS1->len == 0) return;
125 generateGlyphByIDS(partIDS1, partStroke1, 5);
126 if(partStroke1->len == 0) return;
127 partStroke1 = CalcSizes(partStroke1, 0);
128 generateGlyphByIDS(partIDS3, partStroke3, 6);
129 if(partStroke3->len == 0) return;
130 partStroke3 = CalcSizes(partStroke3, 0);
133 divideInto3(in, partIDS1, partIDS2, partIDS3);
134 if(partIDS1->len == 0) return;
136 generateGlyphByIDS(partIDS1, partStroke1, 1);
137 if(partStroke1->len == 0) return;
138 partStroke1 = CalcSizes(partStroke1, 0);
139 generateGlyphByIDS(partIDS2, partStroke2, 1);
140 if(partStroke2->len == 0) return;
141 partStroke2 = CalcSizes(partStroke2, 0);
142 generateGlyphByIDS(partIDS3, partStroke3, 2);
143 if(partStroke3->len == 0) return;
144 partStroke3 = CalcSizes(partStroke3, 0);
147 divideInto3(in, partIDS1, partIDS2, partIDS3);
148 if(partIDS1->len == 0) return;
150 generateGlyphByIDS(partIDS1, partStroke1, 3);
151 if(partStroke1->len == 0) return;
152 partStroke1 = CalcSizes(partStroke1, 0);
153 generateGlyphByIDS(partIDS2, partStroke2, 3);
154 if(partStroke2->len == 0) return;
155 partStroke2 = CalcSizes(partStroke2, 0);
156 generateGlyphByIDS(partIDS3, partStroke3, 4);
157 if(partStroke3->len == 0) return;
158 partStroke3 = CalcSizes(partStroke3, 0);
161 switch((in->str)[4]){
163 combineYoko2(partStroke1, partStroke3, result);
166 combineTate2(partStroke1, partStroke3, result);
169 combineYoko3(partStroke1, partStroke2, partStroke3, result);
172 combineTate3(partStroke1, partStroke2, partStroke3, result);
174 case '4': //full surround
175 combineHame2(partStroke1, partStroke3, result,
177 FLAG_SURROUND_RIGHT |
179 FLAG_SURROUND_BOTTOM);
181 case '5': //surround from above
182 combineHame2(partStroke1, partStroke3, result,
184 FLAG_SURROUND_RIGHT |
187 case '6': //surround from below
188 combineHame2(partStroke1, partStroke3, result,
190 FLAG_SURROUND_RIGHT |
191 FLAG_SURROUND_BOTTOM);
193 case '7': //surround from left
194 combineHame2(partStroke1, partStroke3, result,
197 FLAG_SURROUND_BOTTOM);
199 case '8': //surround from upper left
200 combineHame2(partStroke1, partStroke3, result,
204 case '9': //surround from upper right
205 combineHame2(partStroke1, partStroke3, result,
206 FLAG_SURROUND_RIGHT |
209 case 'a': //surround from lower left
210 combineHame2(partStroke1, partStroke3, result,
212 FLAG_SURROUND_BOTTOM);
214 //case 'b': //overlaid (not supported)
216 switch((in->str)[4]){
227 addStrokeWithTransform(partStroke1, 1, result, out, 1);
228 addStrokeWithTransform(partStroke3, 3, result, out, 1);
232 addStrokeWithTransform(partStroke1, 1, result, out, 1);
233 addStrokeWithTransform(partStroke2, 2, result, out, 1);
234 addStrokeWithTransform(partStroke3, 3, result, out, 1);
237 fprintf(stderr,"%s\n",out->str);
240 void drawGlyph(const KGString *in, const int mode){
243 buf = convertStroke(in->str, buf, &j);
244 for(i = 0; i < j; i++){
245 if(mode == 0){ //normal
246 dfDrawFont(buf[i * 11 + 0],
258 else if(mode == 1){ //without decoration
259 dfDrawFont(buf[i * 11 + 0],