Replace solid black rendering of anti-aliased font edges with period-2 dithering patterns. Full coverage pixels render as solid ink, while partial coverage pixels use checkerboard patterns (50% for dark grey, 25% for light grey) matching fillRectDither behavior. This prevents edge pixels from bolding to black on BW displays and produces proper anti-aliasing for 2-bit fonts.
111 lines
3.3 KiB
Bash
Executable File
111 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")/../builtinFonts"
|
|
|
|
echo "// The contents of this file are generated by ./lib/EpdFont/scripts/build-font-ids.sh"
|
|
echo "#pragma once"
|
|
echo ""
|
|
|
|
echo "#define NOTOSERIF_12_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notoserif_12_regular.h",
|
|
"./notoserif_12_bold.h",
|
|
"./notoserif_12_bolditalic.h",
|
|
"./notoserif_12_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSERIF_14_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notoserif_14_regular.h",
|
|
"./notoserif_14_bold.h",
|
|
"./notoserif_14_bolditalic.h",
|
|
"./notoserif_14_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSERIF_16_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notoserif_16_regular.h",
|
|
"./notoserif_16_bold.h",
|
|
"./notoserif_16_bolditalic.h",
|
|
"./notoserif_16_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSERIF_18_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notoserif_18_regular.h",
|
|
"./notoserif_18_bold.h",
|
|
"./notoserif_18_bolditalic.h",
|
|
"./notoserif_18_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSANS_12_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notosans_12_regular.h",
|
|
"./notosans_12_bold.h",
|
|
"./notosans_12_bolditalic.h",
|
|
"./notosans_12_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSANS_14_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notosans_14_regular.h",
|
|
"./notosans_14_bold.h",
|
|
"./notosans_14_bolditalic.h",
|
|
"./notosans_14_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSANS_16_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notosans_16_regular.h",
|
|
"./notosans_16_bold.h",
|
|
"./notosans_16_bolditalic.h",
|
|
"./notosans_16_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define NOTOSANS_18_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notosans_18_regular.h",
|
|
"./notosans_18_bold.h",
|
|
"./notosans_18_bolditalic.h",
|
|
"./notosans_18_italic.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define UI_10_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./ubuntu_10_regular.h",
|
|
"./ubuntu_10_bold.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define UI_12_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./ubuntu_12_regular.h",
|
|
"./ubuntu_12_bold.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo "#define SMALL_FONT_ID ($(
|
|
ruby -rdigest -e 'puts [
|
|
"./notosans_8_regular.h",
|
|
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
|
))"
|
|
|
|
echo ""
|
|
echo "// Font ID 0 is reserved as the \"not found\" sentinel."
|
|
echo "// Guard against any hash accidentally producing 0."
|
|
for id in NOTOSERIF_12 NOTOSERIF_14 NOTOSERIF_16 NOTOSERIF_18 \
|
|
NOTOSANS_12 NOTOSANS_14 NOTOSANS_16 NOTOSANS_18 \
|
|
UI_10 UI_12 SMALL; do
|
|
echo "static_assert(${id}_FONT_ID != 0, \"Font ID collision with sentinel\");"
|
|
done
|