feat: Proper Emoji support in Chrome images

We often have flaky tests around emoji rendering. Maybe we can improve
the test quality by adding a proper emoji font.

The existing install-noto-image script wasn't utilized and could be
simplified anyhow. Furthermore I think it is fine to install the font
when Chrome is installed, given that we use the Chrome images for
integration tests with the browser.
This commit is contained in:
Lukas Eipert 2022-12-07 11:42:00 +01:00
parent cc548a28af
commit 51cdfcf732
2 changed files with 21 additions and 52 deletions

View file

@ -3,6 +3,14 @@
set -xeuo pipefail
IFS=$'\n\t'
function download_noto() {
local NOTO_VERSION
# https://github.com/googlefonts/noto-emoji/releases/tag/v2.038
NOTO_VERSION="v2.038"
curl --silent -O --location --fail "https://github.com/googlefonts/noto-emoji/raw/${NOTO_VERSION}/fonts/NotoColorEmoji.ttf"
echo "NotoColorEmoji.ttf"
}
function download_deb() {
component=$1
@ -44,6 +52,19 @@ function build_debian() {
rm -f "$DRIVER_DEB"
fi
# We have loads of tests rendering emoji, so let's ensure a proper emoji font is installed
echo "Installing Noto emoji font"
FONT_FILE=$(download_noto)
mkdir -p /usr/local/share/fonts
mv "$FONT_FILE" /usr/local/share/fonts/
chmod 644 "/usr/local/share/fonts/${FONT_FILE}"
ls -la /usr/local/share/fonts/
fc-cache -fv
fc-match -s noto
# Cleanup
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*

View file

@ -1,52 +0,0 @@
#!/bin/bash
# This script installs noto color emoji
function build_debian() {
apt-get update
apt-get install unzip
cat > ~/.fonts.conf << EOM
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="scan">
<test name="family">
<string>Noto Color Emoji</string>
</test>
<edit name="scalable" mode="assign"><bool>true</bool></edit>
</match>
<match target="pattern">
<test name="prgname">
<string>chrome</string>
</test>
<edit name="family" mode="prepend_first">
<string>Noto Color Emoji</string>
</edit>
</match>
</fontconfig>
EOM
mkdir setup_fonts
cd setup_fonts
curl https://noto-website-2.storage.googleapis.com/pkgs/NotoColorEmoji-unhinted.zip -LO
unzip NotoColorEmoji-unhinted.zip
mkdir -p /usr/local/share/fonts
cp NotoColorEmoji.ttf /usr/local/share/fonts/
ls -la /usr/local/share/fonts/
chmod 644 /usr/local/share/fonts/NotoColorEmoji.ttf
fc-cache -fv
cd ..
rm -r setup_fonts
apt-get clean -yqq && rm -rf /var/lib/apt/lists/*
}
BUILD_OS=${BUILD_OS:-debian}
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi