text2svg 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ca9a26a917f6eb21d00b9776e25080e1025adbf
4
- data.tar.gz: 7e83538306525d6b741f978fde59f69911e066e6
3
+ metadata.gz: 0c9369612ae9c5bdb3a13197045796bfbbb1d9b1
4
+ data.tar.gz: 774fff023b854634b8321a0f3584f7db1d09f841
5
5
  SHA512:
6
- metadata.gz: 7d8ec9d4ff1857f2718ee3cb3a0d0d29cd1a9b91116a9faf5603922089ec8d35b12fde1b0b24f302250b323758363ed8483451c48717e5850578a1ebcab96dbb
7
- data.tar.gz: 56a9b1e77140fae8c73e9cfcd9a29183c310948552312495f71e28dc2e6e3ad40c8d7f54d1ff72cc386e975a07a7ba7a6beb3d357bca0ef5b812590a10754bdd
6
+ metadata.gz: 7035f7c09512a93ef2672916a73c769c3a54884027425e8146f491264d19b59946056e878752b01a0b4b2e0e578db2f4939f9e1fa6a7a1463d79da929e685994
7
+ data.tar.gz: 81f15f3f29af0fe100dfe2958ff4c5f412807215b123d0b3700b61240300c5139d8329816cbcc22d739a9a3b9d93d226f532c09261c57f0fc7ea4ab39a0cf7a3
data/README.md CHANGED
@@ -23,6 +23,14 @@ Usage: text2svg [options]
23
23
  --option STRING decorate options (default nil)(e.g. fill="red" stroke-width="100")
24
24
  ```
25
25
 
26
+ ## Ruby API
27
+
28
+ ```ruby
29
+ require 'text2svg'
30
+ puts Text2svg('Hello, World!', font: "/Library/Fonts/Times New Roman.ttf", text_align: :left, bold: true)
31
+ #=> "<svg ...>"
32
+ ```
33
+
26
34
  ## Installation
27
35
 
28
36
  Add this line to your application's Gemfile:
data/lib/text2svg.rb CHANGED
@@ -2,3 +2,9 @@ require 'text2svg/option'
2
2
  require 'text2svg/outline2d'
3
3
  require 'text2svg/typography'
4
4
  require 'text2svg/version'
5
+
6
+ module Kernel
7
+ def Text2svg(text, option)
8
+ Text2svg::Typography.build(text, option)
9
+ end
10
+ end
@@ -123,13 +123,11 @@ module Text2svg
123
123
 
124
124
  line.each do |cs|
125
125
  x += f.kerning_unfitted(before_char, cs.char).x.to_i
126
- output << %! <g transform="translate(#{x.to_i},0)">\n!
127
126
  if cs.draw?
128
- output << %( <path d="#{cs.d}"/>\n)
127
+ output << %! <path transform="translate(#{x.to_i},0)" d="#{cs.d}"/>\n!
129
128
  end
130
129
  x += cs.width
131
130
  x += inter_char_space if cs != line.last
132
- output << " </g>\n".freeze
133
131
  before_char = cs.char
134
132
  end
135
133
  output << "</g>\n".freeze
@@ -1,3 +1,3 @@
1
1
  module Text2svg
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-12 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: freetype