Преглед изворни кода

* when cutting fonts, detect black pixels below 240, not below 128

* allow last column to be non-white
  * better error message when all glyphs


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@451 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam пре 20 година
родитељ
комит
47b2c48535
1 измењених фајлова са 15 додато и 10 уклоњено
  1. +15
    -10
      src/font.c

+ 15
- 10
src/font.c Прегледај датотеку

@@ -71,18 +71,22 @@ struct font *font_load_variable(char *file, char *chars)
font->size = strlen(chars);
font->glyphs = malloc(font->size * sizeof(struct glyph));

for(x = 0, i = 0, xmin = 0; x < font->img->width && i < font->size; x++)
for(x = 0, i = 0, xmin = 0; x <= font->img->width && i < font->size; x++)
{
int found = 0;
for(y = 0; y < font->img->height; y++)
{
getpixel(font->img, x, y, &r, &g, &b);
if(r < 128)
if(x != font->img->width)
for(y = 0; y < font->img->height; y++)
{
found = 1;
count += (255 - r);
getpixel(font->img, x, y, &r, &g, &b);
if(r < 240)
{
found = 1;
count += (255 - r);
}
}
}
else
found = 0;

if(found && !incell)
{
incell = 1;
@@ -102,7 +106,7 @@ struct font *font_load_variable(char *file, char *chars)
for(newx = xmin; newx < xmax; newx++)
{
getpixel(font->img, newx, y, &r, &g, &b);
if(r < 128)
if(r < 240)
{
gotit = 1;
break;
@@ -131,7 +135,8 @@ struct font *font_load_variable(char *file, char *chars)

if(i != font->size)
{
printf("%s: could not find %i glyphs in font\n", argv0, font->size);
fprintf(stderr, "%s: could only find %i of %i glyphs in font %s\n",
argv0, i, font->size, file);
image_free(font->img);
free(font->glyphs);
free(font);


Loading…
Откажи
Сачувај