Changeset 1058 for libcaca/trunk
- Timestamp:
- Sep 18, 2006, 7:40:35 PM (16 years ago)
- Location:
- libcaca/trunk/cucul
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/cucul.h
r1039 r1058 207 207 unsigned int cucul_get_font_width(cucul_font_t *); 208 208 unsigned int cucul_get_font_height(cucul_font_t *); 209 unsigned long int const *cucul_get_font_blocks(cucul_font_t *); 209 210 int cucul_render_canvas(cucul_canvas_t *, cucul_font_t *, void *, 210 211 unsigned int, unsigned int, unsigned int); -
libcaca/trunk/cucul/font.c
r1046 r1058 69 69 70 70 struct block_info *block_list; 71 unsigned int *user_block_list; 71 72 struct glyph_info *glyph_list; 72 73 uint8_t *font_data; … … 189 190 } 190 191 192 f->user_block_list = malloc((f->header.blocks + 1) 193 * 2 * sizeof(unsigned long int)); 194 if(!f->user_block_list) 195 { 196 free(f->block_list); 197 free(f); 198 #if defined(HAVE_ERRNO_H) 199 errno = ENOMEM; 200 #endif 201 return NULL; 202 } 203 191 204 memcpy(f->block_list, 192 205 f->private + 8 + sizeof(struct font_header), … … 202 215 || f->block_list[i].index >= f->header.glyphs) 203 216 { 217 free(f->user_block_list); 204 218 free(f->block_list); 205 219 free(f); … … 209 223 return NULL; 210 224 } 211 } 225 226 f->user_block_list[i * 2] = f->block_list[i].start; 227 f->user_block_list[i * 2 + 1] = f->block_list[i].stop; 228 } 229 230 f->user_block_list[i * 2] = 0; 231 f->user_block_list[i * 2] = 0; 212 232 213 233 f->glyph_list = malloc(f->header.glyphs * sizeof(struct glyph_info)); 214 234 if(!f->glyph_list) 215 235 { 236 free(f->user_block_list); 216 237 free(f->block_list); 217 238 free(f); … … 238 259 { 239 260 free(f->glyph_list); 261 free(f->user_block_list); 240 262 free(f->block_list); 241 263 free(f); … … 301 323 } 302 324 325 /** \brief Get a font's list of supported glyphs. 326 * 327 * This function returns the list of Unicode blocks supported by the 328 * given font. The list is a zero-terminated list of indices. Here is 329 * an example: 330 * 331 * \code 332 * { 333 * 0x0, 0x80, // Basic latin: A, B, C, a, b, c 334 * 0x80, 0x100, // Latin-1 supplement: "A, 'e, ^u 335 * 0x530, 0x590, // Armenian 336 * 0x0, 0x0, // END 337 * }; 338 * \endcode 339 * 340 * This function never fails. 341 * 342 * \param f The font, as returned by cucul_load_font() 343 * \return The list of Unicode blocks supported by the font. 344 */ 345 unsigned long int const *cucul_get_font_blocks(cucul_font_t *f) 346 { 347 return (unsigned long int const *)f->user_block_list; 348 } 349 303 350 /** \brief Free a font structure. 304 351 * … … 316 363 { 317 364 free(f->glyph_list); 365 free(f->user_block_list); 318 366 free(f->block_list); 319 367 free(f);
Note: See TracChangeset
for help on using the changeset viewer.