123.6. noto-cjk-2.004
Noto Sans CJK — Chinese, Japanese and Korean coverage in one collection
| Version | 2.004, release 1 |
| Shelf | fonts — Font packages, and font libraries and tooling |
| Phase | 41_system (System), 528 of 1047 in build order |
| Licence | OFL-1.1 |
| Homepage | https://github.com/notofonts/noto-cjk |
| Build time | 0.6 SBU |
| Installed size | 111.8 MiB in 4 files |
| Recipe | ports/core/fonts/noto-cjk/kpkgbuild |
About
Noto Sans CJK is Google and Adobe’s sans-serif face for Chinese, Japanese and Korean, shipped as one OpenType Collection, NotoSansCJK.ttc, that holds the Simplified Chinese, Traditional Chinese, Hong Kong, Japanese and Korean variants and a monospaced variant of each. It is the system’s one CJK face, and so the fallback for any CJK character a program’s own font lacks. Like the other Noto ports, it installs the face upstream publishes rather than building it (see What is built from source).
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/fonts.txt:
One OpenType Collection covering Chinese, Japanese and Korean. Without a CJK face, fontconfig has nothing to fall back to and every CJK codepoint renders as a box — in Konsole, in an alien app, and in any filename that carries one.
Sources
noto-cjk-2.004.zip(90.8 MiB)
sha256a56077736038875f3a5b1e6715b2713a2bd049cc0bf0dfdf645927b070d38bfc
upstream: https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/00_NotoSansCJK.ttc.zip
archive copy: sources-2/fonts--noto-cjk-2.004.zip
Dependencies
Depends on: unzip.
Required by (3): noto-cjk-prefer-ja, noto-cjk-prefer-ko, noto-cjk-prefer-zh.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install noto-cjk'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/fonts/noto-cjk.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/fonts/noto-cjk
echo 'a56077736038875f3a5b1e6715b2713a2bd049cc0bf0dfdf645927b070d38bfc noto-cjk-2.004.zip' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/noto-cjk
SRC=$SRC_ROOT/noto-cjk-2.004
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
cp noto-cjk-2.004.zip "$SRC"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
unzip -q -o $name-$version.zip
install -dm755 $PKG/usr/share/fonts/noto-cjk
install -m644 NotoSansCJK.ttc $PKG/usr/share/fonts/noto-cjk/
install -dm755 $PKG/usr/share/licenses/$name
install -m644 LICENSE $PKG/usr/share/licenses/$name/
install -dm755 $PKG/usr/share/fontconfig/conf.avail $PKG/etc/fonts/conf.d
cat > $PKG/usr/share/fontconfig/conf.avail/70-noto-cjk.conf <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="lang" compare="contains"><string>ja</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK JP</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>ja</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK JP</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>ja</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK JP</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-tw</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK TC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-tw</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK TC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-tw</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK TC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-hk</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-hk</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-hk</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-mo</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-mo</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-mo</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK HK</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-cn</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-cn</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-cn</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-sg</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-sg</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>zh-sg</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK SC</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>ko</string></test>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK KR</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>ko</string></test>
<test name="family"><string>serif</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans CJK KR</string></edit>
</match>
<match target="pattern">
<test name="lang" compare="contains"><string>ko</string></test>
<test name="family"><string>monospace</string></test>
<edit name="family" mode="prepend_first"><string>Noto Sans Mono CJK KR</string></edit>
</match>
</fontconfig>
XML
ln -s ../../../usr/share/fontconfig/conf.avail/70-noto-cjk.conf \
$PKG/etc/fonts/conf.d/70-noto-cjk.conf
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/noto-cjk, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf noto-cjk-2.004-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/noto-cjk, and runs the triggers its paths call for.
Contents
Installed directories: /usr/share/fonts/noto-cjk, /usr/share/licenses/noto-cjk.
Notes
The source is a .zip, which kpkg copies into $SRC whole rather than unpacking, so build.sh unzips it itself; it holds only the collection and its licence.
The recipe writes 70-noto-cjk.conf into /usr/share/fontconfig/conf.avail and enables it with a symbolic link in /etc/fonts/conf.d. For text tagged with a CJK language (ja, ko, zh-cn, zh-sg, zh-tw, zh-hk, zh-mo) it puts the variant for that language at the very front of sans-serif, serif and monospace (prepend_first), so the same code point is drawn with Japanese, Korean or the right Chinese glyph shapes. serif is mapped to the sans face, because no CJK serif face is installed.
The collection is a large file, and noto-fonts-extra deliberately does not ship it a second time: two packages owning one path conflict at install time.