ruby-escpos 0.0.2 → 0.0.3
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/ruby-escpos.rb +58 -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: a725c3d8908c99bb7199a01f49bd5667696bcfd1
|
4
|
+
data.tar.gz: c5c9d5c327a8881b37078bc2424c2cdebd10a24f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df40d8ffb77e1ae9a0e682521bdf8afa411a7e981c47960fb1910062e35cccafcc180b8960c05288ccf23262cf86251a0ad6901b8f745dfc92b544898a81e1f
|
7
|
+
data.tar.gz: 7168865b0fcd7cdc72d16c6e0b4af9278d91f6ea7a93665c8802c97b1c445827ccf5a57c0961c46a71d70e585ae05c9c8d7ae2e6ff69363efa191d1c3c86d362
|
data/lib/ruby-escpos.rb
CHANGED
@@ -9,6 +9,34 @@ class RubyEscPos
|
|
9
9
|
text nil, lines
|
10
10
|
end
|
11
11
|
|
12
|
+
def style(style, align)
|
13
|
+
if style == :header
|
14
|
+
style = STYLE_HEADER
|
15
|
+
elsif style == :subheader
|
16
|
+
style = STYLE_SUBHEADER
|
17
|
+
elsif style == :normal
|
18
|
+
style = STYLE_NORMAL
|
19
|
+
elsif style == :footer
|
20
|
+
style = STYLE_FOOTER
|
21
|
+
end
|
22
|
+
|
23
|
+
if align == :left
|
24
|
+
align = TXT_ALIGN_LT
|
25
|
+
elsif align == :center
|
26
|
+
align = TXT_ALIGN_CT
|
27
|
+
elsif align == :right
|
28
|
+
align = TXT_ALIGN_RT
|
29
|
+
end
|
30
|
+
|
31
|
+
set(
|
32
|
+
align,
|
33
|
+
style[:font],
|
34
|
+
style[:font_type],
|
35
|
+
style[:width],
|
36
|
+
style[:height]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
12
40
|
def set(align = TXT_ALIGN_LT, font = TXT_FONT_A, font_type = FONT_TYPE_NORMAL, width = 1, height = 1, density = nil)
|
13
41
|
write align
|
14
42
|
|
@@ -49,7 +77,7 @@ class RubyEscPos
|
|
49
77
|
write density if density
|
50
78
|
end
|
51
79
|
|
52
|
-
def barcode(code, bc = BARCODE_UPC_A, pos =
|
80
|
+
def barcode(code, width = 64, height = 64, bc = BARCODE_UPC_A, pos = BARCODE_TXT_OFF, font = nil)
|
53
81
|
write TXT_ALIGN_CT
|
54
82
|
write pos
|
55
83
|
write font
|
@@ -143,4 +171,33 @@ class RubyEscPos
|
|
143
171
|
FONT_TYPE_BOLD_UNDERLINE = "BU"
|
144
172
|
FONT_TYPE_BOLD_UNDERLINE_2 = "BU2"
|
145
173
|
FONT_TYPE_NORMAL = "N"
|
174
|
+
|
175
|
+
# Styles
|
176
|
+
STYLE_HEADER = {
|
177
|
+
:font => RubyEscPos::TXT_FONT_A,
|
178
|
+
:font_type => RubyEscPos::FONT_TYPE_BOLD,
|
179
|
+
:width => 2,
|
180
|
+
:height => 2
|
181
|
+
}
|
182
|
+
|
183
|
+
STYLE_SUBHEADER = {
|
184
|
+
:font => RubyEscPos::TXT_FONT_A,
|
185
|
+
:font_type => RubyEscPos::FONT_TYPE_BOLD,
|
186
|
+
:width => 1,
|
187
|
+
:height => 1
|
188
|
+
}
|
189
|
+
|
190
|
+
STYLE_NORMAL = {
|
191
|
+
:font => RubyEscPos::TXT_FONT_A,
|
192
|
+
:font_type => RubyEscPos::FONT_TYPE_NORMAL,
|
193
|
+
:width => 1,
|
194
|
+
:height => 1
|
195
|
+
}
|
196
|
+
|
197
|
+
STYLE_FOOTER = {
|
198
|
+
:font => RubyEscPos::TXT_FONT_B,
|
199
|
+
:font_type => RubyEscPos::FONT_TYPE_NORMAL,
|
200
|
+
:width => 1,
|
201
|
+
:height => 1
|
202
|
+
}
|
146
203
|
end
|