Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Adobe Font Metrics to recognised filetypes #3731

Merged
merged 4 commits into from Aug 8, 2017
Merged

Add Adobe Font Metrics to recognised filetypes #3731

merged 4 commits into from Aug 8, 2017

Conversation

Alhadis
Copy link
Collaborator

@Alhadis Alhadis commented Jul 23, 2017

Adobe Font Metrics (*.afm files) are a data format for storing character measurements, encoding data, and other PostScript/Type 1-specific metadata. Wikipedia's page on PostScript fonts touches on it briefly:

(AFM files)… contain general font information and font metrics information for the font program. These files are generally used directly only in Unix environments. An AFM file provides both global metrics for a font program and the metrics of each individual character.

The metrics of a multiple master font are described by one AMFM file, which specifies the control data and global font information, plus one AFM file for each of the master designs in the font.

An ACFM file provides information about the structure of a composite font. Specifically, the global metrics of the composite font program and the global metrics of each of its immediately descendent font programs. ACFM file does not associate with a base font, but act as the top-level structure of a composite font. The character metrics of individual characters in the composite font are described completely by one of more associated AFM files.

The formats are sufficiently similar that a compliant parser can parse AFM, ACFM, and AMFM files.

Fundamentally, all three formats are the same for our purposes: they share the same file-extension and perceivable syntax, so I haven't bothered adding *.acfm and *.amfm files as associated extensions. Not that there even are, anyway. I have included them as language aliases, however.

In-the-wild usage

Scrape and logs stashed in the silo, as per usual: Alhadis/Linguist-Silo/tree/afm. Nearly 269,000 results in-the-wild, most of them duplicates. Which doesn't surprise me, considering a good deal of those results point to GhostScript forks/mirrors. GhostScript (the most popular free implementation of Adobe PostScript) distributes free versions of the base 35 PDF fonts in several formats, which includes AFM files.

Origin of samples

Both of the samples I added were converted from TTF files sourced from google/fonts, both released under Apache-friendly licenses:

To be honest, I really don't think it matters, though. AFM files don't contain any glyph information: just the width and heights, spacing adjustments, et al. I erred on the side of caution anyway. GhostScript's fonts are released under the GNU Affero License, so... suffice to say that was a no-go.

@pchaigno
Copy link
Contributor

The 2 sample files are huge and will likely increase samples.json's size in memory. Couldn't we reduce them by removing similar chunks of code?

@Alhadis
Copy link
Collaborator Author

Alhadis commented Jul 23, 2017

HAH! I looked at their filesizes before pushing and thought 416 KBs and 161 KBs were reasonable amounts. Totally lost my sense of scale watching 111 MBs of search results being pulled in...

Will fix, hang on.

@Alhadis
Copy link
Collaborator Author

Alhadis commented Jul 23, 2017

Three times now I've accidentally written GFM (GitHub-flavoured Markdown) instead of AFM. Ugh.

All done!

This is just an attempt to get the build passing, after it failed for no
particular reason (maybe Travis thought I needed a shave, or something).
@Alhadis Alhadis merged commit f1daf61 into master Aug 8, 2017
@Alhadis Alhadis deleted the afm branch August 8, 2017 08:30
@lildude lildude mentioned this pull request Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants