[bdf] Simplify comment collection or lack thereof.

BDF comments are neither actually collected nor retrieved. There is
no need to be fancy with delimiters.

* src/bdf/bdflib.c (_add_bdf_comment): Delimit comments with zeros...
(bdf_load_font): ...and do not null-terminate comments additionally.
(_bdf_parse_glyphs): Check if comments are kept, which they are not.
(_bdf_parse_start): Minor clean up.
This commit is contained in:
Alexei Podtelezhnikov 2021-09-24 22:06:44 -04:00
parent a29e020059
commit a69320a9b2
1 changed files with 12 additions and 27 deletions

View File

@ -949,7 +949,7 @@
cp = font->comments + font->comments_len;
FT_MEM_COPY( cp, comment, len );
cp[len] = '\n';
cp[len] = '\0';
font->comments_len += len + 1;
@ -1304,15 +1304,18 @@
/* Check for a comment. */
if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
{
linelen -= 7;
s = line + 7;
if ( *s != 0 )
if ( p->opts->keep_comments )
{
s++;
linelen--;
linelen -= 7;
s = line + 7;
if ( *s != 0 )
{
s++;
linelen--;
}
error = _bdf_add_comment( p->font, s, linelen );
}
error = _bdf_add_comment( p->font, s, linelen );
goto Exit;
}
@ -1894,13 +1897,8 @@
s++;
linelen--;
}
error = _bdf_add_comment( p->font, s, linelen );
if ( error )
goto Exit;
/* here font is not defined! */
}
goto Exit;
}
@ -2269,20 +2267,7 @@
}
}
if ( p->font )
{
/* Make sure the comments are null terminated if they exist. */
if ( p->font->comments_len > 0 )
{
if ( FT_QRENEW_ARRAY( p->font->comments,
p->font->comments_len,
p->font->comments_len + 1 ) )
goto Fail;
p->font->comments[p->font->comments_len] = 0;
}
}
else if ( !error )
if ( !p->font && !error )
error = FT_THROW( Invalid_File_Format );
*font = p->font;