diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-24 22:06:44 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-24 22:06:44 -0400 |
commit | a69320a9b27ed87f87d2d28fffa04907c4752873 (patch) | |
tree | eafd1e36175e9717f0838374adf44b80d30b97b7 | |
parent | a29e020059ca6f73a212ec76af94b22a694ad765 (diff) | |
download | freetype2-a69320a9b27ed87f87d2d28fffa04907c4752873.tar.gz |
[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.
-rw-r--r-- | src/bdf/bdflib.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index fa92fdffa..f2ce328ee 100644 --- 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; |