media-fonts/noto-emoji: Install pre-built font by default
authorPacho Ramos <pacho@gentoo.org>
Thu, 23 Apr 2020 00:27:28 +0000 (02:27 +0200)
committerPacho Ramos <pacho@gentoo.org>
Thu, 23 Apr 2020 00:27:28 +0000 (02:27 +0200)
As suggested in bug #717654 install prebuilt font by default, even still
allowing to optionally built it with supplied images as they contain more
updated images and, sometimes, more emojis.

Also be more verbose while building

Closes: https://bugs.gentoo.org/717654
Thanks-to: Kent Fredric
Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Pacho Ramos <pacho@gentoo.org>
media-fonts/noto-emoji/files/noto-emoji-pngquant.patch [new file with mode: 0644]
media-fonts/noto-emoji/files/noto-emoji-zopflipng.patch [new file with mode: 0644]
media-fonts/noto-emoji/metadata.xml
media-fonts/noto-emoji/noto-emoji-20200317-r1.ebuild [new file with mode: 0644]

diff --git a/media-fonts/noto-emoji/files/noto-emoji-pngquant.patch b/media-fonts/noto-emoji/files/noto-emoji-pngquant.patch
new file mode 100644 (file)
index 0000000..8a152be
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/Makefile~        2020-04-22 23:04:44.000000000 +0200
++++ b/Makefile 2020-04-22 23:06:42.069275340 +0200
+@@ -20,7 +20,7 @@
+ PNGQUANT = pngquant
+ PYTHON = python3
+-PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force
++PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force -v
+ BODY_DIMENSIONS = 136x128
+ IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center
diff --git a/media-fonts/noto-emoji/files/noto-emoji-zopflipng.patch b/media-fonts/noto-emoji/files/noto-emoji-zopflipng.patch
new file mode 100644 (file)
index 0000000..0cb2729
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/Makefile~        2020-04-22 23:07:33.000000000 +0200
++++ b/Makefile 2020-04-22 23:11:46.356767595 +0200
+@@ -194,7 +194,7 @@
+ ifdef MISSING_ZOPFLI
+       @$(OPTIPNG) -quiet -o7 -clobber -force -out "$@" "$<"
+ else
+-      @$(ZOPFLIPNG) -y "$<" "$@" 1> /dev/null 2>&1
++      @$(ZOPFLIPNG) -y "$<" "$@" 2>&1
+ endif
index 3da97a9953ccb9ca1fa0ac158becc51d3055adba..18a049a172d795219c5cbaca2433e28ac105d2b4 100644 (file)
@@ -5,4 +5,7 @@
                <email>pacho@gentoo.org</email>
                <name>Pacho Ramos</name>
        </maintainer>
+<use>
+       <flag name="buildfont">Build Noto Emoji font with supplied images.</flag>
+</use>
 </pkgmetadata>
diff --git a/media-fonts/noto-emoji/noto-emoji-20200317-r1.ebuild b/media-fonts/noto-emoji/noto-emoji-20200317-r1.ebuild
new file mode 100644 (file)
index 0000000..15394e1
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+PYTHON_COMPAT=( python3_{6,7,8} )
+
+inherit font python-any-r1
+
+DESCRIPTION="Google Noto Emoji fonts"
+HOMEPAGE="https://www.google.com/get/noto/ https://github.com/googlefonts/noto-emoji"
+
+COMMIT="ac1703e9d7feebbf5443a986e08332b1e1c5afcf"
+SRC_URI="https://github.com/googlefonts/noto-emoji/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="Apache-2.0 OFL-1.1"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="buildfont"
+
+DEPEND="buildfont? (
+               ${PYTHON_DEPS}
+               app-arch/zopfli
+               $(python_gen_any_dep '
+                       dev-python/fonttools[${PYTHON_USEDEP}]
+                       dev-python/nototools[${PYTHON_USEDEP}]
+               ')
+               media-gfx/pngquant
+               x11-libs/cairo
+               || ( media-gfx/imagemagick[png] media-gfx/graphicsmagick[png] )
+       )
+"
+RDEPEND=""
+
+RESTRICT="binchecks strip"
+
+S="${WORKDIR}/${PN}-${COMMIT}"
+
+python_check_deps() {
+       has_version "dev-python/fonttools[${PYTHON_USEDEP}]" && \
+        has_version "dev-python/nototools[${PYTHON_USEDEP}]"
+}
+
+src_prepare() {
+       default
+
+       if use buildfont; then
+               # From Fedora
+               eapply "${FILESDIR}/${PN}-build-all-flags.patch"
+
+               # https://github.com/googlei18n/noto-emoji/issues/240
+               eapply "${FILESDIR}/${PN}-20180823-build-path.patch"
+
+               # Be more verbose, bug #717654
+               eapply "${FILESDIR}"/${PN}-pngquant.patch
+               eapply "${FILESDIR}"/${PN}-zopflipng.patch
+
+               # Based on Fedora patch to allow graphicsmagick usage
+               if has_version media-gfx/graphicsmagick; then
+                       eapply "${FILESDIR}/${PN}-20190328-use-gm.patch"
+               fi
+       fi
+}
+
+src_compile() {
+       if ! use buildfont; then
+               einfo "Installing pre-built fonts provided by upstream."
+               einfo "They could be not fully updated or miss some items."
+               einfo "To build fonts based on latest images enable 'buildfont'"
+               einfo "USE (that will require more time and resources too)."
+       else
+               einfo "Building fonts..."
+               default
+       fi
+}
+
+src_install() {
+       if ! use buildfont; then
+               FONT_S="${S}/fonts"
+       else
+               mv -i fonts/NotoEmoji-Regular.ttf "${S}" || die
+               # Built font and Regular font
+               FONT_S="${S}"
+
+               # Don't lose fancy emoji icons
+               insinto /usr/share/icons/"${PN}"/128x128/emotes/
+               doins png/128/*.png
+
+               insinto /usr/share/icons/"${PN}"/scalable/emotes/
+               doins svg/*.svg
+       fi
+
+       FONT_SUFFIX="ttf"
+       font_src_install
+
+       dodoc README.md
+}