wiz_rtf 0.6.8 → 0.6.9
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/lib/wiz_rtf/document.rb +29 -27
- data/lib/wiz_rtf/font.rb +26 -26
- data/lib/wiz_rtf/text.rb +2 -2
- data/lib/wiz_rtf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e50f7ba95e98ae48567ca4bfd0a8421ace84aec
|
4
|
+
data.tar.gz: 287b9d99cccae42cfee1304b212f40bde5f13cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bd83208addc0565fda353b1b9c2102ac81a73c2e6e1dbbe70345f464723143746a492cdafdc28cb7541b0a140a1ba0d560d8d8ffd420080318ed35a33bf206
|
7
|
+
data.tar.gz: c94b03baf6581b26c6d3b0e84154ae840ddb978fa9e5c2b382172c35b2e9b8ecbfea0e70f53a69cdfe7816f3bcc42cacecbaa00387b3481427e597d0eb340bc7
|
data/lib/wiz_rtf/document.rb
CHANGED
@@ -9,25 +9,25 @@ module WizRtf
|
|
9
9
|
#
|
10
10
|
# Creates a new Rtf document specifing the format of the pages.
|
11
11
|
# == Example:
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
12
|
+
#
|
13
|
+
# doc = WizRtf::Document.new do
|
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
|
+
# image('h:\eahey.png')
|
16
|
+
# page_break
|
17
|
+
# text "A Table Demo", 'foreground-color' => WizRtf::Color::RED, 'background-color' => '#0f00ff'
|
18
|
+
# table [[{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
|
19
|
+
# [{content:'4',rowspan:3,colspan:2},8],[11]], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
|
20
|
+
# add_row [1]
|
21
|
+
# end
|
21
22
|
# end
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# ```
|
23
|
+
# doc.save('c:\text.rtf')
|
24
|
+
#
|
25
25
|
class Document
|
26
26
|
def initialize(options = {}, &block)
|
27
27
|
@fonts = []
|
28
28
|
@colors = []
|
29
29
|
@parts = []
|
30
|
-
font '
|
30
|
+
font 'NSimSun'
|
31
31
|
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
32
32
|
end
|
33
33
|
|
@@ -111,18 +111,20 @@ module WizRtf
|
|
111
111
|
# current drawing position.
|
112
112
|
# == Styles:
|
113
113
|
# * +text-align+ - sets the horizontal alignment of the text. optional values: +:left+, +:center+, +:right+
|
114
|
-
# * +font-family+ - set the font family of the text.
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
114
|
+
# * +font-family+ - set the font family of the text.
|
115
|
+
# - optional values:
|
116
|
+
# 'Arial', 'Arial Black', 'Arial Narrow','Bitstream Vera Sans Mono',
|
117
|
+
# 'Bitstream Vera Sans','Bitstream Vera Serif','Book Antiqua','Bookman Old Style','Castellar','Century Gothic',
|
118
|
+
# 'Comic Sans MS','Courier New','Franklin Gothic Medium','Garamond','Georgia','Haettenschweiler','Impact','Lucida Console'
|
119
|
+
# 'Lucida Sans Unicode','Microsoft Sans Serif','Monotype Corsiva','Palatino Linotype','Papyrus','Sylfaen','Symbol'
|
120
|
+
# 'Tahoma','Times New Roman','Trebuchet MS','Verdana'.
|
119
121
|
# * +font-size+ - set font size of the text.
|
120
122
|
# * +font-bold+ - setting the value true for bold of the text.
|
121
123
|
# * +font-italic+ - setting the value true for italic of the text.
|
122
124
|
# * +font-underline+ - setting the value true for underline of the text.
|
123
125
|
# == Example:
|
124
126
|
#
|
125
|
-
#
|
127
|
+
# 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
|
126
128
|
#
|
127
129
|
def text(str, styles = {})
|
128
130
|
styles['foreground-color'] = color(styles['foreground-color']) if styles['foreground-color']
|
@@ -142,14 +144,14 @@ module WizRtf
|
|
142
144
|
# == Options:
|
143
145
|
# * +column_widths+ - sets the widths of the Columns.
|
144
146
|
# == Example:
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
147
|
+
#
|
148
|
+
# table [
|
149
|
+
# [{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
|
150
|
+
# [{content:'4',rowspan:3,colspan:2},8],[11]
|
151
|
+
# ], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
|
152
|
+
# add_row [1]
|
153
|
+
# end
|
154
|
+
#
|
153
155
|
def table(rows = [],options = {}, &block)
|
154
156
|
@parts << WizRtf::Table.new(rows, options, &block)
|
155
157
|
end
|
data/lib/wiz_rtf/font.rb
CHANGED
@@ -46,34 +46,34 @@ module WizRtf
|
|
46
46
|
|
47
47
|
FONTS = [
|
48
48
|
{name:'Arial', family:'fswiss', character:0, pitch:2, panose:'020b0604020202020204'},
|
49
|
-
{name:'Arial Black', family:'
|
50
|
-
{name:'Arial Narrow', family:'
|
51
|
-
{name:'Bitstream Vera Sans Mono', family:'
|
52
|
-
{name:'Bitstream Vera Sans', family:'
|
53
|
-
{name:'Bitstream Vera Serif', family:'
|
54
|
-
{name:'Book Antiqua', family:'
|
55
|
-
{name:'Bookman Old Style', family:'
|
56
|
-
{name:'Castellar', family:'
|
57
|
-
{name:'Century Gothic', family:'
|
58
|
-
{name:'Comic Sans MS', family:'
|
49
|
+
{name:'Arial Black', family:'fswiss', character:0, pitch:2, panose:'020b0a04020102020204'},
|
50
|
+
{name:'Arial Narrow', family:'fswiss', character:0, pitch:2, panose:'020b0506020202030204'},
|
51
|
+
{name:'Bitstream Vera Sans Mono', family:'fmodern', character:0, pitch:1, panose:'020b0609030804020204'},
|
52
|
+
{name:'Bitstream Vera Sans', family:'fswiss', character:0, pitch:2, panose:'020b0603030804020204'},
|
53
|
+
{name:'Bitstream Vera Serif', family:'froman', character:0, pitch:2, panose:'02060603050605020204'},
|
54
|
+
{name:'Book Antiqua', family:'froman', character:0, pitch:2, panose:'02040602050305030304'},
|
55
|
+
{name:'Bookman Old Style', family:'froman', character:0, pitch:2, panose:'02050604050505020204'},
|
56
|
+
{name:'Castellar', family:'froman', character:0, pitch:2, panose:'020a0402060406010301'},
|
57
|
+
{name:'Century Gothic', family:'fswiss', character:0, pitch:2, panose:'020b0502020202020204'},
|
58
|
+
{name:'Comic Sans MS', family:'fscript', charater:0, pitch:2, panose:'030f0702030302020204'},
|
59
59
|
{name:'Courier New', family:'froman', character:0, pitch:1, panose:'02070309020205020404'},
|
60
|
-
{name:'Franklin Gothic Medium', family:'
|
61
|
-
{name:'Garamond', family:'
|
62
|
-
{name:'Georgia', family:'
|
63
|
-
{name:'Haettenschweiler', family:'
|
64
|
-
{name:'Impact', family:'
|
65
|
-
{name:'Lucida Console', family:'
|
66
|
-
{name:'Lucida Sans Unicode', family:'
|
67
|
-
{name:'Microsoft Sans Serif', family:'
|
68
|
-
{name:'Monotype Corsiva', family:'
|
69
|
-
{name:'Palatino Linotype', family:'
|
70
|
-
{name:'Papyrus', family:'
|
71
|
-
{name:'Sylfaen', family:'
|
72
|
-
{name:'Symbol', family:'
|
73
|
-
{name:'Tahoma', family:'
|
60
|
+
{name:'Franklin Gothic Medium', family:'fswiss', character:0, picth:2, panose:'020b0603020102020204'},
|
61
|
+
{name:'Garamond', family:'froman' , character:0, pitch:2, panose:'02020404030301010803'},
|
62
|
+
{name:'Georgia', family:'froman', character:0, pitch:2, panose:'02040502050405020303'},
|
63
|
+
{name:'Haettenschweiler', family:'fswiss', character:0, pitch:2, panose:'020b0706040902060204'},
|
64
|
+
{name:'Impact', family:'fswiss', character:0, pitch:2, panose:'020b0806030902050204'},
|
65
|
+
{name:'Lucida Console', family:'fmodern', character:0, pitch:1, panose:'020b0609040504020204'},
|
66
|
+
{name:'Lucida Sans Unicode', family:'fswiss' , character:0, pitch:2, panose:'020b0602030504020204'},
|
67
|
+
{name:'Microsoft Sans Serif', family:'fswiss', character:0, pitch:2, panose:'020b0604020202020204'},
|
68
|
+
{name:'Monotype Corsiva', family:'fscript', character:0, pitch:2, panose:'03010101010201010101'},
|
69
|
+
{name:'Palatino Linotype', family:'froman', character:0, pitch:2, panose:'02040502050505030304'},
|
70
|
+
{name:'Papyrus', family:'fscript', character:0, pitch:2, panose:'03070502060502030205'},
|
71
|
+
{name:'Sylfaen', family:'froman', character:0, pitch:2, panose:'010a0502050306030303'},
|
72
|
+
{name:'Symbol', family:'froman', character:2, pitch:2, panose:'05050102010706020507'},
|
73
|
+
{name:'Tahoma', family:'fswiss', character:0, pitch:2, panose:'020b0604030504040204'},
|
74
74
|
{name:'Times New Roman', family:'froman', character:0, pitch:2, panose:'02020603050405020304'},
|
75
|
-
{name:'Trebuchet MS', family:'
|
76
|
-
{name:'Verdana', family:'
|
75
|
+
{name:'Trebuchet MS', family:'fswiss', character:0, pitch:2, panose:'020b0603020202020204'},
|
76
|
+
{name:'Verdana', family:'fswiss', character:0, pitch:2, panose:'020b0604030504040204'},
|
77
77
|
{name:'SimSun', family:'fnil', character:134, pitch:2},
|
78
78
|
{name:'KaiTi', family:'fmodern', character:134, pitch:1},
|
79
79
|
{name:'FangSong', family:'fnil', character:134, pitch:1},
|
data/lib/wiz_rtf/text.rb
CHANGED
@@ -28,7 +28,7 @@ module WizRtf
|
|
28
28
|
#
|
29
29
|
def initialize(str = '', styles = {})
|
30
30
|
@str = str
|
31
|
-
@styles = {'text-align' => :left, 'font-family' => 0, 'font-size' =>
|
31
|
+
@styles = {'text-align' => :left, 'font-family' => 0, 'font-size' => 12, 'font-bold' => false, 'font-italic' => false, 'font-underline' => false, 'foreground-color' => 0, 'background-color' => 0 }.merge(styles)
|
32
32
|
end
|
33
33
|
|
34
34
|
# Outputs the Partial Rtf Document to a Generic Stream as a Rich Text Format (RTF).
|
@@ -38,7 +38,7 @@ module WizRtf
|
|
38
38
|
io.cmd :pard
|
39
39
|
io.cmd TEXT_ALIGN_MAP[@styles['text-align']]
|
40
40
|
io.cmd :f, @styles['font-family']
|
41
|
-
io.cmd :fs, @styles['font-size']
|
41
|
+
io.cmd :fs, @styles['font-size'] * 2
|
42
42
|
io.cmd @styles['font-bold'] ? 'b' : 'b0'
|
43
43
|
io.cmd @styles['font-italic'] ? 'i' : 'i0'
|
44
44
|
io.cmd @styles['font-underline'] ? 'ul' : 'ulnone'
|
data/lib/wiz_rtf/version.rb
CHANGED