Changeset 1062 for libcaca


Ignore:
Timestamp:
Sep 19, 2006, 2:02:59 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Got rid of cucul_render_glyph(). Ahahahaha.
Location:
libcaca/trunk/cucul
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/cucul.h

    r1058 r1062  
    210210int cucul_render_canvas(cucul_canvas_t *, cucul_font_t *, void *,
    211211                         unsigned int, unsigned int, unsigned int);
    212 int cucul_render_glyph(cucul_font_t *, unsigned int, void *, unsigned int);
    213212int cucul_free_font(cucul_font_t *);
    214213/*  @} */
  • libcaca/trunk/cucul/font.c

    r1059 r1062  
    494494}
    495495
    496 /** \brief Render a single glyph onto an image buffer
    497  *
    498  *  This function renders the given character on an image buffer using a
    499  *  specific font. The pixel format is fixed (8 bits per pixel).
    500  *
    501  *  The required buffer size can be computed using cucul_get_font_width()
    502  *  and cucul_get_font_height().
    503  *
    504  *  This function never fails.
    505  *
    506  *  \param f The font, as returned by cucul_load_font()
    507  *  \param ch The character to render
    508  *  \param buf The image buffer
    509  *  \param stride width of the destination buffer
    510  *  \return This function always returns 0.
    511  */
    512 int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
    513                        unsigned int stride)
    514 {
    515     unsigned int b, y;
    516     struct glyph_info *g;
    517     uint8_t *glyph = NULL;
    518 
    519     /* Find the Unicode block where our glyph lies */
    520     for(b = 0; b < f->header.blocks; b++)
    521     {
    522         if(ch < f->block_list[b].start)
    523         {
    524             b = f->header.blocks;
    525             break;
    526         }
    527         if(ch < f->block_list[b].stop) {
    528             break;
    529         }
    530     }
    531 
    532     /* Glyph not in font? Skip it. */
    533     if(b == f->header.blocks)
    534         return 0;
    535 
    536     if(f->header.bpp != 8)
    537         glyph = malloc(f->header.width * f->header.height);
    538 
    539     g = &f->glyph_list[f->block_list[b].index
    540                        + ch - f->block_list[b].start];
    541 
    542     /* Step 1: unpack glyph */
    543     switch(f->header.bpp)
    544     {
    545     case 8:
    546         glyph = f->font_data + g->data_offset;
    547         break;
    548     case 4:
    549         unpack_glyph4(glyph, f->font_data + g->data_offset,
    550                       g->width * g->height);
    551         break;
    552     case 2:
    553         unpack_glyph2(glyph, f->font_data + g->data_offset,
    554                       g->width * g->height);
    555         break;
    556     case 1:
    557         unpack_glyph1(glyph, f->font_data + g->data_offset,
    558                       g->width * g->height);
    559         break;
    560     }
    561 
    562     /* Step 2: render glyph */
    563     for(y = 0; y < g->height; y++)
    564         memcpy((uint8_t*)buf + y * stride, glyph + y * g->width, g->width);
    565 
    566     if(f->header.bpp != 8)
    567         free(glyph);
    568 
    569     return 0;
    570 }
    571 
    572496/*
    573497 * The libcaca font format, version 1
Note: See TracChangeset for help on using the changeset viewer.