/*
* TODO in future work:
*
- * - include the version IDs.
- *
* - linearised PDF, perhaps?
*
* - compression of output files. For the actual text display,
* * a hyphen in a word by itself might prefer to be an en-dash
* * (Americans might even want a convenient way to use an
* em-dash)
+ * * DON'T DO ANY OF THE ABOVE WITHIN \c OR \cw!
* * substituting `minus' for `hyphen' in the standard encoding
* is probably preferable in Courier, though certainly not in
* the main text font
page_data *last, object *resources);
static int make_outline(object *parent, outline_element *start, int n,
int open);
+static int pdf_versionid(FILE *fp, word *words);
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
indexdata *idx, void *vdoc) {
}
/*
- * Header
+ * Header. I'm going to put the version IDs in the header as
+ * well, simply in PDF comments.
*/
fileoff = fprintf(fp, "%%PDF-1.3\n");
+ for (p = sourceform; p; p = p->next)
+ if (p->type == para_VersionID)
+ fileoff += pdf_versionid(fp, p->words);
/*
* Body
return totalcount;
}
+
+static int pdf_versionid(FILE *fp, word *words)
+{
+ int ret;
+
+ ret = fprintf(fp, "%% ");
+
+ for (; words; words = words->next) {
+ char *text;
+ int type;
+
+ switch (words->type) {
+ case word_HyperLink:
+ case word_HyperEnd:
+ case word_UpperXref:
+ case word_LowerXref:
+ case word_XrefEnd:
+ case word_IndexRef:
+ continue;
+ }
+
+ type = removeattr(words->type);
+
+ switch (type) {
+ case word_Normal:
+ text = utoa_dup(words->text);
+ break;
+ case word_WhiteSpace:
+ text = dupstr(" ");
+ break;
+ case word_Quote:
+ text = dupstr("'");
+ break;
+ }
+
+ fputs(text, fp);
+ ret += strlen(text);
+ sfree(text);
+ }
+
+ ret += fprintf(fp, "\n");
+
+ return ret;
+}
#include "halibut.h"
#include "paper.h"
+static void ps_versionid(FILE *fp, word *words);
+
paragraph *ps_config_filename(char *filename)
{
paragraph *p;
fprintf(fp, "%%%%EndProlog\n");
fprintf(fp, "%%%%BeginSetup\n");
+
+ /*
+ * This is as good a place as any to put version IDs.
+ */
+ for (p = sourceform; p; p = p->next)
+ if (p->type == para_VersionID)
+ ps_versionid(fp, p->words);
+
/*
* Re-encode and re-metric the fonts.
*/
sfree(filename);
}
+
+static void ps_versionid(FILE *fp, word *words)
+{
+ fprintf(fp, "%% ");
+
+ for (; words; words = words->next) {
+ char *text;
+ int type;
+
+ switch (words->type) {
+ case word_HyperLink:
+ case word_HyperEnd:
+ case word_UpperXref:
+ case word_LowerXref:
+ case word_XrefEnd:
+ case word_IndexRef:
+ continue;
+ }
+
+ type = removeattr(words->type);
+
+ switch (type) {
+ case word_Normal:
+ text = utoa_dup(words->text);
+ break;
+ case word_WhiteSpace:
+ text = dupstr(" ");
+ break;
+ case word_Quote:
+ text = dupstr("'");
+ break;
+ }
+
+ fputs(text, fp);
+ sfree(text);
+ }
+
+ fprintf(fp, "\n");
+}