aboutsummaryrefslogtreecommitdiff
path: root/font_api/API.md
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2018-12-05 15:41:56 +0100
committerPierre-Yves Rollo <dev@pyrollo.com>2018-12-05 15:41:56 +0100
commitf46dd0a72ecf04937cef661a2e599ffb71417ba7 (patch)
tree2df7a24a7c85f3a090e08e270078e445310c159d /font_api/API.md
parentb71d5a8f01e068f4a99520674eafce04af7626ea (diff)
downloaddisplay_modpack_no_craft-f46dd0a72ecf04937cef661a2e599ffb71417ba7.tar.gz
display_modpack_no_craft-f46dd0a72ecf04937cef661a2e599ffb71417ba7.zip
New Font:render method
Diffstat (limited to 'font_api/API.md')
-rw-r--r--font_api/API.md44
1 files changed, 30 insertions, 14 deletions
diff --git a/font_api/API.md b/font_api/API.md
index 6c14ac4..f3f4437 100644
--- a/font_api/API.md
+++ b/font_api/API.md
@@ -37,7 +37,7 @@ minetest.register_node("mymod:test_text_node", {
})
```
-At this step, your node already displays text form "display_text" (hardcoded) node meta.
+At this step, your node already displays text form "display_text" (by default) node meta. If you want to store your text into another meta data field, add a `meta_text` field to display entity definition.
But it uses defaults (default font, default size, default color). Likely you need something more.
@@ -59,6 +59,28 @@ Then specify the char width. Two methods available:
* `halign`: Horizontal alignment: "left", "center" or "right" (default "center").
* `valign`: Vertical alignement: "top", "middle" or "bottom" (default "middle").
+### Example
+Using blue //botic// font, three lines height, aligned top left. Text stored in "text" node meta.
+```
+minetest.register_node("mymod:test_text_node", {
+ ...
+ ...
+ display_entities = {
+ ["mymod:text"] = {
+ depth = -0.5 - display_api.entity_spacing,
+ on_display_update = font_api.on_display_update
+ meta_text = "text",
+ font_name = "botic",
+ color = "#0000FF",
+ maxlines = 3,
+ aspect_ratio = 0.5,
+ halign = "left",
+ valign = "top",
+ },
+ }
+ ...
+})
+```
## Provided methods
### font_api.get_default_font_name()
Returns de default font name.
@@ -159,19 +181,13 @@ Returns line(s) height. Takes care of top and bottom margins and line spacing.
Returns the width of a text line. Beware, if line contains any new line char, they are ignored.
* `line`: Line of text which the width will be computed.
-### font:make_line_texture(line, texturew, x, y)
-Create a texture for a text line.
- * `line`: Line of text to be rendered in texture.
- * `texturew`: Width of the texture (extra text is not rendered).
- * `x`: Starting x position in texture.
- * `y`: Vertical position of the line in texture.
-
-### font:make_text_texture(text, texturew, textureh, maxlines, halign, valign, color)
+### font:renter(text, texturew, textureh, style)
Builds texture for a multiline colored text.
* `text`: Text to be rendered.
* `texturew`: Width of the texture (extra text will be truncated).
- * `textureh`: Height of the texture.
- * `maxlines`: Maximum number of lines.
- * `halign`: Horizontal text align ("left"/"center"/"right") (optional).
- * `valign`: Vertical text align ("top"/"center"/"bottom") (optional).
- * `color`: Color of the text (optional).
+ * `textureh`: Height of the texture (extra text will be truncated).
+ * `style`: A table with style indications:
+ - `lines` or `maxlines`: Maximum number of lines (default none).
+ - `halign`: Horizontal text align: "left"/"center"/"right" (default "center")
+ - `valign`: Vertical text align: "top"/"middle"/"bottom" (default "middle")
+ - `color`: Color of the text (default black)