GitXplorerGitXplorer
g

nanoemoji

public
239 stars
19 forks
56 issues

Commits

List of commits on branch main.
Unverified
fbd1a35916c2f22804a6139992d07e74480a9209

tools/colr2svg.py: fix import of colr_to_svg module

aanthrotype committed 6 months ago
Unverified
ed1155c6647c64ace4b1309a19b61714c6f512b5

[reorder_glyphs] updated link to public doc

aanthrotype committed 6 months ago
Verified
fb4b0b3e10f7197e7fe33c4ae6949841e4440397

Merge pull request #462 from googlefonts/drop-py37

aanthrotype committed a year ago
Verified
bf04a59c2e6303376bfbf690a51c280443f5ec2e

Revert "Merge pull request #452 from CyberTailor/main"

aanthrotype committed a year ago
Verified
0582c33b386957fc4bdd580c207e3fa71e69e5a5

ci: no longer test py37, test py310 and py311 too

aanthrotype committed a year ago
Verified
99885bfdd0314f583c8712ba785f1759f8d40a87

Drop support for EOL Python 3.7, require >= 3.8

aanthrotype committed a year ago

README

The README file for this repository.

CI Build Status PyPI pyup

nanoemoji

A wee tool to build color fonts, including the proposed COLRv1. Relies heavily on Skia via picosvg, as well as resvg to rasterize SVG to PNG for the bitmap color formats.

For example, to build a COLRv1 font with a focus on handwriting do the following in a venv:

pip install -e .
nanoemoji --helpfull
nanoemoji --color_format glyf_colr_1 $(find ../noto-emoji/svg -name 'emoji_u270d*.svg')

Requires Python 3.8 or greater.

Color table support

Format Support Notes
COLRv1 Yes x-glyph reuse
COLRv0 Yes x-glyph reuse (limited), no gradients
SVG Yes x-glyph reuse
sbix Yes Only for Mac Safari due to https://github.com/harfbuzz/harfbuzz/issues/2679#issuecomment-1021419864. Only square bitmaps. Uses resvg.
CBDT Yes Only square bitmaps. Uses resvg.

Adding color tables to existing fonts

⚠️ under active development, doubtless full of bugs

Given at least one vector color table (COLR or SVG) the other vector color table and bitmap table(s) can be generated:

# Adds COLR to a font with SVG and vice versa
maximum_color my_colr_font.ttf

# Adds COLR to a font with SVG and vice versa, and generates a CBDT table
maximum_color --bitmaps my_colr_font.ttf

The intended result is a font that will Just Work in any modern browser:

Color table Target browser Notes
COLR Chrome 98+ https://developer.chrome.com/blog/colrv1-fonts/
SVG Firefox, Safari
CBDT Chrome <98 Only generated if you pass --bitmaps to maximum_color

Note that at time of writing Chrome 98+ prefers CBDT to COLR. Same for any environment, such as Android, that relies on Skia, which in turns depends on FreeType to parse color tables (cf. Skia's issue 12945 and FreeType's issue 1142). Also CBDT is huge. So ... maybe take the resulting font and subset it per-browser if at all possible. Wouldn't it be nice if Google Fonts did that for you?

Releasing

See https://googlefonts.github.io/python#make-a-release.

QA

To help confirm valid output nanoemoji can optionally perform image diffs between browser rendering of the original SVGs and rendering from the compiled font.

Chrome must be installed in the normal location.

Usage:

# Get some svgs to play with
git clone --recursive git@github.com:googlefonts/color-fonts.git

# Now run nanoemoji, render some hands, and see how we do!
# https://rsheeter.github.io/android_fonts/emoji.html?q=u:270b
nanoemoji --gen_svg_font_diffs \
	$(find color-fonts/font-srcs/noto-emoji/svg -name 'emoji_u270b*.svg')