-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
d1318cb
commit 690bf57
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |