opentype.js
opentype.js copied to clipboard
Allow Open Contour Fonts?
Hi, I was wondering if there is a way to use single line fonts (like those listed here).
Expected Behavior

Current Behavior
Currently, open paths are automatically closed:

Possible Solution
I have been able to make it work by removing any "Z" command from the commands list. but this solution seems to be highly situationally dependent.
Context
I'm making a single-line font to use with a pen plotter. (Here is the trial font that I'm using (it only has a few glyphs, FYI).)
The goal is to use this font and easily insert the paths (extracted via opentype.js) into an SVG (or canvas if the need arises).
Your Environment
- Version used:
- Font used: see above
- Browser Name and version: Chrome
- Operating System and version (desktop or mobile): MacOS
- Link to your project: n/a
Is the stroke width for these fonts defined by the StrokeWidth
property in the cff
table?
I found some info in https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf that describes the different values for PaintType
which is one of the fields in the cff
table's TopDict:
endchar - endchar (14) |- finishes a charstring outline definition and must be the last com- mand in a character’s outline (except for accented characters defined using seac). When endchar is executed, Type 1 BuildChar performs several tasks. It executes a setcachedevice operation, using a bounding box it computes directly from the character outline and using the width information acquired from a previ- ous hsbw or sbw operation. (Note that this is not the same order of events as in Type 3 Fonts.) BuildChar then calls a special ver- sion of fill or stroke depending on the value of PaintType in the font dictionary. The Type 1 font format supports only PaintType 0 (fill) and 2 (outline). Note that this single fill or stroke implies that there can be only one path (possibly containing several sub- paths) that can be created to be filled or stroked by the endchar command.
opentype.js should be able to determine whether or not to add Z
commands to the path based on the value of PaintType
.
Hi @kevinbarabash,
My StrokeWidth
is set, i'll have to check on the PaintType
. I'm using fontforge, so I hope that I have access to these options... I'm also not a professional, so please bare with me! 😂
If you have any experience setting these values I would appreciate the help... a little lost here... Would these be set in the font info? i'm not able to find a place to update this info...
Hey @HenrySkup did you ever find a solution to this. I have the same problem I'm trying to use a font from OneLineFonts to engrave text on a CNC machine with files generated through makerjs.
The font has bezier and straight line versions but I get the same problem with both where it seems Opentype is closing the open paths causing duplicate lines in the output.
Did you have any luck with the PaintType thing? If not could you help by pointing me in the right direction to experiment with the Z commands things as I can't see where that is?
@kevinbarabash here's the specific font I'm using in case you are able to help at all, both the bezier and straight line versions attached Archive.zip .
@timdiacon for me the project has been on hold for some time, i will have to check on this. though i think in the end, i did the "remove the z command" route and baked that into the build flow...
I think this should be fairly easy to implement, I'll have a look at it.