A converter that converts standardized TrueType (.ttf) fonts into Bitstream's proprietary "Portable Font Resource" (.pfr) format. This was achieved through referencing FreeType's (somewhat flawed and doesn't even implement DocLock) code and reverse-engineering nstdfp32.dll used in Netscape Navigator 4.
Pass your desired TTF font as one argument, and then your output PFR as another. You can, optionally, specify a custom family name if you wish.
ttf2pfr: TrueType Font (.ttf) to Portable Font Resource (.pfr) Converter
For dynamic font embedding in vintage browsers like Netscape Navigator 4.
Usage:
python ttf2pfr.py <input.ttf> <output.pfr> [font_family_name]
Arguments:
input.ttf Path to the input TrueType font to convert.
output.pfr Path where the compiled PFR font will be written.
font_family_name Optional. Custom font family name. If omitted,
extracted automatically from the TTF name records.
Netscape does not support CSS' @font-face in its (buggy and very broken) CSS implementation. Instead, you must declare fontdef in your HTML. Example:
<link rel="fontdef" src="assets/fonts/vcrmono_ns4.pfr">
Then, optionally declare it in your CSS (careful!):
.vcr-css {
font-family: "VCR OSD Mono", monospace;
font-size: 28px;
}
After that, you can just use it:
<h2>2. VCR OSD Mono Font Test</h2>
<!-- Example via standard Font Tag -->
<p>
<font face="VCR OSD Mono" size="+2">
Font Tag: THIS TEXT SHOULD RENDER IN VCR OSD MONO.
</font>
</p>
<!-- Example via CSS -->
<p class="vcr-css">
CSS Style: THIS TEXT SHOULD RENDER IN VCR OSD MONO.
</p>
Netscape will NOT load .pfr fonts that are not returned with the application/font-tdpfr MIME type. Make sure your server properly returns this and not octet-stream! No modern HTTP servers do this today by default. For NGINX, add this to your nginx.conf:
# Netscape PFR support mapping
types {
application/font-tdpfr pfr;
}
This was Bitstream's security system designed to prevent users from just taking fonts from other sites and using them. It's implemented in the auxillary block data and, while not present in the spec, Netscape requires it to be present. It will silently ignore any font with this data not present.
While Bitstream's spec sheet completely omits any information regarding DocLock, it was discovered through reverse-engineering Netscape's responsible DLL for .pfr fonts (nstdfp32.dll) that a type of 0x8003 and the bytes 00 00 01 00 02 03 will cause Netscape to completely ignore the domain, effectively allowing the fonts to work anywhere and bypassing the system entirely! See sub_100023F0 for more information.
This program—and any future versions—are licensed under the Unlicense license. Please consult the LICENSE file for further information.
