From 6062bc6fa2938bd87f63ce66588768ceca43173f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0abata?= Date: Thu, 15 Oct 2020 09:41:31 +0200 Subject: [PATCH] RHEL 9.0.0 Alpha bootstrap The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/google-noto-emoji-fonts#58d2109df68f1bc773b3b05f8097e6c89c921c4b --- .gitignore | 25 ++ google-noto-emoji-color.metainfo.xml | 11 + google-noto-emoji-fonts.spec | 231 +++++++++++++ google-noto-emoji.metainfo.xml | 11 + noto-emoji-build-all-flags.patch | 11 + noto-emoji-check-sequence.patch | 20 ++ noto-emoji-port-to-python3.patch | 303 ++++++++++++++++++ noto-emoji-python3.patch | 176 ++++++++++ noto-emoji-use-gm.patch | 30 ++ noto-emoji-use-system-pngquant.patch | 29 ++ sources | 1 + tests/roles/custom-test-fonts/README.md | 69 ++++ .../roles/custom-test-fonts/defaults/main.yml | 7 + .../custom-test-fonts/files/run-family-test | 162 ++++++++++ .../files/run-lang-coverage-test | 252 +++++++++++++++ tests/roles/custom-test-fonts/meta/main.yml | 4 + tests/roles/custom-test-fonts/tasks/main.yml | 48 +++ tests/tests.yml | 20 ++ 18 files changed, 1410 insertions(+) create mode 100644 google-noto-emoji-color.metainfo.xml create mode 100644 google-noto-emoji-fonts.spec create mode 100644 google-noto-emoji.metainfo.xml create mode 100644 noto-emoji-build-all-flags.patch create mode 100644 noto-emoji-check-sequence.patch create mode 100644 noto-emoji-port-to-python3.patch create mode 100644 noto-emoji-python3.patch create mode 100644 noto-emoji-use-gm.patch create mode 100644 noto-emoji-use-system-pngquant.patch create mode 100644 sources create mode 100644 tests/roles/custom-test-fonts/README.md create mode 100644 tests/roles/custom-test-fonts/defaults/main.yml create mode 100755 tests/roles/custom-test-fonts/files/run-family-test create mode 100755 tests/roles/custom-test-fonts/files/run-lang-coverage-test create mode 100644 tests/roles/custom-test-fonts/meta/main.yml create mode 100644 tests/roles/custom-test-fonts/tasks/main.yml create mode 100644 tests/tests.yml diff --git a/.gitignore b/.gitignore index e69de29..6d068ba 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,25 @@ +/google-noto-emoji-fonts-*-*.*.src.rpm +/noto-emoji-e7a7241.tar.gz +/nototools-c1f2cff.tar.gz +/noto-emoji-1c0ce22.tar.gz +/nototools-d59a186.tar.gz +/noto-emoji-ff566b2.tar.gz +/nototools-b5af4b9.tar.gz +/nototools-674ccc7.tar.gz +/noto-emoji-ca22132.tar.gz +/noto-emoji-8692845.tar.gz +/nototools-d8f3d16.tar.gz +/noto-emoji-a4ddd5b.tar.gz +/nototools-feacefe.tar.gz +/nototools-0c99dff.tar.gz +/noto-emoji-411334c.tar.gz +/results_google-noto-emoji-fonts/ +/noto-emoji-153e1d4.tar.gz +/noto-emoji-352632e.tar.gz +/noto-emoji-3ffd20e.tar.gz +/noto-emoji-f09acc5.tar.gz +/noto-emoji-833a43d.tar.gz +/noto-emoji-16151a2.tar.gz +/noto-emoji-ac1703e.tar.gz +/noto-emoji-f8131fc.tar.gz +/noto-emoji-d5e2614.tar.gz diff --git a/google-noto-emoji-color.metainfo.xml b/google-noto-emoji-color.metainfo.xml new file mode 100644 index 0000000..4316bcd --- /dev/null +++ b/google-noto-emoji-color.metainfo.xml @@ -0,0 +1,11 @@ + + + + google-noto-emoji-color + CC-BY-3.0 + Noto Color Emoji + Google Noto Color Emoji Font + https://github.com/googlei18n/noto-emoji + + google-noto + diff --git a/google-noto-emoji-fonts.spec b/google-noto-emoji-fonts.spec new file mode 100644 index 0000000..0c3b65a --- /dev/null +++ b/google-noto-emoji-fonts.spec @@ -0,0 +1,231 @@ +%global commit0 d5e261484286d33a1fe8a02676f5907ecc02106f +%global shortcommit0 %(c=%{commit0}; echo ${c:0:7}) + +%global fontname google-noto-emoji + +%if (0%{?fedora} > 25) +%global buildfont 1 +%else +%global buildfont 0 +%endif + + +Name: %{fontname}-fonts +Version: 20200723 +Release: 2%{?dist} +Summary: Google “Noto Emoji” Black-and-White emoji font + +# In noto-emoji-fonts source +## noto-emoji code is in ASL 2.0 license +## Emoji fonts are under OFL license +### third_party color-emoji code is in BSD license +### third_party region-flags code is in Public Domain license +# In nototools source +## nototools code is in ASL 2.0 license +### third_party ucd code is in Unicode license +License: OFL and ASL 2.0 +URL: https://github.com/googlei18n/noto-emoji +Source0: https://github.com/googlei18n/noto-emoji/archive/%{commit0}.tar.gz#/noto-emoji-%{shortcommit0}.tar.gz +Source2: %{fontname}.metainfo.xml +Source3: %{fontname}-color.metainfo.xml + +Patch0: noto-emoji-build-all-flags.patch +Patch1: noto-emoji-use-gm.patch +Patch2: noto-emoji-use-system-pngquant.patch +Patch3: noto-emoji-check-sequence.patch + +BuildArch: noarch +BuildRequires: gcc +BuildRequires: fontpackages-devel +%if %buildfont +BuildRequires: fonttools +BuildRequires: python3-fonttools +BuildRequires: nototools +BuildRequires: python3-nototools +BuildRequires: python3-devel +BuildRequires: GraphicsMagick +BuildRequires: pngquant +BuildRequires: zopfli +BuildRequires: cairo-devel +%endif + +Requires: fontpackages-filesystem + +Obsoletes: google-noto-color-emoji-fonts < 20150617 +Provides: google-noto-color-emoji-fonts = 20150617 + +%description +This package provides the Google “Noto Emoji” Black-and-White emoji font. + +%package -n %{fontname}-color-fonts +Summary: Google “Noto Color Emoji” colored emoji font +Requires: fontpackages-filesystem +Obsoletes: google-noto-color-emoji-fonts < 20150617 +Provides: google-noto-color-emoji-fonts = 20150617 + +%description -n %{fontname}-color-fonts +This package provides the Google “Noto Color Emoji” colored emoji font. + +%prep +%setup -n noto-emoji-%{commit0} +%patch0 -p1 -b .noto-emoji-build-all-flags +%patch1 -p1 -b .noto-emoji-use-gm.patch +%patch2 -p1 -b .noto-emoji-use-system-pngquant +%patch3 -p1 -b .noto-emoji-check-sequence + +rm -rf third_party/pngquant + +%build +%if %buildfont +# Work around UTF-8 +export LANG=C.UTF-8 + +%make_build OPT_CFLAGS="$RPM_OPT_FLAGS" BYPASS_SEQUENCE_CHECK='True' +%endif + +%install +install -m 0755 -d %{buildroot}%{_fontdir} + +%if %buildfont +# Built by us from the supplied pngs: +install -m 0644 -p NotoColorEmoji.ttf %{buildroot}%{_fontdir} +%else +# Pre-built, and included with the source: +install -m 0644 -p fonts/NotoColorEmoji.ttf %{buildroot}%{_fontdir} +%endif + +# Pre-built, and included with the source: +install -m 0644 -p fonts/NotoEmoji-Regular.ttf %{buildroot}%{_fontdir} + +mkdir -p %{buildroot}%{_datadir}/appdata +install -m 0644 -p %{SOURCE2} %{buildroot}%{_datadir}/appdata +install -m 0644 -p %{SOURCE3} %{buildroot}%{_datadir}/appdata + +%_font_pkg NotoEmoji-Regular.ttf +%license LICENSE +%doc AUTHORS CONTRIBUTING.md CONTRIBUTORS README.md +%{_datadir}/appdata/google-noto-emoji.metainfo.xml + +%_font_pkg -n color NotoColorEmoji.ttf +%license LICENSE +%doc AUTHORS CONTRIBUTING.md CONTRIBUTORS README.md +%{_datadir}/appdata/google-noto-emoji-color.metainfo.xml + + +%changelog +* Tue Jul 28 2020 Fedora Release Engineering - 20200723-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Tue Jul 21 2020 Mike FABIAN - 20200723-1 +- Update to upstream snapshot tarball (Unicode 13.0.0 support) + +* Mon Jul 13 2020 Tom Stellard - 20200402-2 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + +* Thu Apr 02 2020 Mike FABIAN - 20200402-1 +- Update to upstream snapshot tarball (fixes U+1F9D1 U+200D U+1F3A8 "artist" + and many other sequences) + +* Wed Jan 29 2020 Fedora Release Engineering - 20191019-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Sat Oct 19 2019 Mike FABIAN - 20191019-1 +- Update to upstream snapshot tarball (Fixes for people holding hands) + +* Thu Aug 29 2019 Mike FABIAN - 20190829-1 +- Update to upstream snapshot tarball (Fixes FR and NL flags) + +* Thu Jul 25 2019 Fedora Release Engineering - 20190709-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Tue Jul 09 2019 Mike FABIAN - 20190709-1 +- Update to upstream snapshot tarball (Contains the new emoji added in Unicode 12.0.0, + also fixes the "people holding hands" sequence. +- Port to Python3 and build using Python3 + +* Fri Feb 01 2019 Fedora Release Engineering - 20180814-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Tue Aug 14 2018 Mike FABIAN - 20180814-1 +- Update to upstream snapshot tarball (Contains the new emoji added in Unicode 11.0.0) + +* Mon Jul 23 2018 Mike FABIAN - 20180508-6 +- Fix build in rawhide +- Resolves: rhbz#1604247 + +* Fri Jul 13 2018 Fedora Release Engineering - 20180508-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Jun 26 2018 Peng Wu - 20180508-4 +- Fixes buildfont macro + +* Tue Jun 19 2018 Peng Wu - 20180508-3 +- Only build emoji color font since Fedora 26 + +* Wed May 23 2018 Peng Wu - 20180508-2 +- Use GraphicsMagick instead of ImageMagick + +* Tue May 08 2018 Mike FABIAN - 20180508-1 +- Update to upstream snapshot tarball (color emoji font version 2.011) +- Add patch to build all country flags (Resolves: rhbz#1574195) + +* Wed Mar 07 2018 Mike FABIAN - 20180307-1 +- Update to upstream snapshot tarball (color emoji font version 2.004) + +* Wed Feb 07 2018 Fedora Release Engineering - 20170928-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Feb 5 2018 Peng Wu - 20170928-3 +- Use nototools package to build google-noto-emoji-fonts + +* Wed Nov 8 2017 Peter Oliver - 20170928-2 +- Prefer zopflipng to optipng, since it should yield smaller files. +- Use the font we built, rather than the one included with the source. + +* Thu Sep 28 2017 Mike FABIAN - 20170828-1 +- Update to upstream snapshot tarball +- split black-and-white and color fonts into different sub-packages. + +* Mon Aug 28 2017 Mike FABIAN - 20170827-1 +- Update to upstream snapshot tarball +- Update color emoji font to version 2.001, new design. +- Contains the new emoji added in Unicode 10.0.0. + +* Wed Jul 26 2017 Fedora Release Engineering - 20170608-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Thu Jun 08 2017 Mike FABIAN - 20170608-1 +- Update to upstream snapshot tarball + +* Tue May 23 2017 Mike FABIAN - 20170523-1 +- Update to upstream snapshot tarball +- This fixes the skin tones of the light/medium light male cook emoji, + which had been swapped. + +* Wed Apr 26 2017 Mike FABIAN - 20170426-1 +- Update to upstream snapshot tarball + (fixes the family emoji sequences: + kiss: woman, man U+1F469 U+200D U+2764 U+FE0F U+200D U+1F48B U+200D U+1F468 + couple with heart: woman, man U+1F469 U+200D U+2764 U+FE0F U+200D U+1F468) + +* Thu Feb 23 2017 Peng Wu - 20170223-1 +- Update to upstream snapshot tarball + +* Fri Feb 10 2017 Fedora Release Engineering - 20160406-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Fri May 6 2016 Peng Wu - 20160406-5 +- Avoid to use python setup.py + +* Fri Apr 29 2016 Peng Wu - 20160406-4 +- Replace google-noto-color-emoji-fonts package + +* Mon Apr 25 2016 Peng Wu - 20160406-3 +- Add google-noto-emoji.metainfo.xml + +* Wed Apr 20 2016 Peng Wu - 20160406-2 +- Use system pngquant + +* Wed Apr 20 2016 Peng Wu - 20160406-1 +- Initial packaging diff --git a/google-noto-emoji.metainfo.xml b/google-noto-emoji.metainfo.xml new file mode 100644 index 0000000..beecdc8 --- /dev/null +++ b/google-noto-emoji.metainfo.xml @@ -0,0 +1,11 @@ + + + + google-noto-emoji + CC-BY-3.0 + Noto Emoji + Google Noto Emoji Font + https://github.com/googlei18n/noto-emoji + + google-noto + diff --git a/noto-emoji-build-all-flags.patch b/noto-emoji-build-all-flags.patch new file mode 100644 index 0000000..564b08a --- /dev/null +++ b/noto-emoji-build-all-flags.patch @@ -0,0 +1,11 @@ +--- old/Makefile 2018-05-03 20:32:14.000000000 +0200 ++++ new/Makefile 2018-05-08 11:48:20.811073447 +0200 +@@ -78,7 +78,7 @@ + + ALL_FLAGS = $(basename $(notdir $(wildcard $(FLAGS_SRC_DIR)/*.png))) + +-FLAGS = $(SELECTED_FLAGS) ++FLAGS = $(ALL_FLAGS) + + FLAG_NAMES = $(FLAGS:%=%.png) + FLAG_FILES = $(addprefix $(FLAGS_DIR)/, $(FLAG_NAMES)) diff --git a/noto-emoji-check-sequence.patch b/noto-emoji-check-sequence.patch new file mode 100644 index 0000000..c5f1db7 --- /dev/null +++ b/noto-emoji-check-sequence.patch @@ -0,0 +1,20 @@ +diff -ru noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f.orig/Makefile noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f/Makefile +--- noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f.orig/Makefile 2020-07-22 04:16:40.000000000 +0200 ++++ noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f/Makefile 2020-07-24 12:36:48.786209598 +0200 +@@ -206,7 +206,7 @@ + @rm -f "$@" + ttx "$<" + +-$(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ ++$(EMOJI).ttf: $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ + $(ALL_COMPRESSED_FILES) | check_tools + + @$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u" +@@ -230,5 +230,5 @@ + .SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \ + $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) + +-.PHONY: clean flags emoji renamed_flags quantized compressed check_tools ++.PHONY: clean flags emoji renamed_flags quantized compressed check_tools check_sequence + +noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f のみに存在: Makefile.~1~ diff --git a/noto-emoji-port-to-python3.patch b/noto-emoji-port-to-python3.patch new file mode 100644 index 0000000..46b21e9 --- /dev/null +++ b/noto-emoji-port-to-python3.patch @@ -0,0 +1,303 @@ +From e158cbe50e17dad1bd41c641d01f3c3989c083c6 Mon Sep 17 00:00:00 2001 +From: Mike FABIAN +Date: Wed, 17 Jul 2019 10:33:21 +0200 +Subject: [PATCH 1/2] Make it work both with Python2 and Python3 + +--- + add_glyphs.py | 8 +-- + map_pua_emoji.py | 4 +- + third_party/color_emoji/emoji_builder.py | 63 ++++++++++++++---------- + third_party/color_emoji/png.py | 42 +++++++++++----- + 4 files changed, 73 insertions(+), 44 deletions(-) + +diff --git a/add_glyphs.py b/add_glyphs.py +index a12b4401..b5918d42 100644 +--- a/add_glyphs.py ++++ b/add_glyphs.py +@@ -66,7 +66,7 @@ def collect_seq_to_file(image_dirs, prefix, suffix): + + + def remap_values(seq_to_file, map_fn): +- return {k: map_fn(v) for k, v in seq_to_file.iteritems()} ++ return {k: map_fn(v) for k, v in seq_to_file.items()} + + + def get_png_file_to_advance_mapper(lineheight): +@@ -280,7 +280,7 @@ def add_ligature_sequences(font, seqs, aliases): + return + + rtl_seq_to_target_name = { +- get_rtl_seq(seq): name for seq, name in seq_to_target_name.iteritems()} ++ get_rtl_seq(seq): name for seq, name in seq_to_target_name.items()} + seq_to_target_name.update(rtl_seq_to_target_name) + # sequences that don't have rtl variants get mapped to the empty sequence, + # delete it. +@@ -289,7 +289,7 @@ def add_ligature_sequences(font, seqs, aliases): + + # organize by first codepoint in sequence + keyed_ligatures = collections.defaultdict(list) +- for t in seq_to_target_name.iteritems(): ++ for t in seq_to_target_name.items(): + first_cp = t[0][0] + keyed_ligatures[first_cp].append(t) + +@@ -339,7 +339,7 @@ def apply_aliases(seq_dict, aliases): + source is a key in the dictionary, we can delete it. This updates the + dictionary and returns the usable aliases.""" + usable_aliases = {} +- for k, v in aliases.iteritems(): ++ for k, v in aliases.items(): + if v in seq_dict: + usable_aliases[k] = v + if k in seq_dict: +diff --git a/map_pua_emoji.py b/map_pua_emoji.py +index aac031c5..ff8d6a9b 100644 +--- a/map_pua_emoji.py ++++ b/map_pua_emoji.py +@@ -53,8 +53,8 @@ def add_pua_cmap(source_file, target_file): + """Add PUA characters to the cmap of the first font and save as second.""" + font = ttLib.TTFont(source_file) + cmap = font_data.get_cmap(font) +- for pua, (ch1, ch2) in (add_emoji_gsub.EMOJI_KEYCAPS.items() +- + add_emoji_gsub.EMOJI_FLAGS.items()): ++ for pua, (ch1, ch2) in (list(add_emoji_gsub.EMOJI_KEYCAPS.items()) ++ + list(add_emoji_gsub.EMOJI_FLAGS.items())): + if pua not in cmap: + glyph_name = get_glyph_name_from_gsub([ch1, ch2], font) + if glyph_name is not None: +diff --git a/third_party/color_emoji/emoji_builder.py b/third_party/color_emoji/emoji_builder.py +index 4157807e..7f17c62f 100644 +--- a/third_party/color_emoji/emoji_builder.py ++++ b/third_party/color_emoji/emoji_builder.py +@@ -19,7 +19,7 @@ + + + from __future__ import print_function +-import sys, struct, StringIO ++import sys, struct + from png import PNG + import os + from os import path +@@ -112,9 +112,9 @@ class CBDT: + line_height = (ascent + descent) * y_ppem / float (upem) + line_ascent = ascent * y_ppem / float (upem) + y_bearing = int (round (line_ascent - .5 * (line_height - height))) +- # fudge y_bearing if calculations are a bit off +- if y_bearing == 128: +- y_bearing = 127 ++ # fudge y_bearing if calculations are a bit off ++ if y_bearing == 128: ++ y_bearing = 127 + advance = width + + vert_x_bearing = - width / 2 +@@ -133,22 +133,22 @@ class CBDT: + # CHAR vertBearingX + # CHAR vertBearingY + # BYTE vertAdvance +- try: +- if big_metrics: +- self.write (struct.pack ("BBbbBbbB", ++ try: ++ if big_metrics: ++ self.write (struct.pack ("BBbbBbbB", + height, width, + x_bearing, y_bearing, + advance, + vert_x_bearing, vert_y_bearing, + vert_advance)) +- else: +- self.write (struct.pack ("BBbbB", ++ else: ++ self.write (struct.pack ("BBbbB", + height, width, + x_bearing, y_bearing, + advance)) +- except Exception as e: +- raise ValueError("%s, h: %d w: %d x: %d y: %d %d a:" % ( +- e, height, width, x_bearing, y_bearing, advance)) ++ except Exception as e: ++ raise ValueError("%s, h: %d w: %d x: %d y: %d %d a:" % ( ++ e, height, width, x_bearing, y_bearing, advance)) + + def write_format1 (self, png): + +@@ -179,12 +179,15 @@ class CBDT: + self.write (pixel) + offset += stride + +- png_allowed_chunks = ["IHDR", "PLTE", "tRNS", "sRGB", "IDAT", "IEND"] ++ png_allowed_chunks = [ ++ "IHDR", "PLTE", "tRNS", "sRGB", "IDAT", "IEND", # Python2 ++ b"IHDR", b"PLTE", b"tRNS", b"sRGB", b"IDAT", b"IEND", # Python3 ++ ] + + def write_format17 (self, png): + self.write_format17or18(png, False) + +- def write_format18 (self, png): ++ def write_format18 (self, png): + self.write_format17or18(png, True) + + def write_format17or18 (self, png, big_metrics): +@@ -202,7 +205,7 @@ class CBDT: + + def image_write_func (self, image_format): + if image_format == 1: return self.write_format1 +- if image_format == 17: return self.write_format17 ++ if image_format == 17: return self.write_format17 + if image_format == 18: return self.write_format18 + return None + +@@ -441,7 +444,10 @@ By default they are dropped. + + def add_font_table (font, tag, data): + tab = ttLib.tables.DefaultTable.DefaultTable (tag) +- tab.data = str(data) ++ if sys.version_info >= (3, 0, 0): ++ tab.data = data ++ else: ++ tab.data = str(data) + font[tag] = tab + + def drop_outline_tables (font): +@@ -478,7 +484,7 @@ By default they are dropped. + eblc.write_header () + eblc.start_strikes (len (img_prefixes)) + +- def is_vs(cp): ++ def is_vs(cp): + return cp >= 0xfe00 and cp <= 0xfe0f + + for img_prefix in img_prefixes: +@@ -491,14 +497,20 @@ By default they are dropped. + codes = img_file[len (img_prefix):-4] + if "_" in codes: + pieces = codes.split ("_") +- cps = [int(code, 16) for code in pieces] +- uchars = "".join ([unichr(cp) for cp in cps if not is_vs(cp)]) ++ cps = [int(code, 16) for code in pieces] ++ if sys.version_info >= (3, 0, 0): ++ uchars = "".join ([chr(cp) for cp in cps if not is_vs(cp)]) ++ else: ++ uchars = "".join ([unichr(cp) for cp in cps if not is_vs(cp)]) + else: +- cp = int(codes, 16) +- if is_vs(cp): +- print("ignoring unexpected vs input %04x" % cp) +- continue +- uchars = unichr(cp) ++ cp = int(codes, 16) ++ if is_vs(cp): ++ print("ignoring unexpected vs input %04x" % cp) ++ continue ++ if sys.version_info >= (3, 0, 0): ++ uchars = chr(cp) ++ else: ++ uchars = unichr(cp) + img_files[uchars] = img_file + if not img_files: + raise Exception ("No image files found in '%s'." % glb) +@@ -561,8 +573,7 @@ By default they are dropped. + # hack removal of cmap pua entry for unknown flag glyph. If we try to + # remove it earlier, getGlyphID dies. Need to restructure all of this + # code. +- font_data.delete_from_cmap(font, [0xfe82b]) +- ++ font_data.delete_from_cmap(font, [0xfe82b]) + font.save (out_file) + print("Output font '%s' generated." % out_file) + +diff --git a/third_party/color_emoji/png.py b/third_party/color_emoji/png.py +index 20f849ae..f5d4c2d5 100644 +--- a/third_party/color_emoji/png.py ++++ b/third_party/color_emoji/png.py +@@ -17,7 +17,12 @@ + # Google Author(s): Behdad Esfahbod + # + +-import struct, StringIO ++import struct ++import sys ++if sys.version_info >= (3,0,0): # Python3 ++ from io import StringIO ++else: ++ from StringIO import StringIO + + + class PNG: +@@ -26,7 +31,7 @@ class PNG: + + def __init__ (self, f): + +- if isinstance(f, basestring): ++ if (isinstance(f, str) or isinstance(f, type(u''))): + f = open (f, 'rb') + + self.f = f +@@ -43,7 +48,10 @@ class PNG: + + def data (self): + self.seek (0) +- return bytearray (self.f.read ()) ++ if sys.version_info >= (3,0,0): # Python3 ++ return bytearray (self.f.read (), 'iso-8859-1') ++ else: ++ return bytearray (self.f.read ()) + + class BadSignature (Exception): pass + class BadChunk (Exception): pass +@@ -55,7 +63,8 @@ class PNG: + return PNG.signature + + def read_chunk (self): +- length = struct.unpack (">I", self.f.read (4))[0] ++ buf = self.f.read (4) ++ length = struct.unpack (">I", buf)[0] + chunk_type = self.f.read (4) + chunk_data = self.f.read (length) + if len (chunk_data) != length: +@@ -67,7 +76,7 @@ class PNG: + + def read_IHDR (self): + (chunk_type, chunk_data, crc) = self.read_chunk () +- if chunk_type != "IHDR": ++ if chunk_type not in ("IHDR", b"IHDR"): + raise PNG.BadChunk + # Width: 4 bytes + # Height: 4 bytes +@@ -93,15 +102,24 @@ class PNG: + + def filter_chunks (self, chunks): + self.seek (0); +- out = StringIO.StringIO () +- out.write (self.read_signature ()) ++ out = StringIO () ++ if sys.version_info >= (3,0,0): # Python3 ++ out.write (self.read_signature ().decode('iso-8859-1')) ++ else: ++ out.write (self.read_signature ()) + while True: + chunk_type, chunk_data, crc = self.read_chunk () + if chunk_type in chunks: +- out.write (struct.pack (">I", len (chunk_data))) +- out.write (chunk_type) +- out.write (chunk_data) +- out.write (crc) +- if chunk_type == "IEND": ++ if sys.version_info >= (3,0,0): # Python3 ++ out.write (struct.pack (">I", len (chunk_data)).decode('iso-8859-1')) ++ out.write (chunk_type.decode('iso-8859-1')) ++ out.write (chunk_data.decode('iso-8859-1')) ++ out.write (crc.decode('iso-8859-1')) ++ else: ++ out.write (struct.pack (">I", len (chunk_data))) ++ out.write (chunk_type) ++ out.write (chunk_data) ++ out.write (crc) ++ if chunk_type in ("IEND", b"IEND"): + break + return PNG (out) +-- +2.21.0 + diff --git a/noto-emoji-python3.patch b/noto-emoji-python3.patch new file mode 100644 index 0000000..3872b40 --- /dev/null +++ b/noto-emoji-python3.patch @@ -0,0 +1,176 @@ +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/Makefile noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/Makefile +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/Makefile 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/Makefile 2018-08-14 14:16:40.601744161 +0200 +@@ -209,7 +209,7 @@ + # 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) ++ @python3 $(ADD_GLYPHS) -f "$<" -o "$@" -d "$(COMPRESSED_DIR)" $(ADD_GLYPHS_FLAGS) + + %.ttf: %.ttx + @rm -f "$@" +@@ -217,8 +217,8 @@ + + $(EMOJI).ttf: $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ + $(ALL_COMPRESSED_FILES) | check_vs_adder +- @python $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u" +- @python $(PUA_ADDER) "$@" "$@-with-pua" ++ @python3 $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u" ++ @python3 $(PUA_ADDER) "$@" "$@-with-pua" + @$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua" + @mv "$@-with-pua-varsel" "$@" + @rm "$@-with-pua" +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_aliases.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_aliases.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_aliases.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_aliases.py 2018-08-14 14:15:28.586483050 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2017 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_emoji_gsub.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_emoji_gsub.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_emoji_gsub.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_emoji_gsub.py 2018-08-14 14:15:28.586483050 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2014 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_glyphs.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_glyphs.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_glyphs.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_glyphs.py 2018-08-14 14:15:28.587483040 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + + """Extend a ttx file with additional data. + +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_svg_glyphs.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_svg_glyphs.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/add_svg_glyphs.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/add_svg_glyphs.py 2018-08-14 14:15:28.588483029 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2015 Google, Inc. All Rights Reserved. + # + # Licensed under the Apache License, Version 2.0 (the "License"); +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/check_emoji_sequences.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/check_emoji_sequences.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/check_emoji_sequences.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/check_emoji_sequences.py 2018-08-14 14:15:28.588483029 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2016 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/collect_emoji_svg.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/collect_emoji_svg.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/collect_emoji_svg.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/collect_emoji_svg.py 2018-08-14 14:15:28.589483019 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2015 Google, Inc. All Rights Reserved. + # + # Licensed under the Apache License, Version 2.0 (the "License"); +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/flag_glyph_name.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/flag_glyph_name.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/flag_glyph_name.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/flag_glyph_name.py 2018-08-14 14:15:28.589483019 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2014 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/flag_info.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/flag_info.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/flag_info.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/flag_info.py 2018-08-14 14:15:28.590483009 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # + # Copyright 2016 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/gen_version.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/gen_version.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/gen_version.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/gen_version.py 2018-08-14 14:15:28.590483009 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2015 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_html.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_html.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_html.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_html.py 2018-08-14 14:15:28.591482998 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2016 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_name_data.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_name_data.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_name_data.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_name_data.py 2018-08-14 14:15:28.591482998 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # -*- coding: utf-8 -*-# + # + # Copyright 2015 Google Inc. All rights reserved. +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_thumbnails.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_thumbnails.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_emoji_thumbnails.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_emoji_thumbnails.py 2018-08-14 14:15:28.592482988 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2017 Google Inc. All rights reserved. + # + # Licensed under the Apache License, Version 2.0 (the "License"); +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_test_html.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_test_html.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/generate_test_html.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/generate_test_html.py 2018-08-14 14:15:28.592482988 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2015 Google, Inc. All Rights Reserved. + # + # Licensed under the Apache License, Version 2.0 (the "License"); +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/map_pua_emoji.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/map_pua_emoji.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/map_pua_emoji.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/map_pua_emoji.py 2018-08-14 14:15:28.593482978 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2014 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/materialize_emoji_images.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/materialize_emoji_images.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/materialize_emoji_images.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/materialize_emoji_images.py 2018-08-14 14:15:28.593482978 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2016 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/strip_vs_from_filenames.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/strip_vs_from_filenames.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/strip_vs_from_filenames.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/strip_vs_from_filenames.py 2018-08-14 14:15:28.594482968 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2017 Google Inc. All rights reserved. + # +diff -ru noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/svg_cleaner.py noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/svg_cleaner.py +--- noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362.orig/svg_cleaner.py 2018-08-10 22:25:19.000000000 +0200 ++++ noto-emoji-3ffd20ec7504657aa17c84f9aa475ad09b20c362/svg_cleaner.py 2018-08-14 14:15:28.594482968 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2015 Google, Inc. All Rights Reserved. + # + # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/noto-emoji-use-gm.patch b/noto-emoji-use-gm.patch new file mode 100644 index 0000000..e1cf6ee --- /dev/null +++ b/noto-emoji-use-gm.patch @@ -0,0 +1,30 @@ +diff -ru noto-emoji-f8131fc45736000552cd04a8388dc414d666a829.orig/Makefile noto-emoji-f8131fc45736000552cd04a8388dc414d666a829/Makefile +--- noto-emoji-f8131fc45736000552cd04a8388dc414d666a829.orig/Makefile 2020-06-25 16:02:56.000000000 +0200 ++++ noto-emoji-f8131fc45736000552cd04a8388dc414d666a829/Makefile 2020-07-21 11:12:06.948389580 +0200 +@@ -22,7 +22,8 @@ + PYTHON = python3 + PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force + BODY_DIMENSIONS = 136x128 +-IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center ++#IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center ++IMOPS = -size 136x128 -background none -gravity center -extent 136x128 -compose copy + + ZOPFLIPNG = zopflipng + TTX = ttx +@@ -163,13 +164,13 @@ + # imagemagick packaged with ubuntu trusty (6.7.7-10) by using -composite. + + $(EMOJI_DIR)/%.png: $(EMOJI_SRC_DIR)/%.png | $(EMOJI_DIR) +- @convert $(IMOPS) "$<" -composite "PNG32:$@" ++ @gm convert $(IMOPS) "$<" "PNG32:$@" + + $(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag | $(FLAGS_DIR) + @./waveflag $(FLAGS_DIR)/ "$<" + + $(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR) +- @convert $(IMOPS) "$<" -composite "PNG32:$@" ++ @gm convert $(IMOPS) "$<" "PNG32:$@" + + flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR) + @$(subst ^, , \ + diff --git a/noto-emoji-use-system-pngquant.patch b/noto-emoji-use-system-pngquant.patch new file mode 100644 index 0000000..f3dd7ff --- /dev/null +++ b/noto-emoji-use-system-pngquant.patch @@ -0,0 +1,29 @@ +diff -ru noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f.orig/Makefile noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f/Makefile +--- noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f.orig/Makefile 2020-07-23 18:53:36.935321925 +0200 ++++ noto-emoji-d5e261484286d33a1fe8a02676f5907ecc02106f/Makefile 2020-07-23 19:05:20.380141144 +0200 +@@ -15,10 +15,10 @@ + EMOJI = NotoColorEmoji + font: $(EMOJI).ttf + +-CFLAGS = -std=c99 -Wall -Wextra `pkg-config --cflags --libs cairo` ++CFLAGS = $(OPT_CFLAGS) -Wextra `pkg-config --cflags --libs cairo` + LDFLAGS = -lm `pkg-config --libs cairo` + +-PNGQUANT = pngquant ++PNGQUANT = /usr/bin/pngquant + PYTHON = python3 + PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force + BODY_DIMENSIONS = 136x128 +@@ -87,9 +87,9 @@ + endif + endif + +-ifndef VIRTUAL_ENV +- MISSING_VENV = fail +-endif ++#ifndef VIRTUAL_ENV ++# MISSING_VENV = fail ++#endif + + ifeq (, $(shell which $(VS_ADDER))) + MISSING_PY_TOOLS = fail diff --git a/sources b/sources new file mode 100644 index 0000000..bb1ab36 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (noto-emoji-d5e2614.tar.gz) = 9b3960151114e57b94d698d1dc9d794da97d7061bf60e24f6b2513c40ef73bcd8db4b239c60719adf102a825713dc3086a825d1e58e2000f1b00438b8795d75e diff --git a/tests/roles/custom-test-fonts/README.md b/tests/roles/custom-test-fonts/README.md new file mode 100644 index 0000000..d28fc26 --- /dev/null +++ b/tests/roles/custom-test-fonts/README.md @@ -0,0 +1,69 @@ +# Ansible role for tests using fontconfig + +Put this role in your `tests.yml` playbook. The playbook will first install +package dependencies listed on playbook on your localhost, then it will proceed +to run testing. You can redefine the following variables: + + * **artifacts**: An artifacts directory on localhost to store logs + * **remote_artifacts**: The directory on the system under test where the logs + are stored. Note: if this variable is left undefined, it will default to + `/tmp/artifacts` + * **required_packages**: A list of prerequisite packages required by tests. + Please note that for Atomic Host, additional packages will be installed + using the `rpm-ostree` command which is affecting the test subject (it's + similar as rebuilding an rpm package to be tested) so this should be used + with caution on only when necessary. + * **path_prefix**: The directory on the system where fonts are installed. + please use one in coverage sub-parameter if having different path_prefix + per sub-packages. + * **package**: The package name to test. this is used to find out fontconfig + config file. please use one in families sub-parameter if having different + config files per sub-packages. + * **coverage**: A list of languages for language coverage tests. + * **families**: A list of family test cases. + +## Language coverage test parameters + +Supporting two types of formats. one is a simple list of languages: + + coverage: + - en + - fr + +Another one is a dictionary that has a language as a key and values as parameters: + + coverage: + en: + ... + fr: + ... + +You can redefine the following variables for dictionary format: + + * **exclude**: A list of font file names to exclude on this testing. this is + useful to avoid unexpected failures on iterating tests when a package has + multiple font files and has different coverages but you need to prevent + testing for few fonts which has different coverages to them. + Please note that the file name is relative to `path_prefix` parameter. also + good to consider using `include` if non-targeted files is more than targeted. + * **include**: A list of font file names to include on this testing. this is + useful to avoid unexpected failures on iterating tests when a pcakge has + multiple font files and has different coverages but you need to prevent + testing for few fonts which has different coverages to them. + Please note that the file name is relative to `path_prefix` parameter. also + good to consider using `exclude` if targeted files is more than non-targeted. + * **name**: The name to store logs. the test script is trying to make an unique + file names to store logs but not perfectly working in some cases. this is + optional parameter to make it unique by yourself. + * **path_prefix**: A list of directory names where fonts are installed on system. + this is optional parameter and tries to obtain the font paths from installed + packages by `required_packages` if not available. + +## Family test parameters + + * **lang**: A language to test family name for. + * **alias**: An alias name to test. + * **family**: A family name to test, which is supposed to be assinged to the alias. + * **package**: The package name to test. this is used to find out fontconfig + config file. this is optional. if not specified here, global `package` + parameter will be used. diff --git a/tests/roles/custom-test-fonts/defaults/main.yml b/tests/roles/custom-test-fonts/defaults/main.yml new file mode 100644 index 0000000..fe09145 --- /dev/null +++ b/tests/roles/custom-test-fonts/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +role_pkgs_req: + - fontconfig + - fontconfig-devel + - pkg-config + - rsync diff --git a/tests/roles/custom-test-fonts/files/run-family-test b/tests/roles/custom-test-fonts/files/run-family-test new file mode 100755 index 0000000..bbbed73 --- /dev/null +++ b/tests/roles/custom-test-fonts/files/run-family-test @@ -0,0 +1,162 @@ +#! /bin/bash -efu + +debug() { + if [ -n "$DEBUG" ]; then + echo "$*" >&2 + fi +} + +msg_usage() { + cat <<_EOF_ +Run family test. + +Usage: +$PROG + +Options: +-h, --help Display this help and exit +-v, --verbose Turn on debug +-l, --lang=LANG Test LANG language coverage (default: en) +-f, --family=FILE Set a family name supposed to be assigned for alias. +-g, --alias=STR Set an alias name. (default: sans-serif) +-a, --artifactsdir=DIR Set environment dir to store artifacts +-k, --package=NAME Set a package name for fonts. +_EOF_ +} + +PROG="${PROG:-${0##*/}}" +DEBUG="${DEBUG:-}" +OPT_LANG="${OPT_LANG:-en}" +OPT_FAMILY="${OPT_FAMILY:-}" +OPT_ARTIFACTS_DIR="${OPT_ARTIFACTS_DIR:-}" +OPT_ALIAS="${OPT_ALIAS:-sans-serif}" +OPT_PACKAGE="${OPT_PACKAGE:-}" + +opt=$(getopt -n "$0" --options "hvl:f:t:a:g:k:" --longoptions "help,verbose,lang:,family:,test:,artifactsdir:,alias:,package:" -- "$@") +eval set -- "$opt" +while [[ $# -gt 0 ]]; do + case "$1" in + -k|--package) + OPT_PACKAGE="$2" + shift 2 + ;; + -g|--alias) + OPT_ALIAS="$2" + shift 2 + ;; + -a|--artifactsdir) + OPT_ARTIFACTS_DIR="$2" + shift 2 + ;; + -f|--family) + OPT_FAMILY="$2" + shift 2 + ;; + -l|--lang) + OPT_LANG="$2" + shift 2 + ;; + -v|--verbose) + DEBUG="-v" + shift + ;; + -h|--help) + msg_usage + exit 0 + ;; + --) + shift + ;; + *) + msg_usage + exit 1 + esac +done + +if [ -z "$OPT_ARTIFACTS_DIR" ] || [ -z "$OPT_LANG" ] || [ -z "$OPT_FAMILY" ]; then + echo "Use: $PROG -h for help." + exit 0 +fi + +debug "Alias: $OPT_ALIAS" +debug "Family: $OPT_FAMILY" +debug "Lang: $OPT_LANG" +debug "Artifacts dir: $OPT_ARTIFACTS_DIR" +debug "Package name: $OPT_PACKAGE" +STR_TEST_DASHED=$(echo "${OPT_PACKAGE}_${OPT_ALIAS}_${OPT_LANG}" | sed -e 's/\//-/g' -e 's/ /-/g') +debug "Log file: $STR_TEST_DASHED.log" + +clean_exit() { + rc=$?; + trap - SIGINT SIGTERM SIGABRT EXIT + echo "Run test $OPT_ALIAS: done. Test's exit code: $rc" + for pid in $(ps -o pid --no-headers --ppid $$); do + if [ -n "$(ps -p $pid -o pid=)" ]; then + kill -s HUP $pid + fi + done + local log_file_name="$STR_TEST_DASHED.log" + local log_file_path="$OPT_ARTIFACTS_DIR/$log_file_name" + local status + if [[ $rc -eq 127 ]]; then + status="ERROR" + elif grep -q "RESULT: WARN" "$log_file_path"; then + status="ERROR" + elif grep -q "RESULT: FAIL" "$log_file_path"; then + status="FAIL" + elif grep -q "RESULT: PASS" "$log_file_path"; then + status="PASS" + elif grep -q "FAIL" "$log_file_path"; then + status="FAIL" + elif grep -q "PASS" "$log_file_path"; then + status="PASS" + else + status="ERROR" + fi + echo "$status $OPT_ALIAS" >> "$OPT_ARTIFACTS_DIR/test.log" + mv "$log_file_path" "$OPT_ARTIFACTS_DIR/${status}-${log_file_name}" + local results="$OPT_ARTIFACTS_DIR/results.yml" + local result=$(echo $status | tr '[:upper:]' '[:lower:]') + test -f "$results" || echo 'results:' > "$results" + printf '%s\n' '' \ + "- test: $OPT_ALIAS" \ + " result: $result" \ + " logs:" \ + " - ${status}_${log_file_name}" \ + >> "$results" + exit 0 +} +trap clean_exit SIGINT SIGTERM SIGABRT EXIT + +cachedir=`pkg-config --variable cachedir fontconfig` +tmpconfd=`mktemp --tmpdir -d fontsci.XXXXXXXX` +conf=$(for i in `rpm -ql $OPT_PACKAGE | grep conf.d`; do + echo "$i" +done) +cat <<_EOF_> $tmpconfd/fonts.conf + + /usr/share/fonts + $conf + $cachedir + +_EOF_ +debug "Config: `cat $tmpconfd/fonts.conf`" + +mkdir -p "$OPT_ARTIFACTS_DIR" +export OUTPUTFILE="$(realpath "$OPT_ARTIFACTS_DIR")/$STR_TEST_DASHED-out.log" +logfile="$OPT_ARTIFACTS_DIR/$STR_TEST_DASHED.log" +logfile="$(realpath "$logfile")" +exec > >(tee -a "$logfile") 2>&1 + +debug "Check family assignment" +res=`FONTCONFIG_FILE=$tmpconfd/fonts.conf fc-match -f "%{family[0]}" :family=$OPT_ALIAS:lang=$OPT_LANG` +ret=0 +if [ "x$res" = "x$OPT_FAMILY" ]; then + echo "RESULT: PASS: $OPT_FAMILY was assigned to $OPT_ALIAS as expected" +else + echo "RESULT: FAIL: $OPT_FAMILY wasn't assigned to $OPT_ALIAS (actual result: $res)" + ret=1 +fi +rm -rf $tmpconfd + +exit $ret diff --git a/tests/roles/custom-test-fonts/files/run-lang-coverage-test b/tests/roles/custom-test-fonts/files/run-lang-coverage-test new file mode 100755 index 0000000..a0de1fb --- /dev/null +++ b/tests/roles/custom-test-fonts/files/run-lang-coverage-test @@ -0,0 +1,252 @@ +#! /bin/bash -efu + +debug() { + if [ -n "$DEBUG" ]; then + echo "$*" >&2 + fi +} + +msg_usage() { + cat <<_EOF_ +Run language coverage test. + +Usage: +$PROG + +Options: +-h, --help Display this help and exit +-v, --verbose Turn on debug +-l, --lang=LANG Test LANG language coverage (default: en) +-p, --path=PATH Test fonts on PATH +-k, --package=PACKAGE Specify PACKAGE to obtain some information +-n, --name=NAME Set NAME to store a log file. +-a, --artifactsdir=DIR test environment dir to store artifacts +-e, --exclude=FILE Exclude FILE to check. +-i, --include=FILE Include File to check. +_EOF_ +} + +PROG="${PROG:-${0##*/}}" +DEBUG="${DEBUG:-}" +OPT_LANG="${OPT_LANG:-en}" +OPT_PATH=() +OPT_PACKAGE=() +OPT_ARTIFACTS_DIR="${OPT_ARTIFACTS_DIR:-}" +OPT_EXCLUDE=() +OPT_INCLUDE=() +OPT_NAME="${OPT_NAME:-}" + +opt=$(getopt -n "$0" --options "hvl:p:k:n:a:e:i:" --longoptions "help,verbose,lang:,path:,package:,name:,artifactsdir:,exclude:,include:" -- "$@") +eval set -- "$opt" +while [[ $# -gt 0 ]]; do + case "$1" in + -n|--name) + OPT_NAME="$2" + shift 2 + ;; + -i|--include) + OPT_INCLUDE+=("$2") + shift 2 + ;; + -e|--exclude) + OPT_EXCLUDE+=("$2") + shift 2 + ;; + -a|--artifactsdir) + OPT_ARTIFACTS_DIR="$2" + shift 2 + ;; + -p|--path) + OPT_PATH+=("$2") + shift 2 + ;; + -k|--package) + OPT_PACKAGE+=("$2") + shift 2 + ;; + -l|--lang) + OPT_LANG="$2" + shift 2 + ;; + -v|--verbose) + DEBUG="-v" + shift + ;; + -h|--help) + msg_usage + exit 0 + ;; + --) + shift + ;; + *) + msg_usage + exit 1 + esac +done + +if [ -z "$OPT_ARTIFACTS_DIR" ] || [ -z "$OPT_LANG" ] || [ ! -v OPT_PATH ] && [ ! -v OPT_PACKAGE ]; then + echo "Use: $PROG -h for help." + exit 0 +fi + +STR_TEST_DASHED=$(echo "${OPT_NAME:-$OPT_LANG}" | sed -e 's/\//-/g') + +clean_exit() { + rc=$?; + trap - SIGINT SIGTERM SIGABRT EXIT + echo "Run test $OPT_LANG: done. Test's exit code: $rc" + for pid in $(ps -o pid --no-headers --ppid $$); do + if [ -n "$(ps -p $pid -o pid=)" ]; then + kill -s HUP $pid + fi + done + local log_file_name="$STR_TEST_DASHED.log" + local log_file_path="$OPT_ARTIFACTS_DIR/$log_file_name" + local status + if [[ $rc -eq 127 ]]; then + status="ERROR" + elif grep -q "RESULT: WARN" "$log_file_path"; then + status="ERROR" + elif grep -q "RESULT: FAIL" "$log_file_path"; then + status="FAIL" + elif grep -q "RESULT: PASS" "$log_file_path"; then + status="PASS" + elif grep -q "WARN" "$log_file_path"; then + status="ERROR" + elif grep -q "FAIL" "$log_file_path"; then + status="FAIL" + elif grep -q "PASS" "$log_file_path"; then + status="PASS" + else + status="ERROR" + fi + echo "$status $OPT_LANG" >> "$OPT_ARTIFACTS_DIR/test.log" + mv "$log_file_path" "$OPT_ARTIFACTS_DIR/${status}-${log_file_name}" + local results="$OPT_ARTIFACTS_DIR/results.yml" + local result=$(echo $status | tr '[:upper:]' '[:lower:]') + test -f "$results" || echo 'results:' > "$results" + printf '%s\n' '' \ + "- test: $OPT_LANG" \ + " result: $result" \ + " logs:" \ + " - ${status}_${log_file_name}" \ + >> "$results" + exit 0 +} +trap clean_exit SIGINT SIGTERM SIGABRT EXIT + +mkdir -p "$OPT_ARTIFACTS_DIR" +export OUTPUTFILE="$(realpath "$OPT_ARTIFACTS_DIR")/$STR_TEST_DASHED-out.log" +logfile="$OPT_ARTIFACTS_DIR/$STR_TEST_DASHED.log" +logfile="$(realpath "$logfile")" +exec > >(tee -a "$logfile") 2>&1 + +for pkg in ${OPT_PACKAGE[@]}; do + if ! rpm -q ${pkg} > /dev/null 2>&1; then + echo "Package isn't installed or maybe a typo: ${pkg}" + exit 127 + fi + d=$(for d in $(rpm -ql ${pkg}|grep /usr/share/fonts); do + dirname $d + done | sort | uniq | grep /usr/share/fonts/) + if [[ ! " ${OPT_PATH[@]} " =~ " ${d} " ]]; then + OPT_PATH+=("$d") + fi +done + +expand_regex() { + local p ret=() + local regex="$1" + shift + debug "Expanding $regex" + for p; do + set +f + debug "$p: $regex" + (cd $p; + local x=$(find -regextype posix-egrep -regex "./$regex" -print|sed -e 's,^\./,,g') + debug "$x" + ret+=($x) + set -f + echo -n ${ret[@]} + ) + done + echo -n ${ret[@]} +} + +iv=() +ev=() +x=() +for p in ${OPT_INCLUDE[@]}; do + x=$(expand_regex $p ${OPT_PATH[@]}) + if [ "x$x" == "x" ]; then + echo "RESULT: WARN: No matches on \"$p\". maybe typo or something changed?" + continue + fi + iv=("${iv[@]}" "${x[@]}") +done +for p in ${OPT_EXCLUDE[@]}; do + x=$(expand_regex $p ${OPT_PATH[@]}) + if [ "x$x" == "x" ]; then + echo "RESULT: WARN: No matches on \"$p\". maybe typo or something changed?" + continue + fi + ev=("${ev[@]}" "${x[@]}") +done +OPT_EXCLUDE=(${ev[@]}) +OPT_INCLUDE=(${iv[@]}) + +debug "Path: ${OPT_PATH[@]}" +debug "Lang: $OPT_LANG" +debug "Artifacts dir: $OPT_ARTIFACTS_DIR" +debug "Exclude: ${#OPT_EXCLUDE[@]}: ${OPT_EXCLUDE[@]}" +debug "Include: ${#OPT_INCLUDE[@]}: ${OPT_INCLUDE[@]}" + +contains() { + local e match="$1" + shift + for e; do [[ "$e" == "$match" ]] && return 1; done + return 0 +} + +debug "Check language coverage" +ret=0 +set +f +for p in ${OPT_PATH[@]}; do + for i in `find $p -regex '.*/*\.\(t1\)?\(ttf\)?\(otf\)?\(ttc\)?\(pcf.*\)?\(pfa\)?'`; do + set -f + debug "$i" + if test -f $i; then + n=`basename $i` + set +e + contains "$n" "${OPT_EXCLUDE[@]}" + r=$? + set -e + if [ $r -eq 1 ]; then + debug "ignoring $i" + continue + fi + if [ ${#OPT_INCLUDE[@]} -ne 0 ]; then + set +e + contains "$n" "${OPT_INCLUDE[@]}" + r=$? + set -e + if [ $r -eq 0 ]; then + debug "$i isn't targeted file" + continue + fi + NOT_MATCHED=("${NOT_MATCHED[@]/$n}") + fi + debug " $i" + res=`fc-validate -l $OPT_LANG $i || :` + if echo $res | grep -q Missing; then + echo "RESULT: FAIL: $i doesn't satisfy $OPT_LANG language coverage." + ret=1 + else + echo "RESULT: PASS: $i satisfy $OPT_LANG language coverage." + fi + fi + done +done + +exit $ret diff --git a/tests/roles/custom-test-fonts/meta/main.yml b/tests/roles/custom-test-fonts/meta/main.yml new file mode 100644 index 0000000..f6d273c --- /dev/null +++ b/tests/roles/custom-test-fonts/meta/main.yml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: str-common-init diff --git a/tests/roles/custom-test-fonts/tasks/main.yml b/tests/roles/custom-test-fonts/tasks/main.yml new file mode 100644 index 0000000..073fbf8 --- /dev/null +++ b/tests/roles/custom-test-fonts/tasks/main.yml @@ -0,0 +1,48 @@ +--- + +- block: + - name: language coverage + environment: + LANG: "en_US.UTF-8" + script: run-lang-coverage-test --lang "{{ item }}" {% if path_prefix is defined %} --path {{ path_prefix }} {% elif coverage.values is not defined or coverage[item].path_prefix is not defined %} {% else %} {{ '--path "' + (coverage[item].path_prefix | join('" --path "')) + '"' }} {% endif %} --artifactsdir "{{ remote_artifacts }}" {% if coverage.values is not defined or coverage[item].name is not defined %} {% else %} {{ "--name " + coverage[item].name }} {% endif %} {% if coverage.values is not defined or coverage[item].exclude is not defined %} {% else %} {{ '--exclude "' + (coverage[item].exclude | join('" --exclude "')) + '"' }} {% endif %} {% if coverage.values is not defined or coverage[item].include is not defined %} {% else %} {{ '--include "' + (coverage[item].include | join('" --include "')) + '"' }} {% endif %} {% if path_prefix is defined or coverage.values is defined and coverage[item].path_prefix is defined %} {% else %} {{ '--package "' + (required_packages|join('" --package "')) + '"' }} {% endif %} + with_items: + - "{{ coverage if coverage.keys is not defined else coverage.keys()|list }}" + - name: generic family assignment + environment: + LANG: "en_US.UTF-8" + when: families is defined + script: run-family-test --lang {{ item.lang }} --family '{{ item.family }}' --alias {{ item.alias }} --artifactsdir {{ remote_artifacts }} --package {{ package if item.package is not defined else item.package }} + with_items: + - "{{ families }}" + + - name: Check the results + shell: | + log="{{ remote_artifacts }}/test.log" + if [ ! -f "$log" ]; then + echo ERROR + echo "Test results not found." 1>&2 + elif grep ^ERROR "$log" 1>&2; then + echo ERROR + elif grep ^FAIL "$log" 1>&2; then + echo FAIL + elif grep -q ^PASS "$log"; then + echo PASS + else + echo ERROR + echo "No test results found." 1>&2 + fi + register: test_results + + - name: Set role result + set_fact: + role_result: "{{ test_results.stdout }}" + role_message: "{{ test_results.stderr|d('test execution error.') }}" + role_result_failed: "{{ test_results.stdout != 'PASS' }}" + role_result_msg: "{{ test_results.stderr|d('test execution error.') }}" + + - include_role: + name: str-common-final + + - name: Validate the result + shell: echo "test_results.stdout" + failed_when: test_results.stdout != 'PASS' diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..f564cd3 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,20 @@ +- hosts: localhost + tags: + - classic + roles: + - role: custom-test-fonts + required_packages: + - google-noto-emoji-fonts + - google-noto-emoji-color-fonts + coverage: + und-zsye: + path_prefix: + - /usr/share/fonts/google-noto-emoji + include: + - NotoEmoji-Regular.ttf + - NotoColorEmoji.ttf + families: + - lang: und-zsye + package: google-noto-emoji-color-fonts + alias: emoji + family: Noto Emoji