-
Notifications
You must be signed in to change notification settings - Fork 3
/
slacheckfonts
97 lines (79 loc) · 2.29 KB
/
slacheckfonts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# slacheckfonts
. shellcolors
if [ "$1" = "-?" ] || [ "$1" = "-h" ] || [ "$1" = "" ]
then
echo "Usage : slacheckfont [-h] [-v] scribusfile"
echo "Checks whether all used fonts are either embeded or subset in scribusfile.sla"
echo "Options (order matters) :"
echo -h displays this help
echo -v displays details
exit
fi
if [ "$1" = "-v" ]
then
verbose=oui
shift
fi
vecto=""
if [ "$1" = "-vecto" ]
then
vecto="-vecto"
shift
elif [ "$1" = "-novecto" ]
then
vecto="-novecto"
shift
fi
if [ "$1" = "" ]
then
echo Error : scribus file argument missing
exit
fi
[ ! -f "$1.sla" ] && echo Error : missing $1.sla file && exit
# Liste of all fonts uses
#
# Possible fonts uses are :
# <ITEXT FONT="Arimo Regular" CH=" "/>
# <CHARSTYLE CNAME="Default Character Style" DefaultStyle="1" FONT="Liberation Sans Regular" FONTSIZE="8.8" FCOLOR="Black"/>
# <STYLE NAME="NoteSignature" PARENT="Signature" FONT="Liberation Sans Regular"/>
# <tab FONT="Wingdings Regular" FONTSIZE="15"/>
#
# s/regexp/replacement/
# ! The replacement may contain the special character & to refer to that portion of the pattern which matched
# looking for fontnames contained in all FONT="..."
# excluding <STYLE and <STYLENAME uses that are style definitions, not uses
used=`grep -v '^\s*<CHARSTYLE ' $1.sla | grep -v '^\s*<STYLE ' | grep " \(FONT\|DFONT\)=\"[^\"]*\"" | sed -e 's/^.* FONT=\(\"[^\"]*\"\).*$/\1/' | sed -e 's/^.* DFONT=\(\"[^\"]*\"\).*$/\1/'`
#
# Embeded fonts : <Fonts Name="CC Icons Regular"/>
# Subseted fonts : <Subset Name="Arimo Regular"/>
managed=`sed -n '/\(<Fonts \|<Subset \)/p' $1.sla | sed 's/.*Name=\(\"[^\"]*\"\).*$/\1/'`
errormessage="font is neither vectorized nor embeded"
IFS=$'\n'
for usedfont in $used
do
recognised=""
errored=""
for managedfont in $managed
do
if [ "$usedfont" = "$managedfont" ]
then recognised=oui;
fi
done
if [ "$recognised" = "" ]
then
echo -e "${ESC_error} in $1.sla with $usedfont : $errormessage${ESC_normal}"
errored=oui;
fi
done
if [ "$verbose" = oui ] || [ "$errored" = "oui" ]
then
echo -e ${ESC_green}Embeded or subset fonts are :$ESC_normal
echo $managed
echo -e ${ESC_green}Used fonts are :$ESC_normal
echo $used
fi
if [ "$verbose" = "oui" ] && [ "$errored" = "" ]
then echo "${ESC_green}No font error has been found${ESC_normal}"
fi
exit