This repository has been archived by the owner on Aug 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
/
build-icon.sh
78 lines (61 loc) · 2.11 KB
/
build-icon.sh
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
#!/bin/bash
basepath=$(dirname $0)
server_prefix=/zanui-weapp
# convert relative path to absolute path
function abspath() {
pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs -l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" ]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename \"$1\"`"; fi; fi; popd > /dev/null;
}
command_exists () {
type "$1" >/dev/null 2>&1
}
fontname() {
echo "https://b.yzcdn.cn$server_prefix/$(basename $basepath/../assets/icons/build/font/zanui-weapp-icon-*.$1)"
}
# generate font files from sketch file
$basepath/icons/extract-icons.sh
$basepath/icons/generate-font.sh
if command_exists superman ; then
# upload to cdn
superman cdn $server_prefix $basepath/../assets/icons/build/font/zanui-weapp-icon-*
fi
# generate fontface style
eot=$(fontname eot)
cat > $basepath/../packages/icon/index.pcss <<EOF
/* DO NOT EDIT! Generated by fount */
@font-face {
font-family: 'zanui-weapp-icon';
src: url('$eot');
src: url('$eot?#iefix') format('embedded-opentype'),
url('$(fontname woff2)') format('woff2'),
url('$(fontname woff)') format('woff'),
url('$(fontname ttf)') format('truetype')
}
.zan-icon {
display: inline-block;
}
.zan-icon::before {
font-family: "zanui-weapp-icon" !important;
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-decoration: inherit;
width: 1em;
text-align: center;
/* For safety - reset parent styles, that can break glyph codes*/
font-variant: normal;
text-transform: none;
/* fix buttons height, for twitter bootstrap */
line-height: 1em;
/* Animation center compensation - margins should be symmetric */
/* remove if not needed */
/* margin-left: .2em; */
/* you can be more comfortable with increased icons size */
/* font-size: 120%; */
/* Font smoothing. That was taken from TWBS */
-webkit-font-smoothing: antialiased;
/* Uncomment for 3D effect */
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}
EOF
cat $basepath/../assets/icons/build/css/zanui-weapp-icon-codes.css >> $basepath/../packages/icon/index.pcss