From f2cf240dc050f1eb376dfd1d952b3a255893be6f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 16 Apr 2004 10:56:31 +0000 Subject: Compacted PS and PDF output files by removing redundant reiterations of the same font and position designations. Reduced the size of the Halibut manual PDF to less than half what it started out as, and the PS one to more like a third of its original size. [originally from svn r4083] --- bk_paper.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'bk_paper.c') diff --git a/bk_paper.c b/bk_paper.c index 2e05028..dba4efd 100644 --- a/bk_paper.c +++ b/bk_paper.c @@ -14,14 +14,6 @@ * * - linearised PDF, perhaps? * - * - compression of output files. For the actual text display, - * both output formats currently average about 50-60 characters - * per 5-6 character word of text, and almost all of it's the - * same. - * * In PS, we can define custom text operators to make things - * more efficient. - * * In PDF, there already are! - * * - I'm uncertain of whether I need to include a ToUnicode CMap * in each of my font definitions in PDF. Currently things (by * which I mean cut and paste out of acroread) seem to be @@ -1563,7 +1555,8 @@ static void add_rect_to_page(page_data *page, int x, int y, int w, int h) } static void add_string_to_page(page_data *page, int x, int y, - font_encoding *fe, int size, char *text) + font_encoding *fe, int size, char *text, + int width) { text_fragment *frag; @@ -1581,6 +1574,7 @@ static void add_string_to_page(page_data *page, int x, int y, frag->fe = fe; frag->fontsize = size; frag->text = dupstr(text); + frag->width = width; } /* @@ -1634,7 +1628,8 @@ static int render_string(page_data *page, font_data *font, int fontsize, if (!subfont || sf != subfont) { if (subfont) { text[textpos] = '\0'; - add_string_to_page(page, x, y, subfont, fontsize, text); + add_string_to_page(page, x, y, subfont, fontsize, text, + textwid); x += textwid; } else { assert(textpos == 0); @@ -1651,7 +1646,7 @@ static int render_string(page_data *page, font_data *font, int fontsize, if (textpos > 0) { text[textpos] = '\0'; - add_string_to_page(page, x, y, subfont, fontsize, text); + add_string_to_page(page, x, y, subfont, fontsize, text, textwid); x += textwid; } -- cgit v1.1