From ed99f7ded3d6e0458a7380e784b106af2d9fe771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 10:39:37 +0100 Subject: [PATCH 1/6] chore(test): improve font comparison --- .github/workflows/build-and-test.yml | 4 +- tests/lib/common.sh | 21 ++- tests/lib/compare_fonts.py | 249 +++++++++++++++++++++++++++ tests/patch-test.sh | 73 +++++--- 4 files changed, 312 insertions(+), 35 deletions(-) create mode 100755 tests/lib/compare_fonts.py diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 8afb5c5..a271561 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -107,8 +107,8 @@ jobs: - name: Docker inspect run: docker buildx imagetools inspect ${IMAGE_NAME} | grep '${{ matrix.platform }}' - - name: Install ttx tool - run: sudo apt update -y && sudo apt install -y python3-fonttools fonttools + - name: Install fontTools + run: sudo apt update -y && sudo apt install -y python3-fonttools - name: Execute tests env: diff --git a/tests/lib/common.sh b/tests/lib/common.sh index 4d62b91..30e5b81 100644 --- a/tests/lib/common.sh +++ b/tests/lib/common.sh @@ -213,20 +213,23 @@ function font_patcher() --volume "${INPUT_DIR}/":/input \ --volume "${OUTPUT_DIR}/":/output \ --env PUID="$(id -u)" --env PGID="$(id -g)" \ + --env SOURCE_DATE_EPOCH \ -- "${IMAGE_NAME}" "$@" } #--- FUNCTION ------------------------------------------------------------------------------------------------------- -# NAME: get_font_info -# DESCRIPTION: Get font information from the given font file and save it into the specified file. -function get_font_info() +# NAME: font_build_time +# DESCRIPTION: Print the build time of the given font ('head.modified') as a Unix timestamp. +#---------------------------------------------------------------------------------------------------------------------- +function font_build_time() { local FONT_PATH="${1}" - local INFO_OUTPUT_FILE="${2}" - - # Generate a TTX file with font information - ttx -q --recalc-timestamp -o "${INFO_OUTPUT_FILE}" "${FONT_PATH}" - # Remove the following tags from the TTX file: - sed -E -i 's/.*<(checkSumAdjustment|modified|FFTimeStamp|sourceModified).*//g' "${INFO_OUTPUT_FILE}" + # 'head' stores seconds since 1904-01-01; epoch_diff converts them to Unix time + python3 -c ' +import sys +from fontTools.misc.timeTools import epoch_diff +from fontTools.ttLib import TTFont +print(TTFont(sys.argv[1])["head"].modified + epoch_diff) +' "${FONT_PATH}" } diff --git a/tests/lib/compare_fonts.py b/tests/lib/compare_fonts.py new file mode 100755 index 0000000..8209686 --- /dev/null +++ b/tests/lib/compare_fonts.py @@ -0,0 +1,249 @@ +#!/usr/bin/env python3 +"""Compare a directory of patched fonts against a directory of reference fonts. + +Usage: + compare_fonts.py EXPECTED_DIR ACTUAL_DIR [--max-items N] + +For every font in EXPECTED_DIR (``*.ttf``/``*.otf``) a font with the same file +name must exist in ACTUAL_DIR, and vice versa. Each pair is compared in three +stages, from cheapest to most detailed: + +1. Byte identity (SHA-256). This is the expected outcome when the patcher runs + with the same FontForge build and SOURCE_DATE_EPOCH as the reference fonts. +2. Table by table, on the raw table bytes. Only ``head.modified`` and + ``head.checkSumAdjustment`` are ignored: they depend on the build time, + not on the patching itself. +3. For each table that differs, a readable report: changed name records, + remapped code points, renamed glyphs, changed outlines or metrics, changed + header fields, or a short TTX diff for any other table. + +Exit status: 0 if all fonts are equivalent, 1 otherwise, 2 on usage errors. +""" + +import argparse +import difflib +import hashlib +import io +import sys +from pathlib import Path + +from fontTools.pens.recordingPen import DecomposingRecordingPen +from fontTools.ttLib import TTFont + +FONT_SUFFIXES = {".ttf", ".otf"} + +# Fields that change with the build time but not with the patching. They are +# the only differences that are tolerated. +IGNORED_FIELDS = {"head": {"modified", "checkSumAdjustment"}} + + +def sha256(path): + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def font_files(directory): + return {p.name: p for p in directory.iterdir() if p.suffix.lower() in FONT_SUFFIXES} + + +def clip(items, max_items): + """Return at most max_items lines, plus a line saying how many were left out.""" + items = list(items) + if len(items) <= max_items: + return items + return items[:max_items] + [f"... ({len(items) - max_items} more)"] + + +# --- Per-table reporters ----------------------------------------------------- +# Each one receives both fonts and returns a list of human-readable differences. +# An empty list means "no meaningful difference" for that table. + + +def diff_fields(table_tag, expected, actual): + """Compare the decompiled attributes of a simple table (head, hhea, OS/2...).""" + ignored = IGNORED_FIELDS.get(table_tag, set()) + exp, act = vars(expected[table_tag]), vars(actual[table_tag]) + lines = [] + for field in sorted(set(exp) | set(act)): + if field in ignored or field.startswith("_") or field == "tableTag": + continue + if exp.get(field) != act.get(field): + lines.append(f"{field}: {exp.get(field)!r} -> {act.get(field)!r}") + return lines + + +def diff_name(expected, actual): + def records(font): + return { + (r.nameID, r.platformID, r.platEncID, r.langID): r.toUnicode() + for r in font["name"].names + } + + exp, act = records(expected), records(actual) + lines = [] + for key in sorted(set(exp) | set(act)): + if exp.get(key) != act.get(key): + name_id, platform_id = key[0], key[1] + lines.append( + f"nameID {name_id} (platform {platform_id}): " + f"{exp.get(key)!r} -> {act.get(key)!r}" + ) + return lines + + +def diff_cmap(expected, actual): + exp, act = expected.getBestCmap(), actual.getBestCmap() + lines = [] + for cp in sorted(set(exp) | set(act)): + if exp.get(cp) != act.get(cp): + lines.append(f"U+{cp:04X}: {exp.get(cp)} -> {act.get(cp)}") + # Same best cmap but different raw bytes: the subtable layout changed. + if not lines: + lines.append("Same mapping, different subtables/encoding") + return lines + + +def diff_glyph_order(expected, actual): + exp, act = expected.getGlyphOrder(), actual.getGlyphOrder() + lines = [] + if len(exp) != len(act): + lines.append(f"glyph count: {len(exp)} -> {len(act)}") + for gid, (e, a) in enumerate(zip(exp, act)): + if e != a: + lines.append(f"gid {gid}: {e} -> {a}") + return lines + + +def diff_post(expected, actual): + # Glyph names live in 'post' (format 2), so that is where renames show up. + lines = diff_glyph_order(expected, actual) + header = [ + line + for line in diff_fields("post", expected, actual) + if not line.startswith(("extraNames", "mapping", "glyphOrder", "data")) + ] + return header + lines + + +def diff_outlines(expected, actual): + exp_set, act_set = expected.getGlyphSet(), actual.getGlyphSet() + common = [g for g in expected.getGlyphOrder() if g in act_set] + lines = [] + for name in common: + pens = [] + for glyph_set in (exp_set, act_set): + pen = DecomposingRecordingPen(glyph_set) + glyph_set[name].draw(pen) + pens.append(pen.value) + if pens[0] != pens[1]: + lines.append(f"outline of {name!r} differs") + if not lines: + # Outlines are the same, so the difference is in hinting/instructions + # or in how the table is encoded. + lines.append("Same outlines, different hinting or encoding") + return lines + + +def diff_hmtx(expected, actual): + exp, act = expected["hmtx"].metrics, actual["hmtx"].metrics + lines = [] + for name in expected.getGlyphOrder(): + if name in act and exp[name] != act[name]: + lines.append(f"{name}: (advance, lsb) {exp[name]} -> {act[name]}") + return lines + + +def diff_ttx(table_tag, expected, actual): + """Fallback for complex tables (GSUB, GPOS...): unified diff of their TTX dump.""" + + def dump(font): + buffer = io.StringIO() + font.saveXML(buffer, tables=[table_tag]) + return buffer.getvalue().splitlines()[2:] # skip the header with the version + + diff = difflib.unified_diff(dump(expected), dump(actual), "expected", "actual", lineterm="", n=1) + return list(diff)[2:] # skip the ---/+++ header + + +REPORTERS = { + "name": diff_name, + "cmap": diff_cmap, + "post": diff_post, + "glyf": diff_outlines, + "CFF ": diff_outlines, + "hmtx": diff_hmtx, +} +FIELD_TABLES = {"head", "hhea", "maxp", "OS/2", "vhea"} + + +def compare_fonts(expected_path, actual_path): + """Return a dict {table: [differences]}; empty if the fonts are equivalent.""" + expected, actual = TTFont(expected_path), TTFont(actual_path) + problems = {} + + exp_tags, act_tags = set(expected.keys()), set(actual.keys()) + exp_tags.discard("GlyphOrder") + act_tags.discard("GlyphOrder") + if exp_tags - act_tags: + problems["(tables)"] = [f"missing tables: {sorted(exp_tags - act_tags)}"] + if act_tags - exp_tags: + problems.setdefault("(tables)", []).append(f"extra tables: {sorted(act_tags - exp_tags)}") + + for tag in sorted(exp_tags & act_tags): + # Raw bytes first: cheap and exact. 'head' always differs in raw bytes + # when the timestamps differ, so it is checked field by field. + if tag != "head" and expected.reader[tag] == actual.reader[tag]: + continue + if tag in REPORTERS: + lines = REPORTERS[tag](expected, actual) + elif tag in FIELD_TABLES: + lines = diff_fields(tag, expected, actual) + else: + lines = diff_ttx(tag, expected, actual) + if lines: + problems[tag] = lines + return problems + + +def main(): + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("expected_dir", type=Path, help="Directory with the reference fonts") + parser.add_argument("actual_dir", type=Path, help="Directory with the fonts under test") + parser.add_argument("--max-items", type=int, default=10, help="Differences shown per table (default: 10)") + args = parser.parse_args() + + for directory in (args.expected_dir, args.actual_dir): + if not directory.is_dir(): + parser.error(f"not a directory: {directory}") + + expected, actual = font_files(args.expected_dir), font_files(args.actual_dir) + if not expected: + parser.error(f"no fonts found in {args.expected_dir}") + + failed = False + for name in sorted(set(expected) - set(actual)): + print(f"๐Ÿ”ฅ {name}: not generated") + failed = True + for name in sorted(set(actual) - set(expected)): + print(f"๐Ÿ”ฅ {name}: generated but not in the reference set") + failed = True + + for name in sorted(set(expected) & set(actual)): + if sha256(expected[name]) == sha256(actual[name]): + print(f"โœ… {name}: identical") + continue + problems = compare_fonts(expected[name], actual[name]) + if not problems: + print(f"โœ… {name}: equivalent (only build timestamps differ)") + continue + failed = True + print(f"๐Ÿ”ฅ {name}: differs in {', '.join(problems)}") + for tag, lines in problems.items(): + print(f" [{tag}]") + for line in clip(lines, args.max_items): + print(f" {line}") + + return 1 if failed else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/patch-test.sh b/tests/patch-test.sh index dec5d65..2b53b51 100644 --- a/tests/patch-test.sh +++ b/tests/patch-test.sh @@ -10,6 +10,7 @@ SCRIPT_PATH="$( pwd -P )" COMMON_FILE="${SCRIPT_PATH}/lib/common.sh" +COMPARE_FONTS="${SCRIPT_PATH}/lib/compare_fonts.py" # shellcheck source=tests/lib/common.sh source "${COMMON_FILE}" @@ -19,10 +20,16 @@ NERDFONTS_VERSION="$(cat VERSION)" log_info "๐Ÿงช Running patch tests ..." -# Setup +# Setup: everything happens inside a temporary directory, so the repository's +# in/ and out/ directories are never touched. WORK_DIR="$(mktemp -d)" +trap 'rm -rf "${WORK_DIR}"' EXIT pushd "${WORK_DIR}" +export INPUT_DIR="${WORK_DIR}/in" +export OUTPUT_DIR="${WORK_DIR}/out" +mkdir -p "${INPUT_DIR}" "${OUTPUT_DIR}" + # Test font-patcher version log_info "Checking font-patcher version..." FONTPATCHER_VERSION="$(font_patcher --version | grep 'Nerd Fonts Patcher')" @@ -37,35 +44,53 @@ TEST_FONT_URL="https://github.com/tonsky/FiraCode/releases/download/6.2/Fira_Cod NERDFONT_FONT_FILE_NAME="${TEST_FONT_NAME}NerdFont.zip" NERDFONT_FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/v${NERDFONTS_VERSION}/${TEST_FONT_NAME}.zip" -### THEN +# Same options as upstream's bin/scripts/gotta-patch-em-all-font-patcher!.sh: +# - common options: -q -c --no-progressbars +# - the font's own config.cfg (for FiraCode it only adds: --makegroups 2) +# - one run per variant: Nerd Font (no extra option), Mono (--mono) +# and Propo (--variable-width-glyphs) +# The config.cfg is read from the image, so the test follows upstream if the +# options for this font change in a new release. +FONT_CONFIG_FILE="/nerd-fonts/repo/src/unpatched-fonts/${TEST_FONT_NAME}/config.cfg" +COMMON_OPTIONS=(--quiet --no-progressbars --complete --configfile "${FONT_CONFIG_FILE}") +VARIANT_OPTIONS=("" "--mono" "--variable-width-glyphs") + +### WHEN log_info "==> Downloading original ${TEST_FONT_NAME} (${TEST_FONT_URL}) font ..." download "${TEST_FONT_URL}" "${TEST_FONT_FILE_NAME}" - -TEST_FONT_DIRECTORY="$(mktemp -d)" -unzip -q "${TEST_FONT_FILE_NAME}" -d "${TEST_FONT_DIRECTORY}/" -mv "${TEST_FONT_DIRECTORY}"/ttf/*.ttf "${INPUT_DIR}/" - -log_info "==> Patching original ${TEST_FONT_NAME} font ..." -font_patcher --quiet --no-progressbars --complete 2>/dev/null +unzip -q "${TEST_FONT_FILE_NAME}" 'ttf/*.ttf' -d original/ +mv original/ttf/*.ttf "${INPUT_DIR}/" log_info "==> Downloading patched ${TEST_FONT_NAME} font ..." download "${NERDFONT_FONT_URL}" "${NERDFONT_FONT_FILE_NAME}" +mkdir -p reference/ +unzip -q "${NERDFONT_FONT_FILE_NAME}" '*.ttf' -d reference/ + +# Use the build time of the reference fonts, so our fonts can be identical byte +# by byte. FontForge honors SOURCE_DATE_EPOCH (https://reproducible-builds.org). +# The comparison would still pass without it: the build time is ignored there. +SOURCE_DATE_EPOCH="$(font_build_time "$(find reference/ -name '*.ttf' | head -n 1)")" +export SOURCE_DATE_EPOCH +log_info "Using SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} from the reference fonts" + +for variant in "${VARIANT_OPTIONS[@]}"; do + log_info "==> Patching original ${TEST_FONT_NAME} font (variant options: '${variant}') ..." + # FontForge prints thousands of harmless notices, so the output goes to a log. + # Only font-patcher's own warnings are shown, or the end of the log on failure. + PATCH_LOG="patch${variant:+-${variant#--}}.log" + # shellcheck disable=SC2086 # An empty variant must expand to no argument at all + if ! font_patcher "${COMMON_OPTIONS[@]}" ${variant} >"${PATCH_LOG}" 2>&1; then + tail -n 50 "${PATCH_LOG}" + error "font-patcher failed (variant options: '${variant}')" + fi + grep -E '^(WARNING|ERROR|CRITICAL):' "${PATCH_LOG}" | sort | uniq -c | while read -r line; do + log_warn "font-patcher: ${line}" + done +done +### THEN log_info "==> Comparing own patched fonts with nerd font patched fonts ..." -mkdir -p patched/ -unzip -q "${NERDFONT_FONT_FILE_NAME}" -d patched/ - -while IFS='' read -r FONT; do - log_info "==> Comparing ${FONT} ..." - - patched_font="${OUTPUT_DIR}/${FONT}" - [[ -f "${patched_font}" ]] || error "Font ${FONT} not found: ${patched_font}" - - get_font_info "${patched_font}" custom_patched_font.ttx - get_font_info "patched/${FONT}" nerdfonts_patched_font.ttx - - diff -u nerdfonts_patched_font.ttx custom_patched_font.ttx || error "Font ${FONT} is not patched correctly" - ok "Font ${FONT} is patched correctly" -done < <(find "${OUTPUT_DIR}" -type f -maxdepth 1 -iname '*.ttf' -exec basename {} \; 2>/dev/null) +python3 "${COMPARE_FONTS}" reference/ "${OUTPUT_DIR}/" || error "Patched fonts differ from the official ones" +ok "All ${TEST_FONT_NAME} fonts are patched correctly" popd From bd427aa76ed47d02ed6a89322b360b673c767f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 10:46:14 +0100 Subject: [PATCH 2/6] chore(deps): update ubuntu base image --- Dockerfile | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 97ad307..3cd8b9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:noble-20250415.1 +FROM ubuntu:resolute-20261024.1 ARG BUILD_DATE ARG VCS_REF @@ -29,7 +29,7 @@ LABEL org.opencontainers.image.vendor="cdalvaro" LABEL org.opencontainers.image.created="${BUILD_DATE}" LABEL org.opencontainers.image.version="${IMAGE_VERSION}" LABEL org.opencontainers.image.revision="${VCS_REF}" -LABEL org.opencontainers.image.base.name="ubuntu:noble-20250415.1" +LABEL org.opencontainers.image.base.name="ubuntu:resolute-20261024.1" LABEL org.opencontainers.image.licenses="MIT" # Entrypoint diff --git a/README.md b/README.md index 3423566..751a2f6 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ docker pull ghcr.io/cdalvaro/docker-nerd-fonts-patcher [nerdfonts_badge]: https://img.shields.io/badge/Nerd%20Fonts-v3.4.0-lightgrey.svg [nerdfonts_release_notes]: https://github.com/ryanoasis/nerd-fonts/releases/tag/v3.4.0 "Nerd Fonts Release Notes" -[ubuntu_badge]: https://img.shields.io/badge/ubuntu-jammy--20240227-E95420.svg?logo=Ubuntu +[ubuntu_badge]: https://img.shields.io/badge/ubuntu-resolute--20261024.1-E95420.svg?logo=Ubuntu [ubuntu_hub_docker]: https://hub.docker.com/_/ubuntu/ "Ubuntu Image" [github_publish_badge]: https://github.com/cdalvaro/docker-nerd-fonts-patcher/actions/workflows/publish.yml/badge.svg [github_publish_workflow]: https://github.com/cdalvaro/docker-nerd-fonts-patcher/actions/workflows/publish.yml From 300e633548998ad7de2354f9e7c5d1827408ca22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 10:46:59 +0100 Subject: [PATCH 3/6] upgrade: nerd-fonts 3.5.1 --- CHANGELOG.md | 8 +++++++- Dockerfile | 2 +- README.md | 6 +++--- VERSION | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd4910..15c4f3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -The following list only reflects changes made on this project. Please, refer to the [Nerd Fonts 3.4.0 Release Notes](https://www.nerdfonts.com/releases) for the complete list of changes. +The following list only reflects changes made on this project. Please, refer to the [Nerd Fonts 3.5.1 Release Notes](https://www.nerdfonts.com/releases) for the complete list of changes. + +**3.5.1** + +- Upgrade Nerd Fonts to `3.5.1` +- Improve font comparison in tests +- Change Docker base image to `ubuntu:resolute-20261024.1` **3.4.0** diff --git a/Dockerfile b/Dockerfile index 3cd8b9c..cead04d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ARG VCS_REF # https://github.com/ryanoasis/nerd-fonts/releases ENV NERDFONTS_VERSION="v3.4.0" \ - NERDFONTS_SHA256="0387198b376639dc2f5359b52b9edc4861ef7ad48b769fcad045736ad1a27d03" + NERDFONTS_SHA256="81627f9e1d79c5028e2ac28a011b46dc335e146c6ce9d0c368f28c5c3601955a" ENV IMAGE_VERSION="${NERDFONTS_VERSION}" ENV BUILD_DIR="/build" \ diff --git a/README.md b/README.md index 751a2f6..14fca6c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Architecture AMD64][arch_amd64_badge]][arch_link] [![Architecture ARM64][arch_arm64_badge]][arch_link] -# Dockerized Nerd Fonts Patcher v3.4.0 +# Dockerized Nerd Fonts Patcher v3.5.1 Dockerfile to build a Nerd Fonts Patcher image for the Docker opensource container platform. @@ -67,8 +67,8 @@ or from [GitHub Container Registry](https://ghcr.io/cdalvaro/docker-nerd-fonts-p docker pull ghcr.io/cdalvaro/docker-nerd-fonts-patcher ``` -[nerdfonts_badge]: https://img.shields.io/badge/Nerd%20Fonts-v3.4.0-lightgrey.svg -[nerdfonts_release_notes]: https://github.com/ryanoasis/nerd-fonts/releases/tag/v3.4.0 "Nerd Fonts Release Notes" +[nerdfonts_badge]: https://img.shields.io/badge/Nerd%20Fonts-v3.5.1-lightgrey.svg +[nerdfonts_release_notes]: https://github.com/ryanoasis/nerd-fonts/releases/tag/v3.5.1 "Nerd Fonts Release Notes" [ubuntu_badge]: https://img.shields.io/badge/ubuntu-resolute--20261024.1-E95420.svg?logo=Ubuntu [ubuntu_hub_docker]: https://hub.docker.com/_/ubuntu/ "Ubuntu Image" [github_publish_badge]: https://github.com/cdalvaro/docker-nerd-fonts-patcher/actions/workflows/publish.yml/badge.svg diff --git a/VERSION b/VERSION index fbcbf73..3c8ff8c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.4.0 \ No newline at end of file +3.5.1 \ No newline at end of file From 4ec177b594d1c92f983585e77d92b26ce002c69c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 13:13:10 +0100 Subject: [PATCH 4/6] fix: fix packages names for Ubuntu 26.04 --- CHANGELOG.md | 1 + Dockerfile | 2 +- assets/build/functions.sh | 4 ++++ assets/build/install.sh | 8 ++++---- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c4f3b..7d5622c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The following list only reflects changes made on this project. Please, refer to - Upgrade Nerd Fonts to `3.5.1` - Improve font comparison in tests - Change Docker base image to `ubuntu:resolute-20261024.1` +- Fix package names for Ubuntu 26.04 and skip fontforge translations (gettext >= 0.22) **3.4.0** diff --git a/Dockerfile b/Dockerfile index cead04d..ae2c8a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG BUILD_DATE ARG VCS_REF # https://github.com/ryanoasis/nerd-fonts/releases -ENV NERDFONTS_VERSION="v3.4.0" \ +ENV NERDFONTS_VERSION="v3.5.1" \ NERDFONTS_SHA256="81627f9e1d79c5028e2ac28a011b46dc335e146c6ce9d0c368f28c5c3601955a" ENV IMAGE_VERSION="${NERDFONTS_VERSION}" diff --git a/assets/build/functions.sh b/assets/build/functions.sh index 36d621a..9420693 100644 --- a/assets/build/functions.sh +++ b/assets/build/functions.sh @@ -164,6 +164,10 @@ function install_fontforge() { check_sha256 "${FILE}" "${SHA256}" extract "${FILE}" "${EXTRACT_DIR}" + # Do not build translations: they are not needed in a headless container, and + # gettext >= 0.22 rejects some format strings in fontforge 20230101's fr.po. + : > "${EXTRACT_DIR}/po/LINGUAS" + BUILD_OPTS=( -DENABLE_GUI=OFF ) diff --git a/assets/build/install.sh b/assets/build/install.sh index eb780e4..5e3401d 100644 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -10,14 +10,14 @@ source "${FUNCTIONS_FILE}" log_info "Installing required packages and build dependencies ..." REQUIRED_PACKAGES=( - libpng16-16 zlib1g libjpeg8 libxml2 libspiro1 libgif7 libtiff6 \ - libiconv-hook1 libfreetype6 libcairo2 libwoff1 libglib2.0-0 \ - libuninameslist1 libreadline8 libpython3.10 python3 unifont \ + libpng16-16t64 zlib1g libjpeg8 libxml2-16 libspiro1 libgif7 libtiff6 \ + libiconv-hook1 libfreetype6 libcairo2 libwoff1 libglib2.0-0t64 \ + libuninameslist1 libreadline8t64 libpython3.14 python3 unifont \ python3-setuptools python3-dev python3-fonttools fonttools ) BUILD_DEPENDENCIES=( - libjpeg-dev libtiff5-dev libpng-dev libfreetype6-dev libgif-dev \ + libjpeg-dev libtiff5-dev libpng-dev libfreetype-dev libgif-dev \ libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev \ libuninameslist-dev libreadline-dev libwoff-dev ca-certificates \ ninja-build cmake build-essential openssl wget gettext git \ From 8943e6e2ca4b6ba8c5de6621b3a5e3ce98a85be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 15:09:29 +0100 Subject: [PATCH 5/6] chore(ci): improve times on arm64 arch --- .github/workflows/build-and-test.yml | 16 +++++++++++----- tests/patch-test.sh | 12 ++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a271561..e21084d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,12 +66,20 @@ jobs: path: ${{ env.REGISTRY_PATH }}/ test: - name: Test - runs-on: ubuntu-latest + name: Test (${{ matrix.platform }}) + # Each platform runs on a native runner: under QEMU emulation, patching + # fonts is several times slower and the arm64 tests take more than an hour. + runs-on: ${{ matrix.runner }} needs: build + timeout-minutes: 30 strategy: + fail-fast: false matrix: - platform: [linux/amd64, linux/arm64] + include: + - platform: linux/amd64 + runner: ubuntu-latest + - platform: linux/arm64 + runner: ubuntu-24.04-arm env: DOCKER_CLI_EXPERIMENTAL: enabled PLATFORM: ${{ matrix.platform }} @@ -91,8 +99,6 @@ jobs: # Enable docker daemon experimental support. echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json sudo systemctl restart docker - # Install QEMU multi-architecture support for docker buildx. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - name: Start Docker registry run: | diff --git a/tests/patch-test.sh b/tests/patch-test.sh index 2b53b51..8693cd6 100644 --- a/tests/patch-test.sh +++ b/tests/patch-test.sh @@ -76,13 +76,21 @@ log_info "Using SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} from the reference fonts" for variant in "${VARIANT_OPTIONS[@]}"; do log_info "==> Patching original ${TEST_FONT_NAME} font (variant options: '${variant}') ..." # FontForge prints thousands of harmless notices, so the output goes to a log. - # Only font-patcher's own warnings are shown, or the end of the log on failure. + # Only the progress lines of the entrypoint ("Patching font ...") are shown + # live, plus font-patcher's own warnings, or the end of the log on failure. + # pipefail makes the subshell fail when font_patcher fails, not only grep. PATCH_LOG="patch${variant:+-${variant#--}}.log" + VARIANT_START="${SECONDS}" # shellcheck disable=SC2086 # An empty variant must expand to no argument at all - if ! font_patcher "${COMMON_OPTIONS[@]}" ${variant} >"${PATCH_LOG}" 2>&1; then + if ! ( + set -o pipefail + font_patcher "${COMMON_OPTIONS[@]}" ${variant} 2>&1 | tee "${PATCH_LOG}" \ + | { grep --line-buffered 'Patching font' || true; } + ); then tail -n 50 "${PATCH_LOG}" error "font-patcher failed (variant options: '${variant}')" fi + log_info "Variant patched in $((SECONDS - VARIANT_START)) s" grep -E '^(WARNING|ERROR|CRITICAL):' "${PATCH_LOG}" | sort | uniq -c | while read -r line; do log_warn "font-patcher: ${line}" done From 9b9a668761f8a1f9dacb3212dc35185b183e543c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Mon, 9 Nov 2026 16:00:48 +0100 Subject: [PATCH 6/6] fix: build fontforge without FMA contraction AArch64 has FMA in its base ISA and GCC contracts a*b+c into a single fused instruction by default in GNU C mode. The single rounding changes the last bit of some results and, once coordinates are rounded to integers, the outlines of scaled glyphs. Fonts patched on arm64 then differ from the official ones, which are built on x86-64, where the base ISA has no FMA. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + assets/build/functions.sh | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5622c..c5ba6b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The following list only reflects changes made on this project. Please, refer to - Improve font comparison in tests - Change Docker base image to `ubuntu:resolute-20261024.1` - Fix package names for Ubuntu 26.04 and skip fontforge translations (gettext >= 0.22) +- Build fontforge with `-ffp-contract=off`, so fonts patched on arm64 match the official ones **3.4.0** diff --git a/assets/build/functions.sh b/assets/build/functions.sh index 9420693..b51574d 100644 --- a/assets/build/functions.sh +++ b/assets/build/functions.sh @@ -170,6 +170,13 @@ function install_fontforge() { BUILD_OPTS=( -DENABLE_GUI=OFF + # Do not fuse a*b+c into a single FMA instruction. AArch64 has FMA in its + # base ISA and GCC contracts by default in GNU C mode, which changes the + # last bit of some results and, after rounding coordinates, the outlines of + # scaled glyphs. With contraction off, arm64 matches the official fonts, + # which are built on x86-64 (no FMA in its base ISA). + -DCMAKE_C_FLAGS=-ffp-contract=off + -DCMAKE_CXX_FLAGS=-ffp-contract=off ) (cd $EXTRACT_DIR && build_and_install "fontforge ${VERSION}" "${BUILD_OPTS[@]}")