Module Hugin_text.Text
Rich text.
A text is a sequence of Unicode characters, each with a style: bold or not, italic or not, a size factor, a baseline shift and an optional colour. Layout sets a text in a list of faces at a size as the glyph runs (Hugin_font.Run) that draw it, and measures them.
Texts and layouts are immutable, every function is pure, and values may be shared between domains.
Texts
type tThe type for texts.
v s is the characters of the UTF-8 string s, neither bold nor italic, with size factor 1., shift 0. and no colour. Each maximal invalid subpart of s, as String.get_utf_8_uchar decodes it, becomes U+FFFD. Newlines end lines (Lines).
concat ts is the characters of ts in order, each with its style. concat [] is v "".
Styles
A character of size factor k and shift d in a text set at size s is set at size k *. s with its baseline d *. s below the line's, above it if d is negative.
Each combinator restyles every character of its argument and keeps what an inner combinator set: in color c (concat [ a; color c' b ]) the characters of b keep c'.
scale s t is t with every size factor and shift multiplied by s.
Raises Invalid_argument if s is not finite and positive.
val color : Hugin_gg.Color.t -> t -> tcolor c t is t with the colour c on every character that has none.
sup t is t as a superscript: every size factor k and shift d become 0.7 *. k and 0.7 *. d -. 0.4.
sub t is t as a subscript: every size factor k and shift d become 0.7 *. k and 0.7 *. d +. 0.2.
Comparing and formatting
equal t t' is true iff t and t' have the same characters with the same styles, size factors and shifts compared by Float.equal and colours by Hugin_gg.Color.equal.
pp ppf t formats t for debugging, in spans of one style.