forked from finale-lua/lua-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs_reset_staff_full_name_fonts.lua
55 lines (52 loc) · 2.21 KB
/
prefs_reset_staff_full_name_fonts.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function plugindef()
finaleplugin.Author = "Robert Patterson"
finaleplugin.Copyright = "CC0 https://creativecommons.org/publicdomain/zero/1.0/"
finaleplugin.Version = "1.0.2"
finaleplugin.Date = "June 12, 2020"
finaleplugin.CategoryTags = "Staff"
finaleplugin.Notes = [[
This script only affects selected staves.
If you select the entire document before running this script, it modifies any
full staff names found in staff styles as well.
]]
return "Reset Full Staff Name Fonts", "Reset Full Staff Name Fonts",
"Reset all full staff names to document's default font settings."
end
local library = require("library.general_library")
local enigma_string = require("library.enigma_string")
function prefs_reset_staff_full_name_fonts()
local sel_region = library.get_selected_region_or_whole_doc()
local font_info = finale.FCFontInfo()
font_info:LoadFontPrefs(finale.FONTPREF_STAFFNAME)
local sys_staves = finale.FCSystemStaves()
sys_staves:LoadAllForRegion(sel_region)
for sys_staff in each(sys_staves) do
local staff = finale.FCStaff()
staff:Load(sys_staff:GetStaff())
local staff_name_id = staff:GetFullNameID()
if 0 ~= staff_name_id then
local text_block = finale.FCTextBlock()
if text_block:Load(staff_name_id) then
if enigma_string.change_first_text_block_font(text_block, font_info) then
text_block:Save()
end
end
end
end
-- duplicate patterson plugin functionality which updates staff styles if the entire document is selected
if sel_region:IsFullDocumentSpan() then
local staff_styles = finale.FCStaffStyleDefs()
staff_styles:LoadAll()
for staff_style in each(staff_styles) do
if staff_style.UseFullName then
local text_block = finale.FCTextBlock()
if text_block:Load(staff_style:GetFullNameID()) then
if enigma_string.change_first_text_block_font(text_block, font_info) then
text_block:Save()
end
end
end
end
end
end
prefs_reset_staff_full_name_fonts()