From d453af82c932434ebd6cd322c03658e6ac05c811 Mon Sep 17 00:00:00 2001 From: Roel Nieskens Date: Mon, 2 Nov 2020 14:26:15 +0100 Subject: [PATCH] Output Windows compatible font with glyf + loca table --- Makefile | 24 +- ...ColorEmoji_WindowsCompatible.tmpl.ttx.tmpl | 711 ++++++++++++++++++ add_glyphs.py | 12 + 3 files changed, 742 insertions(+), 5 deletions(-) create mode 100644 NotoColorEmoji_WindowsCompatible.tmpl.ttx.tmpl diff --git a/Makefile b/Makefile index ff684625b..1a94bd252 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ # limitations under the License. EMOJI = NotoColorEmoji -font: $(EMOJI).ttf +EMOJI_WINDOWS = NotoColorEmoji_WindowsCompatible +all: $(EMOJI).ttf $(EMOJI_WINDOWS).ttf CFLAGS = -std=c99 -Wall -Wextra `pkg-config --cflags --libs cairo` LDFLAGS = -lm `pkg-config --libs cairo` @@ -108,7 +109,7 @@ RESIZED_FLAG_FILES = $(addprefix $(RESIZED_FLAGS_DIR)/, $(FLAG_NAMES)) ifndef MISSING_PY_TOOLS FLAG_GLYPH_NAMES = $(shell $(PYTHON) flag_glyph_name.py $(FLAGS)) else -FLAG_GLYPH_NAMES = +FLAG_GLYPH_NAMES = endif RENAMED_FLAG_NAMES = $(FLAG_GLYPH_NAMES:%=emoji_%.png) RENAMED_FLAG_FILES = $(addprefix $(RENAMED_FLAGS_DIR)/, $(RENAMED_FLAG_NAMES)) @@ -199,8 +200,11 @@ $(COMPRESSED_DIR)/%.png: $(QUANTIZED_DIR)/%.png | check_tools $(COMPRESSED_DIR) # ... # Run make without -j if this happens. -%.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(ALL_COMPRESSED_FILES) - @$(PYTHON) $(ADD_GLYPHS) -f "$<" -o "$@" -d "$(COMPRESSED_DIR)" $(ADD_GLYPHS_FLAGS) +$(EMOJI).tmpl.ttx: $(EMOJI).tmpl.ttx.tmpl $(ADD_GLYPHS) $(ALL_COMPRESSED_FILES) + $(PYTHON) $(ADD_GLYPHS) -f "$<" -o "$@" -d "$(COMPRESSED_DIR)" $(ADD_GLYPHS_FLAGS) + +$(EMOJI_WINDOWS).tmpl.ttx: $(EMOJI_WINDOWS).tmpl.ttx.tmpl $(ADD_GLYPHS) $(ALL_COMPRESSED_FILES) + $(PYTHON) $(ADD_GLYPHS) -f "$<" -o "$@" -d "$(COMPRESSED_DIR)" $(ADD_GLYPHS_FLAGS) %.ttf: %.ttx @rm -f "$@" @@ -215,6 +219,16 @@ $(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ @mv "$@-with-pua-varsel" "$@" @rm "$@-with-pua" +$(EMOJI_WINDOWS).ttf: check_sequence $(EMOJI_WINDOWS).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ + $(ALL_COMPRESSED_FILES) | check_tools + + @$(PYTHON) $(EMOJI_BUILDER) -O $(SMALL_METRICS) -V $(word 2,$^) "$@" "$(COMPRESSED_DIR)/emoji_u" + @$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua" + @$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua" + @mv "$@-with-pua-varsel" "$@" + @rm "$@-with-pua" + + check_sequence: ifdef BYPASS_SEQUENCE_CHECK @echo Bypassing the emoji sequence checks @@ -223,7 +237,7 @@ else endif clean: - rm -f $(EMOJI).ttf $(EMOJI).tmpl.ttf $(EMOJI).tmpl.ttx + rm -f $(EMOJI).ttf $(EMOJI_WINDOWS).ttf $(EMOJI).tmpl.ttf $(EMOJI_WINDOWS).tmpl.ttf $(EMOJI).tmpl.ttx $(EMOJI_WINDOWS).tmpl.ttx rm -f waveflag rm -rf $(BUILD_DIR) diff --git a/NotoColorEmoji_WindowsCompatible.tmpl.ttx.tmpl b/NotoColorEmoji_WindowsCompatible.tmpl.ttx.tmpl new file mode 100644 index 000000000..76cfc57b9 --- /dev/null +++ b/NotoColorEmoji_WindowsCompatible.tmpl.ttx.tmpl @@ -0,0 +1,711 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright 2013 Google Inc. + + + Noto Color Emoji + + + Regular + + + Noto Color Emoji + + + Noto Color Emoji + + + Version 2.020;GOOG;noto-emoji:20200914:BETA + + + NotoColorEmoji + + + Noto is a trademark of Google Inc. + + + Google, Inc. + + + Google, Inc. + + + Color emoji font using CBDT glyph data. + + + http://www.google.com/get/noto/ + + + http://www.google.com/get/noto/ + + + This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software. + + + http://scripts.sil.org/OFL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/add_glyphs.py b/add_glyphs.py index dd788ad96..05578765f 100644 --- a/add_glyphs.py +++ b/add_glyphs.py @@ -18,6 +18,9 @@ import sys from fontTools import ttx from fontTools.ttLib.tables import otTables +from fontTools.ttLib import newTable +from fontTools.pens.ttGlyphPen import TTGlyphPen +from fontTools.ttLib.tables._c_m_a_p import CmapSubtable import add_emoji_gsub import add_aliases @@ -158,10 +161,17 @@ def add_glyph_data(font, seqs, seq_to_advance, vadvance): # # The added codepoints have no advance information, so will get a zero # advance. + # + # If a glyf table is present, empty glyphs will be added to ensure + # compatibility with systems requiring a glyf table, like Windows 10. cmap = get_font_cmap(font) hmtx = font['hmtx'].metrics vmtx = font['vmtx'].metrics + if 'glyf' in font: + pen = TTGlyphPen(None) + empty_glyph = pen.glyph() + glyf = font['glyf'] # We don't expect sequences to be in the glyphOrder, since we removed all the # single-cp sequences from it and don't expect it to already contain names @@ -186,6 +196,8 @@ def add_glyph_data(font, seqs, seq_to_advance, vadvance): if name not in reverseGlyphMap: font.glyphOrder.append(name) updatedGlyphOrder=True + if 'glyf' in font: + glyf[name] = empty_glyph if updatedGlyphOrder: delattr(font, '_reverseGlyphOrderDict')