Implementing footnotes in FOP
Footnotes present difficulties for page layout primarily because their point of invocation in the flow is different from their point of appearance in the area tree. All of the content lines of a footnote may appear on the same page as its invocation point, all may appear on a following page, or the lines may be split over a page or pages. (This characteristic leads to another problem when a footnote overflows the last page of flow content, but that difficulty will not be discussed here.) This note considers some aspects of the implementation of footnotes in a galley-based design.
Footnotes and galleys
In the structure described in the introduction to FOP galleys, footnotes would be pre-processed as galleys themselves, but they would remain attached as subtrees to their points of invocation in the main text. Allocation to a footnote-reference-area would only occur in the resolution to Area nodes.
When footnotes are introduced, the communication between galleys and layout manager, as mentioned above, would be affected. The returned information would two b-p-d values: the primary line-area b-p-d impact and the footnote b-p-d impact. The distinction is necessary for two reasons; to alert the layout manager to the first footnote of the page, and because the footnote b-p-d will always impact the main-reference-area b-p-d, whereas the primary inline-area may not, e.g. in the case of multiple span-areas.
Multiple columns and footnotes
This note assumes a galley, as discussed elsewhere, flowing text with footnotes and possibly other blocks into a possibly multi-column area. The logic of flowing into multiple columns is trivially applied to a single column. The galley is manipulated within the context of the layout tree.
Associated with the galley are two sets of data. One contains the maps of all "natural" break-points and the of all hyphenation break-points. This set is constructed at the time of construction of the galley and is a constant for a given galley. The second contains dynamic data which represents one possible attempt to lay out the galley. There may be multiple sets of such data to reflect varying attempts. The data of this set are, essentially, representations of line-areas, with the supporting information necessary to determine these line-areas.
The line-area data includes the boundaries within the galley of each line-area, the boundaries of each column and the boundaries of the "page", or main area. When a line-area boundary occurs at a hyphenation point, a "virtual hyphen" is assumed and accounted for in the i-p-d. As mentioned, individual footnote galleys will hang from the parent galley. The associated data of the footnote galleys is similar: a once-only break-points map, and one or more line-area maps. No column boundaries are required, but a page boundary is required at the end of the last footnote or where a footnote breaks across a page boundary.
A number of b-p-d values are also maintained. For each
line-area, the b-p-d, the main area b-p-d increment, the
footnote b-p-d increment and the footnote's page-related
b-p-d increment are required. The main-area b-p-d
increments for any particular line-area are dependent on
the column position of the line-area. Total b-p-d's are
also kept: total footnote b-p-d, total main area b-p-d,
and totals for each column.
Figure 1 Columns before first footnote.
Figure 2 Adding a line area with first footnote.
Columns are balanced dynamically in the galley preliminary
layout. While the galley retains its basic linear
structure, the accompanying data structures accomplish
column distribution and balancing. As each line-area is
added, the columns are re-balanced. N.B.
This re-balancing involves only some of the dynamic data
associated with the participating galley(s). The data
structures associating breakpoints with the beginning and
end of individual line areas does not change in
re-balancing; only the association of line-area with column,
and, possibly, the various impact values for each line-area.
Figure 3 Adding a line area with next footnote.
Layout managers in the flow of control
by Peter B. West