Prepare Fonts for the Web Using FontForge
Preparing a font for web distribution using FontForge involves cleaning vector outlines, validating font metrics, standardizing metadata, and exporting the glyphs into compressed, web-compatible formats like WOFF and WOFF2. Following these steps ensures your web font renders crisply across all screens, maintains small file sizes for fast page loading, and functions consistently across various web browsers.
1. Open and Clean Up Vector Outlines
Start by opening your source font file (typically .otf
or .ttf) in FontForge. Web fonts perform best when glyph
outlines are simplified and clean to keep file sizes minimal.
- Select all glyphs by pressing
Ctrl + A(orCmd + Aon macOS). - Navigate to Element > Overlap > Remove Overlap to merge intersecting paths and prevent rendering artifacts.
- Go to Element > Simplify > Simplify to reduce unnecessary control points while preserving the intended shape.
- Run Element > Correct Direction to ensure that outer paths run clockwise and cutouts (inner paths) run counterclockwise, which is essential for proper browser rasterization.
2. Snap Points to the Pixel Grid
Non-integer coordinates cause rendering issues and inflate file sizes. To fix this:
- With all glyphs selected, go to Element > Round > To Int. This snaps all control points and handles to whole integer values, ensuring cleaner rendering and better compression.
3. Apply Hinting for Screen Display
Hinting instructs web browsers how to align vector paths with physical screen pixels, particularly at smaller font sizes on low-resolution displays.
- Select all glyphs and choose Hints > AutoHint.
- If your font is PostScript-based (CFF/OTF), navigate to Hints > Auto Counter to optimize internal glyph spaces.
4. Review and Set Font Information
Browsers rely heavily on metadata to properly group font families, styles, and weights in CSS.
- Navigate to Element > Font Info.
- Under the PS Names tab, verify that the Fontname, Family Name, and Weight fields are accurately defined without spaces in the technical names.
- Under the OS/2 tab, set the weight class (e.g., 400
for Regular, 700 for Bold) and check your vertical metrics
(
Ascent,Descent, andLineGap) to prevent inconsistent line-heights across different operating systems. - Under the TTF Values tab, ensure the embedding licensing restrictions are set appropriately for web distribution.
5. Validate the Font
Before exporting, check the font for technical errors:
- Go to Element > Validation > Validate.
- Review the report and resolve critical errors such as missing extrema points, self-intersecting paths, or missing unicode values.
6. Generate Web Font Formats
Modern web browsers primarily require WOFF2 (offering the best compression) and WOFF (as a fallback for older environments).
- Go to File > Generate Fonts.
- In the export dialog, select Web Open Font Format (WOFF) from the dropdown and save.
- Repeat the process, selecting Web Open Font Format 2 (WOFF2) from the dropdown.
- If WOFF2 is not available in your build of FontForge, export a
standard OpenType (
.otf) or TrueType (.ttf) file and convert it using command-line tools like Google’swoff2_compress.
7. Deploy via CSS
Once generated, place the .woff2 and .woff
files on your web server and reference them using a standard
@font-face rule in your stylesheet:
@font-face {
font-family: 'YourFontName';
src: url('yourfont.woff2') format('woff2'),
url('yourfont.woff') format('woff');
font-weight: 400;
font-style: normal;
font-display: swap;
}