Skip to content

Instantly share code, notes, and snippets.

@weiweihuanghuang
weiweihuanghuang / Compare Fonts.py
Last active July 27, 2016 06:27
Compare Two Open Fonts – (Should only have two files open have them open to the same master, a new tab will open with all the changed glyphs)
#MenuTitle: Compare Fonts
# -*- coding: utf-8 -*-
__doc__="""
- Compare 2 open files and opens a new tab (in the current font) for each master showing the glyphs that are different between the 2 files.
- A decomposed copy of each different glyph from the other file will also be pasted in the background of each glyph in the current file.
*** WARNING *** This will clear the background in the current font. Uncomment the "doNotCopyToBackground" line to disable it.
"""
@weiweihuanghuang
weiweihuanghuang / Set Same View in All Tabs.py
Created January 28, 2016 11:09
Set Same View in All Tabs
Font = Glyphs.font
Doc = Glyphs.currentDocument
Glyphs.clearLog()
currentGraphicView = Glyphs.currentDocument.windowController().activeEditViewController().graphicView()
thisActivePosition = currentGraphicView.activePosition()
thisVisibleRect = currentGraphicView.visibleRect()
thisScale = currentGraphicView.scale()
@weiweihuanghuang
weiweihuanghuang / Show master.py
Created January 23, 2016 12:29
Show master in the Preview Field or Window
#MenuTitle: Show master
# -*- coding: utf-8 -*-
__doc__="""
Show the amster in preview field or preview window.
"""
import GlyphsApp
from Foundation import NSApplication
numberOfInstances = len( Glyphs.font.instances )
@weiweihuanghuang
weiweihuanghuang / Set Transform Origin to Centre of Selection.py
Last active January 9, 2016 14:50
Set Transform Origin to Centre of Selection
#MenuTitle: Set Transform Origin to Centre of Selection
# -*- coding: utf-8 -*-
__doc__="""
Sets origin point for Rotate tool to the centre of the selection.
"""
import GlyphsApp
Font = Glyphs.font
Doc = Glyphs.currentDocument
selectedLayer = Font.selectedLayers[0]
@weiweihuanghuang
weiweihuanghuang / setPreviewPanel.py
Last active March 12, 2017 21:49
Set Preview Panel Height Across Every Tab
#MenuTitle: Set Preview Panel
# -*- coding: utf-8 -*-
__doc__="""
Set preview panel height across every tab to the same as this tab
"""
import GlyphsApp
Font = Glyphs.font
frameHeight = Font.currentTab.previewView().frame().size.height
#MenuTitle: Show Glyphs with this Anchor
# -*- coding: utf-8 -*-
__doc__="""
New Tab with all Glyphs that have the selected anchor.
"""
thisFont = Glyphs.font # frontmost font
selectedLayer = thisFont.selectedLayers[0]
selection = selectedLayer.selection
@weiweihuanghuang
weiweihuanghuang / Show Glyphs with this Anchor.py
Last active December 6, 2015 21:20
Show Glyphs with this Anchor
#MenuTitle: Show Glyphs with this Anchor
# -*- coding: utf-8 -*-
__doc__="""
New Tab with all Glyphs that are have the selected anchor.
"""
thisFont = Glyphs.font # frontmost font
selectedLayer = thisFont.selectedLayers[0]
selection = selectedLayer.selection
from robofab.interface.all.dialogs import SelectFont
from robofab.pens.digestPen import DigestPointPen
# f1 = SelectFont("Select 'Master' font:")
# f2 = SelectFont("Select font to compare:")
fonts = AllFonts()
f1 = fonts[0]
f2 = fonts[1]
@weiweihuanghuang
weiweihuanghuang / Delete Kerning Pairs Smaller Than
Created April 6, 2015 09:17
Delete Kerning Pairs Smaller Than
#MenuTitle: Delete Kerning Pairs Smaller Than #
# -*- coding: utf-8 -*-
__doc__="""
Delete all kerning pairs equal to or smaller than # in selected master
"""
import vanilla
import GlyphsApp
class deleteKerning( object ):
#MenuTitle: Uppercase
# -*- coding: utf-8 -*-
"""Converts the selected text to upppercase."""
Doc = Glyphs.currentDocument
Font = Glyphs.font
Doc = Glyphs.currentDocument
TextStoreage = Doc.windowController().activeEditViewController().graphicView().textStorage()
String = TextStoreage.text().string()
Range = TextStoreage.selectedRange()