Hi All
Am hoping someone here can help me out of this hole I seem to have dug for myself. I have very little programming Fu these days but have found myself coding an Applescript to query a text file and discover used fonts and font attributes. My issue lies in that the TextEdit dictionary returns my fonts with their PostScript names and in my efforts to parlay that into a simple font family name I’ve ended up here in AppleScriptObjC land.
Within the larger context I’m trying to call a subroutine which simply returns the family name for a font of a given PostScript name as below:
tell application "TextEdit"
activate
open targetFile
if exists window 1 then
tell text of document 1
set paras to count paragraphs
repeat with i from 1 to paras
set myfontname to my fontfamily(font of paragraph i)
end repeat
end tell
close window 1
end if
end tell
on fontfamily(thefontname)
set myFont to NSFont's fontWithName_(thefontname)
return myFont's familyName
end fontfamily
What happens when I get to this though is the error “+[NSFont fontWithName:]: unrecognized selector sent to class 0x7fff7043b720”
Any thoughts on where I should be looking for the root cause of the problem and how I might overcome it. Needless to say, is driving me nuts.
Many thanks in advance
Andy