Determine whether a font file is OpenType format or TrueType format
Yeshurun Kubi
Posts: 14
We are working on a program that needs to distinguish between OpenType fonts to TTF fonts [like the font list InDesign has], but we could not mannge to find the right way to determine if a given font is OpenType format file.
I have found some discussions about it on Stackoverflow - like: here and here and here.
And it seems that they don't have the right answer, cause it does not depend on file extension, for there can be a TTF file that has opentype format.
So my question is - how can i make my program distinguish between OpenType font file to TrueType font file.
I have found some discussions about it on Stackoverflow - like: here and here and here.
And it seems that they don't have the right answer, cause it does not depend on file extension, for there can be a TTF file that has opentype format.
So my question is - how can i make my program distinguish between OpenType font file to TrueType font file.
0
Comments
-
An in-depth discussion about TrueType versus OpenType can be found here:Based on the specifications, all TrueType fonts are also OpenType fonts, but only a very small percentage of OpenType fonts are also TrueType fonts.Another thing you should be aware of is the fact people sometimes talk about TrueType fonts while they actually refer to OpenType fonts based on TrueType outlines.1
-
Depends on what you want to do with that information, you can either check the first four bytes or check the presence of CFF or CFF2 tables vs. glyf & loca tables.
3 -
The first four bytes indicate whether a font is:- OpenType font that contains TrueType outlines- OpenType font containing CFF data- Something elseIt doesn't distinguish between- TrueType fonts- OpenType fonts that contain TrueType outlinesIf a font contains TrueType based outlines (thus contains both glyf and loca tables) and doesn't contain OpenType feature related tables (e.g. DSIG, GDEF, GSUB, GPOS) then it is most likely a TrueType font.2
-
TrueType and OpenType can mean a lot of things.What do you need to differentiate: the outline format, the presence of OpenType layout extension, or both?2
-
Khaled Hosny said:Depends on what you want to do with that information, you can either check the first four bytes or check the presence of CFF or CFF2 tables vs. glyf & loca tables.Erwin Denissen said:...Based on the specifications, all TrueType fonts are also OpenType fonts, but only a very small percentage of OpenType fonts are also TrueType fonts....
This makes me figure that the distinguish we need is between fonts that have opentype features to other fonts that have no features, for it looks like designers that want to use a font, might prefer those that has opentype features, and that what makes them think "this is an opentype font".Denis Moyogo Jacquerye said:TrueType and OpenType can mean a lot of things.What do you need to differentiate: the outline format, the presence of OpenType layout extension, or both?
Though i am not sure but it might be the way InDesign do that on there font list.
0 -
I'm pretty sure InDesign is deciding which icon to display only on the basis of which outline type is used, not whether the font contains OpenType Layout features. There are fonts identified as TrueType in the InDesign menu that I know for a fact have OTL features.
Back in 1997, when OpenType was announced, the only distinction Microsoft could come up with between a TrueType font and an OpenType font with TT outlines was the presence of a DSIG table, since the OTL tables were all considered optional. So technically, one can have a TTF with OTL tables that is not an OpenType font.
And of course it is possible to make a CFF font with no OTL features, and InDesign will dutifully assign it the OT icon.
It sounds like for your purposes you're going to want to check for the presence of a GSUB table. That's the most likely indicator that a font contains some kind of glyph processing beyond the cmap table.
2 -
For Wakamai Fondue I check for the presence of a glyf table to call it a TrueType font, and if it's not there I call it an OpenType/CFF font.
The comment above that code says "TODO: is this oversimplified?", and judging by the comments in this thread the answer to that is "yes".1 -
You need to ask WHY you want to make a distinction.
For many needs, what Roel does, and what Adobe does, is useful: distinguish between the two different kinds of outlines.
I do not find the approach Windows uses to ever be helpful.
You could try to make some kind of feature-based distinction instead. Depends on your audience and needs, that might be fine. For myself, I don’t find it helpful to have two different fonts with different outline formats to get the same icon/indicator. But it depends on your audience and their needs.2 -
InDesign CS6 shows a TTF with OT tables with TT 'glyf' outlines as OT font if it has a DSIG, and as TT font it it doesn’t have a DSIG.
1 -
My inclination, in terms of providing accurate and useful information is not to make a distinction between TrueType and OpenType, but instead between TTF and CFF (outline format distinction) and then indicate whether it is an OpenType Layout font (contains GSUB/GPOS tables.
6 -
We dropped the O v TT icons in Office as they really were not helpful. Previously we looked for CFF and/or DSIG table. An alternative would have been to base the icon on CFF and / or GPOS, GSUB.4
-
Based on the specifications, all TrueType fonts are also OpenType fonts, but only a very small percentage of OpenType fonts are also TrueType fonts.
This is not right, in my opinion.All TrueType fonts are valid as OpenType fonts, but that is because OpenType is mostly a superset of TrueType; and a huge percentage of OpenType fonts are also TrueType fonts, and called "TrueType flavor" OpenType fonts.
The OpenType fonts that are not TrueType fonts are the "CFF flavor" ones.
I believe that a simple heuristic to answer Yeshurun Kubi's question, "how can i make my program distinguish between OpenType font file to TrueType font file" is by checking for the presence of either a CFF or GSUB table - if either is present, its OpenType, and if neither is present, its TrueType.3 -
Dave Crossland said:and a huge percentage of OpenType fonts are also TrueType fonts, and called "TrueType flavor" OpenType fonts.These TrueType flavor OpenType fonts (I refer to them as OpenType fonts with TrueType based outlines), shouldn't be called TrueType fonts, unless they have no OpenType features, no DSIG table, no license description, and an OS/2 version of 0 or 1. That is way I think only a small percentage of OpenType fonts is also considered to be TrueType fonts.3
-
How one diagrams the relationships of the various sfnt font flavours depends on what aspect of those relationships one considers important. I tend to think in terms of outline format and glyph processing capability:
sfnt fonts<br>——TrueType outlines<br>————non-smart TTF (no glyph processing tables)<br>————Apple smart TTF (GX/AAT glyph processing)<br>————Microsoft smart TTF (TrueType Open / OpenType glyph processing)<br>——CFF outlines<br>————non-smart CFF (PDF embedding format)<br>————smart CFF (OpenType glyph processing)
2 -
Nice how you 'repurpose' DecoType's notion of "smart", backport it to refer to OpenType Layout, when 'smart' in DecoType-speak refers to something that OTL is not.
Your 'glyph processing' is not exactly exact, by the way, as 'GX/AAT glyph processing' indicates, with 'GX' referring to interpolation of glyphs' outlines and 'AAT' referring to layout or positioning of glyphs.
What I find striking, given above attempts to clarify the meaning of 'OpenType', is just how cleverly vague the term 'OpenType' is, and has been since day one, which makes me wonder if this is intentionally so. For illustration: How to express that a font uses either glyf/loca or CFF[2] tables for outline description – but addresses a different layout technology? Correctly speaking, it would be something like 'based on standard sfnt font data structure', but then ... explain 'sfnt' to a lay or even type designer audience ... so one inevitably needs to resort to a better known term like 'TrueType based' or 'OpenType based'. Yet 'TrueType' most likely bears the connotation of glyf/loca outline description while 'OpenType' is associated with OTL and 'features' in particular. But then, the ambiguity of the data format's (or data formats') name (or names) reflects the mess, or more politely: diversity, of data that one may find inside, so it may be considered appropriate.
0 -
Nice how you 'repurpose' DecoType's notion of "smart", backport it to refer to OpenType Layout, when 'smart' in DecoType-speak refers to something that OTL is not.
The term 'smart font' was common in the introduction of OpenType twenty years ago. I don't recall, but it is quite possible that the term was also used around the introduction of GX fonts. SIL use the term also in reference to their Graphite glyph processing, which I should have thought to include in my diagram. DecoType doesn't have a monopoly on the use of the term or on its interpretation.Your 'glyph processing' is not exactly exact, by the way, as 'GX/AAT glyph processing' indicates, with 'GX' referring to interpolation of glyphs' outlines and 'AAT' referring to layout or positioning of glyphs.Initially, AAT was simply part of the larger Quickdraw GX, which was never limited to the interpolation of glyph outlines. When the technology was presented at the ATypI conference in 1994, the term AAT was never used: the font format side of the technology including both interpolation and glyph processing was presented as 'GX Fonts', which is also the name under which they were developed and marketed by Linotype. After Quickdraw GX failed, the term GX became verboten at Apple — literally: when Steve Jobs returned to Apple, he said he never wanted to hear the term mentioned again —, and AAT was salvaged under that name. It is only recently that the term GX has come back into use, this time to refer specifically to the outline interpolation model. So I used the term 'GX/AAT' to indicate the glyph processing model that originated at Apple in those technologies of the early 1990s.
I don't think the vagueness of the meaning of the term 'OpenType' is intentional; rather, it is the evolved outcome of the fact that the most distinctive aspects of the format are all optional tables. The name was a compromise, because originally it had been TrueType Open, but when Adobe asked for CFF to be incorporated into the format a new name was needed to indicate that it wasn't just TrueType. Then the problem became how to distinguish between a TrueType font and an OpenType font for trademark purposes. TrueType is an Apple trademark; OpenType is a Microsoft trademark. So when does the MS trademark apply to a font? When the format was first published, the distinction was made based on the presence of a DSIG table, since that was at that time defined as the only new table in the OpenType format that wasn't optional. So there was a definition of OpenType for legal purposes that ended up being completely irrelevant to the use of the term in practice by font makers and users.
6 -
The term 'smart font' was common in the introduction of OpenType twenty years ago. I don't recall, but it is quite possible that the term was also used around the introduction of GX fonts. SIL use the term also in reference to their Graphite glyph processing, which I should have thought to include in my diagram. DecoType doesn't have a monopoly on the use of the term or on its interpretation.
The art of referring to far-away precedence when actual precedence is much closer.
As to GX/AAT, I am aware of all this, the old QuickDraw brochure still sits somewhere on one of my bookshelves. But history does not really help with today's 'define the format' effort. There is no monolithic QuickDraw GX plus TrueType GX any more (where outline description, outline variation, line layout etc are part and parcel), as opposed to a monolithic OpenType with Microsoft OpenType Layout technology inside (TrueType+ but unfortunately Adobe brought CFF plus some other tables to the table too, when again one term ended up referring to more than just one specific aspect of it). Things are more fragmented now, and separate ingredients need to be told apart in a meaningful way, ideally by category (outline description? outline scaling? outline interpolation/variation? layout technology?), to make an at least halfway precise description possible.
To allow for more precision, a chart better be structured by way of categories, rather than a list (even if hierarchical):carrier format:<br>— sfnt<br>— ?<br>outline data:*<br>— bezier, cubic<br>— bezier, quadratic<br>— ? (cf font format history)<br>outline tables:*<br>— CFF (alternatively: CFF2)<br>— glyf/loca (additionally: -var)<br>— ? (cf font format history)<br>layout tables†:<br>— AAT's tables<br>— ACE's tables<br>— OTL's tables<br>— SIL's tables<br>— ?
This allows to choose, per each category, without a risk to make or evoke implicit assumptions about any other category.
* Note how I keep outline data and outline table separate. E.g. URW stored IK, bezier, etc data (almost) the same way. E.g. it has been discussed to store cubic bezier data the same way as quadratic bezier data, in glyf/loca tables.
† Including glyph substitution and positioning.
[Now this is completely outside of the scope of the original question.]
0 -
Fun fact. The alleged earlier uses of ‹smart› – for OT, for GX – do not seem to exist. I re-read the QuickDraw GX brochure of 1992 and could not find a single occurrence. (This brochure is striking in that it lacks the hyperbole that is so typical for Apple PR today.) No occurence in the announcement of and early information on OT either. (OT-related PR repeatedly speaks of ‹Advanced Typography› though.)
0 -
Some of us were there.
As I wrote earlier, I don't recall whether the term was used around the time that GX fonts were announced, but by the time OpenType arrived there was a need to distinguish between fonts with glyph processing capabilities (smart) and those without (dumb). This was common parlance when talking with folk in the relevant technical teams at Microsoft and Adobe, and the term is intuitive enough — and non-specific in terms of particular technology — that I've never found anyone to be confused as to what it meant. When SIL announced Graphite at the Unicode conference, they used the term 'a smart font technology' and everyone understood it to refer to parallel Graphite to AAT and OpenType.3 -
If you say so.
1 -
I think that having “smart fonts” in the titles of talks at both the major type conferences of the time is strong evidence that the terms was in general use in 2002.I can second John’s recollection that talking about smart fonts became common lingo during the move to OpenType. Many of us involved in creating and promoting the technology used the phrase on a regular basis. I think it started to come into use about 20 years ago (late 90s) as OpenType started to ramp up.The title of my presentation at TypeCon on 13 July 2002 was “Smart fonts are dead! Long live smart fonts!” (subtitle: Why OpenType is succeeding where GX didn’t)Paul Nelson’s presentation at ATypI in September 2002 was titled “OpenType and other smart font technologies for multiple scripts.”A 2004 “Graphite Overview” presentation by Sharon Correll and Peter Constable, which I have a copy of, talks about “smart font behaviors” in the notes for the title slide.2
-
And here's SIL not only using but defining the term in mid-1996:TrueType Open (TTO) is a Microsoft designed extension of the TrueType technology that provides facilities such as contextual substitution and glyph positioning. We use the term “smart font” to describe technologies such as TTO and Apple’s QuickDraw GX fonts because there is the ability to encode information into the font itself that modifies the way each character is displayed based on its context.
from NRSI Update #1 – July 1996
I think it is quite possible that SIL personnel first started using the term and the rest of us picked it up from there.
2 -
Thanks for both of these references! (I was aware of SIL. My hunch was with GX and OT in particular.)
0 -
We in SIL were using the term as early as 1992 specifically to describe the things that GX would allow. It may be that the term came out of discussions with Apple, but I'm not sure.1
-
John Hudson said:My inclination, in terms of providing accurate and useful information is not to make a distinction between TrueType and OpenType, but instead between TTF and CFF (outline format distinction) and then indicate whether it is an OpenType Layout font (contains GSUB/GPOS tables.0
-
Technically, a TTF font can have the .otf extension if it has GSUB/GPOS tables. I can't remember why at the moment, but few do in practice.2
-
Claudio Piccinini said:Hi John, is this what generally is explained as having a "Postscript flavored" and “Truetype flavored" font? Aside from Opentype features, doesn’t the first have a "OTF" extension and the second a "TTF" one?The file extension has no meaning; you need to look inside the file to determine what it contains. If you don't believe me, do change the file extension from an OpenType font file that contains CFF based outlines from .otf to .ttf.It remains an OpenType font with CFF based outlines, but you can still install it in Windows.2
-
Hi John, is this what generally is explained as having a "Postscript flavored" and “Truetype flavored" font?
Yes, although technically CFF is not actually PostScript in the sense that Type 1 fonts were.Aside from Opentype features, doesn’t the first have a "OTF" extension and the second a "TTF" one?That’s just a convention, and one that mainly exists so that TTF OpenType fonts could be backwards compatible with older versions operating systems that didn’t recognise the .otf extension. There isn’t really a need for the convention any more.
2 -
John Hudson said:Hi John, is this what generally is explained as having a "Postscript flavored" and “Truetype flavored" font?
Yes, although technically CFF is not actually PostScript in the sense that Type 1 fonts were.Aside from Opentype features, doesn’t the first have a "OTF" extension and the second a "TTF" one?That’s just a convention, and one that mainly exists so that TTF OpenType fonts could be backwards compatible with older versions operating systems that didn’t recognise the .otf extension. There isn’t really a need for the convention any more.
As far as the convention goes, technically a font could be recognized by older OSs by merely changing the extension at desktop level?0 -
Erwin Denissen said:Claudio Piccinini said:Hi John, is this what generally is explained as having a "Postscript flavored" and “Truetype flavored" font? Aside from Opentype features, doesn’t the first have a "OTF" extension and the second a "TTF" one?The file extension has no meaning; you need to look inside the file to determine what it contains. If you don't believe me, do change the file extension from an OpenType font file that contains CFF based outlines from .otf to .ttf.It remains an OpenType font with CFF based outlines, but you can still install it in Windows.0
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 798 Font Technology
- 1K Technique and Theory
- 617 Type Business
- 444 Type Design Critiques
- 541 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 483 Typography
- 301 History of Typography
- 114 Education
- 68 Resources
- 498 Announcements
- 79 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 269 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports