- Timestamp:
- Nov 15, 2006, 12:42:11 AM (16 years ago)
- Location:
- toilet/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/figlet.c
r1385 r1400 44 44 return -1; 45 45 46 cx->left = malloc(cx->height * sizeof(int)); 47 cx->right = malloc(cx->height * sizeof(int)); 48 46 49 cx->feed = feed_figlet; 47 50 cx->flush = flush_figlet; … … 53 56 static int feed_figlet(context_t *cx, uint32_t ch, uint32_t attr) 54 57 { 55 unsigned int c, w, h, x, y ;58 unsigned int c, w, h, x, y, overlap, mx; 56 59 57 60 switch(ch) … … 84 87 } 85 88 89 /* Compute how much the next character will overlap */ 90 overlap = w; 91 for(y = 0; y < h; y++) 92 { 93 /* Compute how much spaces we can eat from the new glyph */ 94 for(x = 0; x < overlap; x++) 95 if(cucul_get_char(cx->image, x, y + c * cx->height) != ' ') 96 break; 97 98 /* Compute how much spaces we can eat from the previous glyph */ 99 for(mx = 0; x + mx < overlap && mx < cx->x; mx++) 100 if(cucul_get_char(cx->cv, cx->x - 1 - mx, cx->y + y) != ' ') 101 break; 102 103 if(x + mx < overlap) 104 overlap = x + mx; 105 } 106 86 107 /* Check whether the current canvas is large enough */ 87 if(cx->x + w > cx->w) 88 cx->w = cx->x + w < cx->term_width ? cx->x + w : cx->term_width; 108 if(cx->x + w - overlap > cx->w) 109 cx->w = cx->x + w - overlap < cx->term_width 110 ? cx->x + w - overlap : cx->term_width; 89 111 90 112 if(cx->y + h > cx->h) … … 101 123 uint32_t tmpch = cucul_get_char(cx->image, x, y + c * cx->height); 102 124 //uint32_t tmpat = cucul_get_attr(cx->image, x, y + c * cx->height); 125 if(tmpch == ' ') 126 continue; 103 127 /* FIXME: this could be changed to cucul_put_attr() when the 104 128 * function is fixed in libcucul */ 105 129 //cucul_set_attr(cx->cv, tmpat); 106 cucul_put_char(cx->cv, cx->x + x , cx->y + y, tmpch);130 cucul_put_char(cx->cv, cx->x + x - overlap, cx->y + y, tmpch); 107 131 //cucul_put_attr(cx->cv, cx->x + x, cx->y + y, tmpat); 108 132 } 109 133 110 134 /* Advance cursor */ 111 cx->x += w ;135 cx->x += w - overlap; 112 136 113 137 return 0; … … 116 140 static int flush_figlet(context_t *cx) 117 141 { 142 unsigned int x, y; 143 118 144 cx->torender = cx->cv; 119 145 cucul_set_canvas_size(cx->torender, cx->w, cx->h); 146 147 /* FIXME: do this somewhere else, or record hardblank positions */ 148 for(y = 0; y < cx->h; y++) 149 for(x = 0; x < cx->w; x++) 150 if(cucul_get_char(cx->torender, x, y) == 0xa0) 151 { 152 uint32_t attr = cucul_get_attr(cx->torender, x, y); 153 cucul_put_char(cx->torender, x, y, ' '); 154 cucul_put_attr(cx->torender, x, y, attr); 155 } 120 156 121 157 cx->x = cx->y = 0; … … 128 164 static int end_figlet(context_t *cx) 129 165 { 166 free(cx->left); 167 free(cx->right); 130 168 cucul_free_canvas(cx->image); 131 169 free(cx->lookup); … … 270 308 ch = cucul_get_char(cx->image, i, j); 271 309 272 /* TODO:Replace hardblanks with U+00A0 NO-BREAK SPACE */310 /* Replace hardblanks with U+00A0 NO-BREAK SPACE */ 273 311 if(ch == cx->hardblank) 274 cucul_put_char(cx->image, i, j, ch = ' '); 275 //cucul_put_char(cx->image, i, j, ch = 0xa0); 312 cucul_put_char(cx->image, i, j, ch = 0xa0); 276 313 277 314 if(oldch && ch != oldch) -
toilet/trunk/src/toilet.h
r1385 r1400 33 33 int (*end)(struct toilet_context *); 34 34 35 /* Used by the big driver */36 cucul_font_t *f;37 cucul_canvas_t *onechar;38 unsigned char *buf;39 40 35 /* Used by the FIGlet driver */ 41 36 unsigned long int hardblank; … … 45 40 unsigned int glyphs; 46 41 cucul_canvas_t *image; 42 int *left, *right; /* Unused yet */ 47 43 unsigned int *lookup; 48 44
Note: See TracChangeset
for help on using the changeset viewer.