btrz-liquid-templates 1.6.0 → 1.7.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.
- package/docs/index.md +29 -2
- package/package.json +1 -1
- package/src/escp.js +24 -0
- package/src/index.js +2 -0
package/docs/index.md
CHANGED
|
@@ -148,7 +148,7 @@ Small condensed fonts
|
|
|
148
148
|
|
|
149
149
|
* ## lineSpacing
|
|
150
150
|
|
|
151
|
-
Line spacing to 1/
|
|
151
|
+
Line spacing to 1/9 of an inch
|
|
152
152
|
|
|
153
153
|
```liquid
|
|
154
154
|
{% raw%} {% lineSpacing %} {% endraw %}
|
|
@@ -156,12 +156,39 @@ Line spacing to 1/6 of an inch
|
|
|
156
156
|
|
|
157
157
|
* ## lineSpacing2
|
|
158
158
|
|
|
159
|
-
Line spacing to 1/
|
|
159
|
+
Line spacing to 1/6 of an inch
|
|
160
160
|
|
|
161
161
|
```liquid
|
|
162
162
|
{% raw%} {% lineSpacing2 %} {% endraw %}
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
* ## lineSpacingX
|
|
166
|
+
|
|
167
|
+
Sets the line spacing to n/216 inch
|
|
168
|
+
|
|
169
|
+
```liquid
|
|
170
|
+
{% raw%} {% lineSpacingX value %} {% endraw %}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Parameters
|
|
174
|
+
|
|
175
|
+
| name | range | required | default |
|
|
176
|
+
|------|------------|----------|---------|
|
|
177
|
+
| pos | 0 <= value <= 255 | Y | |
|
|
178
|
+
|
|
179
|
+
* value: Number of vertical dots to insert between lines. For example, a value of 24 sets the line spacing to 1/9 inch.
|
|
180
|
+
|
|
181
|
+
#### Common Values (for reference) 9-Pin ESC/P
|
|
182
|
+
|
|
183
|
+
| Value | Inches | Description |
|
|
184
|
+
| ----- | ------ | --------------------- |
|
|
185
|
+
| 6 | 1/36 | Very tight spacing |
|
|
186
|
+
| 12 | 1/18 | Tight spacing |
|
|
187
|
+
| 24 | 1/9 | Standard compact text |
|
|
188
|
+
| 36 | 1/6 | Default line spacing |
|
|
189
|
+
| 48 | 2/9 | Loose spacing |
|
|
190
|
+
| 72 | 1/3 | Very loose spacing |
|
|
191
|
+
|
|
165
192
|
* ## escNewLine
|
|
166
193
|
|
|
167
194
|
New line
|
package/package.json
CHANGED
package/src/escp.js
CHANGED
|
@@ -30,6 +30,29 @@ function lineSpacing2(engine) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function lineSpacingX(engine) {
|
|
34
|
+
this.registerTag("lineSpacingX", {
|
|
35
|
+
parse: function(tagToken, remainTokens) {
|
|
36
|
+
try {
|
|
37
|
+
const args = (tagToken.args || "").split(" ");
|
|
38
|
+
this.spacingValue = args[0] || 0;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
this.spacingValue = args[0] || 0;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
render: async function(ctx) {
|
|
44
|
+
try {
|
|
45
|
+
const spacing = this.spacingValue < 0 ? 0 : this.spacingValue > 255 ? 255 : this.spacingValue;
|
|
46
|
+
const value = String.fromCharCode(spacing);
|
|
47
|
+
const escLineSpacingX = "\x1B\x33" + value;
|
|
48
|
+
return escLineSpacingX;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return "PNA";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
function fontSelection(engine) {
|
|
34
57
|
this.registerTag("fontSelection", {
|
|
35
58
|
parse: function(tagToken, remainTokens) {
|
|
@@ -144,6 +167,7 @@ module.exports = {
|
|
|
144
167
|
escInitQzTray,
|
|
145
168
|
lineSpacing,
|
|
146
169
|
lineSpacing2,
|
|
170
|
+
lineSpacingX,
|
|
147
171
|
fontSelection,
|
|
148
172
|
escBold,
|
|
149
173
|
escCancelBold,
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
escInitQzTray,
|
|
18
18
|
lineSpacing,
|
|
19
19
|
lineSpacing2,
|
|
20
|
+
lineSpacingX,
|
|
20
21
|
fontSelection,
|
|
21
22
|
escBold,
|
|
22
23
|
escCancelBold,
|
|
@@ -98,6 +99,7 @@ module.exports = {
|
|
|
98
99
|
engine.plugin(escInitQzTray);
|
|
99
100
|
engine.plugin(lineSpacing);
|
|
100
101
|
engine.plugin(lineSpacing2);
|
|
102
|
+
engine.plugin(lineSpacingX);
|
|
101
103
|
engine.plugin(fontSelection);
|
|
102
104
|
engine.plugin(escBold);
|
|
103
105
|
engine.plugin(escCancelBold);
|