This is a rewrite of add_glyphs in third_party/color_emoji. The
primary motivation was to move special aliasing rules out of that
code and use an external aliases file instead. This new version
is a bit more thorough about aliasing, and hopefully a little
easier to read.
The new add_glyphs takes its parameters using keywords, so
the invocation in the Makefile changed (as well as the path to
the tool).
emoji_aliases.txt was extended to add the flag aliases that were
formerly defined in the old add_glyphs code.
add_aliases was modified so the name of the alias file could be
passed in as a parameter to the main utility function that reads
the alias mapping from the file.
The new code expects all glyphs used by the template GSUB tables
to be named in the GlyphOrder table, but doesn't require the cmap
and hmtx table to be fleshed out. The new code fleshes these out
when it processes the sequences to add. As a result the cmap and
hmtx tables in the template were truncated.
The new code also sorts the GlyphOrder table when it extends/rebuilds
it.
Instead of writing code to build the additional lookups needed for
subregion missing flag handling, this adds a GSUB table to the
template and lets add_glyphs do its normal thing to the first
GSUB lookup.
- update Makefile to include approved GB subregion flags by default
- update flag_glyph_name to generate sequence names for these
- fix bug where the glyphorder table wasn't getting updated with
components, which was causing ttx to fail when compiling the
ttx to ttf in a later phase.
--skip_if_larger does nothing and returns an error if pngquant would
generate a larger file than the original. Formerly we would not copy
the file in this case so later operations expecting the file would fail.
No image triggered this, though, so the issue went unnoticed. We want
the smaller of the two files. It's unclear if later compression using
optipng would still do better with the larger quantized file vs the
original unquantized file, but we need to have a file.
Previously our copy of waveflag took just an input and output filename.
Upstream takes a prefix and one or more input filenames, and concatenates
the prefix to the input filename as the output.
The makefile is changed to pass a prefix and the input filename, instead
of the input filename and the output filename as it formerly did.
Unfortunately for us, our inputs have a directory prefix since they're
not in the current directory, and we don't want this prefix in the output
file path. So we tweak our copy of waveflag.c to call basename on the
input file path before we append it to the prefix.
We also make the tool a little less noisy by putting more printfs
under the debug flag.
This adds some additional flags to the default set. In addition,
it contains code that creates ligatures for some flag sequences to
others, for a few cases where we want different regions to share
the same flag. Finally, it adds default ligatures so that pairs of
regional indicator characters for which there's no predefined glyph
get a 'missing flag' glyph. This avoids cases where sequences of
regional indicator sequences accidentally match at odd locations
because of a previous mismatch.
There is no actual 'missing flag' glyph yet. The code uses an
existing emoji as a placeholder.
- fix ascent/descent in hhea and os/2 to match noto UI expectations,
zero linegap, clear useTypoMetrics bit, set weight to regular (400).
- add missing entries to name table, update revision
- map U+0000 to null glyph (not .notdef)
In addition, this tweaks the Makefile in some small ways:
- quiet zopflipng output somewhat (listen to your cpu fan to know
that something's happening) :-)
- make flag-symlinks target an order-only dependency (it was triggering
quantize+compress even when images hadn't changed)
- add comment about how to bypass make bug if multithread hangs
Change the build process to provide more intermediate steps and maintain
intermediate targets. This slows down make's analysis phase, though.
Make can be run with -j to parallelize the building, but be careful
with multiple targets on the command line (e.g. 'make clean font') since
clean's deletion of the output tree can sometimes occur after some of
the output directories get built.
This is preparatory to replacing the png images with the original internal
set. These require a bit more cleanup and processing, which is what these
changes do. The overall flow is:
- convert all emoji to desired size (136x128). All are smaller than this,
most are 128x128 but there are some others.
- run waveflag on the flags
- convert all flags to desired size(136x128). The flags are 128x128
originally.
- 'rename' the flags by creating softlinks with the desired names
- run pngquant on all the images and copy them into a single directory,
this reduces slight antialiasing differences.
- compress all the images, using zopflipng if available, else optipng.
zopflipng saves about 10%, but is 10x slower.
The remaining steps of building the font are unchanged, for the moment.
The intermediate image files are put into a 'build' subdirectory to organize
them and keep them out of the way.
Another way to do this is to create a target, but when I tried that
it reintroduced the dependency analysis problem-- rules with this
dependency always triggered. Of course I might have missed something
subtle. Both the target approach and this approach come from
http://stackoverflow.com/questions/5618615/check-if-a-program-exists-from-a-makefile)
This always runs, but unless you're just running clean you'd always want to
perform this check, so I think that's ok.
This reverts some changes in commit b257b6647d that were causing build
issues. Those changes quoted the path to pngquant in order to deal
with spaces in the path, but as a side effect that prevented
build-dependency analysis (gnu 3.81 on ubuntu) from recognizing that
the .png files didn't need to be built, and so rebuilt them every
time, which takes several minutes. Apparently make doesn't like
quotes-- strings passed to the shell are fine, but things make itself
processes (like names of targets) are treated literally.
Since the path to pngquant is (now, anyway) a local subpath of the
current directory that has no spaces, it should be ok to use the
subpath and not bother to quote.
Another change replaces two dependencies on flag-symlinks with a
dependency on PNG128_FLAGS, for the same reason: after flag-symlinks
executed it was not recognized as being up to date and so the rules
with these dependencies always executed.
The tool and data was moved to nototools.
Makefile now needs to invoke the tool as a script, rather than passing
it to python, since the tool is no longer local. Running setup.py in
nototools will make the script accessible. Setup (apparently) copies
the script to /usr/local/bin and it is not automatically updated when
nototools changes, still need to figure out how to address this.
This script takes ~1 second for startup, so calling it repeatedly for
each flag slows the Makefile considerably, and unnecessarily since it
can be called for all the flags at once.
Now make clean takes about 1.2s, instead of 3m45s.
The bitmap emoji tools are extended to create GSUB rules for character
sequences. The images are renamed to code the character sequence in their
filenames. New images are created for ASCII digits and number sign. A new
script is added to add cmaps to the files for backward compatibility.