I can, but it will be much easier to replace existed font resource.
For now it worked like that
--replace font
--game font is same name i used for my current font
go.set(msg.url(self.target_gui), "fonts", COMMON.LOCALIZATION.font_all, { key = "game_font" })
--nodes still use old font. So i need send message to gui
msg.post(self.target_gui, "font_changed")
--replace font for all nodes that used localization strings
--it is easy to forgot some nodes(
--also it will be better replace this old font with new for every text node to reduce draw calls, but i replace only part of nodes.
function Script:on_message(message_id, message, sender)
if message_id == COMMON.HASHES.hash("font_changed") then
self.game_font_all = hash("game_font")
GUI.replace_font(self.game_font_all, {
self.views.title_lbl.node,
self.views.music_lbl.node,
self.views.sound_lbl.node,
self.views.shadows_lbl.node,
})
--changing font is not enought. I need to change text. If i don't change text it not worked(use old font)
self:on_language_changed()
end
end
Change nodes text. Font will use new font only after changing text.
function Script:on_language_changed()
local locale = COMMON.LOCALIZATION:locale_get()
gui.set_enabled(self.views.flags.en.vh.selected, true) --fallback to en
for k, flag in pairs(self.views.flags) do
gui.set_enabled(flag.vh.selected, locale == flag.language)
end
self.views.title_lbl:set_text(COMMON.LOCALIZATION:translate("settings_title"))
self.views.music_lbl:set_text(COMMON.LOCALIZATION:translate("settings_music"))
self.views.sound_lbl:set_text(COMMON.LOCALIZATION:translate("settings_sound"))
self.views.shadows_lbl:set_text(COMMON.LOCALIZATION:translate("settings_shadow"))
end