wiz_rtf 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 665ba51cf6271ff694ce0efb2f216fc003b4b4e0
4
- data.tar.gz: 9d7ccf728f5a4a48b407ae140753361fef56bacd
3
+ metadata.gz: ac771b35f8a2481049d6d3903d414cf682efe9dc
4
+ data.tar.gz: 0abedded749171f1f81d71c9da0dcedf23477f20
5
5
  SHA512:
6
- metadata.gz: cdc6e1fa527e59e1587cb55de522b1fe0d78d8ebe14280c1af463c7280480c63213464863101f7ac1cb18da1f126c2330991169d8cb980cbe7646af576434971
7
- data.tar.gz: 8256f04da52d810bd1a2b0094679227e7f5e8acce6b5c11431b65236d838df03b8fd4897bc80cd12780c915242f8137d0d15ab13dd95e05af72187b1d15f91b3
6
+ metadata.gz: e34a0f6a7a53dee404b7968223edfdb0d5761aa53bb6f6db8f0aed809a0b83619ae9eec4252566514dfe28e1a253669610e8c9b05fc612754c630425a7e71905
7
+ data.tar.gz: ffd7b8bdc8b6e8d81b92193296977a35cb0794216d6139f82a94a66eebcddc22fc1df578df17ffb9ad3cb7b7ce150f44966b2f95769f93a039ee542b47af6297
data/lib/wiz_rtf/color.rb CHANGED
@@ -23,6 +23,8 @@ module WizRtf
23
23
  GRAY = '#808080'
24
24
  BLACK = '#000000'
25
25
 
26
+ attr_reader :red, :green, :blue
27
+
26
28
  def initialize(*rgb)
27
29
  case rgb.size
28
30
  when 1
@@ -50,13 +52,5 @@ module WizRtf
50
52
  "#" + to_rgb.map {|c| "%02X" % c }.join
51
53
  end
52
54
 
53
- def render(io)
54
- io.delimit do
55
- io.cmd :red, @red
56
- io.cmd :green, @green
57
- io.cmd :blue, @blue
58
- end
59
- end
60
-
61
55
  end
62
56
  end
@@ -9,7 +9,7 @@ module WizRtf
9
9
  #
10
10
  # Creates a new Rtf document specifing the format of the pages.
11
11
  # == Example:
12
- #
12
+ # ```ruby
13
13
  # doc = WizRtf::Document.new do
14
14
  # text "A Example of Rtf Document", 'text-align' => :center, 'font-family' => 'Microsoft YaHei', 'font-size' => 48, 'font-bold' => true, 'font-italic' => true, 'font-underline' => true
15
15
  # image('h:\eahey.png')
@@ -21,7 +21,7 @@ module WizRtf
21
21
  # end
22
22
  # end
23
23
  # doc.save('c:\text.rtf')
24
- #
24
+ # ```
25
25
  class Document
26
26
  def initialize(options = {}, &block)
27
27
  @fonts = []
@@ -41,15 +41,28 @@ module WizRtf
41
41
  io.cmd :deff, 0
42
42
  io.group do
43
43
  io.cmd :fonttbl
44
- @fonts.each do |font|
45
- font.render(io)
44
+ @fonts.each_with_index do |font, index|
45
+ io.group do
46
+ io.delimit do
47
+ io.cmd :f, index
48
+ io.cmd font.family
49
+ io.cmd :fprq, font.pitch
50
+ io.cmd :fcharset, font.character_set
51
+ io.write ' '
52
+ io.write font.name
53
+ end
54
+ end
46
55
  end
47
56
  end
48
57
  io.group do
49
58
  io.cmd :colortbl
50
59
  io.delimit
51
60
  @colors.each do |color|
52
- color.render(io)
61
+ io.delimit do
62
+ io.cmd :red, color.red
63
+ io.cmd :green, color.green
64
+ io.cmd :blue, color.blue
65
+ end
53
66
  end
54
67
  end
55
68
  @parts.each do |part|
@@ -69,11 +82,15 @@ module WizRtf
69
82
  end
70
83
 
71
84
  # Sets the Font for the text.
72
- def font(name, family = nil, character_set = 0, prq = 2)
85
+ def font(name, family = nil, character_set = 0, pitch = 2)
73
86
  unless index = @fonts.index {|f| f.name == name}
74
87
  index = @fonts.size
75
88
  opts = WizRtf::Font::FONTS.detect {|f| f[:name] == name}
76
- @fonts << WizRtf::Font.new(index, opts[:name], opts[:family], opts[:character], opts[:prq])
89
+ if opts
90
+ @fonts << WizRtf::Font.new(opts[:name], opts[:family], opts[:character], opts[:pitch])
91
+ else
92
+ @fonts << WizRtf::Font.new(name, family, character_set, pitch)
93
+ end
77
94
  end
78
95
  index
79
96
  end
@@ -94,7 +111,11 @@ module WizRtf
94
111
  # current drawing position.
95
112
  # == Styles:
96
113
  # * +text-align+ - sets the horizontal alignment of the text. optional values: +:left+, +:center+, +:right+
97
- # * +font-family+ - set the font family of the text. optional values:
114
+ # * +font-family+ - set the font family of the text. optional values: 'Arial', 'Arial Black', 'Arial Narrow','Bitstream Vera Sans Mono',
115
+ # 'Bitstream Vera Sans','Bitstream Vera Serif','Book Antiqua','Bookman Old Style','Castellar','Century Gothic',
116
+ # 'Comic Sans MS','Courier New','Franklin Gothic Medium','Garamond','Georgia','Haettenschweiler','Impact','Lucida Console'
117
+ # 'Lucida Sans Unicode','Microsoft Sans Serif','Monotype Corsiva','Palatino Linotype','Papyrus','Sylfaen','Symbol'
118
+ # 'Tahoma','Times New Roman','Trebuchet MS','Verdana'.
98
119
  # * +font-size+ - set font size of the text.
99
120
  # * +font-bold+ - setting the value true for bold of the text.
100
121
  # * +font-italic+ - setting the value true for italic of the text.
@@ -121,14 +142,14 @@ module WizRtf
121
142
  # == Options:
122
143
  # * +column_widths+ - sets the widths of the Columns.
123
144
  # == Example:
124
- #
145
+ # ```ruby
125
146
  # table [
126
147
  # [{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
127
148
  # [{content:'4',rowspan:3,colspan:2},8],[11]
128
149
  # ], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
129
150
  # add_row [1]
130
151
  # end
131
- #
152
+ # ```
132
153
  def table(rows = [],options = {}, &block)
133
154
  @parts << WizRtf::Table.new(rows, options, &block)
134
155
  end
data/lib/wiz_rtf/font.rb CHANGED
@@ -45,38 +45,54 @@ module WizRtf
45
45
  }
46
46
 
47
47
  FONTS = [
48
- {family:'fswiss', name:'Arial', character:0, prq:2},
49
- {family:'froman', name:'Courier New', character:0, prq:1},
50
- {family:'froman', name:'Times New Roman', character:0, prq:2},
51
- {family:'fnil', name:'SimSun', character:134, prq:2},
52
- {family:'fmodern', name:'KaiTi', character:134, prq:1},
53
- {family:'fnil', name:'FangSong', character:134, prq:1},
54
- {family:'fmodern', name:'SimHei', character:134, prq:1},
55
- {family:'fmodern', name:'NSimSun', character:134, prq:1},
56
- {family:'fswiss', name:'Microsoft YaHei', character:134, prq:2}
48
+ {name:'Arial', family:'fswiss', character:0, pitch:2, panose:'020b0604020202020204'},
49
+ {name:'Arial Black', family:'swiss', character:0, pitch:2, panose:'020b0a04020102020204'},
50
+ {name:'Arial Narrow', family:'swiss', character:0, pitch:2, panose:'020b0506020202030204'},
51
+ {name:'Bitstream Vera Sans Mono', family:'modern', character:0, pitch:1, panose:'020b0609030804020204'},
52
+ {name:'Bitstream Vera Sans', family:'swiss', character:0, pitch:2, panose:'020b0603030804020204'},
53
+ {name:'Bitstream Vera Serif', family:'roman', character:0, pitch:2, panose:'02060603050605020204'},
54
+ {name:'Book Antiqua', family:'roman', character:0, pitch:2, panose:'02040602050305030304'},
55
+ {name:'Bookman Old Style', family:'roman', character:0, pitch:2, panose:'02050604050505020204'},
56
+ {name:'Castellar', family:'roman', character:0, pitch:2, panose:'020a0402060406010301'},
57
+ {name:'Century Gothic', family:'swiss', character:0, pitch:2, panose:'020b0502020202020204'},
58
+ {name:'Comic Sans MS', family:'script', charater:0, pitch:2, panose:'030f0702030302020204'},
59
+ {name:'Courier New', family:'froman', character:0, pitch:1, panose:'02070309020205020404'},
60
+ {name:'Franklin Gothic Medium', family:'swiss', character:0, picth:2, panose:'020b0603020102020204'},
61
+ {name:'Garamond', family:'roman' , character:0, pitch:2, panose:'02020404030301010803'},
62
+ {name:'Georgia', family:'roman', character:0, pitch:2, panose:'02040502050405020303'},
63
+ {name:'Haettenschweiler', family:'swiss', character:0, pitch:2, panose:'020b0706040902060204'},
64
+ {name:'Impact', family:'swiss', character:0, pitch:2, panose:'020b0806030902050204'},
65
+ {name:'Lucida Console', family:'modern', character:0, pitch:1, panose:'020b0609040504020204'},
66
+ {name:'Lucida Sans Unicode', family:'swiss' , character:0, pitch:2, panose:'020b0602030504020204'},
67
+ {name:'Microsoft Sans Serif', family:'swiss', character:0, pitch:2, panose:'020b0604020202020204'},
68
+ {name:'Monotype Corsiva', family:'script', character:0, pitch:2, panose:'03010101010201010101'},
69
+ {name:'Palatino Linotype', family:'roman', character:0, pitch:2, panose:'02040502050505030304'},
70
+ {name:'Papyrus', family:'script', character:0, pitch:2, panose:'03070502060502030205'},
71
+ {name:'Sylfaen', family:'roman', character:0, pitch:2, panose:'010a0502050306030303'},
72
+ {name:'Symbol', family:'roman', character:2, pitch:2, panose:'05050102010706020507'},
73
+ {name:'Tahoma', family:'swiss', character:0, pitch:2, panose:'020b0604030504040204'},
74
+ {name:'Times New Roman', family:'froman', character:0, pitch:2, panose:'02020603050405020304'},
75
+ {name:'Trebuchet MS', family:'swiss', character:0, pitch:2, panose:'020b0603020202020204'},
76
+ {name:'Verdana', family:'swiss', character:0, pitch:2, panose:'020b0604030504040204'},
77
+ {name:'SimSun', family:'fnil', character:134, pitch:2},
78
+ {name:'KaiTi', family:'fmodern', character:134, pitch:1},
79
+ {name:'FangSong', family:'fnil', character:134, pitch:1},
80
+ {name:'SimHei', family:'fmodern', character:134, pitch:1},
81
+ {name:'NSimSun', family:'fmodern', character:134, pitch:1},
82
+ {name:'Microsoft YaHei', family:'fswiss', character:134, pitch:2}
57
83
  ]
58
84
 
59
- attr_accessor :name, :num
60
- def initialize(num, name, family = 'fnil', character_set = 0, prq = 2)
61
- @num = num
62
- @family = family if family
85
+ attr_accessor :name, :family, :character_set, :pitch, :panose, :alternate
86
+
87
+ def initialize(name, family = 'fnil', character_set = 0, pitch = nil, panose = nil, alternate = nil)
63
88
  @name = name
89
+ @family = family
64
90
  @character_set = character_set
65
- @prq = prq
91
+ @pitch = pitch
92
+ @panose = panose
93
+ @alternate = alternate
66
94
  end
67
95
 
68
- def render(io)
69
- io.group do
70
- io.delimit do
71
- io.cmd :f, @num
72
- io.cmd @family
73
- io.cmd :fprq, @prq
74
- io.cmd :fcharset, @character_set
75
- io.write ' '
76
- io.write @name
77
- end
78
- end
79
- end
80
96
  end
81
97
  end
82
98
 
data/lib/wiz_rtf/text.rb CHANGED
@@ -13,7 +13,11 @@ module WizRtf
13
13
  # creates a text of +str+ to the document.
14
14
  # == Styles:
15
15
  # * +text-align+ - sets the horizontal alignment of the text. optional values: +:left+, +:center+, +:right+
16
- # * +font-family+ - set the font family of the text. optional values:
16
+ # * +font-family+ - set the font family of the text. optional values: 'Arial', 'Arial Black', 'Arial Narrow','Bitstream Vera Sans Mono',
17
+ # 'Bitstream Vera Sans','Bitstream Vera Serif','Book Antiqua','Bookman Old Style','Castellar','Century Gothic',
18
+ # 'Comic Sans MS','Courier New','Franklin Gothic Medium','Garamond','Georgia','Haettenschweiler','Impact','Lucida Console'
19
+ # 'Lucida Sans Unicode','Microsoft Sans Serif','Monotype Corsiva','Palatino Linotype','Papyrus','Sylfaen','Symbol'
20
+ # 'Tahoma','Times New Roman','Trebuchet MS','Verdana'.
17
21
  # * +font-size+ - set font size of the text.
18
22
  # * +font-bold+ - setting the value true for bold of the text.
19
23
  # * +font-italic+ - setting the value true for italic of the text.
@@ -1,3 +1,3 @@
1
1
  module WizRtf
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
data/wiz_rtf.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["songgz"]
10
10
  spec.email = ["sgzhe@163.com"]
11
11
 
12
- spec.summary = %q{A gem for exporting Word Documents in ruby using the Microsoft Rich Text Format (RTF) Specification.}
13
- spec.description = %q{A gem for rtf.}
12
+ spec.summary = %q{A gem for creating RTF document.}
13
+ spec.description = %q{A gem for exporting Word Documents in ruby using the Microsoft Rich Text Format (RTF) Specification.}
14
14
  spec.homepage = "https://github.com/songgz/wiz_rtf"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiz_rtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - songgz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,7 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: A gem for rtf.
41
+ description: A gem for exporting Word Documents in ruby using the Microsoft Rich Text
42
+ Format (RTF) Specification.
42
43
  email:
43
44
  - sgzhe@163.com
44
45
  executables: []
@@ -93,6 +94,5 @@ rubyforge_project:
93
94
  rubygems_version: 2.2.3
94
95
  signing_key:
95
96
  specification_version: 4
96
- summary: A gem for exporting Word Documents in ruby using the Microsoft Rich Text
97
- Format (RTF) Specification.
97
+ summary: A gem for creating RTF document.
98
98
  test_files: []