robofont.com
Merz
A new way of visualizing data on your screens The previous approach The new approach Merz is a lightweight wrapper around Apple’s CoreAnimation framework with a Pythonic API that allows for ergonomic, declarative and performant object drawing within RoboFont. Written and contributed by Tal Leming. You can find the detailed documentation here. A new way of visualizing data on your screens Merz is one of the major new features in RoboFont 4.0. Most users will not notice much difference from RoboFont 3.0, but it represents a radical change in how the application visualizes data on the screen. Rendering speed will enormously benefit from this shift. RoboFont’s extension ecosystem plays an important role in the overall user experience, so the RoboFont team will try to make it as easy as possible for tool developers the switch from mojo.drawingTools to Merz. Merz represents a substantial conceptual shift from mojo.drawingTools – and Drawbot. The mojo.drawingTools modules follow a strict procedural painter’s model: each drawing operation applies a layer of paint to an output canvas. The paint already applied cannot be modified, only new layers of paint can obscure or change the appearance of the previous layers. Differently, Merz adopts an object-oriented approach. It isn’t even correct to define Merz – and the Core Animation framework on which Merz relies upon – a drawing system itself. Merz is an infrastructure for compositing and manipulating data organized in layer objects. Or, in other words, Merz allows for creating visual layers of data. The previous approach Let’s compare two scripts returning the same output on the screen. The first one uses a drawbot-style approach. You can run this code in the Drawbot extension in RoboFont. myGlyph = CurrentGlyph() newPage(myGlyph.width, myGlyph.font.info.unitsPerEm) translate(0, -myGlyph.font.info.descender) drawGlyph(myGlyph) stroke(1, 0, 0) line((0, 0), (myGlyph.width, 0)) Open in RoboFont: merz_vs_drawbot_01.py Download: merz_vs_drawbot_01.py Look at the sequence of actions: the script accesses the glyph, creates a canvas, adjusts the canvas reference point, draws the glyph, set a line stroke, draws the baseline. It mimics the painter’s gestures. This drawing approach will keep working on RoboFont 4.0, but it is deprecated. It is considerably slower than Merz, and RoboFont 4.0 sets a resolution limit to mojo.drawingTools in order to preserve the user experience from rendering delays. The following screenshot is made using the WurstSchreiber extension – still using mojo.drawingTools – at 100%. So far, so good. But this is what happens if the users zoom in at 500%. The resolution limit kicks in, and contours become blurry. Not ideal, but a compromise. For this reason, the RoboFont team encourages extension developers to update their tools to Merz. Most extensions will become faster, and the object-oriented approach of Merz will make drawing code better adhere to the tool object structure. The new approach The following example uses Merz. You can run this code in the Merz Playground extension. myGlyph = CurrentGlyph() # a layer for the glyph and the baseline groupLayer = container.appendBaseSublayer( size=(myGlyph.width, myGlyph.font.info.unitsPerEm) ) glyphLayer = groupLayer.appendPathSublayer() glyphPath = myGlyph.getRepresentation(