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
;
22 * This data structure represents the overall document, in the form
23 * it will be given to the client backends.
26 int paper_width
, paper_height
;
32 * This data structure represents a particular font.
34 struct font_data_Tag
{
36 * Specify the PostScript name of the font and its point size.
40 * An array of pointers to the available glyph names, and their
41 * corresponding character widths. These two arrays have
45 const char *const *glyphs
;
48 * For reasonably speedy lookup, we set up a 65536-element
49 * table representing the Unicode BMP (I can conveniently
50 * restrict myself to the BMP for the moment since I happen to
51 * know that no glyph in the Adobe Glyph List falls outside
52 * it), whose elements are indices into the above two arrays.
54 unsigned short bmp
[65536];
56 * At some point I'm going to divide the font into sub-fonts
57 * with largely non-overlapping encoding vectors. This array
58 * will track which glyphs go into which subfonts. Also here I
59 * keep track of the latest subfont of any given font, so I can
60 * go back and extend its encoding.
62 subfont_map_entry
*subfont_map
;
63 font_encoding
*latest_subfont
;
65 * The font list to which this font belongs.
70 struct subfont_map_entry_Tag
{
71 font_encoding
*subfont
;
72 unsigned char position
;
76 * This data structure represents a sub-font: a font with an
79 struct font_encoding_Tag
{
82 char *name
; /* used by client backends */
84 font_data
*font
; /* the parent font structure */
85 const char *vector
[256]; /* the actual encoding vector */
86 int indices
[256]; /* indices back into main font struct */
87 wchar_t to_unicode
[256]; /* PDF will want to know this */
88 int free_pos
; /* space left to extend encoding */
92 * This data structure represents the overall list of sub-fonts in
95 struct font_list_Tag
{
101 * Constants defining array indices for the various fonts used in a
112 * This is the data structure which is stored in the private_data
113 * field of each paragraph. It divides the paragraph up into a
114 * linked list of lines, while at the same time providing for those
115 * lines to be linked together into a much longer list spanning the
116 * whole document for page-breaking purposes.
119 struct para_data_Tag
{
121 * Data about the fonts used in this paragraph. Indices are the
122 * FONT_* constants defined above.
124 font_data
*fonts
[NFONTS
];
127 * Pointers to the first and last line of the paragraph. The
128 * line structures are linked into a list, which runs from
129 * `first' to `last' as might be expected. However, the list
130 * does not terminate there: first->prev will end up pointing
131 * to the last line of the previous paragraph in most cases,
132 * and likewise last->next will point to the first line of the
135 line_data
*first
; /* first line in paragraph */
136 line_data
*last
; /* last line in paragraph */
139 struct line_data_Tag
{
141 * The parent paragraph.
145 * Pointers to join lines into a linked list.
150 * The extent of the text displayed on this line. Also mention
151 * its starting x position, and by how much the width of spaces
152 * needs to be adjusted for paragraph justification.
154 * (`last' may be NULL if it's more convenient.)
159 int space_adjust
; /* for justifying paragraphs */
161 * Auxiliary text: a section number in a margin, or a list item
162 * bullet or number. Also mention where to display this text
163 * relative to the left margin.
168 * This line might have a non-negotiable page break before it.
169 * Also there will be space required above and below it; also I
170 * store the physical line height (defined as the maximum of
171 * the heights of the three fonts in the pdata) because it's
172 * easier than looking it up repeatedly during page breaking.
179 * These fields are used in the page breaking algorithm.
182 int shortfall
, text
, space
;
183 line_data
*page_last
; /* last line on a page starting here */
185 * After page breaking, we can assign an actual y-coordinate on
186 * the page to each line. Also we store a pointer back to the
187 * page structure itself.
194 * This data structure is constructed to describe each page of the
197 struct page_data_Tag
{
199 * Pointers to join pages into a linked list.
204 * The set of lines displayed on this page.
206 line_data
*first_line
;
207 line_data
*last_line
;
209 * After text rendering: the set of actual pieces of text
210 * needing to be displayed on this page.
212 text_fragment
*first_text
;
213 text_fragment
*last_text
;
215 * This spare pointer field is for use by the client backends.
220 struct text_fragment_Tag
{
229 * Functions and data exported from psdata.c.
231 wchar_t ps_glyph_to_unicode(char const *glyph
);
232 extern const char *const ps_std_glyphs
[];
233 const int *ps_std_font_widths(char const *fontname
);