From baf6ad22b65eca0721d792bfd2365730b4e6b900 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Sat, 6 Oct 2012 20:25:11 +0800 Subject: [PATCH] fix mem issue of 'selected' --- src/ffw.c | 11 ++++++----- test/test.py | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ffw.c b/src/ffw.c index 21dbb32..f5cdc04 100644 --- a/src/ffw.c +++ b/src/ffw.c @@ -98,6 +98,8 @@ void ffw_fin(void) void ffw_load_font(const char * filename) { + assert((cur_fv == NULL) && "Previous font is not destroyed"); + char * _filename = strcopy(filename); SplineFont * font = LoadSplineFont(_filename, 1); @@ -119,14 +121,10 @@ void ffw_load_font(const char * filename) */ void ffw_prepare_font(void) { - /* - * Disabled, because it causes crashing - memset(cur_fv->selected, 1, cur_fv->map->enccount); // remove kern FVRemoveKerns(cur_fv); FVRemoveVKerns(cur_fv); - */ /* * Remove Alternate Unicodes @@ -169,6 +167,9 @@ static void ffw_do_reencode(Encoding * encoding, int force) } SFReplaceEncodingBDFProps(cur_fv->sf, cur_fv->map); + + free(cur_fv->selected); + cur_fv->selected = gcalloc(cur_fv->map->enccount, sizeof(char)); } void ffw_reencode_glyph_order(void) @@ -376,7 +377,7 @@ void ffw_set_widths(int * width_list, int mapping_len, sc->width = width_list[i]; } - for(; i < cur_fv->map->enccount; ++i) + for(; i < map->enccount; ++i) cur_fv->selected[i] = 1; if(remove_unused) diff --git a/test/test.py b/test/test.py index 5298d58..8daeb38 100755 --- a/test/test.py +++ b/test/test.py @@ -4,6 +4,7 @@ DIR = 'pdf' #DIR = '../../pdf.js/test/pdfs' import os +import sys with open('out.html','w') as outf: outf.write('\n
') @@ -12,7 +13,10 @@ with open('out.html','w') as outf: if not f.lower().endswith('.pdf'): continue print f - os.system('pdf2htmlEX --dest-dir html --auto-hint=1 --external-hint-tool="ttfautohint" --remove-unused-glyph 1 "%s/%s"' % (DIR,f)) + if os.system('pdf2htmlEX --dest-dir html --auto-hint=1 --external-hint-tool="ttfautohint" --remove-unused-glyph 0 "%s/%s"' % (DIR,f)) != 0: + print "error on ", f + sys.exit(-1) + #os.system('pdf2htmlEX --dest-dir html --process-nontext 0 --css-draw 1 "%s/%s"' % (DIR,f)) ff = f[:-3] outf.write('%s
' % (ff,ff))