Changeset 451


Ignore:
Timestamp:
01/12/05 01:33:03 (8 years ago)
Author:
sam
Message:
  • when cutting fonts, detect black pixels below 240, not below 128
  • allow last column to be non-white
  • better error message when all glyphs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pwntcha/trunk/src/font.c

    r448 r451  
    7272    font->glyphs = malloc(font->size * sizeof(struct glyph)); 
    7373 
    74     for(x = 0, i = 0, xmin = 0; x < font->img->width && i < font->size; x++) 
     74    for(x = 0, i = 0, xmin = 0; x <= font->img->width && i < font->size; x++) 
    7575    { 
    7676        int found = 0; 
    77         for(y = 0; y < font->img->height; y++) 
    78         { 
    79             getpixel(font->img, x, y, &r, &g, &b); 
    80             if(r < 128) 
     77        if(x != font->img->width) 
     78            for(y = 0; y < font->img->height; y++) 
    8179            { 
    82                 found = 1; 
    83                 count += (255 - r); 
     80                getpixel(font->img, x, y, &r, &g, &b); 
     81                if(r < 240) 
     82                { 
     83                    found = 1; 
     84                    count += (255 - r); 
     85                } 
    8486            } 
    85         } 
     87        else 
     88          found = 0; 
     89 
    8690        if(found && !incell) 
    8791        { 
     
    103107                { 
    104108                    getpixel(font->img, newx, y, &r, &g, &b); 
    105                     if(r < 128) 
     109                    if(r < 240) 
    106110                    { 
    107111                        gotit = 1; 
     
    132136    if(i != font->size) 
    133137    { 
    134         printf("%s: could not find %i glyphs in font\n", argv0, font->size); 
     138        fprintf(stderr, "%s: could only find %i of %i glyphs in font %s\n", 
     139                argv0, i, font->size, file); 
    135140        image_free(font->img); 
    136141        free(font->glyphs); 
Note: See TracChangeset for help on using the changeset viewer.