aboutsummaryrefslogtreecommitdiff
path: root/font_api/init.lua
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2018-12-05 11:42:36 +0100
committerPierre-Yves Rollo <dev@pyrollo.com>2018-12-05 11:42:36 +0100
commitb71d5a8f01e068f4a99520674eafce04af7626ea (patch)
tree9e312e25d3c473241224f7792ea1deee80350d2b /font_api/init.lua
parenta3e0d36a68247cac40349d9089fe3c71546d75e8 (diff)
downloaddisplay_modpack_no_craft-b71d5a8f01e068f4a99520674eafce04af7626ea.tar.gz
display_modpack_no_craft-b71d5a8f01e068f4a99520674eafce04af7626ea.zip
Fixed width fonts specific management
Diffstat (limited to 'font_api/init.lua')
-rw-r--r--font_api/init.lua27
1 files changed, 22 insertions, 5 deletions
diff --git a/font_api/init.lua b/font_api/init.lua
index 27cba99..57a3f44 100644
--- a/font_api/init.lua
+++ b/font_api/init.lua
@@ -48,13 +48,30 @@ function font_api.on_display_update(pos, objref)
local font = font_api.get_font(meta:get_string("font") ~= ""
and meta:get_string("font") or def.font_name)
- local maxlines = def.maxlines or 1 -- TODO:How to do w/o maxlines ?
+ -- Compute entity resolution accroding to given attributes
+ local texturew, textureh
+ textureh = font:get_height(def.lines or def.maxlines or 1)
+
+ if def.columns then
+ if font.fixedwidth then
+ texturew = def.columns * font.fixedwidth
+ if def.aspect_ratio then
+ minetest.log('warning', "[font_api] 'aspect_ratio' ignored because 'columns' is specified")
+ end
+ else
+ minetest.log('warning', "[font_api] 'columns' ignored because '"..font.name.."' is not a fixed width font.")
+ end
+ end
+
+ if not texturew then
+ if not def.aspect_ratio then
+ minetest.log('warning', "[font_api] No 'aspect_ratio' specified, using default 1.")
+ end
+ texturew = textureh * def.size.x / def.size.y / (def.aspect_ratio or 1)
+ end
objref:set_properties({
- textures={font:make_text_texture(text,
- font:get_height(maxlines) * def.size.x / def.size.y
- / (def.aspect_ratio or 1),
- font:get_height(maxlines),
+ textures={font:make_text_texture(text, texturew, textureh,
def.maxlines, def.halign, def.valign, def.color)},
visual_size = def.size
})