From e4e6614dfa133420adb1763a962fff8ea04ab941 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 4 Jul 2018 15:15:43 +0000 Subject: Rewrite font processing for proper memory management; make built-in fonts work with wide characters; fix wild pointer dereference with invalid BDF input git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3291 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/pbmfontdata1.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/pbmfontdata1.c') diff --git a/lib/pbmfontdata1.c b/lib/pbmfontdata1.c index 8552d29e..ab6ce28d 100644 --- a/lib/pbmfontdata1.c +++ b/lib/pbmfontdata1.c @@ -1,4 +1,5 @@ #include "pbmfont.h" +#include "pbmfontdata.h" /* Default fixed-width font All glyphs fit into a 7 x 12 rectangular cell. @@ -20,7 +21,7 @@ */ static struct glyph glFxd[96] = { -/* 32 character */ +/* 32 character */ {7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" }, /* 33 character ! */ {7,12,0,0,7,"\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" }, @@ -210,9 +211,9 @@ static struct glyph glFxd[96] = { {7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0" }, /* 126 character ~ */ {7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\1\0\1\0\1\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" }, -/* 127 character (?) */ +/* 127 character (Control character, retained for backward compatibility) */ {7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" } -}; +}; @@ -246,7 +247,22 @@ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, NULL, 0, 0 +}; + +struct font2 const pbm_defaultFixedfont2 = { + sizeof(pbm_defaultFixedfont2), /* len */ + PBM_FONT2_STRUCT_SIZE(charset_string), /* size */ + 7, 12, 0, 0, /* maxwidth, maxheight, x, y */ + pbm_defaultFixedfont.glyph, /* glyph table */ + 255, NULL, 255, /* maxglyph, selector, maxmaxglyph */ + NULL, 0, 0, /* oldfont, fcols, frows */ + PBM_FORMAT, /* bit_format */ + 96, 96, /* total_chars, chars */ + FIXED_DATA, /* load_fn */ + 32, 1, /* default_char, default_char_defined */ + (char *) "builtin fixed", /* name */ + ISO646_1991_IRV, (char *)"ASCII" /* charset, charset_string */ }; -- cgit 1.4.1