I want to draw a line in printed paper like _____ and the picture below is my font bitmap
and I use this code to download and select my font to printer and print characters
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <svc.h>
#include <printer.h>
int main() {
int retVal;
int handle;
open_block_t parm;
int h_font_file;
char print[32] = {43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43};
handle = open("/dev/com4", 0);
memset(&parm, 0, sizeof (parm));
parm.rate = Rt_19200;
parm.format = Fmt_A8N1 | Fmt_auto | Fmt_RTS;
parm.protocol = P_char_mode;
parm.parameter = 0;
set_opn_blk(handle, &parm);
SVC_WAIT(200);
p3700_init(handle, 6);
SVC_WAIT(100);
/****************SETUP FONT******************/
h_font_file = open("8x16.pft", O_RDONLY); //load font
retVal = p3700_dnld_font_file(handle, h_font_file, 2); //set font
SVC_WAIT(100);
retVal = p3700_select_font(handle, 0x03, 2);
retVal = write(handle, print, 32);
printf("printf: %d\n", retVal);
retVal = write(handle, "\n\n\n\n", 4);
SVC_WAIT(100);
return 0;
}
but the result is the image below and the characters don't connected together. How can I fix this problem?
If all you want to do is print a horizontal line, then I think creating a new font is probably not the way to go. Instead, consider making a graphic that is just a horizontal line and printing it like any other graphic.
You can also try putting the terminal into graphics mode and drawing it manually, although this will take more effort. From the documentation (emphasis added):
So the print characters are defined to be
P 1 G G G G G G
Where P = "Parity as defined by word format", 1=constant 1, and G is a graphics bitThe terminator char is defined to be
P 0 1 0 EXIT X X FEED
where P = "Parity as defined by word format", 0 is a constant 0, 1 is a constant 1, "EXIT" allows you to exit graphics mode (0=don't exit, 1=exit), X is ignored, and "FEED" allows you to send a line feed.I'm not sure if this sample code will work as-is, but it should at least get you started, if you want to play with it:
Final note: I was just looking at some code I had written quite a long time ago that uses graphics mode and it doesn't look like I'm paying any attention to parity, so you may be able to get away with that always being 0.