2 * Paper printing definitions.
4 * This header file defines data structures and constants which are
5 * shared between bk_paper.c and its clients bk_ps.c and bk_pdf.c.
8 #ifndef HALIBUT_PAPER_H
9 #define HALIBUT_PAPER_H
11 typedef struct document_Tag document
;
12 typedef struct font_data_Tag font_data
;
13 typedef struct font_encoding_Tag font_encoding
;
14 typedef struct font_list_Tag font_list
;
15 typedef struct para_data_Tag para_data
;
16 typedef struct line_data_Tag line_data
;
17 typedef struct page_data_Tag page_data
;
18 typedef struct subfont_map_entry_Tag subfont_map_entry
;
19 typedef struct text_fragment_Tag text_fragment
;
20 typedef struct xref_Tag xref
;
21 typedef struct xref_dest_Tag xref_dest
;
22 typedef struct rect_Tag rect
;
23 typedef struct outline_element_Tag outline_element
;
26 * This data structure represents the overall document, in the form
27 * it will be given to the client backends.
30 int paper_width
, paper_height
;
33 outline_element
*outline_elements
;
34 int n_outline_elements
;
38 * This data structure represents a particular font.
40 struct font_data_Tag
{
42 * Specify the PostScript name of the font and its point size.
46 * An array of pointers to the available glyph names, and their
47 * corresponding character widths. These two arrays have
51 const char *const *glyphs
;
54 * For reasonably speedy lookup, we set up a 65536-element
55 * table representing the Unicode BMP (I can conveniently
56 * restrict myself to the BMP for the moment since I happen to
57 * know that no glyph in the Adobe Glyph List falls outside
58 * it), whose elements are indices into the above two arrays.
60 unsigned short bmp
[65536];
62 * At some point I'm going to divide the font into sub-fonts
63 * with largely non-overlapping encoding vectors. This array
64 * will track which glyphs go into which subfonts. Also here I
65 * keep track of the latest subfont of any given font, so I can
66 * go back and extend its encoding.
68 subfont_map_entry
*subfont_map
;
69 font_encoding
*latest_subfont
;
71 * The font list to which this font belongs.
76 struct subfont_map_entry_Tag
{
77 font_encoding
*subfont
;
78 unsigned char position
;
82 * This data structure represents a sub-font: a font with an
85 struct font_encoding_Tag
{
88 char *name
; /* used by client backends */
90 font_data
*font
; /* the parent font structure */
91 const char *vector
[256]; /* the actual encoding vector */
92 int indices
[256]; /* indices back into main font struct */
93 wchar_t to_unicode
[256]; /* PDF will want to know this */
94 int free_pos
; /* space left to extend encoding */
98 * This data structure represents the overall list of sub-fonts in
101 struct font_list_Tag
{
107 * Constants defining array indices for the various fonts used in a
118 * This is the data structure which is stored in the private_data
119 * field of each paragraph. It divides the paragraph up into a
120 * linked list of lines, while at the same time providing for those
121 * lines to be linked together into a much longer list spanning the
122 * whole document for page-breaking purposes.
125 struct para_data_Tag
{
128 * Data about the fonts used in this paragraph. Indices are the
129 * FONT_* constants defined above.
131 font_data
*fonts
[NFONTS
];
134 * Pointers to the first and last line of the paragraph. The
135 * line structures are linked into a list, which runs from
136 * `first' to `last' as might be expected. However, the list
137 * does not terminate there: first->prev will end up pointing
138 * to the last line of the previous paragraph in most cases,
139 * and likewise last->next will point to the first line of the
142 line_data
*first
; /* first line in paragraph */
143 line_data
*last
; /* last line in paragraph */
145 * Some paragraphs have associated graphics; currently this is
146 * nothing more complex than a single black rectangle.
149 RECT_NONE
, RECT_CHAPTER_UNDERLINE
, RECT_RULE
152 * We left- and right-justify in special circumstances.
158 * For constructing the page outline.
160 int outline_level
; /* 0=title 1=C 2=H 3=S 4=S2... */
161 wchar_t *outline_title
;
163 * For adding the page number of a contents entry afterwards.
165 paragraph
*contents_entry
;
168 struct line_data_Tag
{
170 * The parent paragraph.
174 * Pointers to join lines into a linked list.
179 * The extent of the text displayed on this line. Also mention
180 * its starting x position, and by how much the width of spaces
181 * needs to be adjusted for paragraph justification.
183 * (Unlike most of the `last' pointers defined in this file,
184 * this `end' pointer points to the word _after_ the last one
185 * that should be displayed on the line. This is how it's
186 * returned from wrap_para().)
191 int hshortfall
, nspaces
; /* for justifying paragraphs */
194 * Auxiliary text: a section number in a margin, or a list item
195 * bullet or number. Also mention where to display this text
196 * relative to the left margin.
202 * This line might have a non-negotiable page break before it.
203 * Also there will be space required above and below it; also I
204 * store the physical line height (defined as the maximum of
205 * the heights of the three fonts in the pdata) because it's
206 * easier than looking it up repeatedly during page breaking.
213 * Penalties for page breaking before or after this line.
215 int penalty_before
, penalty_after
;
217 * These fields are used in the page breaking algorithm.
220 int *vshortfall
, *text
, *space
;
221 line_data
**page_last
; /* last line on a page starting here */
223 * After page breaking, we can assign an actual y-coordinate on
224 * the page to each line. Also we store a pointer back to the
225 * page structure itself.
232 * This data structure is constructed to describe each page of the
235 struct page_data_Tag
{
237 * Pointers to join pages into a linked list.
242 * The set of lines displayed on this page.
244 line_data
*first_line
;
245 line_data
*last_line
;
247 * After text rendering: the set of actual pieces of text
248 * needing to be displayed on this page.
250 text_fragment
*first_text
;
251 text_fragment
*last_text
;
258 * Rectangles to be drawn. (These are currently only used for
259 * underlining chapter titles and drawing horizontal rules.)
264 * The page number, as a string.
268 * This spare pointer field is for use by the client backends.
273 struct text_fragment_Tag
{
282 struct xref_dest_Tag
{
283 enum { NONE
, PAGE
, URL
} type
;
299 struct outline_element_Tag
{
300 int level
; /* 0=title 1=C 2=H 3=S 4=S2... */
305 * Functions and data exported from psdata.c.
307 wchar_t ps_glyph_to_unicode(char const *glyph
);
308 extern const char *const ps_std_glyphs
[];
309 const int *ps_std_font_widths(char const *fontname
);