font substitution
I had a bug on orgmode website due to the "width/height" parameter in the CSS, so I thought, it is a CSS bug ?
Then, I talked to the dev, and realize it was not,
then, I found a bug similar to mine in firefox, so I thought it was a bug in firefox
https://bugzilla.mozilla.org/show_bug.cgi?id=1336049
Then, I decided to try andrei idea and check it.
Well, guess what, apparently there is a bug that appears in mozilla preventing me to see my dyslexic font when none of the fallback given for a font are installed (or so I imagine, because I don't understand the man pages of fc)
Not my nicest bash script but here is the gist of it first of all no bug when trying to substitute and unknown font prior to the one I want
Hence font MUST be referenced for the bug to appear.
- then trying font substitution in firefox for all fonts declared in fc
- then looking witch one fail by comparing the screenshot from an headless firefox
- look which one are installed
- look which one are supposed to be used for substitution
- then try to see how much of the proposed fonts for substitution are existing on installation
On my OS (reported also on alpine hence the reason I fill the bug here and not on my distro) I have 0 success for the proposal of subsitution when looking up for the failed fonts
HOWTO reproduce
- create a profile with andika installed https://software.sil.org/andika/
- open about:config and try to set the substiution proposed
user_pref("font.default.x-western", "Andika");
user_pref("font.name-list.serif.x-western","Andika");
- close ALL your firefox
- run this script
- expect a "Point proven"
NB https://gist.github.com/jul/ac13585656499ec9b23a27bcc2ffb7bf
EDIT 180 font fails at home / 314 edited a bug on the fly
PPS I hate mardown
#!/usr/bin/bash
MIN_FF_OPT=" --headless "
FF="firefox $MIN_FF_OPT"
die() { echo "$@"; exit 0;}
fc-match Andika || die "le test va pas marcher"
echo "basically if I could create profile from scratch I would put only this"
cat <<EOF
user_pref("font.default.x-western", "Andika");
user_pref("font.name-list.serif.x-western","Andika");
EOF
SUCC=0
FAIL=0
RZ='\e[0m'
GR=${GR-'\e[92m'}
RD=${RD-'\e[91m'}
HL=${HL-'\e[1m'}
TOTAL=$( fc-list | cut -d ":" -f 2 | cut -d "," -f 1 | sed -e 's/^ //' | sort | uniq | wc -l )
OK() { SUCC=$(( SUCC + 1 )); echo -n "$@ :"; echo -e "${HL}${GR}OK${RZ} ($SUCC/$TOTAL)"; echo "$@" >> success.txt; }
KO() { FAIL=$(( FAIL + 1 )); echo -n "$@ :"; echo -e "${HL}${RD}KO${RZ} ($SUCC/$TOTAL)"; echo "$@" >> failture.txt; }
echo "what is the name of the profile for the test ?"
read -r PROFILE
FF="firefox -P $PROFILE $MIN_FF_OPT"
# edit
rm success.txt failture.txt
$FF --screenshot ref.png 'data:text/html,<body style="font-family: serif">test'
diff -q ref.png ref2.png && OK serif || KO serif
$FF --screenshot ref2.png "data:text/html,<body style=\"font-family: 'DejaVu Serif', serif\">test"
diff -q ref.png ref2.png && OK Dejavu Serif || KO dejavu serif
while IFS= read -r font
do
$FF --screenshot ref2.png "data:text/html,<body style=\"font-family: '$font', serif\">test" &> /dev/null
diff -q ref.png ref2.png &> /dev/null && OK "$font" || KO "$font"
done <<< "$( fc-list | cut -d ":" -f 2 | cut -d "," -f 1 | sed -e 's/^ //' | sort | uniq ) "
fc-list -b | perl -ane 'm!/([a-zA-Z]+)\-!; print "$1\n";' | sort | uniq > installed_fonts
while IFS= read -r font; do fc-match "$font"; done < failture.txt | cut -d ":" -f 1 > matched_fonts.txt
TOTAL=$( wc -l failture.txt | cut -d " " -f 1 )
SUCC=0
FAIL=0
while IFS= read -r font; do grep "$font" installed_fonts &> /dev/null && OK "$font" || KO "$font" ; done < matched_fonts.txt
[[ $SUCC == "0" ]] && echo -e "${HL}${RD}point proven if a font has no matched installed fonts in fc-match substitution fail${RZ}"