Add anti-aliased font rendering with dithering

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.
This commit is contained in:
Justin Mitchell
2026-07-05 16:06:56 -04:00
parent 3e1dd31e53
commit 62448b3c08
9 changed files with 17947 additions and 11245 deletions
+9
View File
@@ -99,3 +99,12 @@ 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
+5 -2
View File
@@ -42,8 +42,11 @@ for size in ${UI_FONT_SIZES[@]}; do
# (fontstack is ordered by descending priority).
viet_path="../builtinFonts/source/Ubuntu/Ubuntu-Vietnamese-${style}.ttf"
output_path="../builtinFonts/${font_name}.h"
# 2-bit like the reader fonts: full coverage renders solid in BW mode and
# partial edge coverage dithers (GfxRenderer renderCharImpl), so UI text is
# anti-aliased on 1-bit panels and blends properly in grayscale passes.
python fontconvert.py $font_name $size $font_path $hebrew_path $viet_path \
--additional-intervals 0x05D0,0x05EA > $output_path
--2bit --additional-intervals 0x05D0,0x05EA > $output_path
echo "Generated $output_path"
done
done
@@ -51,7 +54,7 @@ done
python fontconvert.py notosans_8_regular 8 \
../builtinFonts/source/NotoSans/NotoSans-Regular.ttf \
../builtinFonts/source/NotoSansHebrew/NotoSansHebrew-Regular.ttf \
--additional-intervals 0x05D0,0x05EA > ../builtinFonts/notosans_8_regular.h
--2bit --additional-intervals 0x05D0,0x05EA > ../builtinFonts/notosans_8_regular.h
echo ""
echo "Running compression verification..."