Search code examples
fontsspecificationsopentype

If Local and Global Subr INDEXes in OpenType are basically reusable components


I can't tell from the description for the CFF2 table, but it seems to be suggesting that your font can have reusable components.

A subroutine (“subr”) is typically a sequence of CharString bytes representing a sub-program that is used in more than one place in a font’s CharString data. A subr may be stored once but referenced many times from within one or more CharStrings by the use of a call-subroutine operator that takes as an operand the number of the subr to be called.

My question is what these are exactly, and if it means that you can define a CharString as a module or component basically, which will slim down your font file size and make things more refined.

If that's the case, I'm wondering what the purpose is of having local vs. global subroutines. I don't see an advantage to this level of isolation if it's really just about being modular.

Hmm, I guess that's what is described in chapter 8. Just wanting to clarify.


Solution

  • These are what they sound like: they let you define any byte sequence used to define a glyph as a subroutine, so that you can reference it anywhere in a charstrings, including other subroutines. It's both a form of compression, and a way to effect much broader glyph compositionality by allowing arbitrary data to be effectively used as a macro, rather than only allowing composition with entire glyphs.

    Furthermore, there is a global vs. local distinction to both increase compression and help subroutine organisation: if you organized your CFF/CFF2 font data in terms of multiple DICT objects, then a subroutine pas can consist of first doing a global pass, to find all byte substrings shared by glyphs from all dicts in the font, and then you can further compress each DICT separately based on substrings in just those DICT structures.

    Also note that the Type1 spec is completely meaningless at this point in time: Type1 fonts were deprecated years ago and not even Adobe makes them anymore (in fact, they very actively switched all their fonts over to Type2 when that spec got finalized). For your spec consultation, you want "the compact font format" and "the Type2 Charstring format" tech notes, plus the OpenType 1.8 documentation on the differences between CFF2 and CFF2's new charstring format.

    You also probably want to ask questions like these over on http://typedrawers.com instead in the future, which is a dedicated space where typographers and typography engineers hang out for Q&A.