aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--font_api/init.lua3
-rw-r--r--font_api/registry.lua13
-rw-r--r--font_metro/init.lua1
3 files changed, 15 insertions, 2 deletions
diff --git a/font_api/init.lua b/font_api/init.lua
index 06619be..dc3a3e0 100644
--- a/font_api/init.lua
+++ b/font_api/init.lua
@@ -44,7 +44,8 @@ function font_api.on_display_update(pos, objref)
if entity and ndef.display_entities[entity.name] then
local def = ndef.display_entities[entity.name]
- local font = font_api.get_font(meta:get_string("font") or def.font_name)
+ 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 ?
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
diff --git a/font_metro/init.lua b/font_metro/init.lua
index 22d8c71..ec9a918 100644
--- a/font_metro/init.lua
+++ b/font_metro/init.lua
@@ -14,6 +14,7 @@
font_api.register_font(
'metro',
{
+ default = true,
margintop = 3,
linespacing = -2,
height = 15,