ref: a69320a9b27ed87f87d2d28fffa04907c4752873
parent: a29e020059ca6f73a212ec76af94b22a694ad765
author: Alexei Podtelezhnikov <[email protected]>
date: Fri Sep 24 18:06:44 EDT 2021
[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.
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -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;