For a macOS software that works with fonts on the bash shell I need information about the installed fonts. To get the font information I use
system_profiler SPFontsDataType
This works fine on an English macOS. However when run on a German macOS it outputs everything in English, except the font style. And for compatibility I also need the font style in English.
Example German macOS:
Full Name: Times New Roman Fett
Family: Times New Roman
Style: Fett
Example English macOS:
Full Name: Times New Roman Bold
Family: Times New Roman
Style: Bold
I tried to set to change AppleLanguages in the defaults for system_profiler, but it didn't work. The output was still in German:
defaults write com.apple.systemprofiler AppleLanguages '("en-US","de-DE")'
defaults write com.apple.systemprofiler AppleLanguages -array "en-US" "de-DE"
However when I temporarily set the NSGlobalDomain to English it worked:
tempvalues=$(defaults read NSGlobalDomain AppleLanguages)
defaults write NSGlobalDomain AppleLanguages -array "en-US"
system_profiler SPFontsDataType
defaults write NSGlobalDomain AppleLanguages "$tempvalues"
But isn't there a better approach than changing the NSGlobalDomain? Calling system_profiler takes a few seconds, so it might affect other programs too.
From the fonts I need: the full name, family, style, file name and location (=full path), version, copy protected field, embeddable field. All this info is available in SPFontsDataType.
system_profiler -json SPFontsDataType > xx.json
different ? (egrep '^ *"path"' xx.json | sort
gives only the paths.) Also, what are the two macOS versions ?