Fixmore fontchain_lint issues

pull/378/head
Rod S 2021-12-23 17:44:08 -08:00
parent f46188ee49
commit d0bcf99532
6 changed files with 25 additions and 6 deletions

View File

@ -16,6 +16,6 @@ contains emojicompat metadata.
```shell ```shell
# Assumed to be in a python3 environment with requirements.txt fulfilled # Assumed to be in a python3 environment with requirements.txt fulfilled
python postproc.py build/NotoColorEmoji-noflags.ttf \ python colrv1_postproc.py colrv1/build/NotoColorEmoji-noflags.ttf \
PATH_TO/NotoColorEmojiCompat.ttf PATH_TO/NotoColorEmojiCompat.ttf
``` ```

View File

@ -1 +0,0 @@
nanoemoji >= 0.9.12 # we need latest spec support

View File

@ -5,6 +5,9 @@ For now substantially based on copying from a correct bitmap build.
""" """
from absl import app from absl import app
from fontTools import ttLib from fontTools import ttLib
import map_pua_emoji
from nototools import add_vs_cmap
from nototools import unicode_data
def _is_colrv1(font): def _is_colrv1(font):
@ -46,6 +49,13 @@ def _copy_names(colr_font, cbdt_font):
# Amendments # Amendments
_set_name(name_table, 10, "Color emoji font using COLRv1.") _set_name(name_table, 10, "Color emoji font using COLRv1.")
_set_name(name_table, 11, "https://github.com/googlefonts/noto-emoji") _set_name(name_table, 11, "https://github.com/googlefonts/noto-emoji")
_set_name(name_table, 12, "https://github.com/googlefonts/noto-emoji")
# CBDT build step: @$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua"
def _add_vs_cmap(colr_font):
emoji_variants = unicode_data.get_unicode_emoji_variants() | {0x2640, 0x2642, 0x2695}
add_vs_cmap.modify_font("COLRv1 Emoji", colr_font, "emoji", emoji_variants)
def main(argv): def main(argv):
@ -63,7 +73,12 @@ def main(argv):
_copy_emojicompat_data(colr_font, cbdt_font) _copy_emojicompat_data(colr_font, cbdt_font)
_copy_names(colr_font, cbdt_font) _copy_names(colr_font, cbdt_font)
colr_font.save('../fonts/Noto-COLRv1-noflags.ttf') # CBDT build step: @$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua"
map_pua_emoji.add_pua_cmap_to_font(colr_font)
_add_vs_cmap(colr_font)
colr_font.save('fonts/Noto-COLRv1-noflags.ttf')
if __name__ == "__main__": if __name__ == "__main__":

Binary file not shown.

View File

@ -50,9 +50,7 @@ def get_glyph_name_from_gsub(char_seq, font):
return None return None
def add_pua_cmap(source_file, target_file): def add_pua_cmap_to_font(font):
"""Add PUA characters to the cmap of the first font and save as second."""
font = ttLib.TTFont(source_file)
cmap = font_data.get_cmap(font) cmap = font_data.get_cmap(font)
for pua, (ch1, ch2) in itertools.chain( for pua, (ch1, ch2) in itertools.chain(
add_emoji_gsub.EMOJI_KEYCAPS.items(), add_emoji_gsub.EMOJI_FLAGS.items() add_emoji_gsub.EMOJI_KEYCAPS.items(), add_emoji_gsub.EMOJI_FLAGS.items()
@ -61,6 +59,12 @@ def add_pua_cmap(source_file, target_file):
glyph_name = get_glyph_name_from_gsub([ch1, ch2], font) glyph_name = get_glyph_name_from_gsub([ch1, ch2], font)
if glyph_name is not None: if glyph_name is not None:
cmap[pua] = glyph_name cmap[pua] = glyph_name
def add_pua_cmap(source_file, target_file):
"""Add PUA characters to the cmap of the first font and save as second."""
font = ttLib.TTFont(source_file)
add_pua_cmap_to_font(font)
font.save(target_file) font.save(target_file)

View File

@ -1,2 +1,3 @@
fonttools>=4.7.0 fonttools>=4.7.0
notofonttools>=0.2.16 notofonttools>=0.2.16
nanoemoji >= 0.9.12 # we need latest spec support