From d86ad62fe446286296dd97226a1c7748ca40ddf2 Mon Sep 17 00:00:00 2001 From: kramm Date: Wed, 12 Mar 2008 19:10:02 +0000 Subject: [PATCH] converted external fonts into a linked list --- lib/pdf/GFXOutputDev.cc | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 416bf0b..4258a37 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -82,10 +82,14 @@ typedef struct _fontfile const char*filename; int len; // basename length int used; + struct _fontfile*next; } fontfile_t; // for pdfswf_addfont -static fontfile_t fonts[2048]; + +static fontfile_t* global_fonts = 0; +static fontfile_t* global_fonts_next = 0; + static int fontnum = 0; /* config */ @@ -331,13 +335,16 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) int bestlen = 0x7fffffff; const char*bestfilename = 0; - for(t=0;tfilename, name)) { + if(f->len < bestlen) { + bestlen = f->len; + bestfilename = f->filename; } } + f = f->next; } if(bestfilename) { DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), displayFontT1); @@ -2014,9 +2021,9 @@ static const char* dirseparator() void addGlobalFont(const char*filename) { - fontfile_t f; - memset(&f, 0, sizeof(fontfile_t)); - f.filename = filename; + fontfile_t* f = (fontfile_t*)malloc(sizeof(fontfile_t)); + memset(f, 0, sizeof(fontfile_t)); + f->filename = filename; int len = strlen(filename); char*r1 = strrchr(filename, '/'); char*r2 = strrchr(filename, '\\'); @@ -2025,12 +2032,14 @@ void addGlobalFont(const char*filename) if(r1) { len = strlen(r1+1); } - f.len = len; - if(fontnum < sizeof(fonts)/sizeof(fonts[0])) { - msg(" Adding font \"%s\".", filename); - fonts[fontnum++] = f; + f->len = len; + + msg(" Adding font \"%s\".", filename); + if(global_fonts_next) { + global_fonts_next->next = f; + global_fonts_next = global_fonts_next->next; } else { - msg(" Too many external fonts. Not adding font file \"%s\".", filename); + global_fonts_next = global_fonts = f; } } -- 1.7.10.4