mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2026-05-05 06:06:17 +00:00
preparing for support of printers with 360 dpi
This commit is contained in:
@@ -381,6 +381,8 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout)
|
||||
ptdev->tape_width_px=0;
|
||||
for (i=0; tape_info[i].mm > 0; ++i) {
|
||||
if (tape_info[i].mm == buf[10]) {
|
||||
/* TODO: should be adjusted according
|
||||
to printer dpi ! */
|
||||
ptdev->tape_width_px=tape_info[i].px;
|
||||
}
|
||||
}
|
||||
@@ -409,6 +411,33 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ptouch_get_dpi(ptouch_dev ptdev)
|
||||
{
|
||||
if (!ptdev) {
|
||||
fprintf(stderr, _("debug: called ptouch_get_dpi() with NULL ptdev\n"));
|
||||
return 0;
|
||||
}
|
||||
return ptdev->devinfo->dpi;
|
||||
}
|
||||
|
||||
/* TODO: The actual number of maximum lines should be calculated according to
|
||||
printer resolution, tapewidth and fontsize */
|
||||
/* printer resolution is planned to be taken into account when calculating
|
||||
tape_width in px */
|
||||
int ptouch_get_max_lines(ptouch_dev ptdev, int fontsize_px)
|
||||
{
|
||||
if (!ptdev) {
|
||||
fprintf(stderr, _("debug: called ptouch_get_max_lines() with NULL ptdev\n"));
|
||||
return 0;
|
||||
}
|
||||
if (fontsize_px <= 0) {
|
||||
fprintf(stderr, _("debug: called ptouch_get_max_lines() with invalid fontsize_px\n"));
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, _("debug: calculated max lines %d \n"), ptdev->tape_width_px / fontsize_px);
|
||||
return 4;
|
||||
}
|
||||
|
||||
size_t ptouch_get_tape_width(ptouch_dev ptdev)
|
||||
{
|
||||
if (!ptdev) {
|
||||
|
||||
+10
-3
@@ -35,7 +35,7 @@
|
||||
|
||||
#define _(s) gettext(s)
|
||||
|
||||
#define MAX_LINES 4 /* maybe this should depend on tape size */
|
||||
#define MAX_LINES 4 /* this should be calculated depending on tape size */
|
||||
|
||||
#define P_NAME "ptouch-print"
|
||||
|
||||
@@ -56,6 +56,7 @@ struct arguments {
|
||||
int verbose;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
typedef enum { JOB_CUTMARK, JOB_IMAGE, JOB_PAD, JOB_TEXT, JOB_UNDEFINED } job_type_t;
|
||||
|
||||
typedef struct job {
|
||||
@@ -91,7 +92,8 @@ static struct argp_option options[] = {
|
||||
{ "font", 2, "<file>", 0, "Use font <file> or <name>", 1},
|
||||
{ "fontsize", 3, "<size>", 0, "Manually set font size, or ...", 1},
|
||||
{ "fontmargin", 4, "<size>", 0, "Manually set font top/bottom margin (in px)", 1},
|
||||
{ "writepng", 5, "<file>", 0, "Instead of printing, write output to png <file>", 1},
|
||||
{ "write-png", 5, "<file>", 0, "Instead of printing, write output to png <file>", 1},
|
||||
{ "writepng", 5, "<file>", OPTION_ALIAS, "alias for write-png", 1},
|
||||
{ "force-tape-width", 6, "<px>", 0, "Set tape width in pixels, use together with --writepng without a printer connected", 1},
|
||||
{ "copies", 7, "<number>", 0, "Sets the number of identical prints", 1},
|
||||
{ "timeout", 8, "<seconds>", 0, "Set timeout waiting for finishing previous job. Default:1, 0 means infinity", 1},
|
||||
@@ -298,7 +300,11 @@ int get_baselineoffset(char *text, char *font, int fsz)
|
||||
{
|
||||
int brect[8];
|
||||
|
||||
/* NOTE: This assumes that 'z' is always on the baseline */
|
||||
/* NOTE: This assumes that 'z' is on the baseline for the selected font.
|
||||
'z' was choosen instead of 'o' because letters withstraight baseline
|
||||
are the better choice for the majority of fonts here.
|
||||
If this makes problems with non-latin fonts with lots of vertically
|
||||
protruding serifs or decorations, change 'z' to 'o' */
|
||||
gdImageStringFT_180dpi(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "z");
|
||||
int z_offset = brect[1];
|
||||
gdImageStringFT_180dpi(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text);
|
||||
@@ -743,6 +749,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (arguments.info) {
|
||||
printf(_("printer has %d dpi\n"), ptouch_get_dpi(ptdev));
|
||||
printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev));
|
||||
printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev));
|
||||
printf("media type = 0x%02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type));
|
||||
|
||||
Reference in New Issue
Block a user