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.1.1.tar.gz (3.8 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.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: okfonts-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 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.1.1.tar.gz
Algorithm Hash digest
SHA256 c78ec2f808e5bf0c61802bcd9f7528fb32d030cc49632c26fe20e1791e344776
MD5 2e14afdeb9bfbc96982fad248cf4d3c0
BLAKE2b-256 a85385349ba4032f73a2e55e6ed06ea389db75b93b6aca87efa2fde56708034a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: okfonts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d8445e0c3b8aedb5d88ebba826553b0fdaf146a92ad1c7413e73378a2619c86
MD5 f44572302ec70ef269621dd990d878e9
BLAKE2b-256 e79e530b142f59915d012461397e5c427691a2a7dbd31ccc88510b537ff838be

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