TrueType outlines as ASCII text

Grzegorz Rolek's picture

Does anyone know of a way of storing TrueType outlines as human-readable ASCII text that could be easily translated to and from a 'glyf' table bytecode? Similar to how PostScript Type 1 code can be assembled/disassembled with Type 1 Utilities or Adobe's FDK. There's of course TTX or GLIF, but I myself wouldn't count that, as they don’t read nor play well in standard Unix toolchain and versioning systems.

Karl Stange's picture

Can you offer a more detailed example of your requirements?

Khaled Hosny's picture

If you want 100% round trip conversion, I don’t think there is any (certainly not TTX, which can corrupt some OpenType tables badly).

Grzegorz Rolek's picture

I haven't dug into sfntly before, but as I'm reading briefly through the source, it looks like its dumps are only informative and don't print the actual glyph data.

Karl, it basically would be as simple as that; a plaintext description of data contained in the 'glyf' table that could be compiled and fused into a font binary directly. This would allow for storing and versioning TrueType outlines in a manner similar to PostScript or MetaFont sources. But as Khaled said, there may be no such thing available today, not publicly anyway.

Karl Stange's picture

Are you experimenting with parametric design?

Grzegorz Rolek's picture

No, I would simply like to have some reasonable storage for native TrueType designs. Keeping all in binary is not very practical. But having more options for working on TrueType curves would be much appreciated indeed. It appears that it becomes more and more undervalued these days.

Karl Stange's picture

It appears that it becomes more and more undervalued these days.

Judging by some recent discussions I have seen on the matter I think most people would like to see an easier way of working natively with quadratic beziers for drawing, and a more straightforward approach to working natively with TrueType would benefit everyone working with fonts. There still seems to be a significant amount of misunderstanding and even suspicion about the TrueType format even in the type community, which is worrying.

bbg's picture

UFO and RoboFont ended this kind of discussion, I thought?

Glyphs are stored as text in a UFO and native quad editing is available for no extra charge in RoboFont.

Karl Stange's picture

UFO and RoboFont ended this kind of discussion, I thought?

Entirely possible that I am looking at this the wrong way but below are the text results of the same glyph data as taken from a TrueType file decomposed in TTX and then the same taken from the UFO file [EDIT] (generated with FontForge as I do not currently have access to RoboFont):

TTX:
<TTGlyph name="A" xMin="50" yMin="0" xMax="1698" yMax="1648">
<contour>
<pt x="50" y="1648" on="1"/>
<pt x="1698" y="1648" on="1"/>
<pt x="1698" y="0" on="1"/>
<pt x="50" y="0" on="1"/>
</contour>
<instructions><assembly>
</assembly></instructions>
</TTGlyph>

UFO:

<glyph name="A" format="1">
<advance width="1748"/>
<unicode hex="0041"/>
<outline>
<contour>
<point x="50" y="1648" type="line" smooth="no"/>
<point x="1698" y="1648" type="line" smooth="no"/>
<point x="1698" y="0" type="line" smooth="no"/>
<point x="50" y="0" type="line" smooth="no"/>
</contour>
</outline>
</glyph>

Grzegorz, is the second set of data any easier to parse?

Karl Stange's picture

Also, have you experimented with Microsoft's TTFdump tool?

Grzegorz Rolek's picture

Both TTX and UFO would be same easy or same hard to parse if you like. I just wouldn’t consider UFO a mature format, particularly not a format that would be closely tied to any of the target technologies in the industry, i.e., either PostScript or TrueType. It’s the lowest common denominator between the two and while this can be useful in an early work environment, it makes it bad for fine-tuning and storage.

In fact, TTX would be more adequate for the job, but it’s still a bulky XML/Python combo and the tool itself appears not to be maintained any more. I haven’t had any access to Microsoft’s software lately, so I can’t tell nothing about TTFDump.

Karl Stange's picture

I haven’t had any access to Microsoft’s software lately, so I can’t tell nothing about TTFDump.

There appears to be a Linux distribution as well, either independent of or tied to TeX but I have not been able to get that or the Windows version working.

Khaled Hosny's picture

TeX Live’s ttfdump, is a different utility not related to Microsoft one, and it only dumps TTf files (the tables it understands), but can not compile them back.

Karl Stange's picture

TeX Live’s ttfdump, is a different utility not related to Microsoft one, and it only dumps TTf files (the tables it understands), but can not compile them back.

Thank you, Khaled. The Google searches were getting increasingly confusing!

Theunis de Jong's picture

Grzegorz, in essence TrueType font outlines are points, connected with lines. It's hard to describe that in any "easy readable" way.

Can you make up a sample of what sort of output you'd like to see?
Keep in mind there is a limit to "human readabilty" if you want it to be able to be compiled back into a font as well.

ahyangyi's picture

I think it's worth mentioning that FontForge's format, ".sfd", is plain-text. And FontForge's author also wrote some tools to do diff and merge for .sfd files. Even without the extra utilities, it goes well with Git and diff and is fairly human readable.

However, I don't think converting a font to .sfd and back will generate exactly the same thing...

bbg's picture

"I... wouldn’t consider UFO a mature format... not a format that would be closely tied to any of the target technologies in the industry... the lowest common denominator between PostScript or TrueType... bad for fine-tuning and storage."

It's upside-down day. ;)

Grzegorz Rolek's picture

…in essence TrueType font outlines are points, connected with lines. It's hard to describe that in any "easy readable" way.

Thing is, the way those points are stored in the 'glyf' table is for space efficiency and machine performance. For example, points for all contours are listed together and coordinates of both axes are separated into two different arrays with the bounding box cached up front. Human-readable representation I’m thinking of would just make those lists more sanely structured and formatted, and any redundant data or bytecode-related flags would be derived by the compiler. See:

glyph id simpletype

	instructions
		INSTRUCTIONS

	contour
		point on/offcurve x y
		point on/offcurve x y
		...

	contour
		...

glyph id compoundtype

	instructions
		INSTRUCTIONS

	component id x y transformation round
	component id x y transformation round
	...
...

Nothing fancy, just a file that could be read like code and edited by hand if necessary. FontForge’s .sfd in some skinnier form could do, but a one-to-one recompilation would be uncertain indeed. Thanks for mentioning FontForge’s little utilities, I didn’t know they even exist.

Syndicate content Syndicate content