mirror of
https://github.com/crosspoint-reader/crosspoint-reader.git
synced 2026-04-29 10:26:52 -07:00
## Summary **What is the goal of this PR?** Reading a book with frequent numbers, I noticed that the spacing between numeral glyphs was strangely large. This was because Bookerly and Noto Sans default to tabular figures, where every digit gets an identical advance width. This is designed for column alignment in spreadsheets, but in rendering prose it produces visually wide gaps between digits. This change adds a `--pnum` flag to fontconvert.py that applies the font's OpenType `pnum` (proportional numerals) feature during conversion. When active, the converter: - Parses the GSUB table for pnum SingleSubst lookups - Resolves substitute glyph indices via fonttools' glyph order - Loads the proportional alternate glyphs instead of the tabular defaults - Includes substitute glyph names in kern pair extraction, so kerning data that references proportional alternates is captured Bookerly's proportional alternates also carry digit-digit and digit-punctuation kerning that the tabular glyphs lack (e.g., at 16pt 7->4 at -1.69px, 7->. at -2.31px, 7->1 at +1.00px). Noto Sans gains proportional advances but no new kerning (its proportional glyphs have no kern class data in the font). OpenDyslexic is unaffected. Its `cmap` already points to proportional glyphs, so `--pnum` is a no-op. `--pnum` is intentionally omitted from OpenDyslexic in the build script for deliberately uniform digit spacing as an accessibility choice. UI fonts (Ubuntu, notosans_8) also omit `--pnum` to preserve tabular alignment for page numbers, battery percentages, etc. | Before | After | | -- | -- | | <img src="https://github.com/user-attachments/files/26042238/screenshot-31673.bmp" width="300" /> | <img src="https://github.com/user-attachments/files/26042241/screenshot-124075.bmp" width="300" /> | --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**YES**_
60 lines
2.1 KiB
Bash
Executable File
60 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
READER_FONT_STYLES=("Regular" "Italic" "Bold" "BoldItalic")
|
|
BOOKERLY_FONT_SIZES=(12 14 16 18)
|
|
NOTOSANS_FONT_SIZES=(12 14 16 18)
|
|
OPENDYSLEXIC_FONT_SIZES=(8 10 12 14)
|
|
|
|
for size in ${BOOKERLY_FONT_SIZES[@]}; do
|
|
for style in ${READER_FONT_STYLES[@]}; do
|
|
font_name="bookerly_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
|
font_path="../builtinFonts/source/Bookerly/Bookerly-${style}.ttf"
|
|
output_path="../builtinFonts/${font_name}.h"
|
|
python fontconvert.py $font_name $size $font_path --2bit --compress --pnum > $output_path
|
|
echo "Generated $output_path"
|
|
done
|
|
done
|
|
|
|
for size in ${NOTOSANS_FONT_SIZES[@]}; do
|
|
for style in ${READER_FONT_STYLES[@]}; do
|
|
font_name="notosans_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
|
font_path="../builtinFonts/source/NotoSans/NotoSans-${style}.ttf"
|
|
output_path="../builtinFonts/${font_name}.h"
|
|
python fontconvert.py $font_name $size $font_path --2bit --compress --pnum > $output_path
|
|
echo "Generated $output_path"
|
|
done
|
|
done
|
|
|
|
for size in ${OPENDYSLEXIC_FONT_SIZES[@]}; do
|
|
for style in ${READER_FONT_STYLES[@]}; do
|
|
font_name="opendyslexic_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
|
font_path="../builtinFonts/source/OpenDyslexic/OpenDyslexic-${style}.otf"
|
|
output_path="../builtinFonts/${font_name}.h"
|
|
python fontconvert.py $font_name $size $font_path --2bit --compress > $output_path
|
|
echo "Generated $output_path"
|
|
done
|
|
done
|
|
|
|
UI_FONT_SIZES=(10 12)
|
|
UI_FONT_STYLES=("Regular" "Bold")
|
|
|
|
for size in ${UI_FONT_SIZES[@]}; do
|
|
for style in ${UI_FONT_STYLES[@]}; do
|
|
font_name="ubuntu_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
|
font_path="../builtinFonts/source/Ubuntu/Ubuntu-${style}.ttf"
|
|
output_path="../builtinFonts/${font_name}.h"
|
|
python fontconvert.py $font_name $size $font_path > $output_path
|
|
echo "Generated $output_path"
|
|
done
|
|
done
|
|
|
|
python fontconvert.py notosans_8_regular 8 ../builtinFonts/source/NotoSans/NotoSans-Regular.ttf > ../builtinFonts/notosans_8_regular.h
|
|
|
|
echo ""
|
|
echo "Running compression verification..."
|
|
python verify_compression.py ../builtinFonts/
|