text2svg 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/text2svg/typography.rb +3 -2
- data/lib/text2svg/typography_test.rb +13 -11
- data/lib/text2svg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39979ba9c4c9e523e0b5352d5e925e6e4cde104e
|
4
|
+
data.tar.gz: 0974fb70be866aa90bbc23b7a6eea4554dbc6f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31a9e426f33bb9e180febe74b3de0ff2eb86c83827b86db2f3eafe67650da4112492ee3f0895372bc806baf2240c5c31165d47b17ceea4d0d1d27c79132ed4ab
|
7
|
+
data.tar.gz: c38d2d1fdcd2ba77fa9137177237118ef494a449a769429aecbee7a7cb52938a18a3b9102c9b3e2cb552978aa7bc36d16eafd71dd5b6f68497f433b8249b7ae0
|
data/lib/text2svg/typography.rb
CHANGED
@@ -46,12 +46,13 @@ module Text2svg
|
|
46
46
|
lines = []
|
47
47
|
line = []
|
48
48
|
lines << line
|
49
|
-
first_hori_bearing_x = []
|
49
|
+
first_hori_bearing_x = [0]
|
50
50
|
|
51
51
|
space_width = f.glyph(' '.freeze).char_width
|
52
52
|
text.each_char.with_index do |char, index|
|
53
53
|
if NEW_LINE.match char
|
54
54
|
line = []
|
55
|
+
first_hori_bearing_x << 0
|
55
56
|
lines << line
|
56
57
|
next
|
57
58
|
end
|
@@ -78,7 +79,7 @@ module Text2svg
|
|
78
79
|
[space_width, space_width, false]
|
79
80
|
else
|
80
81
|
if line.empty?
|
81
|
-
first_hori_bearing_x
|
82
|
+
first_hori_bearing_x[first_hori_bearing_x.length - 1] = glyph.metrics[:horiBearingX]
|
82
83
|
end
|
83
84
|
[glyph.metrics[:horiAdvance], glyph.metrics[:width], true]
|
84
85
|
end
|
@@ -28,19 +28,21 @@ module Text2svgTypographyTest
|
|
28
28
|
opt.bold = bold
|
29
29
|
[false, true].each do |italic|
|
30
30
|
opt.italic = italic
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
['ABC', "\n", "\n\nA", "", "A\nB\n\n", "A\n\n\nC"].each do |text|
|
32
|
+
begin
|
33
|
+
c = Text2svg::Typography.build(text, opt)
|
34
|
+
rescue => e
|
35
|
+
t.log("raise error #{e.class}: #{e.message} with text=\"#{text}\",opt=#{opt}")
|
36
|
+
raise
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
unless Text2svg::Content === c
|
40
|
+
t.error('return value was break')
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
unless c.data.encoding == Encoding::UTF_8
|
44
|
+
t.error('encoding was changed')
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
data/lib/text2svg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text2svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: freetype
|