Skip to main content

fontsplitta is a command-line tool that splits web fonts and generates CSS.

Project description

fontsplitta

fontsplitta is a command-line tool that splits web fonts and generates CSS.

It creates web fonts that are divided into specific Unicode ranges, similar to Google Fonts.

By properly splitting large fonts such as Japanese fonts, it aims to reduce transfer size and improve user experience.

Requirements

  • Python 3

Getting Started

Install the dependency libraries:

poetry install

Generate unicode_ranges.txt using Google Fonts' CSS:

poetry run fontsplitta get-unicode-ranges-from-google-fonts

Split fonts and generate CSS:

poetry run fontsplitta split FONT_FILE

Using a custom CSS template file

If you want to modify the output CSS, you can create a new font-face.css.template file:

@font-face {
  font-family: "${font_family}";
  font-style: ${font_style};
  font-weight: ${font_weight};
  src: url(http://localhost:8080/output/${font_filename}) format("${font_format}");
  unicode-range: ${unicode_range};
}

Basically, you should use your environment's hostname in the src section.

And then,

poetry run fontsplitta split FONT_FILE --css_template=YOUR_CSS_TEMPLATE

Using custom unicode ranges

If you want to use custom unicode ranges, you can use the --unicode_ranges_file option:

poetry run fontsplitta split FONT_FILE --unicode_ranges_file=YOUR_UNICODE_RANGES_FILE

You can generate the unicode ranges using your web page contents.

Test with local web server

poetry run fontsplitta test-server

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

fontsplitta-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

fontsplitta-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file fontsplitta-0.1.0.tar.gz.

File metadata

  • Download URL: fontsplitta-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.3.0

File hashes

Hashes for fontsplitta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2c65035dc0f63af2998cea1be5ca61f414fcc687f687d7f8bf0f8f66ee6f00a
MD5 01a92521e00432bd9bffca00c2f038e3
BLAKE2b-256 fd983ed206c4b00808a07dd6a5069b0bcf8a6e321ec22219447995404da0f9cc

See more details on using hashes here.

File details

Details for the file fontsplitta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fontsplitta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.3.0

File hashes

Hashes for fontsplitta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85dc3eae7127dbf15007c8383e2be74c0f34ffeff08e3013882570d8ceba109d
MD5 e00f975618b22b3f99bd0bf49a3fa31d
BLAKE2b-256 a34bf3f0d33f04f76d1aef19974792117a7a0b43ebfb1c1384e03ff5ce750469

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