Skip to content

Instantly share code, notes, and snippets.

@okay-type
Last active November 24, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okay-type/9111826ae6571d56905538c98d5de369 to your computer and use it in GitHub Desktop.
Save okay-type/9111826ae6571d56905538c98d5de369 to your computer and use it in GitHub Desktop.
an update of marky mark extension, rebuilt for robofont 4
from merz import MerzView
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
size = 50
class earMark(Subscriber):
debug = True
def build(self):
self.merzView = MerzView((-size, 0, 0, size))
merzContainer = self.merzView.getMerzContainer()
self.triangle = merzContainer.appendPathSublayer(
name='okayType.earMark',
position=(0, 0)
)
pen = self.triangle.getPen()
pen.moveTo((0, size))
pen.lineTo((size, size))
pen.lineTo((size, 0))
pen.closePath()
self.getGlyphEditor().addGlyphEditorSubview(self.merzView)
def destroy(self):
self.getGlyphEditor().removeGlyphEditorSubview(self.merzView)
def glyphEditorDidSetGlyph(self, info):
glyph = info['glyph']
if glyph == None:
return
self.setGlyphMarkColor(glyph)
def glyphEditorGlyphDidChangeInfo(self, info):
glyph = info['glyph']
if glyph == None:
return
self.setGlyphMarkColor(glyph)
def setGlyphMarkColor(self, glyph):
color = glyph.markColor
if color != None:
r, g, b, a = color
color = (r, g, b, a * .9)
if color == None:
color = (0, 0, 0, .05)
self.triangle.setFillColor(color)
registerGlyphEditorSubscriber(earMark)
@typemytype
Copy link

the markColorChanged notification is bundled in ˋglyphDidChangeInfoˋ so the method will be ˋglyphEditorGlyphDidChangeInfoˋ

This will be called when any of Glyph.NameChanged, Glyph.UnicodesChanged, Glyph.NoteChanged, Glyph.MarkColorChanged are posted. Default delay: 0.033 seconds.

https://robofont.com/documentation/reference/api/mojo/mojo-subscriber/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment