Merge branch 'master' into feature/fontlinter

pull/299/head
Guido Theelen 2020-06-16 08:22:41 +02:00 committed by GitHub
commit bebb2f2b39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 56 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ __pycache__/
*.pyc *.pyc
waveflag waveflag
build/ build/
venv/

View File

@ -24,11 +24,8 @@ PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force
BODY_DIMENSIONS = 136x128 BODY_DIMENSIONS = 136x128
IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center
# zopflipng is better (about 5-10%) but much slower. it will be used if
# present. pass ZOPFLIPNG= as an arg to make to use optipng instead.
ZOPFLIPNG = zopflipng ZOPFLIPNG = zopflipng
OPTIPNG = optipng TTX = ttx
EMOJI_BUILDER = third_party/color_emoji/emoji_builder.py EMOJI_BUILDER = third_party/color_emoji/emoji_builder.py
# flag for emoji builder. Default to legacy small metrics for the time being. # flag for emoji builder. Default to legacy small metrics for the time being.
@ -83,6 +80,23 @@ SELECTED_FLAGS = AC AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ \
ZA ZM ZW \ ZA ZM ZW \
GB-ENG GB-SCT GB-WLS GB-ENG GB-SCT GB-WLS
ifeq (,$(shell which $(ZOPFLIPNG)))
ifeq (,$(wildcard $(ZOPFLIPNG)))
MISSING_ZOPFLI = fail
endif
endif
ifndef VIRTUAL_ENV
MISSING_VENV = fail
endif
ifeq (, $(shell which $(VS_ADDER)))
MISSING_PY_TOOLS = fail
endif
ifeq (, $(shell which $(TTX)))
MISSING_PY_TOOLS = fail
endif
ALL_FLAGS = $(basename $(notdir $(wildcard $(FLAGS_SRC_DIR)/*.png))) ALL_FLAGS = $(basename $(notdir $(wildcard $(FLAGS_SRC_DIR)/*.png)))
FLAGS = $(SELECTED_FLAGS) FLAGS = $(SELECTED_FLAGS)
@ -91,7 +105,11 @@ FLAG_NAMES = $(FLAGS:%=%.png)
FLAG_FILES = $(addprefix $(FLAGS_DIR)/, $(FLAG_NAMES)) FLAG_FILES = $(addprefix $(FLAGS_DIR)/, $(FLAG_NAMES))
RESIZED_FLAG_FILES = $(addprefix $(RESIZED_FLAGS_DIR)/, $(FLAG_NAMES)) RESIZED_FLAG_FILES = $(addprefix $(RESIZED_FLAGS_DIR)/, $(FLAG_NAMES))
ifndef MISSING_PY_TOOLS
FLAG_GLYPH_NAMES = $(shell $(PYTHON) flag_glyph_name.py $(FLAGS)) FLAG_GLYPH_NAMES = $(shell $(PYTHON) flag_glyph_name.py $(FLAGS))
else
FLAG_GLYPH_NAMES =
endif
RENAMED_FLAG_NAMES = $(FLAG_GLYPH_NAMES:%=emoji_%.png) RENAMED_FLAG_NAMES = $(FLAG_GLYPH_NAMES:%=emoji_%.png)
RENAMED_FLAG_FILES = $(addprefix $(RENAMED_FLAGS_DIR)/, $(RENAMED_FLAG_NAMES)) RENAMED_FLAG_FILES = $(addprefix $(RENAMED_FLAGS_DIR)/, $(RENAMED_FLAG_NAMES))
@ -103,23 +121,6 @@ ALL_NAMES = $(EMOJI_NAMES) $(RENAMED_FLAG_NAMES)
ALL_QUANTIZED_FILES = $(addprefix $(QUANTIZED_DIR)/, $(ALL_NAMES)) ALL_QUANTIZED_FILES = $(addprefix $(QUANTIZED_DIR)/, $(ALL_NAMES))
ALL_COMPRESSED_FILES = $(addprefix $(COMPRESSED_DIR)/, $(ALL_NAMES)) ALL_COMPRESSED_FILES = $(addprefix $(COMPRESSED_DIR)/, $(ALL_NAMES))
# tool checks
ifeq (,$(shell which $(ZOPFLIPNG)))
ifeq (,$(wildcard $(ZOPFLIPNG)))
MISSING_ZOPFLI = fail
endif
endif
ifeq (,$(shell which $(OPTIPNG)))
ifeq (,$(wildcard $(OPTIPNG)))
MISSING_OPTIPNG = fail
endif
endif
ifeq (, $(shell which $(VS_ADDER)))
MISSING_ADDER = fail
endif
emoji: $(EMOJI_FILES) emoji: $(EMOJI_FILES)
@ -133,22 +134,16 @@ quantized: $(ALL_QUANTIZED_FILES)
compressed: $(ALL_COMPRESSED_FILES) compressed: $(ALL_COMPRESSED_FILES)
check_compress_tool: check_tools:
ifdef MISSING_ZOPFLI ifdef MISSING_ZOPFLI
ifdef MISSING_OPTIPNG $(error "Missing $(ZOPFLIPNG). Try 'brew install zopfli' (Mac) or 'sudo apt-get install zopfli' (linux)")
$(error "neither $(ZOPFLIPNG) nor $(OPTIPNG) is available")
else
@echo "using $(OPTIPNG)"
endif
else
@echo "using $(ZOPFLIPNG)"
endif endif
ifdef MISSING_VENV
check_vs_adder: $(error "Please start your virtual environment, and run: "'pip install -r requirements.txt'")
ifdef MISSING_ADDER endif
$(error "$(VS_ADDER) not in path, run setup.py in nototools") ifdef MISSING_PY_TOOLS
$(error "Missing tools; run: "'pip install -r requirements.txt' in your virtual environment")
endif endif
$(EMOJI_DIR) $(FLAGS_DIR) $(RESIZED_FLAGS_DIR) $(RENAMED_FLAGS_DIR) $(QUANTIZED_DIR) $(COMPRESSED_DIR): $(EMOJI_DIR) $(FLAGS_DIR) $(RESIZED_FLAGS_DIR) $(RENAMED_FLAGS_DIR) $(QUANTIZED_DIR) $(COMPRESSED_DIR):
mkdir -p "$@" mkdir -p "$@"
@ -192,12 +187,8 @@ $(QUANTIZED_DIR)/%.png: $(RENAMED_FLAGS_DIR)/%.png | $(QUANTIZED_DIR)
$(QUANTIZED_DIR)/%.png: $(EMOJI_DIR)/%.png | $(QUANTIZED_DIR) $(QUANTIZED_DIR)/%.png: $(EMOJI_DIR)/%.png | $(QUANTIZED_DIR)
@($(PNGQUANT) $(PNGQUANTFLAGS) -o "$@" "$<"; case "$$?" in "98"|"99") echo "reuse $<";cp $< $@;; *) exit "$$?";; esac) @($(PNGQUANT) $(PNGQUANTFLAGS) -o "$@" "$<"; case "$$?" in "98"|"99") echo "reuse $<";cp $< $@;; *) exit "$$?";; esac)
$(COMPRESSED_DIR)/%.png: $(QUANTIZED_DIR)/%.png | check_compress_tool $(COMPRESSED_DIR) $(COMPRESSED_DIR)/%.png: $(QUANTIZED_DIR)/%.png | check_tools $(COMPRESSED_DIR)
ifdef MISSING_ZOPFLI
@$(OPTIPNG) -quiet -o7 -clobber -force -out "$@" "$<"
else
@$(ZOPFLIPNG) -y "$<" "$@" 1> /dev/null 2>&1 @$(ZOPFLIPNG) -y "$<" "$@" 1> /dev/null 2>&1
endif
# Make 3.81 can endless loop here if the target is missing but no # Make 3.81 can endless loop here if the target is missing but no
# prerequisite is updated and make has been invoked with -j, e.g.: # prerequisite is updated and make has been invoked with -j, e.g.:
@ -216,7 +207,8 @@ endif
ttx "$<" ttx "$<"
$(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ $(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \
$(ALL_COMPRESSED_FILES) | check_vs_adder $(ALL_COMPRESSED_FILES) | check_tools
@$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u" @$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u"
@$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua" @$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua"
@$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua" @$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua"
@ -238,5 +230,5 @@ clean:
.SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \ .SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \
$(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES)
.PHONY: clean flags emoji renamed_flags quantized compressed check_compress_tool .PHONY: clean flags emoji renamed_flags quantized compressed check_tools

View File

@ -2,25 +2,36 @@
# Noto Emoji # Noto Emoji
Color and Black-and-White Noto emoji fonts, and tools for working with them. Color and Black-and-White Noto emoji fonts, and tools for working with them.
## Prerequisites
Building Noto Color Emoji requires:
- Python 3
- [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
- [pngquant](https://pngquant.org/)
- [zopflipng](https://github.com/google/zopfli)
## Building NotoColorEmoji ## Building NotoColorEmoji
This project uses a virtual environment to manage dependencies. Use the following steps to get up and running:
Building NotoColorEmoji currently requires a Python 2.x wide build. To build ```shell
the emoji font you will require a few files from nototools. Clone a copy from # make sure you have the Prerequisites
https://github.com/googlei18n/nototools and either put it in your PYTHONPATH or
use 'python setup.py develop' ('install' currently won't fully install all the
data used by nototools). You will also need fontTools, get it from
https://github.com/behdad/fonttools.git.
Then run make. NotoColorEmoji is the default target. It's suggested to use -j, # create & activate a virtual environment
especially if you are using zopflipng for compression. Intermediate products python3 -m venv venv
(compressed image files, for example) will be put into a build subdirectory; the source venv/bin/activate
font will be at the top level.
# install python requirements
pip install -r requirements.txt
time make -j
```
Intermediate products (compressed image files, for example) will be put into a build subdirectory; the font will be at the top level.
## Using NotoColorEmoji ## Using NotoColorEmoji
NotoColorEmoji uses the CBDT/CBLC color font format, which is supported by Android NotoColorEmoji uses the CBDT/CBLC color font format, which is supported by Android
and Chrome/Chromium OS. Windows supports it starting with Windows 10 Anniversary and Chrome/Chromium OS. Windows supports it starting with Windows 10 Anniversary
Update in Chome and Edge. On macOS, only Chrome supports it, while on Linux it will Update in Chrome and Edge. On macOS, only Chrome supports it, while on Linux it will
support it with some fontconfig tweaking, see [issue #36](https://github.com/googlei18n/noto-emoji/issues/36). Currently we do not build other color font formats. support it with some fontconfig tweaking, see [issue #36](https://github.com/googlei18n/noto-emoji/issues/36). Currently we do not build other color font formats.
## Color emoji assets ## Color emoji assets

View File

@ -18,13 +18,11 @@
__author__ = "roozbeh@google.com (Roozbeh Pournader)" __author__ = "roozbeh@google.com (Roozbeh Pournader)"
import sys import sys
from fontTools import agl from fontTools import agl
from fontTools import ttLib
from fontTools.ttLib.tables import otTables from fontTools.ttLib.tables import otTables
from fontTools import ttLib
from nototools import font_data from nototools import font_data

View File

@ -22,7 +22,11 @@ __author__ = 'roozbeh@google.com (Roozbeh Pournader)'
import re import re
import sys import sys
import add_emoji_gsub try:
import add_emoji_gsub
except ImportError as e:
print(e, file=sys.stderr)
sys.exit('Python environment is not setup right')
def two_letter_code_to_glyph_name(region_code): def two_letter_code_to_glyph_name(region_code):
return 'u%04x_%04x' % ( return 'u%04x_%04x' % (

2
requirements.txt 100644
View File

@ -0,0 +1,2 @@
fonttools>=4.7.0
notofonttools>=0.2.4