8 Pict Text Layout
import: pict/text | package: rhombus-pict-lib |
The text function from pict can draw text, but only in a fixed, given font. The pict/text library provides support for font configuration, nestable styles, and basic paragraph typesetting.
annotation | |
function | ||
|
Support for lists makes t suitable for use with @ notation, as in @t{Hello}.
> parameterize { current_font:
current_font() with (style = #'italic) }:
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
The current_font_to_tt and current_font_to_roman parameters determine how a font is adjusted to make it fixed-width or seriffed.
function | |
| |
function | |
|
> @t{x@superscript{2}}.scale(2)
function | ||||
|
> @strikethrough{wrong}.scale(2)
expression | |
| |
| |
expression | |
| |
| |
expression | |
| |
| |
expression | |
| |
| |
expression | |
| |
| |
expression | |
| |
| |
expression | |
| |
| |
expression | |
|
function | |||||
|
The rules for spacing and line breaks are designed to work naturally with @ notation, and so they treat strings and list nestings specially:
when a string does not start or end with a space, and when it is preceded or followed by a pict (not a string or list), then no space is added before or after the string’s rendering;
after deciding on spacing around a string, the string is split on space characters to obtain a list of strings to convert separately;
strings are converted to text using t, but first rewritten through the following conversions, unless decode is #false:
--- → — (em dash)
-- → – (en dash)
`` → “ (curly open quote)
'' → ” (curly close quote)
' → ’ (curly single close quote)
The width argument determines the maximum width of a line, and if full is true, then the resulting pict is padded to that width. The horiz argument controls both how multiple lines are aligned relative to one another and how padding is added when full is true. Lines are separated by current_line_sep() space.
> @para{Say ``hello'' for me!}
> @para(~width: 50){Say ``hello'' for me!}
> para(& for List (i in 0..50): @t{Echo}.scale((50 - i)/50))
> parameterize { current_font:
current_font() with (size = 18, kind = #'roman) }:
para(@{There's a fine line between fishing},
@{and just standing on the shore like an idiot.},
@{--- Stephen Wright})
function | |||||
| |||||
| |||||
function | |||||
|
> lines(
@para{Outline},
@item{Introduction},
@subitem{short version},
@subitem{long version},
@item{Conclusion}
)
function | ||
|
> @verbatim{
Say ``hello''
for me!
}
context parameter | |
|
context parameter | |
| |
| |
context parameter | |
|
context parameter | |
context parameter | |