Documentation
¶
Overview ¶
Package page lays out the page of a workbook: where each item of a task on a workbook stands, its number, the texts of its line and its boxes, in whole units of the page, from the items alone, by the numbers and the table of widths of format/page.yaml. A box so stands where it stands on every device, whatever its fonts: the canvas fits each text to the width the layout gives it.
Lay gives the Layout of a task's items, each a line of Pieces — a text, or a box —, or NoRoom, the item at whose row the page has no room. TextWidth gives the width of a text as the layout sets it on one line, and Fits whether a value written in a box is no wider than the box, Numbers' BoxWidth. The test vectors of the page, format/vectors/pages/, pin every place, and internal/vectors passes them all.
The check of a module holds task.workbook-page by it, and lesson.workbook-page, whose values fit their boxes by Fits; canvas lays its pages out by the same numbers, from the npm package of spec. The package holds a copy of page.yaml, byte for byte that of spec.Format at the tag go.mod requires, and does not import spec itself: a consumer of the library carries the one file, not every file of the format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fits ¶
Fits says whether a value written in a box fits the box: as a text of the line, it is no wider than the numbers' BoxWidth, as lesson.workbook-page holds the value of each box of a worked example.
func MostItems ¶
func MostItems() int
MostItems gives the most items that a page holds, most_items of page.yaml: the item after them has no room.
func Numbers ¶
func Numbers() formatv0.PageNumbers
Numbers gives the numbers of the layout, numbers of page.yaml, in units of the page: the type size, the width and the height of a box, and the rest.
func TextWidth ¶
TextWidth gives the width, in units of the page, of a text as the layout sets it on one line, as one piece of a line: its words, cut at the runs of the white space that breaks, joined by single spaces, size × (the sum of their widths + the space × the spaces between them) ÷ 100, rounded up. A text of white space alone, or none, is 0 wide.
Types ¶
type Item ¶
Item is an item on the page: its number, n., right in the column of the numbers on the baseline of its first line, and the texts and boxes of its line, in the order they are read.
type Layout ¶
Layout is the page of a task's items: each item on it, in the task's order, and Bottom, the bottom of the last row. A task of no items has none, and its bottom is the margin, where the first row would start.
func Lay ¶
Lay lays out the items of a task on a workbook, each its line of pieces, on the page by page.yaml. Rows start at the margin, each the gap of items below the one before: two short items side by side, in the two columns, and a short item before a long one, or before none, alone at the left; a long item across the page, its lines filled greedily, run by run. When a row would pass the lowest unit, or an item comes after the most_items of page.yaml, it gives a *NoRoom with the first item of that row, and nothing ever shrinks.
type NoRoom ¶
type NoRoom struct {
Item int
}
NoRoom is what Lay gives when the page has no room: Item, counted from 0, is the first item of the row that has none, at which the page is refused (task.workbook-page) — or the first item after the most_items of page.yaml, which has none either.
type Part ¶
type Part struct {
Box bool
Text string
Left int64
Baseline int64
Width int64
Top int64
Height int64
}
Part is a part of an item's line on the page: a text, as a Text, or, when Box is set, a box, from Left and Top, Width wide and Height high. The fields of the other kind are 0, and a box has no Text.