frontend module
The frontend module
Module functions and accessors.
Name | R/W | Parameters | Description |
---|---|---|---|
new() |
string (filename) | Create a new frontend document with the given filename. | |
new_text() |
- | Create a new text object | |
new_fontsource() |
Map (location, features) | Create a new font source with the given location and features. | |
get_language() |
string (name) | Get a language object for the given name. | |
new_table() |
- | Create a new table object | |
new_tr() |
- | Create a new table row object | |
new_td() |
- | Create a new table cell object | |
font_weight_400 |
- | The font weight for normal text | |
font_style_normal |
- | The font style for normal text |
Name | R/W | Parameters | Description |
---|---|---|---|
doc |
r | - | The backend document |
new_fontfamily() |
string (name) | Create a new font family with the given name. | |
build_table() |
Table object | Build a table from the given table object. The table is formatted and returned as a list of vlists. | |
format_paragraph() |
Map | Format a paragraph with the given parameters. Returns a vlist. |
The format_paragraph()
function takes a map with the following parameters:
Name | Type | Description |
---|---|---|
text |
Text object | The text to format. |
width |
scaled point | The width of the paragraph. |
leading |
scaled point | The leading of the paragraph. |
font_size |
scaled point | The font size of the paragraph. |
family |
Font family | The font family to use for the paragraph. |
The settings for the text object that is provided to format_paragraph()
in the text parameter are:
Name | Type | Description |
---|---|---|
color |
color object | The color of the text. |
fontfamily |
font family object | The font family to use for the text. |
halign |
string | The horizontal alignment of the text, one of left , right , center and justify . |
fontexpansion |
float | The font expansion factor. 1.00 is the default, increase slightly. |
fontweight |
int or string | The font weight, 400 is normal, 700 is bold. |
fontstyle |
string | The font style, one of normal , italic , oblique . |
hangingpunctuation |
bool | Set to true if you want hanging punctuation. |
Example:
f := frontend.new("out.pdf")
para.items = ["hello, nice world"]
para.settings["hangingpunctuation"] = true
para.settings["color"] = f.get_color("rebeccapurple")
vlist := f.format_paragraph({
text: para,
...
})