@@ -3317,6 +3317,10 @@ package.preload["library.client"] = package.preload["library.client"] or functio
33173317 luaosutils = {
33183318 test = finenv .EmbeddedLuaOSUtils ,
33193319 error = requires_later_plugin_version (" the embedded luaosutils library" )
3320+ },
3321+ cjson = {
3322+ test = client .get_lua_plugin_version () >= 0.67 ,
3323+ error = requires_plugin_version (" 0.67" , " the embedded cjson library" ),
33203324 }
33213325 }
33223326
@@ -3607,20 +3611,44 @@ package.preload["library.general_library"] = package.preload["library.general_li
36073611 return font_names
36083612 end
36093613
3610- function library .get_smufl_metadata_file (font_info )
3611- if not font_info then
3612- font_info = finale .FCFontInfo ()
3613- font_info :LoadFontPrefs (finale .FONTPREF_MUSIC )
3614+ function library .get_smufl_metadata_file (font_info_or_name )
3615+ local font_name
3616+ if type (font_info_or_name ) == " string" then
3617+ font_name = font_info_or_name
3618+ else
3619+ if not font_info_or_name then
3620+ font_info_or_name = finale .FCFontInfo ()
3621+ font_info_or_name :LoadFontPrefs (finale .FONTPREF_MUSIC )
3622+ end
3623+ font_name = font_info_or_name .Name
36143624 end
3615- local try_prefix = function (prefix , font_info )
3616- local file_path = prefix .. font_info . Name .. " /" .. font_info . Name .. " .json"
3625+ local try_prefix = function (prefix )
3626+ local file_path = prefix .. font_name .. " /" .. font_name .. " .json"
36173627 return io.open (file_path , " r" )
36183628 end
3619- local user_file = try_prefix (calc_smufl_directory (true ), font_info )
3629+ local user_file = try_prefix (calc_smufl_directory (true ))
36203630 if user_file then
36213631 return user_file
36223632 end
3623- return try_prefix (calc_smufl_directory (false ), font_info )
3633+ return try_prefix (calc_smufl_directory (false ))
3634+ end
3635+
3636+ function library .get_smufl_metadata_table (font_info_or_name , subkey )
3637+ if not client .assert_supports (" cjson" ) then
3638+ return
3639+ end
3640+ local cjson = require (" cjson" )
3641+ local json_file = library .get_smufl_metadata_file (font_info_or_name )
3642+ if not json_file then
3643+ return nil
3644+ end
3645+ local contents = json_file :read (" *a" )
3646+ json_file :close ()
3647+ local json_table = cjson .decode (contents )
3648+ if json_table and subkey then
3649+ return json_table [subkey ]
3650+ end
3651+ return json_table
36243652 end
36253653
36263654 function library .is_font_smufl_font (font_info )
@@ -3685,7 +3713,9 @@ package.preload["library.general_library"] = package.preload["library.general_li
36853713
36863714 function library .get_parent_class (classname )
36873715 local class = finale [classname ]
3688- if type (class ) ~= " table" then return nil end
3716+ if type (class ) ~= " table" then
3717+ return nil
3718+ end
36893719 if not finenv .IsRGPLua then
36903720 local classt = class .__class
36913721 if classt and classname ~= " __FCBase" then
@@ -4111,6 +4141,14 @@ package.preload["library.utils"] = package.preload["library.utils"] or function(
41114141 end
41124142 end )
41134143 end
4144+
4145+ function utils .parse_codepoint (codepoint_string )
4146+ return tonumber (codepoint_string :match (" U%+(%x+)" ), 16 )
4147+ end
4148+
4149+ function utils .format_codepoint (codepoint )
4150+ return string.format (" U+%04X" , codepoint )
4151+ end
41144152 return utils
41154153end
41164154package.preload [" library.localization" ] = package.preload [" library.localization" ] or function ()
0 commit comments