像这样的东西
开始:
private void defineChars() {
int[] cmd = new int[5 + 37] ; // already set to 0
cmd[0] = 0x1b; // ESC
cmd[1] = 0x26; // &
cmd[2] = 0x03; // y - height
cmd[3] = 'A'; // starting char to define, c1, 'A' ..
cmd[4] = 'A'; // c2, ending character, in this case we define only one
cmd[5] = 12; // x1, dots in horizontal direction
int shift = 6;
// fill the matrix as you wish..
// 'A' -> black square
for (int i = 0; i < 36; i++) {
cmd[i + shift] = 0xff;
}
sendCommand(cmd);
}
不要忘记激活自定义字体与命令算账:
private void setCustomChars(boolean set) {
//select user defined chars
sendCommand(0x1B, 0x25, (set) ? 1 : 0);
}
现在,当您发送“A”字符打印机它将打印您的自定义字符(黑色sqare,因为所有位都设置为1)。