- * - implement some simple graphics
- * * I had an underline below chapter headings in the original
- * Perl version, and I thought it looked rather nice
- * * also we need para_Rule.
+ * - implement para_Rule
*
* - set up contents section now we know what sections begin on
* which pages
*
* - set up contents section now we know what sections begin on
* which pages
static void code_paragraph(para_data *pdata,
font_data *fn, font_data *fi, font_data *fb,
int font_size, int indent, word *words);
static void code_paragraph(para_data *pdata,
font_data *fn, font_data *fi, font_data *fb,
int font_size, int indent, word *words);
+static void add_rect_to_page(page_data *page, int x, int y, int w, int h);
void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
indexdata *idx) {
void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords,
indexdata *idx) {
int base_para_spacing = 10 * 4096;
int chapter_top_space = 72 * 4096;
int sect_num_left_space = 12 * 4096;
int base_para_spacing = 10 * 4096;
int chapter_top_space = 72 * 4096;
int sect_num_left_space = 12 * 4096;
+ int chapter_underline_depth = 14 * 4096;
+ int chapter_underline_thickness = 3 * 4096;
int base_width = paper_width - left_margin - right_margin;
int page_height = paper_height - top_margin - bottom_margin;
int base_width = paper_width - left_margin - right_margin;
int page_height = paper_height - top_margin - bottom_margin;
*/
case para_IM:
case para_BR:
*/
case para_IM:
case para_BR:
case para_Biblio:
case para_NotParaType:
case para_Config:
case para_Biblio:
case para_NotParaType:
case para_Config:
p->type == para_UnnumberedChapter) {
pdata->first->page_break = TRUE;
pdata->first->space_before = chapter_top_space;
p->type == para_UnnumberedChapter) {
pdata->first->page_break = TRUE;
pdata->first->space_before = chapter_top_space;
+ pdata->last->space_after +=
+ chapter_underline_depth + chapter_underline_thickness;
if (ldata == pdata->last)
break;
}
if (ldata == pdata->last)
break;
}
+
+ /*
+ * Some section headings (FIXME: should be configurable
+ * which) want to be underlined.
+ */
+ if (p->type == para_Chapter || p->type == para_Appendix ||
+ p->type == para_UnnumberedChapter || p->type == para_Title) {
+ add_rect_to_page(pdata->last->page,
+ left_margin,
+ (paper_height - top_margin -
+ pdata->last->ypos - chapter_underline_depth),
+ base_width,
+ chapter_underline_thickness);
+ }
page->last_line = l->page_last;
page->first_text = page->last_text = NULL;
page->last_line = l->page_last;
page->first_text = page->last_text = NULL;
page->first_xref = page->last_xref = NULL;
page->first_xref = page->last_xref = NULL;
+ page->first_rect = page->last_rect = NULL;
/*
* Now assign a y-coordinate to each line on the page.
/*
* Now assign a y-coordinate to each line on the page.
+static void add_rect_to_page(page_data *page, int x, int y, int w, int h)
+{
+ rect *r = mknew(rect);
+
+ r->next = NULL;
+ if (page->last_rect)
+ page->last_rect->next = r;
+ else
+ page->first_rect = r;
+ page->last_rect = r;
+
+ r->x = x;
+ r->y = y;
+ r->w = w;
+ r->h = h;
+}
+
static void add_string_to_page(page_data *page, int x, int y,
font_encoding *fe, int size, char *text)
{
static void add_string_to_page(page_data *page, int x, int y,
font_encoding *fe, int size, char *text)
{
else
page->first_xref = *xr;
page->last_xref = *xr;
else
page->first_xref = *xr;
page->last_xref = *xr;
/*
* FIXME: Ideally we should have, and use, some
/*
* FIXME: Ideally we should have, and use, some
*/
if (dest->type != NONE) {
xr = mknew(xref);
*/
if (dest->type != NONE) {
xr = mknew(xref);
xr->dest = *dest; /* structure copy */
if (ldata->page->last_xref)
ldata->page->last_xref->next = xr;
xr->dest = *dest; /* structure copy */
if (ldata->page->last_xref)
ldata->page->last_xref->next = xr;
pageno = 0;
for (page = doc->pages; page; page = page->next) {
object *opage, *cstr;
pageno = 0;
for (page = doc->pages; page; page = page->next) {
object *opage, *cstr;
text_fragment *frag;
char buf[256];
text_fragment *frag;
char buf[256];
objref(opage, cstr);
objtext(opage, "\n");
objref(opage, cstr);
objtext(opage, "\n");
+ /*
+ * Render any rectangles on the page.
+ */
+ for (r = page->first_rect; r; r = r->next) {
+ char buf[512];
+ sprintf(buf, "%g %g %g %g re f\n", r->x / 4096.0,
+ r->y / 4096.0, r->w / 4096.0, r->h / 4096.0);
+ objstream(cstr, buf);
+ }
+
objstream(cstr, "BT\n");
for (frag = page->first_text; frag; frag = frag->next) {
char *c;
objstream(cstr, "BT\n");
for (frag = page->first_text; frag; frag = frag->next) {
char *c;
fprintf(fp, "%%%%EndSetup\n");
/*
fprintf(fp, "%%%%EndSetup\n");
/*
+ * Output the text and graphics.
*/
pageno = 0;
for (page = doc->pages; page; page = page->next) {
text_fragment *frag;
*/
pageno = 0;
for (page = doc->pages; page; page = page->next) {
text_fragment *frag;
pageno++;
fprintf(fp, "%%%%Page: %d %d\n", pageno, pageno);
pageno++;
fprintf(fp, "%%%%Page: %d %d\n", pageno, pageno);
+ for (r = page->first_rect; r; r = r->next) {
+ fprintf(fp, "%g %g moveto %g 0 rlineto 0 %g rlineto "
+ "-%g 0 rlineto closepath fill\n",
+ r->x / 4096.0, r->y / 4096.0, r->w / 4096.0,
+ r->h / 4096.0, r->w / 4096.0);
+ }
+
for (frag = page->first_text; frag; frag = frag->next) {
char *c;
for (frag = page->first_text; frag; frag = frag->next) {
char *c;
typedef struct text_fragment_Tag text_fragment;
typedef struct xref_Tag xref;
typedef struct xref_dest_Tag xref_dest;
typedef struct text_fragment_Tag text_fragment;
typedef struct xref_Tag xref;
typedef struct xref_dest_Tag xref_dest;
+typedef struct rect_Tag rect;
/*
* This data structure represents the overall document, in the form
/*
* This data structure represents the overall document, in the form
xref *first_xref;
xref *last_xref;
/*
xref *first_xref;
xref *last_xref;
/*
+ * Rectangles to be drawn. (These are currently only used for
+ * underlining chapter titles and drawing horizontal rules.)
+ */
+ rect *first_rect;
+ rect *last_rect;
+ /*
* This spare pointer field is for use by the client backends.
*/
void *spare;
* This spare pointer field is for use by the client backends.
*/
void *spare;
+struct rect_Tag {
+ rect *next;
+ int x, y, w, h;
+};
+
/*
* Functions and data exported from psdata.c.
*/
/*
* Functions and data exported from psdata.c.
*/