~mdw
/
sgt
/
halibut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Charset support for the man page backend (\cfg{man-charset}).
[sgt/halibut]
/
bk_paper.c
diff --git
a/bk_paper.c
b/bk_paper.c
index
e6e17f7
..
a9f6f24
100644
(file)
--- a/
bk_paper.c
+++ b/
bk_paper.c
@@
-12,20
+12,12
@@
/*
* TODO in future work:
*
/*
* TODO in future work:
*
- * - the index should not refer to the contents, if an indexable
- * term crops up in a section title!
- *
- * - include the version IDs.
- *
* - linearised PDF, perhaps?
*
* - 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!
+ * - 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
*
* - I'm uncertain of whether I need to include a ToUnicode CMap
* in each of my font definitions in PDF. Currently things (by
@@
-75,6
+67,7
@@
* * 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)
* * 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
* * substituting `minus' for `hyphen' in the standard encoding
* is probably preferable in Courier, though certainly not in
* the main text font
@@
-517,7
+510,7
@@
void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
for (page = pages; page; page = page->next) {
sprintf(buf, "%d", ++pagenum);
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) {
}
if (has_index) {
@@
-531,7
+524,7
@@
void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
/* And don't forget the as-yet-uncreated index. */
sprintf(buf, "%d", ++pagenum);
/* 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
);
}
}
}
}
@@
-571,6
+564,9
@@
void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
paper_idx *pi = (paper_idx *)entry->backend_data;
para_data *text, *pages;
paper_idx *pi = (paper_idx *)entry->backend_data;
para_data *text, *pages;
+ if (!pi->words)
+ continue;
+
text = make_para_data(para_Normal, 0, 0,
conf->base_width - conf->index_colwidth,
NULL, NULL, entry->text, conf);
text = make_para_data(para_Normal, 0, 0,
conf->base_width - conf->index_colwidth,
NULL, NULL, entry->text, conf);
@@
-687,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);
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
);
}
/*
}
/*
@@
-1564,7
+1560,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,
}
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;
{
text_fragment *frag;
@@
-1582,6
+1579,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->fe = fe;
frag->fontsize = size;
frag->text = dupstr(text);
+ frag->width = width;
}
/*
}
/*
@@
-1600,8
+1598,10
@@
static int render_string(page_data *page, font_data *font, int fontsize,
while (*str) {
glyph = font->bmp[*str];
while (*str) {
glyph = font->bmp[*str];
- if (glyph == 0xFFFF)
+ if (glyph == 0xFFFF) {
+ str++;
continue; /* nothing more we can do here */
continue; /* nothing more we can do here */
+ }
/*
* Find which subfont this character is going in.
/*
* Find which subfont this character is going in.
@@
-1633,7
+1633,8
@@
static int render_string(page_data *page, font_data *font, int fontsize,
if (!subfont || sf != subfont) {
if (subfont) {
text[textpos] = '\0';
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);
x += textwid;
} else {
assert(textpos == 0);
@@
-1650,7
+1651,7
@@
static int render_string(page_data *page, font_data *font, int fontsize,
if (textpos > 0) {
text[textpos] = '\0';
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;
}
x += textwid;
}
@@
-1681,7
+1682,7
@@
static int render_text(page_data *page, para_data *pdata, line_data *ldata,
if (text->type == word_HyperLink) {
dest.type = URL;
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;
dest.page = NULL;
} else if (text->type == word_PageXref) {
dest.type = PAGE;
@@
-1742,7
+1743,10
@@
static int render_text(page_data *page, para_data *pdata, line_data *ldata,
* referenced by an index entry.
*/
case word_IndexRef:
* referenced by an index entry.
*/
case word_IndexRef:
- {
+ /*
+ * We don't create index references in contents entries.
+ */
+ if (!pdata->contents_entry) {
indextag *tag;
int i;
indextag *tag;
int i;
@@
-2000,13
+2004,6
@@
static void render_para(para_data *pdata, paper_conf *conf,
wid = paper_width_simple(pdata, w);
sfree(w);
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)
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)
@@
-2016,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".");
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);
}
/*
}
/*