像這樣的東西
開始:
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)。