HugoJ
February 12, 2023, 9:45pm
#1
Hey !
I’m writing a script to generate glyphOrder to display glyph by Label Color.
I was wondering if there will be a secret/hack technique to do this dynamically.
Actually if a change a Label Color, I need to run script again to refresh glyphOrder.
There is a hack. But it will only sort, not do the grouping. And it will be very temporary. So a lot of things done with the font view will reset it.
from AppKit import NSSortDescriptor
sortdescriptor = NSSortDescriptor.sortDescriptorWithKey_ascending_("colorIndex", True)
Font.fontView.glyphsArrayController().setSortDescriptors_([sortdescriptor])
1 Like
HugoJ
February 14, 2023, 2:58pm
#3
If like me, you are obsessed with Layer Color, I did a script to filter them in FontView.
#MenuTitle: Filter Layer Color in FontView
# -*- coding: utf-8 -*-
__doc__="""
Generates a new "glyphOrder" that filters glyphs according to the colour of the selected master layer.
If a glyphOrder already exists, it will create a new one, and switch them when the script is triggered.
"""
import os
import codecs
import re
font = Glyphs.font
# Generate code for custom parameter "glyphOrder"
def GenerateLayerColorGlyphOrder():
colorMeaning = Map_Keys(Get_Key_File())
print(colorMeaning)
This file has been truncated. show original
HugoJ
February 14, 2023, 3:19pm
#4
It would be awesome if it was possible to do that natively in Glyphs
And that the filtering is dynamic
I found an extra hack :
Just trigger the script when the user is in FontView and changes Selected Master and TA DA ! , it’s dynamic.