mirror of
https://github.com/pyrollo/display_modpack.git
synced 2025-01-10 09:00:17 +01:00
Document getglyph
& note about formspec escaping
This commit is contained in:
parent
2e5d006e70
commit
bc3b50331e
@ -105,6 +105,7 @@ Font definition table used by **font_api.register_font** and **font\_api.Font:ne
|
|||||||
* `margintop` (optional): Margin (in texture pixels) added on top of each char texture.
|
* `margintop` (optional): Margin (in texture pixels) added on top of each char texture.
|
||||||
* `marginbottom` (optional): Margin (in texture pixels) added at bottom of each char texture.
|
* `marginbottom` (optional): Margin (in texture pixels) added at bottom of each char texture.
|
||||||
* `linespacing` (optional): Spacing (in texture pixels) between each lines.
|
* `linespacing` (optional): Spacing (in texture pixels) between each lines.
|
||||||
|
* `getglyph` (optional, advanced usage): Function that takes a Unicode codepoint (number) and returns a custom texture string for the glyph instead of the default `font_{name}_{codepoint}.png` (see *Additional Requirements* below). The texture string can contain filters like `^[sheet` and will be properly escaped when combined.
|
||||||
|
|
||||||
`margintop`, `marginbottom` and `linespacing` can be negative numbers (default 0) and are to be used to adjust various font styles to each other.
|
`margintop`, `marginbottom` and `linespacing` can be negative numbers (default 0) and are to be used to adjust various font styles to each other.
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ Font attributes effects on several lines:\
|
|||||||
|
|
||||||
Font must have a char 0 which will be used to display any unknown char.
|
Font must have a char 0 which will be used to display any unknown char.
|
||||||
|
|
||||||
All textures corresponding to the indexes in widths array should be present in textures directory with a name matching the pattern :
|
All textures corresponding to the indexes in widths array should be present in textures directory with a name matching the pattern (unless using a custom `getglyph` function):
|
||||||
|
|
||||||
> font\_**{font_name}**_**{utf_code}**.png
|
> font\_**{font_name}**_**{utf_code}**.png
|
||||||
|
|
||||||
@ -189,7 +190,7 @@ 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.
|
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.
|
* `line`: Line of text which the width will be computed.
|
||||||
|
|
||||||
### font:renter(text, texturew, textureh, style)
|
### font:render(text, texturew, textureh, style)
|
||||||
Builds texture for a multiline colored text.
|
Builds texture for a multiline colored text.
|
||||||
* `text`: Text to be rendered.
|
* `text`: Text to be rendered.
|
||||||
* `texturew`: Width of the texture (extra text will be truncated).
|
* `texturew`: Width of the texture (extra text will be truncated).
|
||||||
@ -199,3 +200,5 @@ Builds texture for a multiline colored text.
|
|||||||
- `halign`: Horizontal text align: "left"/"center"/"right" (default "center")
|
- `halign`: Horizontal text align: "left"/"center"/"right" (default "center")
|
||||||
- `valign`: Vertical text align: "top"/"middle"/"bottom" (default "middle")
|
- `valign`: Vertical text align: "top"/"middle"/"bottom" (default "middle")
|
||||||
- `color`: Color of the text (default black)
|
- `color`: Color of the text (default black)
|
||||||
|
|
||||||
|
Note: When used in formspec, be sure to **escape** the texture string with `minetest.formspec_escape`.
|
||||||
|
@ -201,6 +201,9 @@ function Font:make_text_texture(text, texturew, textureh, maxlines,
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Render text with the font in a view
|
--- Render text with the font in a view
|
||||||
|
-- Note: When used in formspec, be sure to escape the texture string with
|
||||||
|
-- `minetest.formspec_escape`.
|
||||||
|
--
|
||||||
-- @param text Text to be rendered
|
-- @param text Text to be rendered
|
||||||
-- @param texturew Width (in pixels) of the texture (extra text will be truncated)
|
-- @param texturew Width (in pixels) of the texture (extra text will be truncated)
|
||||||
-- @param textureh Height (in pixels) of the texture (extra text will be truncated)
|
-- @param textureh Height (in pixels) of the texture (extra text will be truncated)
|
||||||
|
@ -127,8 +127,14 @@ end
|
|||||||
-- UTF codepoints
|
-- UTF codepoints
|
||||||
-- @key margintop (optional) Margin (in texture pixels) added on top of each
|
-- @key margintop (optional) Margin (in texture pixels) added on top of each
|
||||||
-- char texture.
|
-- char texture.
|
||||||
-- @key marginbottom (optional) dded at bottom of each char texture.
|
-- @key marginbottom (optional) Margin (in texture pixels) added at bottom of
|
||||||
|
-- each char texture.
|
||||||
-- @key linespacing (optional) Spacing (in texture pixels) between each lines.
|
-- @key linespacing (optional) Spacing (in texture pixels) between each lines.
|
||||||
|
-- @key getglyph (optional, advanced usage) Function that takes a Unicode
|
||||||
|
-- codepoint (number) and returns a custom texture string for the glyph instead
|
||||||
|
-- of the default `font_{name}_{codepoint}.png`. The texture string can contain
|
||||||
|
-- filters like `^[sheet` and will be properly escaped when combined.
|
||||||
|
--
|
||||||
-- margintop, marginbottom and linespacing can be negative numbers (default 0)
|
-- margintop, marginbottom and linespacing can be negative numbers (default 0)
|
||||||
-- and are to be used to adjust various font styles to each other.
|
-- and are to be used to adjust various font styles to each other.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user