Ahem; that only didn't cause a segfault by sheer luck.
[sgt/halibut] / bk_paper.c
index dba4efd..a9f6f24 100644 (file)
  * 
  *  - linearised PDF, perhaps?
  * 
+ *  - we should use PDFDocEncoding or Unicode for outline strings,
+ *    now that I actually know how to do them. Probably easiest if
+ *    I do this _after_ bringing in libcharset, since I can simply
+ *    supply PDFDocEncoding in there.
+ * 
  *  - 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
@@ -505,7 +510,7 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
 
        for (page = pages; page; page = page->next) {
            sprintf(buf, "%d", ++pagenum);
-           page->number = ufroma_dup(buf);
+           page->number = ufroma_dup(buf, CS_ASCII);
        }
 
        if (has_index) {
@@ -519,7 +524,7 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
 
            /* And don't forget the as-yet-uncreated index. */
            sprintf(buf, "%d", ++pagenum);
-           first_index_page->number = ufroma_dup(buf);
+           first_index_page->number = ufroma_dup(buf, CS_ASCII);
        }
     }
 
@@ -678,7 +683,7 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
        for (page = ipages->next; page; page = page->next) {
            char buf[40];
            sprintf(buf, "%d", ++pagenum);
-           page->number = ufroma_dup(buf);
+           page->number = ufroma_dup(buf, CS_ASCII);
        }
 
        /*
@@ -1677,7 +1682,7 @@ static int render_text(page_data *page, para_data *pdata, line_data *ldata,
 
            if (text->type == word_HyperLink) {
                dest.type = URL;
-               dest.url = utoa_dup(text->text);
+               dest.url = utoa_dup(text->text, CS_ASCII);
                dest.page = NULL;
            } else if (text->type == word_PageXref) {
                dest.type = PAGE;
@@ -1999,13 +2004,6 @@ static void render_para(para_data *pdata, paper_conf *conf,
        wid = paper_width_simple(pdata, w);
        sfree(w);
 
-       render_string(pdata->last->page,
-                     pdata->fonts[FONT_NORMAL],
-                     pdata->sizes[FONT_NORMAL],
-                     conf->paper_width - conf->right_margin - wid,
-                     (conf->paper_height - conf->top_margin -
-                      pdata->last->ypos), num);
-
        for (x = 0; x < conf->base_width; x += conf->leader_separation)
            if (x - conf->leader_separation > last_x - conf->left_margin &&
                x + conf->leader_separation < conf->base_width - wid)
@@ -2015,6 +2013,13 @@ static void render_para(para_data *pdata, paper_conf *conf,
                              conf->left_margin + x,
                              (conf->paper_height - conf->top_margin -
                               pdata->last->ypos), L".");
+
+       render_string(pdata->last->page,
+                     pdata->fonts[FONT_NORMAL],
+                     pdata->sizes[FONT_NORMAL],
+                     conf->paper_width - conf->right_margin - wid,
+                     (conf->paper_height - conf->top_margin -
+                      pdata->last->ypos), num);
     }
 
     /*