2011-08-11 14 views
8

मैं कुछ समय से ऐसा करने की कोशिश कर रहा हूं, और इसे करने का एक प्रभावी तरीका नहीं मिला है। वर्तमान में मैं सभी फ़ॉन्ट मैं इस तरह की सूची बनाएं करने की कोशिश कर दिया गया है:ऐप्पलस्क्रिप्ट - सभी फ़ॉन्ट्स को सूचीबद्ध करें

set the font_list to {"Arial","Comic Sans MS","Arial Black",...} 

लेकिन यह सब फोंट लिखने के लिए हमेशा के लिएलेता है और मुझे पता है कि मैक पर फोंट की टन देखते हैं कि। सिस्टम पर सभी फोंट प्राप्त करने के लिए एक और अधिक प्रभावी तरीका है, टेक्स्ट दस्तावेज़ में सामान का एक गुच्छा लिखें, और उसके बाद प्रत्येक फ़ॉन्ट का फ़ॉन्ट अगले फ़ॉन्ट पर सेट करें (यानी लाइन 1 का फ़ॉन्ट फ़ॉन्ट 1, लाइन 2 का फ़ॉन्ट है फ़ॉन्ट 2, आदि है)?

उत्तर

1

आप सही हैं कि मैक ओएस एक्स में बहुत सारे फोंट हैं। सॉफ़्टवेयर स्थापना और आपके कंप्यूटर पर उपयोगकर्ता खातों की संख्या के आधार पर, इन फ़ॉन्ट्स को चार या अधिक फ़ोल्डर्स के माध्यम से वितरित किया जाता है।

आपके प्रश्न पर +1 है क्योंकि मैं वही काम करने की कोशिश कर रहा हूं, इसलिए मैंने नौकरी करने वाली एक छोटी सी लिपि बनाई। यह चार/पांच अलग-अलग स्थानों से फोंट खींचता है, एक टेक्स्ट दस्तावेज़ में लिखता है, फिर फोंट बदलता है। हालांकि, जब आप इसे चलाते हैं, तो आपका सिस्टम लापरवाही शुरू कर सकता है (जैसा कि मैंने कुछ पलों पहले किया था)। लेकिन अंतराल इसके लायक है!

--"get all the fonts on the system" 

display dialog "WARNING" & return & return & "This script may cause your computer to lag. Are you sure you want to proceed with the font sampler?" with icon caution 
set the font_folders to {"/Users/" & the short user name of (system info) & "/Library/Fonts/", "/Library/Fonts/", "/Network/Library/Fonts/", "/System/Library/Fonts/", "/System Folder/Fonts/"} 
set these_fonts to {} 
repeat with this_font_folder in the font_folders 
    try 
     tell application "Finder" to set the end of these_fonts to every item of ((this_font_folder as POSIX file) as alias) 
    end try 
end repeat 

--"write a bunch of stuff in a text document" 

tell application "TextEdit" 
    activate 
    set zoomed of the front window to true 
    set the name of the front window to "Font Sampler" 
end tell 
repeat with this_font in these_fonts 
    tell application "Finder" to set this_font to the name of this_font 
    tell application "TextEdit" to set the text of document 1 to the text of document 1 & this_font & ": The quick brown fox jumps over the lazy dog." & return 
end repeat 

--"set the font of each consecutive line to the next font (i.e. Line 1's font is Font 1, Line 2's font is Font 2, etc.)" 

repeat with i from 1 to the count of these_fonts 
    tell application "Finder" to set this_font to the name of item i of these_fonts 
    tell application "TextEdit" to tell paragraph i of the text of document 1 to set the font to this_font 
end repeat 
3
tell application "Font Book" to name of font families 

set l to {"Regular", "Roman", "Book", "Plain", "55 Roman", "R"} 
set found to {} 
tell application "Font Book" 
    repeat with x in typefaces 
     if l contains style name of x then set end of found to name of x 
    end repeat 
end tell 
found 
+0

+1 क्योंकि ऐसा लगता है कि आश्चर्य की बात है, मैंने अभी तक 'फ़ॉन्ट बुक' के बारे में नहीं सुना है! : पी – fireshadow52

+0

इसे सही उत्तर के रूप में चिह्नित किया जाना चाहिए! –

2

एक यूनिक्स कमांड है कि आप उपयोग कर सकते हैं: system_profiler यहाँ स्क्रिप्ट है। "SPFontsDataType" का डेटा प्रकार आपको सिस्टम प्रोफ़ाइल से केवल फोंट देगा। एक्सएमएल एक्सएमएल में डेटा पेश करेगा।

system_profiler -xml SPFontsDataType > ~/Desktop/myfonts.plist 

आप इसे स्मृति में या फ़ाइल में कैप्चर कर सकते हैं और जो भी उद्देश्य चाहते हैं उसे पार्स कर सकते हैं।

+0

अन्य शेल कमांड को बीज करने का सही तरीका: "mdls/path/to/font" जो सभी फ़ॉन्ट गुणों को सूचीबद्ध करेगा। – Orwellophile

संबंधित मुद्दे