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 from PyPI:

pip install fontsplitta

Generate unicode_ranges.txt using Google Fonts' CSS:

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

Split fonts and generate CSS:

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,

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:

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

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.3.tar.gz (4.8 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.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fontsplitta-0.1.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.9 Linux/6.8.0-1021-azure

File hashes

Hashes for fontsplitta-0.1.3.tar.gz
Algorithm Hash digest
SHA256 afef17c3f166d89a2590dc945e390d4cc768ecad72f4c96e6ff6de47d2d26804
MD5 13661675ac5e7dd041970b24d5f9d641
BLAKE2b-256 3bb8c68a52e8a15432727b2df53f369ff5dc43ee28450dc6860a58356ce39750

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fontsplitta-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.9 Linux/6.8.0-1021-azure

File hashes

Hashes for fontsplitta-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5beb3b686d0a327b767119bd0a81d70331ed1707d71076c87dbe99aaf31aad07
MD5 166b62f11306608481ffd12f1c5cc2b5
BLAKE2b-256 004f6258b10183dd8fabb2fb72e600f03e3861a3cd47c4b39b29a26a2cf01927

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