lang_coverage: Add FONT_LANG_EXCLUDE_FILES to skip some bogus font files

This commit is contained in:
Akira TAGOH 2024-06-26 17:19:07 +09:00
commit e739c7e376
2 changed files with 16 additions and 1 deletions

View file

@ -96,6 +96,9 @@ Available test cases
- PACKAGE
- FONT_LANG (optional)
- FONT_LANG_EXCLUDE_FILES (optional)
Set a regex to skip some bogus font files.
- Validate family name

View file

@ -3,6 +3,7 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1
FONT_LANG=${FONT_LANG:-"en"}
FONT_LANG_EXCLUDE_FILES=${FONT_LANG_EXCLUDE_FILES:-}
PACKAGE=${PACKAGE:-"blahblah-fonts"}
function get_font_path() {
@ -13,12 +14,21 @@ function get_font_path() {
echo -n $ret
}
function check_exception() {
if [ "x$FONT_LANG_EXCLUDE_FILES" == "x" ]; then
echo -n 1
else
echo $1 | grep -E "$FONT_LANG_EXCLUDE_FILES" 2>&1 > /dev/null
echo -n $?
fi
}
function check_lang_coverage() {
ret=0
for p in $(get_font_path); do
for f in $(find $p -regex '.*/*\.\(t1\)?\(ttf\)?\(otf\)?\(ttc\)?\(otc\)?\(pcf.*\)?\(pfa\)?'); do
set -f
if test -f $f; then
if [ $(check_exception $f) -ne 0 -a -f $f ]; then
IFS=, read -ra langlist <<< "$FONT_LANG"
for l in "${langlist[@]}"; do
res=$(fc-validate -l $l $f || :)
@ -29,6 +39,8 @@ function check_lang_coverage() {
echo $res
fi
done
else
rlLogInfo "Skipping $f"
fi
set +f
done