sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Can you get a list of OSX fonts somehow?

    Scheduled Pinned Locked Moved Developers' Forum
    110 Posts 6 Posters 13.9k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      John - and there is no flashing console windows when you perform that?

      @unknownuser said:

      I have a java program that runs on both Win and OSX if you want a copy.

      I'm good with these solutions here - I prefer them over Flash and Java as then we don't have to rely on plugins to be installed. There's too many users with out of date versions which these days get blocked by browsers or they are locked down due to office policy.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @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.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Of course, running it a second time it's much faster. So it's the overhead of starting the Font Book app.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            How about [MAC]:
            fontList=system(/usr/bin/fc-list : file family | grep /Library)
            ??

            TIG

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Returned false 😕

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                How about:
                fontList=system("#!/bin/bash/usr/bin\n/fc-list : file family | grep /Library")

                TIG

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  false

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    In normal Console:
                    /usr/bin/fc-list : file family | grep \/Library
                    Return:
                    -bash: /usr/bin/fc-list: No such file or directory

                    cd /usr/bin/ fc-list : family
                    Return:
                    List of just font names.

                    fc-list : file family | grep \/Library
                    Returns:
                    Nothing

                    But getting the result of system call under SketchUp, with the system method - all I get is false.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      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
                      => true

                      echo 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 "" 😕

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        System IRB console:

                        >> system 'echo hi' hi => true

                        SketchUp Console:

                        ` > system 'echo hi'
                        true

                        system 'fc-list'
                        false`

                        What gives?

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          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

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            @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.

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              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 😒

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                Jim
                                last edited by

                                @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

                                Hi

                                1 Reply Last reply Reply Quote 0
                                • thomthomT Offline
                                  thomthom
                                  last edited by

                                  @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.

                                  Thomas Thomassen — SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 Reply Last reply Reply Quote 0
                                  • thomthomT Offline
                                    thomthom
                                    last edited by

                                    @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> err

                                    nada 😞

                                    Thomas Thomassen — SketchUp Monkey & Coding addict
                                    List of my plugins and link to the CookieWare fund

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      Tried to output to file:

                                      fc-list : family >> ~/Desktop/fonts.txt

                                      Empty when run from within SketchUp, populated when run in a native console.

                                      Something is messed up with the messaging system! 😞

                                      Thomas Thomassen — SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • TIGT Offline
                                        TIG Moderator
                                        last edited by

                                        system(fc-list : family | out) ?
                                        running out of permutations...

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          Won't that just list fonts with "out" in them?

                                          Thomas Thomassen — SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 Reply Last reply Reply Quote 0
                                          • TIGT Offline
                                            TIG Moderator
                                            last edited by

                                            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 ?

                                            TIG

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 2 / 6
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement