예제 #1
0
    def __init__(self, path=None):
        from robofab.world import world

        self.__path = path
        self._prefs = {}
        if world.inFontLab:
            # we don't have a path, but we know where we can put it
            if not path:
                from robofab.tools.toolsFL import makeDataFolder

                settingsPath = makeDataFolder()
                path = os.path.join(settingsPath, "RFPrefs.plist")
                self.__path = path
                self._makePrefsFile()
                # we do have a path, make sure it exists and load it
            else:
                self._makePrefsFile()
        else:
            # no path, raise error
            if not path:
                raise RoboFabError, "no preferences path defined"
                # we do have a path, make sure it exists and load it
            else:
                self._makePrefsFile()
        self._prefs = Plist.fromFile(path)
예제 #2
0
 def __init__(self, path=None):
     from robofab.world import world
     self.__path = path
     self._prefs = {}
     if world.inFontLab:
         #we don't have a path, but we know where we can put it
         if not path:
             from robofab.tools.toolsFL import makeDataFolder
             settingsPath = makeDataFolder()
             path = os.path.join(settingsPath, 'RFPrefs.plist')
             self.__path = path
             self._makePrefsFile()
         #we do have a path, make sure it exists and load it
         else:
             self._makePrefsFile()
     else:
         #no path, raise error
         if not path:
             raise RoboFabError, "no preferences path defined"
         #we do have a path, make sure it exists and load it
         else:
             self._makePrefsFile()
     self._prefs = Plist.fromFile(path)
예제 #3
0

from robofab.world import CurrentFont
from robofab.tools.toolsFL import makeDataFolder
# all the foundry settings tools live here:
from robofab.tools.toolsAll import readFoundrySettings, getFoundrySetting, setFoundrySetting
import time
import os

# You will need a font open in fontlab for this demo
font = CurrentFont()

# We need to know where the .plist file lives. In the FontLab environment
# it can live in the "RoboFab Data" folder with its friends. makeDataFolder()
# will make the data folder if it doesn't exist and it will return the path
settingsPath = os.path.join(makeDataFolder(), 'FoundrySettings.plist')

# Now, let's load those settings up
# readFoundrySettings(path) will return the data from the .plist as dictionary
mySettings = readFoundrySettings(settingsPath)

# Let's get the current year so that the year string is always up to date 
font.info.year = time.gmtime(time.time())[0]

# Apply those settings that we just loaded
font.info.copyright = mySettings['copyright']
font.info.trademark = mySettings['trademark']
font.info.openTypeNameLicense = mySettings['license']
font.info.openTypeNameLicenseURL = mySettings['licenseurl']
font.info.openTypeNameDescription = mySettings['notice']
font.info.openTypeOS2VendorID = mySettings['ttvendor']