Creating text nodes#
What are nodes?#
Text data structure#
- Hierarchical structure
Text can be a nested structure. Think of
where you can consider the underlined part as a child of the emphasized part.
ul := NewText()
ul.Settings[]
ul.Items = append(ul.Items,"emphasized and underlined")
em := NewText()
em.Settings...
em.Items = append(em.Items, "this is ")
em.Items = append(em.Items, ul
Format a paragraph#
- font family needed
This breaks a paragraph into lines:
func (fe *Document) FormatParagraph(te *Text, hsize bag.ScaledPoint, opts ...TypesettingOption) (*node.VList, *ParagraphInfo, error)
hsize is the desired horizontal size.
format paragraph calls mknodes
which creates a list of nodes from a nested Text data structure.
Typesetting options#
The FormatParagraph()
method takes a typesetting options as the last argument.
Option | Description |
---|---|
Leading(leading bag.ScaledPoint) |
Set the vertical distance between two baselines |
Language(language *lang.Lang) |
Set the language used for hyphenation |
FontSize(size bag.ScaledPoint) |
Set the font size for the paragraph |
IndentLeft(size bag.ScaledPoint, rows int) |
Set the text indent |
HorizontalAlign(a HorizontalAlignment) |
Sets the horizontal alignment for a paragraph |