Skip to main content

No project description provided

Project description

OkFonts

Make font metrics predictable on the web. Given a font file, it adjusts vertical metrics so that:

  • CSS font-size: Npx makes capitals exactly N pixels high
  • CSS line-height: 1 makes single-line block elements exactly N pixels high
  • Capitals are perfectly centered within their lines

It does this by setting both UPM and ascender to the font's cap height, and descender to 0. Glyph coordinates are not scaled.

Supports TTF and WOFF2.

Install

uv add okfonts

CLI

uvx okfonts input.ttf -o output.ttf

Programmatic usage

from fontTools.ttLib import TTFont
from okfonts import process

font = TTFont("input.ttf")
process(font)
font.save("output.ttf")

Public proxy

OkFonts includes a proxy server that acts as a drop-in replacement for Google Fonts. It intercepts CSS responses, downloads and processes every referenced font file, and serves the result with rewritten URLs.

A public instance is available at okfonts.matvei.is. Use it as a drop-in replacement for Google Fonts:

<link
  href="https://okfonts.matvei.is/v1/css2?family=Inter&display=swap"
  rel="stylesheet"
/>

Self-hosted proxy

Install with the proxy extra:

uv add 'okfonts[proxy]'

Run:

okfonts-proxy

The proxy exposes two routes:

  • /v1/css2 — proxies CSS requests to Google Fonts
  • /v1/font/{filename} — serves processed font files from cache

To use it, replace fonts.googleapis.com with your proxy host:

<link
  href="https://your-proxy/v1/css2?family=Inter&display=swap"
  rel="stylesheet"
/>

Configuration

Variable Default Description
PORT 3000 Port the proxy listens on
CACHE_DIR .cache Directory for processed fonts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okfonts-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okfonts-0.3.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file okfonts-0.3.0.tar.gz.

File metadata

  • Download URL: okfonts-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for okfonts-0.3.0.tar.gz
Algorithm Hash digest
SHA256 43379826238168a9baaefebf195fcea4c221dfe49e429d6fef131be02965386b
MD5 fb0c70290c071f8800ddbdc1b1aa15fa
BLAKE2b-256 3b4b1877df9ed798391974dfba0f67cb71f1c748d379f3c5823fe95f5997c4a5

See more details on using hashes here.

File details

Details for the file okfonts-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: okfonts-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for okfonts-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd51e88e1d4d791d7caae3713a6a63d7dc4118fd4eeb4890ca162712bc00555c
MD5 605c831cc338389902e38964debdd6c2
BLAKE2b-256 c60228d5a2b56ab82182d25fce2bfaed78f81c6bcf5e5df4384bd11a0203056e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page