linebender / linebender/norad

Pen Protocol

Open
#87 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
61
Forks
16
PR merge metrics
No merged PRs in 30d

Description

There exists in fontTools the [pen protocol](https://fonttools.readthedocs.io/en/latest/pens/basePen.html), which acts as a mediator between things using their own outline drawing methods. The [scope of the API](https://github.com/fonttools/fonttools/discussions/2165) is to standardise the way outlines and components are drawn, without providing channels for metadata like glyph width.

What's interesting is that the protocol is not only used for mapping outline data from one internal representation to another, but also for e.g. filtering. It is a sort-of-pipeline for outline and component processing, available in a point-based and PostScript-like drawing model. Examples:

- Adapting a point-based drawing model to a PostScript-like drawing model: https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/pointPen.py#L147
- Reversing a contour, e.g. for after you converted cubic to quadratics for a TTF: https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/reverseContourPen.py#L9
- Recording the pen movement, e.g. for later replay into a different pen or for testing (with components optionally decomposed): https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/recordingPen.py
- Testing whether a point falls inside the "black" area of a glyph: https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/pointInsidePen.py#L13
- Converting cubic outlines to quadratic TTF-ready ones: https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/cu2quPen.py
- Compute a hash for an outline for checking if some metadata is out of date: https://github.com/fonttools/fonttools/blob/4fb22ee/Lib/fontTools/pens/hashPointPen.py

This allows e.g. ufoLib2 and glyphsLib to implement just a `drawPoints` method on their glyph objects and use the existing pens to transport or transform the data without reimplementing the functionality at the source or destination, e.g. for compilation inside ufo2ft.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked fontTools basePen API and the referenced examples in pointPen.py, reverseContourPen.py, recordingPen.py, pointInsidePen.py, cu2quPen.py, and hashPointPen.py. The issue does not identify norad files, tests, or a concrete scope; completion would require an agreed Rust protocol design and defined validation criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.