Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
F
fontconfig
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 152
    • Issues 152
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 16
    • Merge Requests 16
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • fontconfig
  • fontconfig
  • Issues
  • #264

Closed
Open
Opened Nov 03, 2020 by julien tayon@jul1

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

  1. create a profile with andika installed https://software.sil.org/andika/
  2. 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");
  1. close ALL your firefox
  2. run this script
  3. 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}"

res2

res1

Edited Nov 03, 2020 by julien tayon
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: fontconfig/fontconfig#264