我想更改 Verifone vx520 内部打印机字体。我用 C 编写了我的程序,并使用字体设计器工具来创建打印机字体。我已经使用<ESC>m<s><t>
命令下载字体表,但我仍然无法更改打印机的字体。我该怎么做?
问问题
3349 次
1 回答
3
您可以考虑在 520 上使用“p3700_”函数,而不是使用直接转义序列。具体来说,您需要 p3700_dnld_font_file() 和 p3700_select_font()。
根据文档:
#include <printer.h>
short p3700_dnld_font_file(short handle, //the open printer handle
short h_font_file, //the open file handle
short font_table //font table to select
);
short p3700_select_font(short h_comm_port, // the open printer handle
short font_size, // size of the font
short font_table // font table to select
);
该文档也将此作为示例程序的一部分(稍作修改):
//Variable declarations
int handle; // file handle for the Printer
open_block_t parm; // structure to fill comm parameters for com port
int h_font_file; // handle to the font file
//open printer
handle = open("/dev/com4", 0);
//initialize printer
memset(&parm,0,sizeof(parm));
parm.rate = Rt_19200; // ITP is always set to 19200 baud
parm.format = Fmt_A8N1 | Fmt_auto |Fmt_RTS; // ITP is always set at 8N1
parm.protocol = P_char_mode;
parm.parameter = 0;
set_opn_blk(handle, &parm);
SVC_WAIT(200);
p3700_init(handle, 6);
SVC_WAIT(100);
// Download a 16x16 printer font file containing 128 chars from offset 0 to 127
h_font_file = open("16x16.pft", O_RDONLY);
// download the printer font file at font table 1
p3700_dnld_font_file (handle, h_font_file, 1);
strcpy((char *)printBuf,(const char *)"Printing 16x16 Font\n\n");
p3700_print(handle, printBuf);
p3700_select_font(handle, 0x01, 1);
// 0x01 corresponds to 16x16 font size
p3700_print(handle, printBuf);
我已经使用 p3700_ 打印功能和 p3300_ 功能对此进行了测试,它们似乎都可以正常工作。一些故障排除注意事项:
- 确保
#include <printer.h>
在您的代码中有 - 保存字体文件时,选择正确的打印机类型。如果您正在使用
p3700
函数调用,请另存为“Verix 37xx”打印机类型。如果您正在使用p3300
通话,则另存为“Verix 33xx”。 - 如果要复制示例代码,则需要确保自定义字体大小为 16x16 并将其保存到字体表 1(在选择打印机类型的同一对话框中选择字体表)。如果你做一些不同的事情,你需要
p3700_select_font
相应地改变。 - 请务必记住将字体下载到终端。
- 检查函数的返回值。例如,
open
应该返回一个正的文件句柄号,并且p3700_dnld_font_file
应该返回下载的字体字符数等。
这是关于打印图形的类似问题和答案。
如果你想坚持使用转义序列,我不确定你从哪里得到<ESC>m<s><t>
。23230_Verix_V_Operating_system_programmers_Manual 显示:
<ESC>m<c><r1>...<rn>; Downloads fonts into memory.
接着
<ESC>l<s><t>; Selects font table for printing and downloading.
就我个人而言,除了切换双倍宽、双倍高和反转之外,我倾向于避免使用转义序列。
于 2015-04-29T18:10:55.183 回答