diff --git a/CorsixTH/Lua/dialogs/jukebox.lua b/CorsixTH/Lua/dialogs/jukebox.lua index 3354c58bd4..62cc601c2a 100644 --- a/CorsixTH/Lua/dialogs/jukebox.lua +++ b/CorsixTH/Lua/dialogs/jukebox.lua @@ -21,6 +21,8 @@ SOFTWARE. --]] local ipairs = ipairs +local TH = require("TH") + class "UIJukebox" (Window) ---@type UIJukebox @@ -41,13 +43,14 @@ function UIJukebox:UIJukebox(app) self.blue_font = app.gfx:loadFont("QData", "Font02V") if TH.freetype_font then + -- Temporarily set the complete path to the font for debugging local font_data = self.app.gfx:_loadFontData("/usr/share/fonts/truetype/material-design-icons-iconfont/MaterialIcons-Regular.ttf") - + if not font_data then error("Can't load the Material Icons font!") end -- Boldly copied from app.lua, lines 197..200, but it makes little sense to me. - local builtin_font = self.gfx:loadBuiltinFont() - self.materials = Graphics._constructTtfFont(font_data, builtin_font:getSheet()) + local builtin_font = app.gfx:loadBuiltinFont() + self.materials = app.gfx:_constructTtfFont(font_data, builtin_font:getSheet()) else - print("no font available") + error("Can't load this UI, Freetype2 missing") end -- Dialog head (current track title & exit button) @@ -168,6 +171,9 @@ function UIJukebox:draw(canvas, x, y) end Window.draw(self, canvas, x, y) x, y = self.x + x, self.y + y + -- draw a material icon character in the top corner of the window + -- Currently using "Link" icon + self.materials:draw(canvas, "\u{e157}", x + 10, y + 10) local playing = self.audio.background_music or "" for i, info in ipairs(self.audio.background_playlist) do diff --git a/CorsixTH/Lua/graphics.lua b/CorsixTH/Lua/graphics.lua index 1f8db69e7f..d89ead0dad 100644 --- a/CorsixTH/Lua/graphics.lua +++ b/CorsixTH/Lua/graphics.lua @@ -169,7 +169,7 @@ function Graphics:loadFontFile() end -- Adjust unicode font in the configuration if needed. - if self.ttf_font_data and self.app.config.unicode_font ~= loaded_font_file then + if self.ttf_font_data and self.app.config.unicode_font ~= loaded_font_path then self.app.config.unicode_font = loaded_font_file self.app:saveConfig() end @@ -429,7 +429,8 @@ function Graphics:loadLanguageFont(name, sprite_table, ...) local cache = self.cache.language_fonts[name] font = cache and cache[sprite_table] if not font then - font = Graphics.lf:_constructTtfFont(self.ttf_font_data, sprite_table) + + font = Graphics:_constructTtfFont(self.ttf_font_data, sprite_table) self.reload_functions_last[font] = font_reloader if not cache then @@ -443,11 +444,16 @@ function Graphics:loadLanguageFont(name, sprite_table, ...) return font end -function Graphics._constructTtfFont(font_data, sprite_table) +-- Prepare a TTF font for use in the UI +-- font_data is the loaded font file +-- sprite_table gives the structural layout, but isn't actually used for TTF so we use +-- builtin_font instead +function Graphics:_constructTtfFont(font_data, sprite_table, direct_load) local font = TH.freetype_font() -- TODO: Choose face based on "name" rather than always using same face. - font:setFace(self.ttf_font_data) + font:setFace(font_data) font:setSheet(sprite_table) + -- Not sure if self.load_info or something similar is needed for persistence return font end