Skip to content

Instantly share code, notes, and snippets.

@yurydelendik
Created March 29, 2013 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurydelendik/5268384 to your computer and use it in GitHub Desktop.
Save yurydelendik/5268384 to your computer and use it in GitHub Desktop.
Converts PDF Type1 data to PFB file
diff --git a/src/fonts.js b/src/fonts.js
index fb5f541..fdde476 100644
--- a/src/fonts.js
+++ b/src/fonts.js
@@ -5514,6 +5514,16 @@ var Type1Font = function Type1Font(name, file, properties) {
this.charstrings = charstrings;
this.data = this.wrap(name, type2Charstrings, this.charstrings,
subrs, properties);
+
+ // creating Type1 binary file
+ properties.pfbFile = 'data:application/x-font-type1;base64,' + btoa(
+ '\x80\x01' + String.fromCharCode(properties.length1 & 255, (properties.length1 >> 8) & 255,
+ (properties.length1 >> 16) & 255, (properties.length1 >>> 24) & 255) + bytesToString(headerBlock) +
+ '\x80\x02' + String.fromCharCode(properties.length2 & 255, (properties.length2 >> 8) & 255,
+ (properties.length2 >> 16) & 255, (properties.length2 >>> 24) & 255) + bytesToString(eexecBlock) +
+ '\x80\x01\x14\x02\x00\x00' +
+ Array(9).join('0000000000000000000000000000000000000000000000000000000000000000\n') +
+ 'cleartomark\r\x80\x03');
};
Type1Font.prototype = {
@yurydelendik
Copy link
Author

Convert to OTF: makeotf -f font.pfb -o font.otf (see FDK; for windows use makeotfexe)

/cc @brendandahl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment