[JW Lua] Number of fonts limited to 256 ?

Jan Angermüller jan at angermueller.com
Tue Dec 29 12:01:22 CET 2015


Jari,

do you know if there is a limit in the number of different fonts used in 
a Finale document ?
The code snippet at the very bottom tries to create an FCString for each 
font installed on the system and returns its internal font ID. But after 
the internal font ID 255 has been used, it only returns 0 for each new font.

If this happens for example in a text expression or a page text block 
assignment, all elements with the font ID 0 get the same font (!), no 
matter what font I explicitly gave them.
Could it be that this is a bug in JW Lua (use of byte instead of word 
?), as Finale also supports internal font IDs above 255 (I think at 
least until 65536).
For example, FCFontInfo:SetNameByID() takes a twobyte value and 
FCFontPrefs:Load(...) also supports values above 255. So I think it's 
either a JW Lua or a Finale PDK problem.

I also tried to implement a workaround in the code by explicitly calling 
FCFontInfo:SetNameByID(...) with a value above 255, but it didn't work.

Jan

local fonts=finale.FCStrings()
fonts:LoadSystemFontNames()
local counter=300
for f in each(fonts) do
     local text=finale.FCString()
     text.LuaString="^font("..f.LuaString..")^size(24)^nfx(0)a"
     local fontinfo=text:CreateLastFontInfo()
     --fontinfo:SetNameByID(counter)   -->workaround, but that didn't 
work with values above 255
     print(text.LuaString,fontinfo:GetNameByID())
     counter=counter+1
end

Prints:
...
^font(Gentium Basic)^size(24)^nfx(0)a 252
^font(Gentium Book Basic)^size(24)^nfx(0)a 253
^font(DejaVu Sans)^size(24)^nfx(0)a 254
^font(DejaVu Sans Mono)^size(24)^nfx(0)a 255
^font(DejaVu Serif Condensed)^size(24)^nfx(0)a 0      --> from now on it 
only returns 0
^font(DejaVu Serif)^size(24)^nfx(0)a 0
^font(DejaVu Sans Light)^size(24)^nfx(0)a 0
...





More information about the JWLua mailing list