@@ -35,7 +35,10 @@ context = {
3535local function format_mapping (mapping )
3636 local codepoint_desc = " [" .. utils .format_codepoint (mapping .codepoint ) .. " ]"
3737 if mapping .glyph then
38- return " '" .. mapping .glyph .. " ' " .. codepoint_desc
38+ codepoint_desc = " '" .. mapping .glyph .. " ' " .. codepoint_desc
39+ end
40+ if mapping .smuflFontName then
41+ codepoint_desc = codepoint_desc .. " (" .. mapping .smuflFontName .. " )"
3942 end
4043 return codepoint_desc
4144end
@@ -84,11 +87,30 @@ local function set_codepoint(control, codepoint)
8487 control :SetText (fcstr )
8588end
8689
90+ local function on_smufl_popup (popup )
91+ local dialog = popup :GetParent ()
92+ local smufl_box = dialog :GetControl (" smufl_box" )
93+ local fcstr = finale .FCString ()
94+ popup :GetItemText (popup :GetSelectedItem (), fcstr )
95+ smufl_box :SetFont (finale .FCFontInfo (fcstr .LuaString , 24 ))
96+ end
97+
8798local function on_popup (popup )
8899 local legacy_codepoint = context .popup_keys [popup :GetSelectedItem () + 1 ] or 0
89100 local current_mapping = legacy_codepoint > 0 and context .current_mapping [legacy_codepoint ]
90101 local smufl_codepoint = current_mapping and current_mapping .codepoint or 0
91102 local dialog = popup :GetParent ()
103+ if current_mapping and current_mapping .smuflFontName then
104+ local smufl_list = dialog :GetControl (" smufl_list" )
105+ for index = 0 , smufl_list :GetCount () - 1 do
106+ local str = finale .FCString ()
107+ smufl_list :GetItemText (index , str )
108+ if str .LuaString == current_mapping .smuflFontName then
109+ smufl_list :SetSelectedItem (index )
110+ on_smufl_popup (smufl_list )
111+ end
112+ end
113+ end
92114 set_codepoint (dialog :GetControl (" legacy_box" ), legacy_codepoint )
93115 set_codepoint (dialog :GetControl (" smufl_box" ), smufl_codepoint )
94116end
@@ -164,6 +186,7 @@ local function on_select_file(control)
164186 t .glyph = glyph
165187 t .codepoint = utils .parse_codepoint (v .codepoint )
166188 t .nameIsMakeMusic = v .nameIsMakeMusic
189+ t .smuflFontName = v .smuflFontName
167190 if t .codepoint == 0xFFFD then
168191 local smufl_box = dialog :GetControl (" smufl_box" )
169192 local _ , info = smufl_glyphs .get_glyph_info (glyph , smufl_box :CreateFontInfo ())
@@ -200,14 +223,6 @@ local function on_symbol_select(box)
200223 enable_disable (dialog )
201224end
202225
203- local function on_smufl_popup (popup )
204- local dialog = popup :GetParent ()
205- local smufl_box = dialog :GetControl (" smufl_box" )
206- local fcstr = finale .FCString ()
207- popup :GetItemText (popup :GetSelectedItem (), fcstr )
208- smufl_box :SetFont (finale .FCFontInfo (fcstr .LuaString , 24 ))
209- end
210-
211226local function on_add_mapping (control )
212227 local dialog = control :GetParent ()
213228 local popup = dialog :GetControl (" mappings" )
@@ -221,13 +236,17 @@ local function on_add_mapping(control)
221236 return
222237 end
223238 end
239+ local font = dialog :GetControl (" smufl_box" ):CreateFontInfo ()
224240 current_mapping = {codepoint = smufl_point }
225- local glyph , info = smufl_glyphs .get_glyph_info (smufl_point , dialog : GetControl ( " smufl_box " ): CreateFontInfo () )
241+ local glyph , info = smufl_glyphs .get_glyph_info (smufl_point , font )
226242 if info then
227243 current_mapping .glyph = glyph
228244 else
229245 current_mapping .glyph = utils .format_codepoint (smufl_point )
230246 end
247+ if font and smufl_point >= 0xF400 and smufl_point <= 0xF8FF then
248+ current_mapping .smuflFontName = font .Name
249+ end
231250 context .current_mapping [legacy_point ] = current_mapping
232251 update_popup (popup , legacy_point )
233252end
@@ -264,6 +283,9 @@ local function emit_json(mapping, reverse_lookup)
264283 else
265284 table.insert (parts , ' \t\t "description": ' .. quote (" " ))
266285 end
286+ if entry .smuflFontName then
287+ table.insert (parts , ' \t\t "smuflFontName": ' .. quote (entry .smuflFontName ))
288+ end
267289 return " {\n " .. table.concat (parts , " ,\n " ) .. " \n\t }"
268290 end
269291
0 commit comments