Ignore:
Timestamp:
Nov 12, 2006, 6:30:08 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Add maxwidth and maxheight members to the font format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/tools/makefont.c

    r1361 r1365  
    9191
    9292    FT_Bitmap img;
    93     int width, height, blocks, glyphs, fullwidth;
     93    int stdwidth, fullwidth, height, blocks, glyphs, fullglyphs;
    9494    unsigned int n, b, i, index;
    95     unsigned int glyph_size, control_size, data_size, current_offset;
     95    unsigned int stdsize, fullsize, control_size, data_size, current_offset;
    9696    uint8_t *glyph_data;
    9797    struct glyph *gtab;
     
    149149    pango_layout_set_markup(l, "@", -1);
    150150    pango_layout_get_extents(l, NULL, &r);
    151     width = PANGO_PIXELS(r.width);
     151    stdwidth = PANGO_PIXELS(r.width);
     152    fullwidth = stdwidth * 2;
    152153    height = PANGO_PIXELS(r.height);
    153     glyph_size = ((width * height) + (8 / bpp) - 1) / (8 / bpp);
     154    stdsize = ((stdwidth * height) + (8 / bpp) - 1) / (8 / bpp);
     155    fullsize = ((fullwidth * height) + (8 / bpp) - 1) / (8 / bpp);
    154156
    155157    /* Compute blocks and glyphs count */
    156158    blocks = 0;
    157159    glyphs = 0;
    158     fullwidth = 0;
     160    fullglyphs = 0;
    159161    for(b = 0; blocklist[b + 1]; b += 2)
    160162    {
     
    163165        for(i = blocklist[b]; i < blocklist[b + 1]; i++)
    164166            if(cucul_utf32_is_fullwidth(i))
    165                 fullwidth++;
    166     }
    167 
    168     control_size = 24 + 12 * blocks + 8 * glyphs;
    169     data_size = glyph_size * (glyphs + fullwidth);
     167                fullglyphs++;
     168    }
     169
     170    control_size = 28 + 12 * blocks + 8 * glyphs;
     171    data_size = stdsize * (glyphs - fullglyphs) + fullsize * fullglyphs;
    170172
    171173    gtab = malloc(glyphs * sizeof(struct glyph));
     
    174176    /* Let's go! */
    175177    printf("/* libcucul font file\n");
    176     printf(" * \"%s\": %i dpi, %i bpp, %ix%i glyphs\n",
    177            font, dpi, bpp, width, height);
     178    printf(" * \"%s\": %i dpi, %i bpp, %ix%i/%ix%i glyphs\n",
     179           font, dpi, bpp, stdwidth, height, fullwidth, height);
    178180    printf(" * Automatically generated by tools/makefont.c:\n");
    179181    printf(" *   tools/makefont %s \"%s\" %i %i\n", prefix, font, dpi, bpp);
     
    205207    printf_u32("\"%s\" /* glyphs */\n", glyphs);
    206208    printf_u16("\"%s\" /* bpp */\n", bpp);
    207     printf_u16("\"%s\" /* width */\n", width);
    208     printf_u16("\"%s\" /* height */\n", height);
     209    printf_u16("\"%s\" /* std width */\n", stdwidth);
     210    printf_u16("\"%s\" /* std height */\n", height);
     211    printf_u16("\"%s\" /* max width */\n", fullwidth);
     212    printf_u16("\"%s\" /* max height */\n", height);
    209213    printf_u16("\"%s\" /* flags */\n", 1);
    210214    printf("\n");
     
    227231        for(i = blocklist[b]; i < blocklist[b + 1]; i++)
    228232        {
    229             int x, y, bytes, current_width = width;
    230             unsigned int k, current_size = glyph_size;
     233            int x, y, bytes, current_width = stdwidth;
     234            unsigned int k, current_size = stdsize;
    231235
    232236            if(cucul_utf32_is_fullwidth(i))
    233237            {
    234                 current_width *= 2;
    235                 current_size *= 2;
     238                current_width = fullwidth;
     239                current_size = fullsize;
    236240            }
    237241            gtab[n].unicode = i;
Note: See TracChangeset for help on using the changeset viewer.