Documentation
¶
Index ¶
Constants ¶
const LineHeight = 1.5
LineHeight is the height of a line, in ems.
Variables ¶
This section is empty.
Functions ¶
func DecodeEntities ¶
DecodeEntities turns Mermaid's `#35;` and `#quot;` codes, as Mermaid hides them, and HTML entities into characters.
Types ¶
type Label ¶
type Label struct {
Lines [][]Span
Widths []float64 // of each line
Width float64 // of the widest line
Height float64
Size float64
LineHeight float64
}
A Label is text laid out in lines to a width, measured.
func Layout ¶
Layout lays out a label as Pele's layoutLabel does: <br> and new lines break it, <b>, <strong>, <i> and <em> set emphasis, as do ** and _ in markdown, fa:fa-name is an icon, entities are decoded, and lines wider than MaxWidth wrap between words, and between any two Chinese or Japanese characters.
type Measurer ¶
A Measurer gives the advance width of text set in a face at a size, in the units the diagram is laid out in. Layout depends on it, so a diagram is drawn in the faces it was measured in.
var Arial Measurer = arial{}
Arial estimates widths from a table of Arial's advances, with no font at hand. Wide East Asian characters take an em, other characters past ASCII 0.58 of one, and monospaced text 0.6 of an em a character. Its widths are those of Pele's metricsMeasurer, to the last bit.
type Options ¶
type Options struct {
Measurer Measurer
Size float64
MaxWidth float64 // lines longer than this are wrapped; 0 is no limit
Face Face // of text with no emphasis of its own
Markdown bool // read **bold** and _italic_
// Icons reports whether the host can draw an icon by name. A label leaves room for an
// icon only where it can; with nil, it never does.
Icons func(name string) bool
// Bounded takes MaxWidth as it is even at 0 or below, as Pele's layoutLabel does: a width
// worked out to fit text in a box of a set size can come out at nothing or less.
Bounded bool
}
Options says how to lay out a label.