From 9255d65b6d99e1dc5ca7b444466d71a3c86db4c7 Mon Sep 17 00:00:00 2001 From: Thatchapon Unprasert Date: Sun, 31 Dec 2023 10:10:01 +0700 Subject: [PATCH] Some updates --- CAVEATS.md | 7 ++-- facebook/facebook-native.sh | 33 ++++++++++++++++++ facebook/facebook.py | 23 +++++++++---- fluentui/fluentui.py | 2 +- noto-emoji-cursed/noto-emoji-cursed.py | 46 ++++++++++++++++++++++++++ noto-emoji-cursed/noto-emoji-cursed.sh | 27 +++++++++++++++ 6 files changed, 126 insertions(+), 12 deletions(-) create mode 100755 facebook/facebook-native.sh create mode 100644 noto-emoji-cursed/noto-emoji-cursed.py create mode 100755 noto-emoji-cursed/noto-emoji-cursed.sh diff --git a/CAVEATS.md b/CAVEATS.md index 1abfc11..3aae2d4 100644 --- a/CAVEATS.md +++ b/CAVEATS.md @@ -8,7 +8,7 @@ Missing emojis or limitations of each non-Apple themed font will be listed here. ## Facebook Emoji -- Unicode 14.0 only. +- Nothing of significant. ## FluentUI Emoji @@ -20,11 +20,10 @@ Missing emojis or limitations of each non-Apple themed font will be listed here. ## JoyPixels Emoji -- Unicode 14.0 only. +- Nothing of significant. ## OpenMoji Emoji -- Unicode 14.0 only. - Couple emojis of different skins will not share the same hair color as it seems so in the original OpenMoji. In my opinion, this is better because why would two people of different races always share the same hair color? ## Samsung One UI Emoji @@ -39,7 +38,7 @@ Missing emojis or limitations of each non-Apple themed font will be listed here. ## Twitter Twemoji -- Unicode 14.0 only. +- Nothing of significant. ## WhatsApp Emoji diff --git a/facebook/facebook-native.sh b/facebook/facebook-native.sh new file mode 100755 index 0000000..e12896d --- /dev/null +++ b/facebook/facebook-native.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -e + +APPLE_FONT_NAME=AppleColorEmoji@2x +NAME=facebook +FONT_NAME=NotoColorEmoji +ASSETS=../../facebook-emojis/images/96 + +../image-sizes.sh false + +cp -r $ASSETS/ images/96 + +echo "Extracting font..." +ttx -q -f -z extfile $FONT_NAME.ttf +ttx -q -f -s -t GSUB $FONT_NAME.ttf + +echo "Resizing and optimizing PNGs..." +mogrify -resize 96x96 -path images/96 bitmaps/strike0/*.png +../resize.sh false false false +rm -rf bitmaps + +mkdir -p extra/images/96 +cp extra/original/*.png extra/images/96 +../get-assets.sh facebook + +python3 $NAME.py ../apple/${APPLE_FONT_NAME}_00.ttf $FONT_NAME.ttf $FONT_NAME.G_S_U_B_.ttx +python3 $NAME.py ../apple/${APPLE_FONT_NAME}_01.ttf $FONT_NAME.ttf $FONT_NAME.G_S_U_B_.ttx + +otf2otc ${APPLE_FONT_NAME}_00.ttf ${APPLE_FONT_NAME}_01.ttf -o $NAME.ttc +rm -f *_00.ttf *_01.ttf + +echo "Output file at $NAME/$NAME.ttc" diff --git a/facebook/facebook.py b/facebook/facebook.py index c9ccbaf..b3455db 100644 --- a/facebook/facebook.py +++ b/facebook/facebook.py @@ -3,13 +3,18 @@ sys.path.append('..') from shared import * +from shared_lig import * # input: font ttf - ttf = sys.argv[1] +bttf = sys.argv[2] +bgsubttx = sys.argv[3] f = ttLib.TTFont(ttf) +lig = Lig(f, bttf, bgsubttx) +lig.build() + def norm_name(name: str): name = base_norm_name(name) if '20e3' in name or name in signs: @@ -34,13 +39,17 @@ def facebook_name(name: str): continue name = base_norm_variants(name) name = base_norm_special(name) - name = facebook_name(name) - path = f'images/{ppem}/{name}.png' - if not os.path.exists(path) or name.startswith('1f491') or name.startswith('1f48f'): - path = f'extra/images/{ppem}/{name}.png' + o_name = facebook_name(name) + name = lig.norm_name(name) + name = lig.get_glyph_name(name) + path = f'images/{ppem}/{o_name}.png' + if not os.path.exists(path) or name.startswith('1f491') or o_name.startswith('1f48f'): + path = f'extra/images/{ppem}/{o_name}.png' if not os.path.exists(path): - name = name.replace('-', '_') - path = f'extra/images/{ppem}/{name}.png' + o_name = o_name.replace('-', '_') + path = f'extra/images/{ppem}/{o_name}.png' + if not os.path.exists(path): + path = f'images/{ppem}/{name}.png' glyph.imageData = get_image_data(path) if not os.path.exists('../.test'): diff --git a/fluentui/fluentui.py b/fluentui/fluentui.py index 0c6767a..a5148d6 100644 --- a/fluentui/fluentui.py +++ b/fluentui/fluentui.py @@ -29,7 +29,7 @@ '1f91d_1f3fb', '1f91d_1f3fc', '1f91d_1f3fd', '1f91d_1f3fe', '1f91d_1f3ff', '1f9d1_200d_1f4bb', '1f9d1_1f3fb_200d_1f4bb', '1f9d1_1f3fc_200d_1f4bb', '1f9d1_1f3fd_200d_1f4bb', '1f9d1_1f3fe_200d_1f4bb', '1f9d1_1f3ff_200d_1f4bb', -] + u15 +] def norm_special(name: str): if name == '1f441_1f5e8': diff --git a/noto-emoji-cursed/noto-emoji-cursed.py b/noto-emoji-cursed/noto-emoji-cursed.py new file mode 100644 index 0000000..8703583 --- /dev/null +++ b/noto-emoji-cursed/noto-emoji-cursed.py @@ -0,0 +1,46 @@ +import os +import sys + +sys.path.append('..') +from shared import * +from shared_lig import * + +# input: apple font ttf, noto-emoji-cursed font ttf, noto-emoji-cursed GSUB ttx + +ttf = sys.argv[1] +bttf = sys.argv[2] +bgsubttx = sys.argv[3] + +f = ttLib.TTFont(ttf) + +lig = Lig(f, bttf, bgsubttx) +lig.build() + +prepare_strikes(f) +for ppem, strike in f['sbix'].strikes.items(): + print(f'Reading strike of size {ppem}x{ppem}') + for name, glyph in strike.glyphs.items(): + if glyph.graphicType != 'png ': + continue + name = base_norm_name(name) + if base_is_whitelist(name): + continue + name = norm_fam(name) + name = norm_dual(name) + if name is None: + continue + name = base_norm_variants(name) + name = base_norm_special(name) + name = lig.norm_name(name) + name = lig.get_glyph_name(name) + path = f'images/{ppem}/{name}.png' + if not os.path.exists(path): + print(name) + name = native_norm_name(name) + path = f'../noto-emoji/extra/images/{ppem}/{name}.png' + glyph.imageData = get_image_data(path) + +if not os.path.exists('../.test'): + print('Saving changes...') + ttf = ttf.replace('../apple/', '') + f.save(ttf) diff --git a/noto-emoji-cursed/noto-emoji-cursed.sh b/noto-emoji-cursed/noto-emoji-cursed.sh new file mode 100755 index 0000000..f3ea47a --- /dev/null +++ b/noto-emoji-cursed/noto-emoji-cursed.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +APPLE_FONT_NAME=AppleColorEmoji@2x +NAME=noto-emoji-cursed +FONT_NAME=SamsungColorEmoji +FONT_PATH=$FONT_NAME.ttf + +../image-sizes.sh false + +echo "Extracting font..." +ttx -q -f -z extfile $FONT_NAME.ttf +ttx -q -f -s -t GSUB $FONT_NAME.ttf + +echo "Resizing and optimizing PNGs..." +mogrify -resize 96x96 -path images/96 bitmaps/strike0/*.png +../resize.sh false false false +rm -rf bitmaps + +python3 $NAME.py ../apple/${APPLE_FONT_NAME}_00.ttf $FONT_NAME.ttf $FONT_NAME.G_S_U_B_.ttx +python3 $NAME.py ../apple/${APPLE_FONT_NAME}_01.ttf $FONT_NAME.ttf $FONT_NAME.G_S_U_B_.ttx + +otf2otc ${APPLE_FONT_NAME}_00.ttf ${APPLE_FONT_NAME}_01.ttf -o $NAME.ttc +rm -f *_00.ttf *_01.ttf + +echo "Output file at $NAME/$NAME.ttc"