Can you get a list of OSX fonts somehow?
-
@driven said:
If you want a list in ruby
fontList=(`osascript -e 'tell application "Font Book"' -e ' set fontList to name of every font family' -e 'end tell'`)Tried it on my Mac Mini - I started this Font Book application which appeared in the dock (not something I'd really want.)
And it was also very slow. Took about 2-3 seconds.
-
Of course, running it a second time it's much faster. So it's the overhead of starting the Font Book app.
-
How about [MAC]:
fontList=system(/usr/bin/fc-list : file family | grep /Library)
?? -
Returned
false
-
How about:
fontList=system("#!/bin/bash/usr/bin\n/fc-list : file family | grep /Library") -
false -
In normal Console:
/usr/bin/fc-list : file family | grep \/Library
Return:
-bash: /usr/bin/fc-list: No such file or directorycd /usr/bin/ fc-list : family
Return:
List of just font names.fc-list : file family | grep \/Library
Returns:
NothingBut getting the result of system call under SketchUp, with the
systemmethod - all I get isfalse. -
http://stackoverflow.com/a/3159997/486990
Either:
system('foobarCommand')foobarCommand``The latter will return the output - the former will output to standard output but return true/false.
` >> system('echo hi')
hi
=> trueecho hi
=> "hi\n"`fc-list : family`` returns a list of font names.(This was using IRB from a system console)
However, using Ruby Console:
echo hi`` returns "hi\n"but
fc-list : family`` returns ""
-
System IRB console:
>> system 'echo hi' hi => trueSketchUp Console:
` > system 'echo hi'
truesystem 'fc-list'
false`What gives?
-
How about something like...
fontList = system(fc-list : family)
??
Do you need to specify the 'shell-type' in the line like ?
fontList=system(#!/bin/bash usr/bin/fc-list : family)
When it works, then is it fast enough ? -
@tig said:
How about something like...
fontList = system(fc-list : family)
??See my previous post - the commands work in native consoles, but not in in SketchUp console - it doesn't appear to capture the output.
-
But the surely surrounding ` ``` '' "" etc can produce different results ??
So... are they all foobar?My other example tried to force it to run as a 'bash' shell... Is that possible?
Not having a MAC available does somewhat curtail my help in this area

-
@thomthom said:
the commands work in native consoles, but not in in SketchUp console
Maybe they are using stderr instead of stdout? You could test on the command line:
fc-list : family > out fc-list : family 2> err -
@tig said:
But the surely surrounding ` ``` '' "" etc can produce different results ??
So... are they all foobar?My other example tried to force it to run as a 'bash' shell... Is that possible?
They all return
false. -
@jim said:
Maybe they are using stderr instead of stdout? You could test on the command line:
fc-list : family > out fc-list : family 2> errnada

-
Tried to output to file:
fc-list : family >> ~/Desktop/fonts.txtEmpty when run from within SketchUp, populated when run in a native console.
Something is messed up with the messaging system!

-
system(fc-list : family | out)?
running out of permutations... -
Won't that just list fonts with "out" in them?
-
The 'grep' is for pattern matching...
The | pipes/passes the output to something else ['out'].
What do you call the 'output' on a MAC ??
The > puts the output into a file.
The >> appends the output to a file.
How do you 'pass/send' something ? -
TT
what osx are you running.
'shell' change to AT&T version with 10.5 , so the syntax needs to be checkedFontBook has had lots of revisions/additions
and those osascripts run it in the background, take miliseconds on my mac.the nice thing is people could set a 'SU 3D Font Collection in fontbook and you can allow them to use just those
john
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement