OTF/CFF global/local subroutines

TLDR: in CFF is it legal to call a local subroutine from a global subroutine?
Hi everyone,
I'm currently working on some software that parses/manipulates charstrings that represent the glyphs in CFF (Compact Font Format) fonts.
While working on the part that handles global and local subroutines, I was initially working under the assumption that:
- charstrings can call local and global subroutines (i.e. use
callsubr
andcallgsubr
) - local subroutines can call other local and global subroutines (i.e. use
callsubr
andcallgsubr
) - global subroutines can only call other global subroutines (i.e. use
callgsubr
)
however, this seems not to be the case: when I ran some tests on a number of font files, I discovered that for example in "Nimbus Roman Italic" (a standard font installed on Ubuntu Linux) global subroutines exist that contain the callsubr
opcode, thereby trying to call local subroutines.
In the context of OTF fonts this can be worked around relatively unambiguously as OTF restricts CFF to contain only one CharSet and therefore only one private dict with local subroutines. But in a general case this seems like a bad idea.
Question:
- did I misunderstand the restrictions? (i.e. is this in fact legal behavior?)
- or are those font-files ill-formed?
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 811 Font Technology
- 1.1K Technique and Theory
- 628 Type Business
- 449 Type Design Critiques
- 547 Type Design Software
- 30 Punchcutting
- 137 Lettering and Calligraphy
- 84 Technique and Theory
- 53 Lettering Critiques
- 493 Typography
- 307 History of Typography
- 115 Education
- 71 Resources
- 505 Announcements
- 81 Events
- 106 Job Postings
- 151 Type Releases
- 166 Miscellaneous News
- 271 About TypeDrawers
- 53 TypeDrawers Announcements
- 117 Suggestions and Bug Reports