Skip to content

Commit

Permalink
Create fonts.lua
Browse files Browse the repository at this point in the history
Creating a font file in the project, so that all fonts from all languages can be added will be of good use to some project managers
  • Loading branch information
bicatcho11 authored Dec 27, 2023
1 parent d1318cb commit 690bf57
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions fonts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function RegisterCustomFont(dict, name, lang)
if not Config.FontList[name] then
Config.FontList[name] = { dict = dict, name = name, lang = lang or 'en', id = nil }
end

if not Config.FontList[name].id then
RegisterFontFile(dict)
Config.FontList[name].id = RegisterFontId(name)
end

return Config.FontList[name].id
end

exports('RegisterCustomFont', RegisterCustomFont)

function GetCustomFontId(name)
return Config.FontList[name] and Config.FontList[name].id or nil
end

exports('GetCustomFontId', GetCustomFontId)

function GetAvailableFonts()
return Config.FontList
end

exports('GetAvailableFonts', GetAvailableFonts)

CreateThread(function()
for _, font in pairs(Config.FontList) do
RegisterCustomFont(font.dict, font.name, font.lang)
end
end)

0 comments on commit 690bf57

Please sign in to comment.