Changeset 1150 for toilet/trunk/src/figlet.c
- Timestamp:
- Sep 30, 2006, 7:53:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/figlet.c
r1143 r1150 29 29 #include "figlet.h" 30 30 31 #define STD_GLYPHS (127 - 32) 32 #define EXT_GLYPHS (STD_GLYPHS + 7) 33 31 34 struct figfont 32 35 { … … 139 142 (font->glyphs + 2048) * 2 * sizeof(int)); 140 143 141 if(font->glyphs < 127 - 32)144 if(font->glyphs < STD_GLYPHS) 142 145 { 143 146 font->lookup[font->glyphs * 2] = 32 + font->glyphs; 144 147 } 145 else if(font->glyphs < (127 - 32) + 7)148 else if(font->glyphs < EXT_GLYPHS) 146 149 { 147 150 static int const tab[7] = { 196, 214, 220, 228, 246, 252, 223 }; 148 font->lookup[font->glyphs * 2] = tab[font->glyphs + (127 - 32)];151 font->lookup[font->glyphs * 2] = tab[font->glyphs - STD_GLYPHS]; 149 152 } 150 153 else 151 154 { 152 155 char number[10]; 153 154 fscanf(f, "%s %*[^\n]", number); 156 int ret = fscanf(f, "%s %*[^\n]", number); 157 158 if(ret == EOF) 159 break; 160 161 if(!ret) 162 { 163 free(data); 164 free(font); 165 fprintf(stderr, "read error at glyph %u in `%s'\n", 166 font->glyphs, path); 167 return NULL; 168 } 155 169 156 170 if(number[1] == 'x') … … 175 189 176 190 fclose(f); 191 192 if(font->glyphs < EXT_GLYPHS) 193 { 194 free(data); 195 free(font); 196 fprintf(stderr, "only %u glyphs in `%s', expected at least %u\n", 197 font->glyphs, path, EXT_GLYPHS); 198 return NULL; 199 } 177 200 178 201 /* Import buffer into canvas */ … … 181 204 cucul_free_buffer(b); 182 205 free(data); 206 207 if(!font->image) 208 { 209 cucul_free_canvas(font->image); 210 free(font); 211 fprintf(stderr, "libcucul could not load data in `%s'\n", path); 212 return NULL; 213 } 183 214 184 215 /* Remove EOL characters. For now we ignore hardblanks, don’t do any … … 215 246 static void free_font(struct figfont *font) 216 247 { 248 cucul_free_canvas(font->image); 217 249 free(font->lookup); 218 250 free(font);
Note: See TracChangeset
for help on using the changeset viewer.