- Timestamp:
- May 5, 2006, 5:12:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/tools/makefont.c
r929 r930 56 56 }; 57 57 58 static void fix_glyph(FT_Bitmap *, uint32_t, unsigned int, unsigned int); 58 59 static int printf_hex(char const *, uint8_t *, int); 59 60 static int printf_u32(char const *, uint32_t); … … 223 224 pango_ft2_render_layout(&img, l, 0, 0); 224 225 226 /* Fix glyphs that we know how to handle better */ 227 fix_glyph(&img, ch, width, height); 228 225 229 /* Write bitmap as an escaped C string */ 226 230 n = 0; … … 253 257 */ 254 258 259 static void fix_glyph(FT_Bitmap *i, uint32_t ch, 260 unsigned int width, unsigned int height) 261 { 262 unsigned int x, y; 263 264 switch(ch) 265 { 266 case 0x00002580: /* ▀ */ 267 for(y = 0; y < height; y++) 268 for(x = 0; x < width; x++) 269 i->buffer[x + y * i->pitch] = y < height / 2 ? 0xff : 0x00; 270 if(height & 1) 271 for(x = 0; x < width; x++) 272 i->buffer[x + (height / 2) * i->pitch] = 0x7f; 273 break; 274 case 0x00002584: /* ▄ */ 275 for(y = 0; y < height; y++) 276 for(x = 0; x < width; x++) 277 i->buffer[x + y * i->pitch] = y < height / 2 ? 0x00 : 0xff; 278 if(height & 1) 279 for(x = 0; x < width; x++) 280 i->buffer[x + (height / 2) * i->pitch] = 0x7f; 281 break; 282 case 0x0000258c: /* ▌ */ 283 for(y = 0; y < height; y++) 284 for(x = 0; x < width; x++) 285 i->buffer[x + y * i->pitch] = x < width / 2 ? 0xff : 0x00; 286 if(width & 1) 287 for(y = 0; y < height; y++) 288 i->buffer[(width / 2) + y * i->pitch] = 0x7f; 289 break; 290 case 0x00002590: /* ▐ */ 291 for(y = 0; y < height; y++) 292 for(x = 0; x < width; x++) 293 i->buffer[x + y * i->pitch] = x < width / 2 ? 0x00 : 0xff; 294 if(width & 1) 295 for(y = 0; y < height; y++) 296 i->buffer[(width / 2) + y * i->pitch] = 0x7f; 297 break; 298 case 0x000025a0: /* ■ */ 299 for(y = 0; y < height; y++) 300 for(x = 0; x < width; x++) 301 i->buffer[x + y * i->pitch] = 302 (y >= height / 4) && (y < 3 * height / 4) ? 0xff : 0x00; 303 if(height & 3) 304 for(x = 0; x < width; x++) /* FIXME: could be more precise */ 305 i->buffer[x + (height / 4) * i->pitch] = 306 i->buffer[x + (3 * height / 4) * i->pitch] = 0x7f; 307 break; 308 case 0x00002588: /* █ */ 309 memset(i->buffer, 0xff, height * i->pitch); 310 break; 311 case 0x00002593: /* ▓ */ 312 for(y = 0; y < height; y++) 313 for(x = 0; x < width; x++) 314 i->buffer[x + y * i->pitch] = 315 ((x + 2 * (y & 1)) & 3) ? 0xff : 0x00; 316 break; 317 case 0x00002592: /* ▒ */ 318 for(y = 0; y < height; y++) 319 for(x = 0; x < width; x++) 320 i->buffer[x + y * i->pitch] = ((x + y) & 1) ? 0xff : 0x00; 321 break; 322 case 0x00002591: /* ░ */ 323 for(y = 0; y < height; y++) 324 for(x = 0; x < width; x++) 325 i->buffer[x + y * i->pitch] = 326 ((x + 2 * (y & 1)) & 3) ? 0x00 : 0xff; 327 break; 328 } 329 } 330 255 331 static int printf_u32(char const *fmt, uint32_t i) 256 332 {
Note: See TracChangeset
for help on using the changeset viewer.