sketchucation logo sketchucation
    • 登入
    ℹ️ 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?

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    110 貼文 6 Posters 13.9k 瀏覽 6 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • TIGT 離線
      TIG Moderator
      最後由 編輯

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

      TIG

      1 條回覆 最後回覆 回覆 引用 0
      • thomthomT 離線
        thomthom
        最後由 編輯

        false

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

        1 條回覆 最後回覆 回覆 引用 0
        • thomthomT 離線
          thomthom
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 0
          • thomthomT 離線
            thomthom
            最後由 編輯

            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 條回覆 最後回覆 回覆 引用 0
            • thomthomT 離線
              thomthom
              最後由 編輯

              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 條回覆 最後回覆 回覆 引用 0
              • TIGT 離線
                TIG Moderator
                最後由 編輯

                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 條回覆 最後回覆 回覆 引用 0
                • thomthomT 離線
                  thomthom
                  最後由 編輯

                  @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 條回覆 最後回覆 回覆 引用 0
                  • TIGT 離線
                    TIG Moderator
                    最後由 編輯

                    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 條回覆 最後回覆 回覆 引用 0
                    • J 離線
                      Jim
                      最後由 編輯

                      @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 條回覆 最後回覆 回覆 引用 0
                      • thomthomT 離線
                        thomthom
                        最後由 編輯

                        @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 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          @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 條回覆 最後回覆 回覆 引用 0
                          • thomthomT 離線
                            thomthom
                            最後由 編輯

                            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 條回覆 最後回覆 回覆 引用 0
                            • TIGT 離線
                              TIG Moderator
                              最後由 編輯

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

                              TIG

                              1 條回覆 最後回覆 回覆 引用 0
                              • thomthomT 離線
                                thomthom
                                最後由 編輯

                                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 條回覆 最後回覆 回覆 引用 0
                                • TIGT 離線
                                  TIG Moderator
                                  最後由 編輯

                                  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 條回覆 最後回覆 回覆 引用 0
                                  • D 離線
                                    driven
                                    最後由 編輯

                                    TT
                                    what osx are you running.
                                    'shell' change to AT&T version with 10.5 , so the syntax needs to be checked

                                    FontBook 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

                                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • thomthomT 離線
                                      thomthom
                                      最後由 編輯

                                      @driven said:

                                      what osx are you running.

                                      10.5

                                      @driven said:

                                      'shell' change to AT&T version with 10.5 , so the syntax needs to be checked
                                      But it works in the system console, and it works from IRB calling system command - but not from SketchUp calling system command.

                                      @driven said:

                                      FontBook has had lots of revisions/additions
                                      and those osascripts run it in the background, take miliseconds on my mac.

                                      Mine took a noticeable lag the first time I ran it, but quick the next runs. And Font Book's icon appeared in the dock.

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

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • D 離線
                                        driven
                                        最後由 編輯

                                        @thomthom said:

                                        But it works in the system console, and it works from IRB calling system command - but not from SketchUp calling system command.

                                        it is possible to get an output to Ruby Console using echo <dev/nul, but I need to dig thru for a working example..

                                        @unknownuser said:

                                        Mine took a noticeable lag the first time I ran it, but quick the next runs. And Font Book's icon appeared in the dock.

                                        I think I would run only once, hold the list in the plugin, but add an update function/item for people who add fonts to FontBook [very few]...
                                        added to the end of the osascript should close it after use -e 'tell application "Font Book" to quit' -e 'end'
                                        john

                                        learn from the mistakes of others, you may not live long enough to make them all yourself...

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • D 離線
                                          driven
                                          最後由 編輯

                                          I've been trying loads of different ways to get the exact font list that SU shows under 'Window' >> 'Show Fonts' all 297 on my mac, this is by far the easiest

                                          macFonts=[]
                                          macFonts=(`osascript -e 'tell application "Font Book" to set macFonts to name of every font family'`).split(",").uniq.each {|a| a.strip! if a.respond_to? ;strip! }.sort
                                          quitFontBook=(`osascript -e 'tell application "Font Book" to quit'`)
                                           if macFonts.length > 1
                                           then quitFontBook
                                           end
                                          macFonts.length
                                          

                                          john

                                          learn from the mistakes of others, you may not live long enough to make them all yourself...

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • thomthomT 離線
                                            thomthom
                                            最後由 編輯

                                            I'll try it on my mac

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

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 2 / 6
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement