Skip to main content

Codepoint definitions for the Google Fonts subsetter

Project description

gfsubsets

This is the collection of nam files (codepoint subsets) that are used to subset fonts before serving on the Google Fonts CSS API.

The subset files

The subset definitions are contained in two forms; the "editable" definitions are found in the subsets-input directory, and the machine readable defitions can be found in Lib/gfsubsets/data.

The machine readable files consist of text files with one Unicode codepoint (a hexadecimal number beginning with 0x) on each line; everything after the codepoint is a comment. Blank lines and comment lines beginning # are ignored.

The editable definitions are similar, but for convenience allow the following "directives":

  • Two codepoints separated by .. denote an (inclusive) range; all codepoints within the range are included.
  • The symbol - before a codepoint or range excludes it from the output set.
  • The directive @include(filename) includes the codepoints in filename.
  • The directive @block(XYZ) includes the codepoints in the Unicode block named XYZ.
  • The directive @script(XYZ) includes all codepoints with either the Unicode Script property equal to XYZ or the ScriptExtensions property equal to XYZ

These editable definitions are turned into their machine-readable equivalents using the script scripts/preprocess_namfile.py.

Python interface

This repository also includes the Python module gfsubsets which provides an interface to these subset definitions. It exports the following functions:

  • CodepointsInFont(filename): Lists the Unicode codepoints supported by the font
  • ListSubsets(): Returns the name of all defined subsets.
  • SubsetsForCodepoint(cp): Returns the names of all subsets including the codepoint.
  • SubsetForCodepoint(cp): Returns the name of the "most relevant" subset including the codepoint.
  • CodepointsInSubset(subset): Returns a set of codepoints included in the subset.
  • SubsetsInFont(filename, min_pct, ext_min_pct): Returns the name of subsets "well" supported by a font.

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

gfsubsets-2024.2.5.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

gfsubsets-2024.2.5-py3-none-any.whl (400.7 kB view details)

Uploaded Python 3

File details

Details for the file gfsubsets-2024.2.5.tar.gz.

File metadata

  • Download URL: gfsubsets-2024.2.5.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for gfsubsets-2024.2.5.tar.gz
Algorithm Hash digest
SHA256 83d4312dadc1d4c313b3e8e68f80b2272499454d33a0535875b399c078ca3da4
MD5 0b368a3c2f77eece071450f1811c1f0b
BLAKE2b-256 66f5f6227140b4bec5cffb7fe4fe69dec3aced7c758ebc48cc44009a1e91388c

See more details on using hashes here.

File details

Details for the file gfsubsets-2024.2.5-py3-none-any.whl.

File metadata

  • Download URL: gfsubsets-2024.2.5-py3-none-any.whl
  • Upload date:
  • Size: 400.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for gfsubsets-2024.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4471448f92bc594ac48da8745e5dd32025f76ed047247b13edf714130d6320
MD5 a5ce52f9b1da451fd840d16713d42a5f
BLAKE2b-256 ffea0767a34c25bab240d34a4bf01bd9f6f501531efa745e473129d492639ed2

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