Changeset 1039


Ignore:
Timestamp:
Sep 17, 2006, 2:02:31 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Fixed cucul_render_glyph(). There is no way this could have ever possibly worked properly.
Location:
libcaca/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_gl.c

    r1028 r1039  
    570570    uint8_t *glyph32 = calloc(16*16*4, 1);
    571571
    572     cucul_render_glyph(dp->drv.p->f, c,
    573                        glyph8, dp->drv.p->font_width, dp->drv.p->font_height);
    574 
     572    cucul_render_glyph(dp->drv.p->f, c, glyph8, dp->drv.p->font_width);
    575573
    576574    /* Convert resulting 8bbp glyph to 32bits, 16x16*/
     
    604602    uint8_t *glyph32 = calloc(16*16*4, 1);
    605603
    606     cucul_render_glyph(dp->drv.p->f, c,
    607                        glyph8, dp->drv.p->font_width, dp->drv.p->font_height);
    608 
     604    cucul_render_glyph(dp->drv.p->f, c, glyph8, dp->drv.p->font_width);
    609605
    610606    /* Convert resulting 8bbp glyph to 32bits, 16x16*/
  • libcaca/trunk/cucul/cucul.h

    r1024 r1039  
    209209int cucul_render_canvas(cucul_canvas_t *, cucul_font_t *, void *,
    210210                         unsigned int, unsigned int, unsigned int);
    211 int cucul_render_glyph(cucul_font_t *, unsigned int, void *,
    212                        unsigned int, unsigned int);
     211int cucul_render_glyph(cucul_font_t *, unsigned int, void *, unsigned int);
    213212int cucul_free_font(cucul_font_t *);
    214213/*  @} */
  • libcaca/trunk/cucul/font.c

    r1024 r1039  
    448448/** \brief Render the given character onto given buffer
    449449 *
    450  *  This function renders the given character on an image buffer using a specific
    451  *  font. The pixel format is fixed (8 bits per pixel).
    452  *
    453  *  The required buffer width can be computed using
    454  *  cucul_get_canvas_width() and cucul_get_font_width(). The required
    455  *  height can be computed using cucul_get_canvas_height() and
    456  *  cucul_get_font_height().
    457  *
    458  *  Glyphs that do not fit in the image buffer are currently not rendered at
    459  *  all. They may be cropped instead in future versions.
     450 *  This function renders the given character on an image buffer using a
     451 *  specific font. The pixel format is fixed (8 bits per pixel).
     452 *
     453 *  The required buffer size can be computed using cucul_get_font_width()
     454 *  and cucul_get_font_height().
    460455 *
    461456 *  This function never fails.
     
    464459 *  \param ch The character to render
    465460 *  \param buf The image buffer
    466  *  \param width The width (in pixels) of the image buffer
    467  *  \param height The height (in pixels) of the image buffer
    468  *  \return This function return 1 if glyph is succesfully renderer, 0 otherwise
    469  */
    470 int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buffer,
    471                        unsigned int width, unsigned int height)
    472 {
    473     unsigned int b;
     461 *  \param pitch The pitch of the image buffer
     462 *  \return This function always returns 0.
     463 */
     464int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
     465                       unsigned int stride)
     466{
     467    unsigned int b, y;
    474468    struct glyph_info *g;
    475     uint8_t *glyph = buffer;
    476 
    477 
     469    uint8_t *glyph;
    478470
    479471    /* Find the Unicode block where our glyph lies */
     
    493485    if(b == f->header.blocks)
    494486        return 0;
     487
     488    if(f->header.bpp != 8)
     489        glyph = malloc(f->header.width * f->header.height);
    495490
    496491    g = &f->glyph_list[f->block_list[b].index
     
    516511        break;
    517512    }
    518     return 1;
    519 }
    520 
    521 
     513
     514    /* Step 2: render glyph */
     515    for(y = 0; y < g->height; y++)
     516        memcpy((uint8_t*)buf + y * stride, glyph + y * g->width, g->width);
     517
     518    if(f->header.bpp != 8)
     519        free(glyph);
     520
     521    return 0;
     522}
    522523
    523524/*
Note: See TracChangeset for help on using the changeset viewer.