From ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 13 Apr 2004 13:17:48 +0000 Subject: Initial work on PS and PDF output. Because these two backends share an enormous amount of preprocessing and differ only in their final output form, I've introduced a new type of layer called a `pre-backend' (bk_paper.c is one). This takes all the information passed to a normal backend and returns an arbitrary void *, which is cached by the front end and passed on to any backend(s) which state a desire for the output of that particular pre-backend. Thus, all the page layout is done only once, and the PS and PDF backends process the same data structures into two output files. Note that these backends are _very_ unfinished; all sorts of vital things such as section numbers, list markers, and title formatting are missing, the paragraph justification doesn't quite work, and advanced stuff like indexes and PDF interactive features haven't even been started. But this basic framework generates valid output files and is a good starting point, so I'm checking it in. [originally from svn r4058] --- bk_text.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'bk_text.c') diff --git a/bk_text.c b/bk_text.c index fdb1055..359ea25 100644 --- a/bk_text.c +++ b/bk_text.c @@ -209,7 +209,7 @@ paragraph *text_config_filename(char *filename) } void text_backend(paragraph *sourceform, keywordlist *keywords, - indexdata *idx) { + indexdata *idx, void *unused) { paragraph *p; textconfig conf; word *prefix, *body, *wp; @@ -219,6 +219,7 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, int nesting, nestindent; int indentb, indenta; + IGNORE(unused); IGNORE(keywords); /* we don't happen to need this */ IGNORE(idx); /* or this */ @@ -472,18 +473,20 @@ static void text_rdaddwc(rdstringc *rs, word *text, word *end) { } } -static int text_width(word *); +static int text_width(void *, word *); -static int text_width_list(word *text) { +static int text_width_list(void *ctx, word *text) { int w = 0; while (text) { - w += text_width(text); + w += text_width(ctx, text); text = text->next; } return w; } -static int text_width(word *text) { +static int text_width(void *ctx, word *text) { + IGNORE(ctx); + switch (text->type) { case word_HyperLink: case word_HyperEnd: @@ -504,7 +507,7 @@ static int text_width(word *text) { : 0) + (text_convert(text->text, NULL) ? ustrlen(text->text) : - text_width_list(text->alt))); + text_width_list(ctx, text->alt))); case word_WhiteSpace: case word_EmphSpace: @@ -560,7 +563,7 @@ static void text_heading(FILE *fp, word *tprefix, word *nprefix, word *text, wrapwidth = indent + width; } - wrapping = wrap_para(text, firstlinewidth, wrapwidth, text_width); + wrapping = wrap_para(text, firstlinewidth, wrapwidth, text_width, NULL, 0); for (p = wrapping; p; p = p->next) { text_rdaddwc(&t, p->begin, p->end); length = (t.text ? strlen(t.text) : 0); @@ -628,7 +631,7 @@ static void text_para(FILE *fp, word *prefix, char *prefixextra, word *text, } else e = indent + extraindent; - wrapping = wrap_para(text, firstlinewidth, width, text_width); + wrapping = wrap_para(text, firstlinewidth, width, text_width, NULL, 0); for (p = wrapping; p; p = p->next) { rdstringc t = { 0, 0, NULL }; text_rdaddwc(&t, p->begin, p->end); -- cgit v1.1