Skip to content

Commit c1ef8c6

Browse files
authored
Merge pull request #43 from pcapanna/master
Resolving text hight not set correctly when in custom sizes case
2 parents b6ac6b4 + a47f879 commit c1ef8c6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

commands.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ _.TEXT_FORMAT = {
8282
TXT_2WIDTH : '\x1b\x21\x20', // Double width text
8383
TXT_4SQUARE : '\x1b\x21\x30', // Double width & height text
8484

85-
TXT_SIZE : '\x1d\x21', // other sizes
85+
TXT_CUSTOM_SIZE : function(width, height){ // other sizes
86+
var widthDec = (width - 1) * 16;
87+
var heightDec = height - 1;
88+
var sizeDec = widthDec+heightDec;
89+
return '\x1d\x21'+String.fromCharCode(sizeDec);
90+
},
91+
8692
TXT_HEIGHT : {
8793
1: '\x00',
8894
2: '\x01',

printer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ Printer.prototype.size = function(width, height) {
237237
this.buffer.write(_.TEXT_FORMAT.TXT_2WIDTH);
238238
}
239239
} else {
240-
this.buffer.write(_.TEXT_FORMAT.TXT_SIZE);
241-
this.buffer.write(_.TEXT_FORMAT.TXT_WIDTH[(8 >= width) ? width : 8]);
242-
this.buffer.write(_.TEXT_FORMAT.TXT_HEIGHT[(8 >= height) ? height : 8]);
240+
this.buffer.write(_.TEXT_FORMAT.TXT_CUSTOM_SIZE(width, height));
243241
}
244242
return this;
245243
};

0 commit comments

Comments
 (0)