3

I want to change the Verifone vx520 internal printer font. I have written my program in C and I used the Font Designer Tool for creating the printer font. I have used the <ESC>m<s><t> command to download font table but I still can't change the printer's font. How can I do it?

David
  • 4,665
  • 4
  • 34
  • 60
farshid
  • 161
  • 5
  • 13

1 Answers1

3

Rather than using the straight escape sequences, you may consider using the "p3700_" functions on a 520. Specifically, you will want p3700_dnld_font_file() and p3700_select_font().

According to the documentation:

#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
);

The documentation also has this as part of an example program (modified slightly):

//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);

I have tested this with both p3700_ print functions and p3300_ functions and they both seem to work fine. A few notes for troubleshooting:

  1. Make sure to have #include <printer.h> in your code
  2. When saving the font file, select the correct printer type. If you are using p3700 function calls, save as a "Verix 37xx" printer type. If you are using p3300 calls, then save as "Verix 33xx".
  3. If you are copying the example code, you'll need to make sure your custom font size is 16x16 and that you save it to font table 1 (select the font table on the same dialog where you select the printer type). If you do something different, you'll need to change p3700_select_font accordingly.
  4. Be sure to remember to download the font to the terminal.
  5. Check the return values of function. For example, open should return a positive file handle number and p3700_dnld_font_file should return the number of font characters that were downloaded, etc.

Here is a similar question and answer regarding printing graphics.


If you want to stick with escape sequences, I'm not sure where you are getting <ESC>m<s><t> from. 23230_Verix_V_Operating_system_programmers_Manual shows:

<ESC>m<c><r1>...<rn>; Downloads fonts into memory.

and then

<ESC>l<s><t>; Selects font table for printing and downloading.

Personally, I tend to avoid the escape sequences for everything other than toggling double wide, double height and inverse.

Community
  • 1
  • 1
David
  • 4,665
  • 4
  • 34
  • 60
  • thanks a lot for your answer and edit. can you help me how to change the printer's font? with set_font() or with <*PTRFNT> or m? and how to download printer's font to POS? – farshid Apr 30 '15 at 11:32
  • I'm sorry--I just did this project and so SCREEN fonts were on the mind, but I see you clearly asked about PRINTER fonts. I've updated the answer to be about PRINTER fonts. If you found the SCREEN font answer helpful, please ask a new question about screen fonts and I'll re-post there (that will keep SO much more neat and tidy). Also, please let me know if this solution works for you or not. – David Apr 30 '15 at 18:01
  • how can i use p3700_dnld_font_file on verix vx520? vx520 can't read this function – farshid May 06 '15 at 19:48
  • @farshid: I just tested this on a Vx520 and it worked just fine. Are you including printer.h? That should be in your ACT libraries. For me, it's C:\eVoAps\ACT2000\1.9.0\Include ALSO, note that I updated the answer--see if the new info helps you at all. – David May 07 '15 at 19:10
  • I changed the printer's font but when i print then in return my dispaly font show another thing and don't use the right display font to show message on screen. do you know what can i do for this? thanks a lot for your answers and guidance. – farshid Aug 09 '15 at 06:08
  • This code shouldn't have anything to do with your screen font. Screen fonts use the API `set_font("")`. As noted above, you should post a new question if you want help on screen fonts in order to keep SO clean. – David Aug 10 '15 at 16:39
  • how can i make print font smaller in width? for example with `DBL_HEIGHT` the print will double height do we have any thing to half in width prints word? – farshid Oct 07 '15 at 14:59
  • 1
    you can do double height to make it taller and double width to make it wider, but if you want to make it smaller, you'll need to load a new font. – David Oct 07 '15 at 15:58
  • can i use two different font in one page print ( for example first word with font1 and second word with font2 print) how can i do this? i use 'p3700_dnld_font_file' and 'p3700_select_font' it just download and print second font file downloaded. – farshid Oct 15 '15 at 10:53
  • i use 8x14 font but its don't merge to each other and there is space in between a line although the - are full pixel in width – farshid Oct 18 '15 at 06:49
  • do you know what is difference between `p3700_print(printerHandler, buff)` and `write (printerHandler, buff, sizeof(buff))` ? – Farshid.M Apr 19 '16 at 06:48
  • 1
    No, although I wouldn't be surprised if the primary difference was just that you don't need to pass the size of buff into it. There could also be some initialization or whatever that goes on behind the scenes, – David Apr 19 '16 at 12:57
  • how this escape sequences `m...` work? where should I write my printer font name? – Farshid.M Apr 25 '16 at 05:06
  • I'm sorry--I don't use the escape sequences, so I don't really know. – David Apr 25 '16 at 17:29
  • can you answer this question please: [print connected character](http://stackoverflow.com/q/37117724/4873354) – Farshid.M May 16 '16 at 13:37