cjk-subsetter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/rack/subsetter.rb +25 -13
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8357489133e8160fb56635f18577855b918d79dd
|
4
|
+
data.tar.gz: b49c453c2e97b7cfdd4b2da5f5e8cd049556aa4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efbd59f6907c83f2d63afe97014d5590d3a0996b0a6420c9b577660fe4ceadcc2f6ab4c75d7087e9fc18ffa839852c20351483bf7ea27f775d59521590d8d1eb
|
7
|
+
data.tar.gz: 0b28530f575f313437a600ec1752c0bbd3a8e6e5ac14c73ae1bf89f8b1c594221db9cc4ec6226d70412f165ce3ad607a8c36ef527695e98b837e55249de88a05
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= subsetter
|
2
2
|
|
3
|
+
![Logo](https://raw.github.com/hxgdzyuyi/AlexPic/master/skin/alexpic_m.png)
|
4
|
+
|
3
5
|
可以在网页中使用中文字体的 Rack 程序。
|
4
6
|
|
5
7
|
=== 原理
|
@@ -8,10 +10,17 @@
|
|
8
10
|
|
9
11
|
=== 依赖
|
10
12
|
|
11
|
-
-
|
13
|
+
- Java 环境
|
12
14
|
- Ruby
|
13
15
|
|
14
16
|
=== 感谢以下开源项目
|
15
17
|
|
16
18
|
- sfntly https://code.google.com/p/sfntly/
|
17
19
|
|
20
|
+
=== 不同浏览器下的表现
|
21
|
+
|
22
|
+
目前不支持 IE(eot), 因为只会生成 ttf 字体
|
23
|
+
|
24
|
+
http://www.browserstack.com/screenshots/d4d8917bd06dcddd17be4706ff4508e5842e5078
|
25
|
+
|
26
|
+
[![Build Status](https://secure.travis-ci.org/hxgdzyuyi/cjk-subsetter.png)](http://travis-ci.org/hxgdzyuyi/cjk-subsetter)
|
data/lib/rack/subsetter.rb
CHANGED
@@ -44,9 +44,9 @@ module Rack
|
|
44
44
|
headers['Content-Type'] =~ /html/
|
45
45
|
end
|
46
46
|
|
47
|
-
def create_path(string, font_name)
|
47
|
+
def create_path(string, font_name, file_type)
|
48
48
|
filename = Digest::SHA1.hexdigest(string + font_name)
|
49
|
-
@font_dist + '/' + filename +
|
49
|
+
@font_dist + '/' + filename + file_type
|
50
50
|
end
|
51
51
|
|
52
52
|
def call(env)
|
@@ -70,19 +70,31 @@ module Rack
|
|
70
70
|
@subset_string_map.each do |font_key, chars_map|
|
71
71
|
subset_string = chars_map.map { |key, value| key }.join
|
72
72
|
font_name = @font_map[font_key].join
|
73
|
-
file_path = create_path(subset_string, font_name)
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
['.ttf', '.eot'].each do |file_type|
|
75
|
+
file_path = create_path(subset_string, font_name, file_type)
|
76
|
+
file_is_eot = file_type == '.eot'
|
77
|
+
|
78
|
+
unless ::File.exist? file_path
|
79
|
+
::File.open(file_path, 'w+')
|
80
|
+
args = ["java", "-jar", "#{@sfnttool}"]
|
81
|
+
|
82
|
+
if file_is_eot
|
83
|
+
args.push "-e"
|
84
|
+
end
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
+
args.concat ["-s", "#{subset_string}",
|
87
|
+
"#{@font_source}/#{font_name}", "#{file_path}"]
|
88
|
+
|
89
|
+
child = POSIX::Spawn::Child.new(*args)
|
90
|
+
end
|
91
|
+
|
92
|
+
p_output = Pathname.new file_path
|
93
|
+
font_url = @relative_url_root + \
|
94
|
+
p_output.relative_path_from(p_public).to_s
|
95
|
+
klass = '.%s-' % @prefix + font_key
|
96
|
+
new_body.gsub!(%r{</head>}, template.result(binding) + "</head>")
|
97
|
+
end
|
86
98
|
end
|
87
99
|
|
88
100
|
response.write new_body
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cjk-subsetter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hxgdzyuyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.14.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.14.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +123,19 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: capybara
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 2.2.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 2.2.0
|
139
139
|
description: You can use chinese webfont
|
140
140
|
email: hxgdzyuyi@gmail.com
|
141
141
|
executables: []
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.0.
|
170
|
+
rubygems_version: 2.0.2
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: You can use chinese webfont
|