iftoc 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/bin/iftoc +2 -20
- data/iconfont.svg +49 -0
- data/lib/iftoc/version.rb +1 -1
- data/lib/iftoc.rb +9 -6
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7c14ede3502c50a5b4e5efca31b7933c5f88dec
|
|
4
|
+
data.tar.gz: 164fc9357ae195c449607c32a1fb293e5cc50f28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d14a82921a4ee5756716f368c547361da67da84b5105b70efd39f0a630fb6d095e3bed937b36f6b3682c49ca7f6b69d9d92c43e200fdc240a5490f4259fd7406
|
|
7
|
+
data.tar.gz: 3f709ea5147b9e029f6fd927115e0e7e50443c9e8c32eb6574b964851f2583726857fdbedd3a512e46af4b8127886f2af310dbf6fbf5a2fc38f5ed552d1a744b
|
data/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
Converts CSS StyleSheets for IconFont like [iconfont.css](https://github.com/panghaijiao/iftoc/blob/master/iconfont.css) to [OC code file](https://github.com/panghaijiao/iftoc/tree/master/iconfont) automatically
|
|
6
|
+
Converts SVG or CSS StyleSheets for IconFont like [iconfont.css](https://github.com/panghaijiao/iftoc/blob/master/iconfont.css) to [OC code file](https://github.com/panghaijiao/iftoc/tree/master/iconfont) automatically
|
|
7
7
|
|
|
8
8
|
## Example
|
|
9
9
|
|
|
10
|
-
- Input: [iconfont.css](https://github.com/panghaijiao/iftoc/blob/master/iconfont.css)
|
|
10
|
+
- Input: [iconfont.css](https://github.com/panghaijiao/iftoc/blob/master/iconfont.css) or [iconfont.svg](https://github.com/panghaijiao/iftoc/blob/master/iconfont.svg)
|
|
11
11
|
- Output: [Iconfont.h](https://github.com/panghaijiao/iftoc/blob/master/iconfont/Iconfont.h) [Iconfont.m](https://github.com/panghaijiao/iftoc/blob/master/iconfont/Iconfont.m)
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -18,25 +18,29 @@ Install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
Usage: iftoc \<cssfile> [--out \<outpath>]
|
|
21
|
+
Usage: iftoc \<svgfile | cssfile> [--out \<outpath>]
|
|
22
22
|
|
|
23
23
|
## e.g.
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
$ iftoc iconfont.svg
|
|
26
|
+
|
|
27
|
+
or
|
|
28
|
+
|
|
25
29
|
$ iftoc iconfont.css
|
|
26
30
|
|
|
27
31
|
or
|
|
28
32
|
|
|
29
|
-
$ iftoc iconfont.
|
|
33
|
+
$ iftoc iconfont.svg --out /iconfont
|
|
30
34
|
|
|
31
|
-
## iconfont.css
|
|
35
|
+
## iconfont.svg & iconfont.css
|
|
32
36
|
|
|
33
|
-
Iconfont.css can be created automatically from
|
|
37
|
+
Iconfont.svg or Iconfont.css can be created automatically from [http://www.iconfont.cn](http://www.iconfont.cn/)
|
|
34
38
|
|
|
35
39
|
.
|
|
36
40
|
|
|
37
41
|
├── **iconfont.css**
|
|
38
42
|
|
|
39
|
-
├── iconfont.svg
|
|
43
|
+
├── **iconfont.svg**
|
|
40
44
|
|
|
41
45
|
├── iconfont.ttf
|
|
42
46
|
|
data/bin/iftoc
CHANGED
|
@@ -37,32 +37,14 @@ def paramCheck
|
|
|
37
37
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def parseSVGFontName(xmlContext)
|
|
41
|
-
fontelement = xmlContext.root.elements["defs"].elements["font"]
|
|
42
|
-
return fontelement.elements["font-face"].attributes["font-family"]
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def parseSVGIconFont(xmlContext)
|
|
46
|
-
iconfonts = Hash.new
|
|
47
|
-
fontelement = xmlContext.root.elements["defs"].elements["font"]
|
|
48
|
-
fontelement.get_elements("glyph").each { |font|
|
|
49
|
-
name = font.attributes["glyph-name"]
|
|
50
|
-
unicode = font.attributes["unicode"].to_s.delete("#x;")
|
|
51
|
-
if unicode.length == 4 then
|
|
52
|
-
iconfonts[name] = unicode
|
|
53
|
-
end
|
|
54
|
-
}
|
|
55
|
-
return iconfonts
|
|
56
|
-
end
|
|
57
|
-
|
|
58
40
|
# main
|
|
59
41
|
paramCheck
|
|
60
42
|
|
|
61
43
|
io = File.open($inpath)
|
|
62
44
|
doc = REXML::Document.new(io.read.to_s.delete("&"))
|
|
63
45
|
if doc.root then
|
|
64
|
-
iconfontName = parseSVGFontName(doc)
|
|
65
|
-
iconfontMap = parseSVGIconFont(doc)
|
|
46
|
+
iconfontName = Iftoc.parseSVGFontName(doc)
|
|
47
|
+
iconfontMap = Iftoc.parseSVGIconFont(doc)
|
|
66
48
|
else
|
|
67
49
|
io.close
|
|
68
50
|
io = File.open($inpath)
|
data/iconfont.svg
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<metadata>
|
|
5
|
+
Created by FontForge 20120731 at Thu Jan 5 11:14:06 2017
|
|
6
|
+
By admin
|
|
7
|
+
</metadata>
|
|
8
|
+
<defs>
|
|
9
|
+
<font id="iconfont" horiz-adv-x="1024" >
|
|
10
|
+
<font-face
|
|
11
|
+
font-family="iconfont"
|
|
12
|
+
font-weight="500"
|
|
13
|
+
font-stretch="normal"
|
|
14
|
+
units-per-em="1024"
|
|
15
|
+
panose-1="2 0 6 3 0 0 0 0 0 0"
|
|
16
|
+
ascent="896"
|
|
17
|
+
descent="-128"
|
|
18
|
+
x-height="792"
|
|
19
|
+
bbox="0 -128 1024 896"
|
|
20
|
+
underline-thickness="0"
|
|
21
|
+
underline-position="0"
|
|
22
|
+
unicode-range="U+0078-E6AF"
|
|
23
|
+
/>
|
|
24
|
+
<missing-glyph
|
|
25
|
+
/>
|
|
26
|
+
<glyph glyph-name=".notdef"
|
|
27
|
+
/>
|
|
28
|
+
<glyph glyph-name=".notdef"
|
|
29
|
+
/>
|
|
30
|
+
<glyph glyph-name=".null" horiz-adv-x="0"
|
|
31
|
+
/>
|
|
32
|
+
<glyph glyph-name="nonmarkingreturn" horiz-adv-x="341"
|
|
33
|
+
/>
|
|
34
|
+
<glyph glyph-name="x" unicode="x" horiz-adv-x="1001"
|
|
35
|
+
d="M281 543q-27 -1 -53 -1h-83q-18 0 -36.5 -6t-32.5 -18.5t-23 -32t-9 -45.5v-76h912v41q0 16 -0.5 30t-0.5 18q0 13 -5 29t-17 29.5t-31.5 22.5t-49.5 9h-133v-97h-438v97zM955 310v-52q0 -23 0.5 -52t0.5 -58t-10.5 -47.5t-26 -30t-33 -16t-31.5 -4.5q-14 -1 -29.5 -0.5
|
|
36
|
+
t-29.5 0.5h-32l-45 128h-439l-44 -128h-29h-34q-20 0 -45 1q-25 0 -41 9.5t-25.5 23t-13.5 29.5t-4 30v167h911zM163 247q-12 0 -21 -8.5t-9 -21.5t9 -21.5t21 -8.5q13 0 22 8.5t9 21.5t-9 21.5t-22 8.5zM316 123q-8 -26 -14 -48q-5 -19 -10.5 -37t-7.5 -25t-3 -15t1 -14.5
|
|
37
|
+
t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-5 19 -11 39h-368zM336 498v228q0 11 2.5 23t10 21.5t20.5 15.5t34 6h188q31 0 51.5 -14.5t20.5 -52.5v-227h-327z" />
|
|
38
|
+
<glyph glyph-name="all" unicode=""
|
|
39
|
+
d="M461 410h25v25v218q0 101 -71 172t-172 71t-172 -71t-71 -172t71 -172t172 -71h218zM51 652.5q0 79.5 56.5 136t136 56.5t135.5 -56.5t56 -135.5v-218l26 26h-218q-79 0 -135.5 56t-56.5 135.5zM461 307l-26 26v-218q0 -79 -56 -135.5t-135.5 -56.5t-136 56.5t-56.5 136
|
|
40
|
+
t56.5 135.5t135.5 56h218zM0 115q0 -101 71 -172t172 -71t172 71t71 172v218v25h-25h-218q-101 0 -172 -71t-71 -172zM563 461l26 -26v218q0 79 56 135.5t135.5 56.5t136 -56.5t56.5 -136t-56.5 -135.5t-135.5 -56h-218zM1024 653q0 101 -71 172t-172 71t-172 -71t-71 -172
|
|
41
|
+
v-218v-25h25h218q101 0 172 71t71 172zM1024 115q0 101 -71 172t-172 71h-218h-25v-25v-218q0 -101 71 -172t172 -71q57 0 107 25q10 5 13.5 15t-1.5 19.5t-15 13t-19 -1.5q-40 -20 -85 -20q-80 0 -136 56.5t-56 135.5v218l-26 -26h218q79 0 135.5 -56t56.5 -136
|
|
42
|
+
q0 -28 -8 -54q-3 -10 2 -19.5t15 -12.5t19.5 2t12.5 15q10 34 10 69z" />
|
|
43
|
+
<glyph glyph-name="smile" unicode=""
|
|
44
|
+
d="M1024 384q0 139 -68.5 257t-186.5 186.5t-257 68.5t-257 -68.5t-186.5 -186.5t-68.5 -257t68.5 -257t186.5 -186.5t257 -68.5q179 0 319 111q8 7 9 17t-5.5 18.5t-16.5 9.5t-18 -6q-126 -100 -288 -100q-94 0 -179.5 36.5t-147.5 98.5t-98.5 147.5t-36.5 179.5
|
|
45
|
+
t36.5 179.5t98.5 147.5t147.5 98.5t179.5 36.5t179.5 -36.5t147.5 -98.5t98.5 -147.5t36.5 -179.5q0 -132 -70 -244q-5 -9 -2.5 -19t11 -15.5t18.5 -3t16 11.5q77 123 77 270zM337 396q26 0 44.5 18.5t18.5 44.5t-18.5 44t-44.5 18t-44 -18t-18 -44t18 -44.5t44 -18.5z
|
|
46
|
+
M712 396q26 0 44 18.5t18 44.5t-18 44t-44 18t-44.5 -18t-18.5 -44t18.5 -44.5t44.5 -18.5zM353 127q69 -55 171.5 -55t171.5 55q36 29 51 59q4 9 1 18.5t-12.5 14.5t-19 1.5t-14.5 -12.5q-2 -4 -8 -12q-12 -16 -29 -30q-56 -44 -140.5 -44t-140.5 44q-17 14 -29 30
|
|
47
|
+
q-6 8 -8 12q-5 9 -14.5 12.5t-19 -1.5t-12.5 -14.5t1 -18.5q15 -30 51 -59z" />
|
|
48
|
+
</font>
|
|
49
|
+
</defs></svg>
|
data/lib/iftoc/version.rb
CHANGED
data/lib/iftoc.rb
CHANGED
|
@@ -17,7 +17,8 @@ module Iftoc
|
|
|
17
17
|
fontelement.get_elements("glyph").each { |font|
|
|
18
18
|
name = font.attributes["glyph-name"]
|
|
19
19
|
unicode = font.attributes["unicode"].to_s.delete("#x;")
|
|
20
|
-
if unicode.length == 4 then
|
|
20
|
+
if name && unicode.length == 4 then
|
|
21
|
+
name = name.gsub(/[^A-Za-z\d_]/, '')
|
|
21
22
|
iconfonts[name] = unicode
|
|
22
23
|
end
|
|
23
24
|
}
|
|
@@ -42,8 +43,10 @@ module Iftoc
|
|
|
42
43
|
line.chomp!
|
|
43
44
|
$iconRegexpStr =~ line
|
|
44
45
|
name = $1
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
unicode = $2.to_s
|
|
47
|
+
if name && unicode.length == 4 then
|
|
48
|
+
name = name.to_s.gsub(/[^A-Za-z\d_]/, '')
|
|
49
|
+
iconfonts[name] = unicode
|
|
47
50
|
end
|
|
48
51
|
end
|
|
49
52
|
return iconfonts
|
|
@@ -126,9 +129,9 @@ module Iftoc
|
|
|
126
129
|
end
|
|
127
130
|
|
|
128
131
|
def putStringToFile(text, path)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
hio = File.open(path, "w+")
|
|
133
|
+
hio.puts(text)
|
|
134
|
+
hio.close
|
|
132
135
|
end
|
|
133
136
|
|
|
134
137
|
module_function :parseSVGFontName
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iftoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 庞海礁
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -57,6 +57,7 @@ files:
|
|
|
57
57
|
- bin/iftoc
|
|
58
58
|
- bin/setup
|
|
59
59
|
- iconfont.css
|
|
60
|
+
- iconfont.svg
|
|
60
61
|
- iconfont/Iconfont.h
|
|
61
62
|
- iconfont/Iconfont.m
|
|
62
63
|
- iftoc.gemspec
|