├── .gitignore ├── Export-and-install.py ├── MIT-LICENSE.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Export-and-install.py: -------------------------------------------------------------------------------- 1 | #MenuTitle: Export and install font 2 | # -*- coding: utf-8 -*- 3 | __doc__=""" 4 | Exports and installs all active instances of this font and avoids caching. 5 | """ 6 | 7 | import os 8 | import re 9 | import datetime 10 | 11 | installFolder = os.path.expanduser("~/Library/Fonts") 12 | suffix = datetime.datetime.now().strftime("%Y%m%d-%H%M") 13 | font = Glyphs.font 14 | for instance in font.instances: 15 | try: 16 | if instance.active: 17 | filePattern = r"^%s(-[\d-]+)?\.(otf|ttf)" % instance.fontName 18 | oldFonts = [f for f in os.listdir(installFolder) if re.match(filePattern, f)] 19 | for oldFont in oldFonts: 20 | os.remove(installFolder + "/" + oldFont) 21 | print "Uninstalled %s" % oldFont 22 | fileName = "%s-%s.otf" % (instance.fontName, suffix) 23 | print "Exporting %s" % fileName 24 | instance.generate(FontPath = installFolder + "/" + fileName) 25 | except Exception, e: 26 | print e 27 | print "Exported and installed %s" % font.familyName 28 | Glyphs.showNotification("Export and install fonts", "Exported and installed %s" % font.familyName) 29 | -------------------------------------------------------------------------------- /MIT-LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018++ Nico Hagenburger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the “Software”), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Export and install fonts from Glyphs.app 2 | 3 | Installing fonts on MacOS sometimes is tricky, as fonts stay cached in the old 4 | version, even when installing a new one. 5 | 6 | This script solves caching issues. 7 | 8 | 1. Exports all active instances of a font 9 | 2. Deletes (uninstalls) older versions of each instance 10 | 3. Renames the exported fonts to `OriginalName-20180212-2234.otf` (including the 11 | current time to avoid caching issues) 12 | 4. Installs the new version into `~/Library/Fonts` 13 | 14 | Before running this script the first time, use Glyph.app’s export function at 15 | least once. The configuration is kept. 16 | 17 | 18 | ## Installation 19 | 20 | ``` 21 | git clone git@github.com:hagenburger/glyphs-export-and-install.git 22 | cd glyphs-export-and-install 23 | ln -s "`pwd`/Export-and-install.py" ~/Library/Application\ Support/Glyphs/Scripts 24 | ``` 25 | 26 | Restart Glyphs.app. 27 | 28 | Screenshot of the installed script in the menu 29 | 30 | 31 | 32 | ## Update 33 | 34 | In case updates are available: 35 | 36 | ``` 37 | cd glyphs-export-and-install 38 | git pull 39 | ``` 40 | 41 | 42 | ## Copyright 43 | 44 | Copyright 2018++ [Nico Hagenburger](http://www.hagenburger.net). 45 | See [MIT-LICENSE.md](MIT-LICENSE.md) for details. 46 | Get in touch with [@hagenburger](https://twitter.com/hagenburger) on Twitter or 47 | [open an issue](https://github.com/hagenburger/glyphs-export-and-install/issues/new). 48 | --------------------------------------------------------------------------------