diff --git a/.gitignore b/.gitignore index 69ef567..947cafc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Internal resources Fonts +release +release.sh update-deb.sh # Font assets diff --git a/QUICKSTART.md b/QUICKSTART.md index e26f8fd..1168205 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -6,7 +6,7 @@ macOS machine with homebrew and Python 3.7+ installed, assumed: ``` bash -c "pip3 install afdko fonttools[repacker]" -brew install pngquant freetype imagemagick librsvg inkscape php +brew install bash pngquant oxipng freetype imagemagick librsvg inkscape php ``` ## AppleColorEmoji font diff --git a/README.md b/README.md index bfe8894..cd23c46 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Python and shell scripts to backport and theme [Apple Color Emoji font](https:// # Prerequisites +- Bash version 5+ (`brew install bash`) - [Python 3.7 or later](http://www.python.org/download/) - [pip](https://pip.pypa.io/en/stable/) - [fonttools](https://github.com/fonttools/fonttools) (`pip3 install fonttools[repacker]`) @@ -48,6 +49,8 @@ EmojiFonts deals with certain font tables; mainly `GDEF` and `sbix`. Theming scripts for all emojis vendors produce the font in TTC format. The font may be used by EmojiFontManager iOS tweak, and is guaranteed to work on iOS 6 and higher. Ensure that you executed `apple.sh` before following instructions below. +It is recommended to limit the depth of clone to `1` (`git clone --depth 1 REPO-URL`) because the repository size is usually big. + ## Blobmoji Emoji 1. Clone [blobmoji](https://github.com/C1710/blobmoji) and place its folder alongside this project. diff --git a/TODO.md b/TODO.md index df053bf..be24d3c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ # TODOs -- [ ] Batch convert SVGs into PNGs faster (something other than `rsvg-convert`) - [ ] Convert from SVGs into PNGs with sufficient memory (to replace the slow `inkscape`) - [ ] Decouple from `emoji-data` repository - [ ] FluentUI Emoji HD diff --git a/apple.py b/apple.py index edf22a5..47e8465 100644 --- a/apple.py +++ b/apple.py @@ -2,15 +2,16 @@ from fontTools import ttLib from shared import get_image_data, prepare_strikes -# input: input font ttf, output font ttf, assets folder +# input: HD boolean, input font ttf, output font ttf, assets folder -ittf = sys.argv[1] -ottf = sys.argv[2] -assets = sys.argv[3] +hd = int(sys.argv[1]) == 1 +ittf = sys.argv[2] +ottf = sys.argv[3] +assets = sys.argv[4] f = ttLib.TTFont(ittf) -prepare_strikes(f) +prepare_strikes(f, hd) for ppem, strike in f['sbix'].strikes.items(): print(f'Reading strike of size {ppem}x{ppem}') for name, glyph in strike.glyphs.items(): diff --git a/apple.sh b/apple.sh index 60ca2b0..c745f71 100755 --- a/apple.sh +++ b/apple.sh @@ -8,6 +8,7 @@ MAC_FONT_NAME=AppleColorEmoji_macOS ASSETS=$NAME MOD=$1 COLORS= +[[ $MOD = 'HD' ]] && HD=1 || HD=0 mkdir -p $ASSETS @@ -28,15 +29,14 @@ then wait fi -echo "Optimizing PNGs using pngquant..." -[[ $MOD == 'HD' ]] && pngquant -f --ext .png $ASSETS/160/*.png & +echo "Optimizing PNGs..." +[[ $HD ]] && pngquant -f --ext .png $ASSETS/160/*.png & pngquant $COLORS -f --ext .png $ASSETS/96/*.png & pngquant $COLORS -f --ext .png $ASSETS/64/*.png & pngquant $COLORS -f --ext .png $ASSETS/40/*.png & wait -echo "Optimizing PNGs using oxipng..." -[[ $MOD == 'HD' ]] && oxipng -q $ASSETS/160/*.png & +[[ $HD ]] && oxipng -q $ASSETS/160/*.png & oxipng -q $ASSETS/96/*.png & oxipng -q $ASSETS/64/*.png & oxipng -q $ASSETS/40/*.png & @@ -49,8 +49,8 @@ else OUT_FONT_NAME=AppleColorEmoji@2x fi -python3 $NAME.py common/${IOS_FONT_NAME}_00.ttf apple/${OUT_FONT_NAME}_00.ttf $ASSETS & -python3 $NAME.py common/${IOS_FONT_NAME}_01.ttf apple/${OUT_FONT_NAME}_01.ttf $ASSETS & +python3 $NAME.py $HD common/${IOS_FONT_NAME}_00.ttf apple/${OUT_FONT_NAME}_00.ttf $ASSETS & +python3 $NAME.py $HD common/${IOS_FONT_NAME}_01.ttf apple/${OUT_FONT_NAME}_01.ttf $ASSETS & wait rm -f apple/$OUT_FONT_NAME.ttf ln apple/${OUT_FONT_NAME}_00.ttf apple/$OUT_FONT_NAME.ttf diff --git a/facebook.sh b/facebook.sh index 4bf4673..416eea0 100755 --- a/facebook.sh +++ b/facebook.sh @@ -36,7 +36,7 @@ mogrify -resize 40x40 -path $NAME-extra/images/40 $NAME-extra/images/64/*.png # mogrify -resize 32x32 -path $NAME-extra/images/32 $NAME-extra/images/40/*.png # mogrify -resize 20x20 -path $NAME-extra/images/20 $NAME-extra/images/32/*.png -echo "Optimizing PNGs using pngquant..." +echo "Optimizing PNGs..." pngquant -f --ext .png $NAME/images/96/*.png & pngquant -f --ext .png $NAME/images/64/*.png & # pngquant -f --ext .png $NAME/images/48/*.png & @@ -45,6 +45,10 @@ pngquant -f --ext .png $NAME/images/40/*.png & # pngquant -f --ext .png $NAME/images/20/*.png & pngquant -f --ext .png $NAME-extra/images/*/*.png & wait +oxipng -q $NAME/images/96/*.png & +oxipng -q $NAME/images/64/*.png & +oxipng -q $NAME/images/40/*.png & +wait python3 $NAME.py apple/${FONT_NAME}_00.ttf & python3 $NAME.py apple/${FONT_NAME}_01.ttf & diff --git a/fluentui.sh b/fluentui.sh index 83f4ba4..a3021d9 100755 --- a/fluentui.sh +++ b/fluentui.sh @@ -40,7 +40,7 @@ mogrify -resize 40x40 -path "$ASSETS"/40 "$ASSETS"/64/*.png # mogrify -resize 32x32 -path "$ASSETS"/32 "$ASSETS"/40/*.png # mogrify -resize 20x20 -path "$ASSETS"/20 "$ASSETS"/32/*.png -echo "Optimizing PNGs using pngquant..." +echo "Optimizing PNGs..." pngquant -f --ext .png "$ASSETS"/96/*.png & pngquant -f --ext .png "$ASSETS"/64/*.png & # pngquant -f --ext .png "$ASSETS"/48/*.png & @@ -48,6 +48,10 @@ pngquant -f --ext .png "$ASSETS"/40/*.png & # pngquant -f --ext .png "$ASSETS"/32/*.png & # pngquant -f --ext .png "$ASSETS"/20/*.png & wait +oxipng -q "$ASSETS"/96/*.png & +oxipng -q "$ASSETS"/64/*.png & +oxipng -q "$ASSETS"/40/*.png & +wait python3 $NAME.py apple/${FONT_NAME}_00.ttf "$STYLE" & python3 $NAME.py apple/${FONT_NAME}_01.ttf "$STYLE" & diff --git a/joypixels.sh b/joypixels.sh index 91f68da..b23f5d2 100755 --- a/joypixels.sh +++ b/joypixels.sh @@ -33,10 +33,13 @@ mogrify -resize 40x40 -path $ASSETS/40 $ASSETS/64/*.png # mogrify -resize 32x32 -path $ASSETS/32 $ASSETS/40/*.png # mogrify -resize 20x20 -path $ASSETS/20 $ASSETS/32/*.png -echo "Optimizing PNGs using pngquant..." +echo "Optimizing PNGs..." pngquant -f --ext .png $ASSETS/*/*.png & pngquant -f --ext .png $NAME-extra/images/*/*.png & wait +oxipng -q $ASSETS/*/*.png & +oxipng -q $NAME-extra/images/*/*.png & +wait python3 $NAME.py apple/${FONT_NAME}_00.ttf $MOD & python3 $NAME.py apple/${FONT_NAME}_01.ttf $MOD & diff --git a/noto-emoji.py b/noto-emoji.py index 7318826..57ed366 100644 --- a/noto-emoji.py +++ b/noto-emoji.py @@ -5,9 +5,10 @@ fontname = 'noto-emoji' -# input: font ttf +# input: HD boolean, font ttf -ttf = sys.argv[1] +hd = sys.argv[1] == 'true' +ttf = sys.argv[2] f = ttLib.TTFont(ttf) @@ -21,7 +22,7 @@ def noto_name(name: str): result = '_'.join(n) return 'u' + result -prepare_strikes(f) +prepare_strikes(f, hd) for ppem, strike in f['sbix'].strikes.items(): print(f'Reading strike of size {ppem}x{ppem}') for name, glyph in strike.glyphs.items(): diff --git a/noto-emoji.sh b/noto-emoji.sh index 9faeeb4..15319e9 100755 --- a/noto-emoji.sh +++ b/noto-emoji.sh @@ -7,11 +7,11 @@ NAME=noto-emoji ASSETS=../$NAME/svg FLAG_ASSETS=../$NAME/third_party/region-flags/waved-svg MAX_SIZE=96 -[[ $1 == 'HD' ]] && HD=true +[[ $1 == 'HD' ]] && HD=true || HD=false [[ $HD = true ]] && MAX_SIZE=160 -rm -rf $NAME +rm -rf $NAME/images mkdir -p $NAME/images/160 $NAME/images/96 $NAME/images/64 $NAME/images/48 $NAME/images/40 $NAME/images/32 $NAME/images/20 echo "Converting SVGs into PNGs..." @@ -48,8 +48,8 @@ echo "Resizing and optimizing PNGs..." ./resize.sh $NAME $HD false false ./resize.sh $NAME-extra $HD false false -python3 $NAME.py apple/${FONT_NAME}_00.ttf & -python3 $NAME.py apple/${FONT_NAME}_01.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_00.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_01.ttf & wait if [[ $HD = true ]]; then diff --git a/oneui.sh b/oneui.sh index f0ce9a1..8526fd0 100755 --- a/oneui.sh +++ b/oneui.sh @@ -26,6 +26,7 @@ cp $NAME-extra/original/*.png $NAME-extra/images/96 ./get-assets.sh oneui pngquant -f --ext .png $NAME-extra/images/*/*.png +oxipng -q $NAME-extra/images/*/*.png python3 $NAME.py apple/${APPLE_FONT_NAME}_00.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx & python3 $NAME.py apple/${APPLE_FONT_NAME}_01.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx & diff --git a/openmoji.py b/openmoji.py index 41c69aa..c596045 100644 --- a/openmoji.py +++ b/openmoji.py @@ -5,9 +5,10 @@ fontname = 'openmoji' -# input: font ttf +# input: HD boolean, font ttf -ttf = sys.argv[1] +hd = sys.argv[1] == 'true' +ttf = sys.argv[2] f = ttLib.TTFont(ttf) @@ -25,7 +26,7 @@ def norm_special(name: str): def openmoji_name(name: str): return name.replace('_', '-').upper() -prepare_strikes(f) +prepare_strikes(f, hd) for ppem, strike in f['sbix'].strikes.items(): print(f'Reading strike of size {ppem}x{ppem}') for name, glyph in strike.glyphs.items(): diff --git a/openmoji.sh b/openmoji.sh index 9b514c8..e9752e0 100755 --- a/openmoji.sh +++ b/openmoji.sh @@ -6,11 +6,11 @@ FONT_NAME=AppleColorEmoji@2x NAME=openmoji ASSETS=../$NAME/color/svg MAX_SIZE=96 -[[ $1 == 'HD' ]] && HD=true +[[ $1 == 'HD' ]] && HD=true || HD=false [[ $HD = true ]] && MAX_SIZE=160 -rm -rf $NAME +rm -rf $NAME/images mkdir -p $NAME/images/160 $NAME/images/96 $NAME/images/64 $NAME/images/48 $NAME/images/40 $NAME/images/32 $NAME/images/20 cd $NAME-extra @@ -42,8 +42,8 @@ echo "Resizing and optimizing PNGs..." ./resize.sh $NAME $HD false false true ./resize.sh $NAME-extra $HD false false true -python3 $NAME.py apple/${FONT_NAME}_00.ttf & -python3 $NAME.py apple/${FONT_NAME}_01.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_00.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_01.ttf & wait if [[ $HD = true ]]; then diff --git a/resize.sh b/resize.sh index 965d124..18c79ae 100755 --- a/resize.sh +++ b/resize.sh @@ -5,9 +5,7 @@ set -e NAME=$1 HD=$2 FULL=$3 -COLORS= -[[ $4 = true ]] && COLORS=256 - +[[ $4 = true ]] && COLORS=256 || COLORS= if [[ $HD = true ]]; then mogrify -resize 160x160 $NAME/images/160/*.png @@ -34,5 +32,4 @@ else fi wait -echo "Optimizing PNGs using oxipng..." oxipng -q $NAME/images/*/*.png diff --git a/shared.py b/shared.py index c806f9b..9b05bd1 100644 --- a/shared.py +++ b/shared.py @@ -248,7 +248,6 @@ def get_image_data(path: str): with open(path, 'rb') as fin: return fin.read() -def prepare_strikes(f: ttLib.TTFont): - if 160 in f['sbix'].strikes: +def prepare_strikes(f: ttLib.TTFont, hd = False): + if not hd and 160 in f['sbix'].strikes: f['sbix'].strikes.pop(160) - # pass diff --git a/templates/semi-native.sh b/templates/semi-native.sh index 75c03a4..4aa7f7b 100755 --- a/templates/semi-native.sh +++ b/templates/semi-native.sh @@ -25,14 +25,9 @@ mogrify -resize 32x32 -path $NAME/images/32 $NAME/images/40/*.png mogrify -resize 20x20 -path $NAME/images/20 $NAME/images/32/*.png rm -rf $NAME/bitmaps -echo "Optimizing PNGs using pngquant..." -pngquant -f --ext .png $NAME/images/96/*.png -pngquant -f --ext .png $NAME/images/64/*.png -pngquant -f --ext .png $NAME/images/48/*.png -pngquant -f --ext .png $NAME/images/40/*.png -pngquant -f --ext .png $NAME/images/32/*.png -pngquant -f --ext .png $NAME/images/20/*.png -# pngquant -f --ext .png $NAME-extra/images/*/*.png +echo "Optimizing PNGs..." +./resize.sh $NAME false false false +# ./resize.sh $NAME-extra false false false python3 $NAME.py common/${APPLE_FONT_NAME}_00.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx python3 $NAME.py common/${APPLE_FONT_NAME}_01.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx diff --git a/twemoji.py b/twemoji.py index 24fdcc0..caab79c 100644 --- a/twemoji.py +++ b/twemoji.py @@ -5,9 +5,10 @@ fontname = 'twemoji' -# input: font ttf +# input: HD boolean, font ttf -ttf = sys.argv[1] +hd = sys.argv[1] == 'true' +ttf = sys.argv[2] f = ttLib.TTFont(ttf) @@ -23,7 +24,7 @@ def norm_special(name: str): def twitter_name(name: str): return name.replace('_', '-') -prepare_strikes(f) +prepare_strikes(f, hd) for ppem, strike in f['sbix'].strikes.items(): print(f'Reading strike of size {ppem}x{ppem}') for name, glyph in strike.glyphs.items(): diff --git a/twemoji.sh b/twemoji.sh index 1074aea..249a73b 100755 --- a/twemoji.sh +++ b/twemoji.sh @@ -6,11 +6,11 @@ FONT_NAME=AppleColorEmoji@2x NAME=twemoji ASSETS=../$NAME/assets/svg MAX_SIZE=96 -[[ $1 == 'HD' ]] && HD=true +[[ $1 == 'HD' ]] && HD=true || HD=false [[ $HD = true ]] && MAX_SIZE=160 -rm -rf $NAME +rm -rf $NAME/images mkdir -p $NAME/images/160 $NAME/images/96 $NAME/images/64 $NAME/images/48 $NAME/images/40 $NAME/images/32 $NAME/images/20 echo "Converting SVGs into PNGs..." @@ -39,8 +39,8 @@ echo "Resizing and optimizing PNGs..." ./resize.sh $NAME $HD false false ./resize.sh $NAME-extra $HD false false -python3 $NAME.py apple/${FONT_NAME}_00.ttf & -python3 $NAME.py apple/${FONT_NAME}_01.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_00.ttf & +python3 $NAME.py $HD apple/${FONT_NAME}_01.ttf & wait if [[ $HD = true ]]; then diff --git a/whatsapp.sh b/whatsapp.sh index 7403fb0..13db344 100755 --- a/whatsapp.sh +++ b/whatsapp.sh @@ -23,6 +23,7 @@ rm -rf $NAME/bitmaps ./get-assets.sh whatsapp pngquant -f --ext .png $NAME-extra/images/*/*.png +oxipng -q $NAME-extra/images/*/*.png python3 $NAME.py apple/${APPLE_FONT_NAME}_00.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx & python3 $NAME.py apple/${APPLE_FONT_NAME}_01.ttf $NAME/$FONT_NAME.ttf $NAME/$FONT_NAME.G_S_U_B_.ttx &