Saturday, April 29, 2017

#1 2017-04-07 08:07:09 pm

paramvir
Member
Registered: 2005-09-29
Posts: 3

Font Catalogue from Folder (not system Fonts folder)

Hello. I have, over the years, collected many free fonts, but haven't installed them all. I am looking for a way to create a catalogue of these fonts from the folder (in my user documents folder) so I can go through them and choose them as per need.

Most of the font catalogue scripts I have come across seem to be wanting to use Apple Font Book in one way or another. I don't want Font Book to install the fonts. I just want to create a PDF catalogue.

Is there a script to achieve this?

Last edited by paramvir (2017-04-07 08:07:21 pm)

Offline

 

#2 2017-04-08 11:04:18 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2957

Re: Font Catalogue from Folder (not system Fonts folder)

Here is a quick and dirty sample code creating the document in Pages.

Applescript:

use AppleScript version "2.4" # requires at least Yosemite
use scripting additions
use framework "Foundation"
use framework "AppKit"

my germaine()

on germaine()
   # Define some constants
   set font4title to "Palatino-Roman"
   set size4title to 12
   set size4sample to 24
   
   set theSample to tab & "ABCDEFGHIJKLM" & linefeed & tab & "NOPQRSTUVWXYZ" & linefeed & tab & "abcdefghijklm" & linefeed & tab & "nopqrstuvwxyz" & linefeed & tab & "àâéèêîôûùœæç" & linefeed & tab & "ÀÂÉÈÊÎÔÛÙŒÆÇ" & linefeed & tab & "1234567890" & linefeed & linefeed
   
   set nbPars to (count paragraphs of theSample) - 2
   
   set pdfPath to (path to desktop as text) & "fonts samples.pdf"
   
   # Get the Postscript names of installed fonts
   set theFonts to current application's NSFontManager's sharedFontManager()'s availableFonts() as list
   
   tell application id "com.apple.iwork.pages"
       activate
       # Get the localized names of delivered templates
       set installedTemplates to name of every template
       set blank_loc to installedTemplates's item 1
       set myDoc to make new document with properties {document template:template blank_loc}
       tell myDoc to tell its body text
           set para to 1
           set beurk to ""
           repeat with aFont in theFonts
               set aFont to aFont as text
               if aFont does not start with "." then
                   # insert the font name
                   if aFont is not "Garamond-LightNarrowItal" then
                       set paragraph para to aFont & linefeed & linefeed
                   else
                       # There is a wrong naming at work.
                       set paragraph para to aFont & " (Garamond-BoldNarrowItal)" & linefeed & linefeed
                       set beurk to beurk & aFont & linefeed
                       set aFont to "Garamond-BoldNarrowItal"
                   end if
                   set font of paragraph para to font4title
                   set para to para + 2
                   # insert the sample text
                   set paragraph para to theSample
                   set size of paragraphs para thru (para + nbPars - 1) to size4sample
                   try
                       set font of paragraphs para thru (para + nbPars - 1) to aFont
                   on error # flag possible other wrong naming
                       set color of paragraphs para thru (para + nbPars - 1) to {64638, 4079, 6844}
                       set beurk to beurk & aFont & linefeed
                   end try
                   set para to para + nbPars
                   set size of paragraph para to size4title
                   set font of paragraph para to font4title
                   set para to para + 1
               end if # aFont does not start with "."
           end repeat
       end tell # myDoc
       export myDoc to file pdfPath as PDF
   end tell # Pages
   set the clipboard to beurk
end germaine

When a character used in the sample is not defined in the font, most of the time the system display it using an other font. Honestly I don't know which scheme rules this substitution process.

Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) samedi 8 avril 2017 17:55:35

Last edited by Yvan Koenig (2017-04-09 05:53:30 am)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.075 seconds, 11 queries executed ]

RSS (new topics) RSS (active topics)