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
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • D 離線
      driven
      最後由 編輯

      I've found the KISS Applescript version, just figuring out if it's easier to strip the results first or in ruby.
      the basic can then run as osascript...

      set search1 to do shell script "mdfind -onlyin /Library/Fonts 'kMDItemContentTypeTree = \"public.truetype-ttf-font\"'" as text
      set search2 to do shell script "mdfind -onlyin ~/Library/Fonts 'kMDItemContentTypeTree = \"public.truetype-ttf-font\"'" as text
      

      results look like this
      %(#0000FF)[/Library/Fonts/NISC18030.ttf
      /Library/Fonts/Kai.ttf
      /Library/Fonts/Hei.ttf
      /Library/Fonts/BiauKai.ttf
      /Library/Fonts/Apple LiSung Light.ttf
      /Library/Fonts/Apple LiGothic Medium.ttf
      /Library/Fonts/Microsoft/Lucida Console.ttf
      /Library/Fonts/Microsoft/Candara Bold Italic.ttf]

      also, I think if a plugins is offering font manipulation for artistic usage, it should have all the 'SU' fonts and let the User decide which to use
      john

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

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

        So that returns the filenames, but do the filenames represent the font names exactly?

        I know that I would not be able to do that with the fonts on a Windows machine as they usually are abbreviations.

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

        1 條回覆 最後回覆 回覆 引用 0
        • Dan RathbunD 離線
          Dan Rathbun
          最後由 編輯

          @thomthom said:

          I know that I would not be able to do that with the fonts on a Windows machine as they usually are abbreviations.

          XP
          %(#004080)[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]

          reg_fonts_on_win.PNG

          I'm not here much anymore.

          1 條回覆 最後回覆 回覆 引用 0
          • TIGT 離線
            TIG Moderator
            最後由 編輯

            I suspect that the ttf file name is not always the font name 😒

            MAC's 'fc-list' will provide the font-name, font-family etc -
            I can't believe that 'we' can't get it to write the list to a variable using system(...) 😕
            Have you tried something like this?
            font_list=system(fc-list : family | cat)
            or similar, where the output gets piped to something that can return a value like 'cat' ?
            OR perhaps:
            font_list=system(cat (fc-list : family))
            OR probably with 'escaped' (), more like:
            font_list=system(cat (fc-list : family))
            😕

            TIG

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

              @tig said:

              I can't believe that 'we' can't get it to write the list to a variable using system(...) 😕

              Yea, I wish I knew why this is mis-behaving inside SketchUp. 😕

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

              1 條回覆 最後回覆 回覆 引用 0
              • TIGT 離線
                TIG Moderator
                最後由 編輯

                Have you tried any of my 'convolutions', to redirect / pipe its output to some other function that then might successfully return the values to 'system' ?
                As it does several 'lines' of output in the console can we pipe it through a loop ?
                Or like font_list=system(cat ($(fc-list : family)))
                Perhaps with some \ escaping of the various () ???

                TIG

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

                  Not the recent ones. I only have access to a Mac at home, and last week I haven't been home for very long - certainly no time to test anything. 😞

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

                  1 條回覆 最後回覆 回覆 引用 0
                  • TIGT 離線
                    TIG Moderator
                    最後由 編輯

                    So there's still hope...
                    Perhaps driven etc can try...
                    I have no MAC access either...

                    TIG

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

                      sticking with things we know return in console

                      > ttfList=(find ~/Library/Fonts/*.ttf`)
                      /Users/johns_iMac/Library/Fonts/Momo.ttf
                      /Users/johns_iMac/Library/Fonts/Tkds9crd.ttf
                      /Users/johns_iMac/Library/Fonts/machtgth.ttf
                      /Users/johns_iMac/Library/Fonts/machtssr-gm.ttf

                      fontsM=(mdls -raw -name com_apple_ats_name_family ~/Library/Fonts/momo.ttf +
                      mdls -raw -name com_apple_ats_name_family ~/Library/Fonts/Tkds9crd.ttf +
                      mdls -raw -name com_apple_ats_name_family ~/Library/Fonts/machtgth.ttf +
                      mdls -raw -name com_apple_ats_name_family ~/Library/Fonts/machtssr-gm.ttf)
                      (
                      Momo
                      )(
                      Trek
                      )(
                      "Machine Tool Gothic"
                      )(
                      "Machine Tool SanSerif"
                      )this is a quick manual cobble, but it could be coerced, john edit: or this > fontsM=(mdls -raw -name com_apple_ats_name_full ~/Library/Fonts/momo.ttf +
                      mdls -raw -name com_apple_ats_name_full ~/Library/Fonts/Tkds9crd.ttf +
                      mdls -raw -name com_apple_ats_name_full ~/Library/Fonts/machtgth.ttf +
                      mdls -raw -name com_apple_ats_name_full ~/Library/Fonts/machtssr-gm.ttf)
                      (
                      Momo
                      )(
                      "Trek DS9 Credits Text"
                      )(
                      "Machine Tool Gothic"
                      )(
                      "Machine Tool SanSerif"
                      )or for completeness > fontsM=(mdls -raw -name kMDItemFonts ~/Library/Fonts/momo.ttf +
                      mdls -raw -name kMDItemFonts ~/Library/Fonts/Tkds9crd.ttf +
                      mdls -raw -name kMDItemFonts ~/Library/Fonts/machtgth.ttf +
                      mdls -raw -name kMDItemFonts ~/Library/Fonts/machtssr-gm.ttf)
                      (
                      Momo,
                      Regular
                      )(
                      HamiltonSteel,
                      Regular,
                      Trek,
                      "Trek DS9 Credits Text"
                      )(
                      "Machine Tool Gothic",
                      MachineToolGothic,
                      Regular
                      )(
                      "Machine Tool SanSerif",
                      MachineToolSanSerif,
                      Regular
                      )`

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

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

                        getting closer, but I really don't know ruby, take lots of trial and error,
                        > a=(find ~/Library/Fonts/*.ttf).to_a b=(a.collect{|x| mdls -raw -name com_apple_ats_name_family #{x}}) ["(\n Momo\n)", "(\n Trek\n)", "(\n \"Machine Tool Gothic\"\n)", "(\n \"Machine Tool SanSerif\"\n)"]how do I clean out the rest?

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

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

                          b=["(\n Momo\n)", "(\n Trek\n)", "(\n \"Machine Tool Gothic\"\n)", "(\n \"Machine Tool SanSerif\"\n)"] c=b.map { |f| f[/[("\s]+([^"\n]+)[)"\s]+/m,1] }

                          Returns:
                          ["Momo", "Trek", "Machine Tool Gothic", "Machine Tool SanSerif"]

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

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

                            excellent Thomas,

                            when I use it on /Library/Fonts/*.*tf I get a more complete list, but some are linked files so I get
                            "could not find /Library/Fonts//儷宋."
                            how do I filter those out? [if I can't resolve them]
                            john

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

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

                              ###################################################################### t=Time.now a=(find -d /Library/Fonts -name "*.t").split("\n").map { |f| f.gsub(" ", "\\ ")} b=(a.collect{|x| mdls -nullMarker missing -raw -name com_apple_ats_name_family #{x}}) c=b.map { |f| f[/[("\s]+([^"\n]+)[)"\s]+/m,1] }.uniq puts c, "\n v2", Time.now-t ######################################################################
                              187 fonts from 1 Library in 7.147912 and I still have a couple of commas to remove...
                              john

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

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

                                characters.png

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

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

                                  `tt,
                                  that's your browser not recognising the UFT8 apple icon. IE sometimes will show the Windows icon.

                                  I use it as a line marker for mac only scripts I'm testing, so when I had 3 time now's I could find the end of each easily.
                                  john

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

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

                                    I use Firefox.
                                    Firefox understands UTF-8. There's some conversion going on here that mangles the formatting.

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

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

                                      Link Preview Image
                                      The Apple Logo in Unicode

                                      favicon

                                      (hea-www.harvard.edu)

                                      @unknownuser said:

                                      This is probably fine for Mac-only applications. But it is NOT appropriate, and even WRONG, and it will NOT work properly as a general web page character. The problem is that the unicode value used is one of several that is set aside for private use. That means that each operating system, or application, or implementation is free to use those unicode characters for anything they want. It just so happens that Apple has chosen to use unicode character U+F8FF (decimal value 63743, or on the web as either  or ) as the Apple Logo. But some Windows fonts put in a Windows logo. And some other fonts put in a Klingon Mummification glyph. Or elven script. Or anything they want. And if it isn't defined in your local font, you'll just see a square. So who knows what you might see when I put the character in right here: 

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

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

                                        Ah - a non-standard. That explains it.

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

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

                                          Found the problem, and a massive speed-up...
                                          > t=Time.now fontList=(/opt/X11/bin/fc-list : file family | grep /Library/Fonts).split("\n").collect { |f| f.split(":")[1] }.collect { |f| f.split(",")[0] }.to_a.uniq.compact.sort[5..-1] fin=Time.now-t puts fontList.length puts fin, Time.now-t puts fontList puts Time.now-t 296 0.049741 0.056441 *...print fonts* 1.440642
                                          however............ not everyone has X11
                                          john

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

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

                                            But, the good news is brew install fontconfig will put it in 'usr/local/bin/fc-list' without all the X11 or hidden system fonts... speed on first run, slower, but still acceptable
                                            then, the penny dropped that you no longer need grep or one of the collects, so
                                            t=Time.now fontList=(/usr/local/bin/fc-list : family ).split("\n").collect { |f| f.split(",")[0] }.to_a.uniq.compact.sort fin=Time.now-t puts fontList.length puts fin, Time.now-t puts fontList puts fontList.length puts fin, Time.now-t 274 0.017442 0.023794 ...print fonts 1.363478
                                            not to shabby
                                            john

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

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

                                            Advertisement