Changeset 1359 for libcaca/trunk/tools
- Timestamp:
- Nov 12, 2006, 1:26:48 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/tools/makefont.c
r1271 r1359 57 57 0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */ 58 58 0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */ 59 0x3040, 0x30a0, /* Hiragana: で す */ 60 0x30a0, 0x3100, /* Katakana: ロ ル */ 59 61 0, 0 60 62 }; … … 65 67 char buf[10]; 66 68 unsigned int same_as; 67 unsigned int data_index; 69 unsigned int data_offset; 70 unsigned int data_width; 71 unsigned int data_size; 68 72 }; 69 73 … … 86 90 87 91 FT_Bitmap img; 88 int width, height, blocks, glyphs; 89 unsigned int n, b, i, index, glyph_size, control_size, data_size; 92 int width, height, blocks, glyphs, fullwidth; 93 unsigned int n, b, i, index; 94 unsigned int glyph_size, control_size, data_size, current_offset; 90 95 uint8_t *glyph_data; 91 96 struct glyph *gtab; … … 150 155 blocks = 0; 151 156 glyphs = 0; 157 fullwidth = 0; 152 158 for(b = 0; blocklist[b + 1]; b += 2) 153 159 { 154 160 blocks++; 155 161 glyphs += blocklist[b + 1] - blocklist[b]; 162 for(i = blocklist[b]; i < blocklist[b + 1]; i++) 163 if(cucul_utf32_is_fullwidth(i)) 164 fullwidth++; 156 165 } 157 166 158 167 control_size = 24 + 12 * blocks + 8 * glyphs; 159 data_size = glyph_size * glyphs;168 data_size = glyph_size * (glyphs + fullwidth); 160 169 161 170 gtab = malloc(glyphs * sizeof(struct glyph)); … … 212 221 213 222 /* Render all glyphs, so that we can know their offset */ 214 n = index = 0;223 current_offset = n = index = 0; 215 224 for(b = 0; blocklist[b + 1]; b += 2) 216 225 { 217 226 for(i = blocklist[b]; i < blocklist[b + 1]; i++) 218 227 { 219 int x, y, bytes; 220 unsigned int k; 221 228 int x, y, bytes, current_width = width; 229 unsigned int k, current_size = glyph_size; 230 231 if(cucul_utf32_is_fullwidth(i)) 232 { 233 current_width *= 2; 234 current_size *= 2; 235 } 222 236 gtab[n].unicode = i; 223 237 bytes = cucul_utf32_to_utf8(gtab[n].buf, gtab[n].unicode); … … 230 244 231 245 /* Fix glyphs that we know how to handle better */ 232 fix_glyph(&img, gtab[n].unicode, width, height);246 fix_glyph(&img, gtab[n].unicode, current_width, height); 233 247 234 248 /* Write bitmap as an escaped C string */ 235 memset(glyph_data + n * glyph_size, 0, glyph_size);249 memset(glyph_data + current_offset, 0, current_size); 236 250 k = 0; 237 251 for(y = 0; y < height; y++) 238 252 { 239 for(x = 0; x < width; x++)253 for(x = 0; x < current_width; x++) 240 254 { 241 255 uint8_t pixel = img.buffer[y * img.pitch + x]; 242 256 243 257 pixel >>= (8 - bpp); 244 glyph_data[ n * glyph_size+ k / 8]258 glyph_data[current_offset + k / 8] 245 259 |= pixel << (8 - bpp - (k % 8)); 246 260 k += bpp; … … 253 267 for(k = 0; k < n; k++) 254 268 { 255 if(!memcmp(glyph_data + k * glyph_size, 256 glyph_data + n * glyph_size, glyph_size)) 269 if(gtab[k].data_size != current_size) 270 continue; 271 #if 0 272 if(!memcmp(glyph_data + gtab[k].data_offset, 273 glyph_data + current_offset, current_size)) 257 274 break; 275 #endif 258 276 } 259 277 260 gtab[n].data_index = index; 278 gtab[n].data_offset = current_offset; 279 gtab[n].data_width = current_width; 280 gtab[n].data_size = current_size; 261 281 gtab[n].same_as = k; 262 282 263 283 if(k == n) 264 index++;284 current_offset += current_size; 265 285 266 286 n++; … … 274 294 for(i = blocklist[b]; i < blocklist[b + 1]; i++) 275 295 { 276 printf_u16("\"%s", width);296 printf_u16("\"%s", gtab[n].data_width); 277 297 printf_u16("%s", height); 278 printf_u32("%s\"\n", gtab[gtab[n].same_as].data_ index * glyph_size);298 printf_u32("%s\"\n", gtab[gtab[n].same_as].data_offset); 279 299 n++; 280 300 } … … 294 314 if(gtab[n].same_as == n) 295 315 printf_hex(" */ \"%s\"\n", 296 glyph_data + n * glyph_size, glyph_size);316 glyph_data + gtab[n].data_offset, gtab[n].data_size); 297 317 else 298 318 {
Note: See TracChangeset
for help on using the changeset viewer.