aboutsummaryrefslogtreecommitdiff
path: root/font_api/registry.lua
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2018-07-16 10:18:08 +0200
committerPierre-Yves Rollo <dev@pyrollo.com>2018-07-16 10:18:08 +0200
commit4b02cfdfca95ec62c30f7f0fdd225df235aae1de (patch)
tree036fa9c9fe67e0ea0236038512be3f5e22e2c773 /font_api/registry.lua
parentfac6dfe1f896b9c8a59c6f0416759c3dc8d715ed (diff)
downloaddisplay_modpack-4b02cfdfca95ec62c30f7f0fdd225df235aae1de.tar.gz
display_modpack-4b02cfdfca95ec62c30f7f0fdd225df235aae1de.tar.bz2
display_modpack-4b02cfdfca95ec62c30f7f0fdd225df235aae1de.zip
Fix default font chosing when multiple fonts
Diffstat (limited to 'font_api/registry.lua')
-rw-r--r--font_api/registry.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/font_api/registry.lua b/font_api/registry.lua
index 62fbb52..4b49b1e 100644
--- a/font_api/registry.lua
+++ b/font_api/registry.lua
@@ -49,7 +49,17 @@ local function get_default_font()
end
end
- -- If failed, choose first font
+ -- If failed, choose first font without default = false
+ if default_font == nil then
+ for _, font in pairs(font_api.registered_fonts) do
+ if font.default then
+ default_font = font
+ break
+ end
+ end
+ end
+
+ -- If failed, chose first font
if default_font == nil then
for _, font in pairs(font_api.registered_fonts) do
default_font = font
@@ -112,6 +122,7 @@ end
-- If registering different sizes of the same font, add size in the font name
-- (e.g. times_10, times_12...).
-- @param def font definition. A associative array with following keys :
+-- @key default True (by default) if this font may be used as default font
-- @key height (mandatory) Height in pixels of all font textures
-- @key widths (mandatory) Array of character widths in pixels, indexed by
-- UTF codepoints