Update support for draft and hi-res printing
The old PT series printers that support 360-dpi printing use an undocumented
"ESC i c" command for switching into 360x360 and 360x720 dpi mode which looks
like a precursor to the "ESC i z" print information command in some regards.
More recent PT series printers use flags in the "ESC i K" advanced mode command
for switching into draft (360x180) and hi-res (360x720) dpi mode; on those
printers, the media type in the print information command must be set to 0x09
for hi-res and draft printing. More recent QL series printers use the same
hi-res flag for switching into 300x600 dpi mode, but they don't support draft
printing; the media type in the print information command must be 0x0a for
continuous-length media and 0x0b for die-cut labels.
Add an option for the old PT series printers to use the "ESC i c" command. On
recent printers (where this option is not set), set the resolution flags in the
advanced mode command instead.
Andreas Gruenbacher authored 4 years ago
Phil Pemberton committed 3 years ago
72 | 72 | opt/Brother-PTQL-SoftwareMirror.xml \ |
73 | 73 | opt/Brother-PTQL-TransferMode.xml \ |
74 | 74 | opt/Brother-PT-HalfCut.xml \ |
75 | opt/Brother-PT-LegacyHires.xml \ | |
75 | 76 | opt/Brother-PT-LegacyTransferMode.xml \ |
76 | 77 | opt/Brother-PT-Margin.xml \ |
77 | 78 | opt/Brother-PT-PageSize.xml \ |
0 | <!-- | |
1 | Copyright (c) 2020 Andreas Gruenbacher <andreas.gruenbacher@gmail.com> | |
2 | ||
3 | This file is part of ptouch-driver. | |
4 | ||
5 | ptouch-driver is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or (at | |
8 | your option) any later version. | |
9 | ||
10 | ptouch-driver is distributed in the hope that it will be useful, but | |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with ptouch-driver; if not, write to the Free Software | |
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
18 | USA | |
19 | --> | |
20 | <option type='enum' id='opt/Brother-PT-LegacyHires'> | |
21 | <arg_longname> | |
22 | <en>Legacy 360/720 DPI Mode</en> | |
23 | </arg_longname> | |
24 | <arg_shortname> | |
25 | <en>LegacyHires</en> | |
26 | </arg_shortname> | |
27 | <arg_execution> | |
28 | <arg_group>PrinterSpecifics</arg_group> | |
29 | <arg_order>100</arg_order> | |
30 | <arg_spot>B</arg_spot> | |
31 | <arg_substitution /> | |
32 | <arg_proto> %s </arg_proto> | |
33 | </arg_execution> | |
34 | <enum_vals> | |
35 | <enum_val id="ev/LegacyHires"> | |
36 | <ev_longname> | |
37 | <en>Legacy 360/720 DPI Mode</en> | |
38 | </ev_longname> | |
39 | <ev_shortname> | |
40 | <en>LegacyHires</en> | |
41 | </ev_shortname> | |
42 | <ev_driverval>LegacyHires</ev_driverval> | |
43 | </enum_val> | |
44 | </enum_vals> | |
45 | </option> |
58 | 58 | <option id="opt/Brother-PTQL-Resolution"> |
59 | 59 | <enum_val id="ev/360dpi" /> |
60 | 60 | </option> |
61 | <option id='opt/Brother-PT-LegacyHires' /> | |
61 | 62 | <option id="opt/Brother-PTQL-BytesPerLine"> |
62 | 63 | <enum_val id="ev/48" /> |
63 | 64 | </option> |
57 | 57 | <option id="opt/Brother-PTQL-Resolution"> |
58 | 58 | <enum_val id="ev/360dpi" /> |
59 | 59 | </option> |
60 | <option id='opt/Brother-PT-LegacyHires' /> | |
60 | 61 | <option id="opt/Brother-PTQL-BytesPerLine"> |
61 | 62 | <enum_val id="ev/48" /> |
62 | 63 | </option> |
57 | 57 | <option id="opt/Brother-PTQL-Resolution"> |
58 | 58 | <enum_val id="ev/360dpi" /> |
59 | 59 | </option> |
60 | <option id='opt/Brother-PT-LegacyHires' /> | |
60 | 61 | <option id="opt/Brother-PTQL-BytesPerLine"> |
61 | 62 | <enum_val id="ev/48" /> |
62 | 63 | </option> |
57 | 57 | <option id="opt/Brother-PTQL-Resolution"> |
58 | 58 | <enum_val id="ev/360dpi" /> |
59 | 59 | </option> |
60 | <option id='opt/Brother-PT-LegacyHires' /> | |
60 | 61 | <option id="opt/Brother-PTQL-BytesPerLine"> |
61 | 62 | <enum_val id="ev/48" /> |
62 | 63 | </option> |
60 | 60 | <enum_val id="ev/360dpi" /> |
61 | 61 | <enum_val id="ev/360x720dpi" /> |
62 | 62 | </option> |
63 | <option id='opt/Brother-PT-LegacyHires' /> | |
63 | 64 | <option id="opt/Brother-PTQL-BytesPerLine"> |
64 | 65 | <enum_val id="ev/48" /> |
65 | 66 | </option> |
58 | 58 | <option id="opt/Brother-PTQL-Resolution"> |
59 | 59 | <enum_val id="ev/360dpi" /> |
60 | 60 | </option> |
61 | <option id='opt/Brother-PT-LegacyHires' /> | |
61 | 62 | <option id="opt/Brother-PTQL-BytesPerLine"> |
62 | 63 | <enum_val id="ev/48" /> |
63 | 64 | </option> |
362 | 362 | int xfer_mode; /**< transfer mode (-1 = don't set) */ |
363 | 363 | bool label_preamble; /**< emit ESC i z ... */ |
364 | 364 | bool label_recoyery; /**< set PI_RECOVER flag */ |
365 | bool legacy_hires; | |
365 | 366 | bool concat_pages; /**< remove interlabel margins */ |
366 | 367 | float margin; /**< top and bottom margin */ |
367 | 368 | unsigned int page; /**< The current page number */ |
393 | 394 | /* xfer_mode (don't set) */ -1, |
394 | 395 | /* label_preamble */ false, |
395 | 396 | /* label_recovery */ false, |
397 | /* legacy_hires */ false, | |
396 | 398 | /* concat_pages */ false, |
397 | 399 | /* margin */ 0.0, |
398 | 400 | }; |
423 | 425 | { "HalfCut", &options.half_cut }, |
424 | 426 | { "LabelPreamble", &options.label_preamble }, |
425 | 427 | { "LabelRecovery", &options.label_recoyery }, |
428 | { "LegacyHires", &options.legacy_hires }, | |
426 | 429 | { "MirrorPrint", &options.mirror_print }, |
427 | 430 | { "PT", &options.pt_series }, |
428 | 431 | { "QL", &options.ql_series }, |
698 | 701 | tape_width_mm); |
699 | 702 | tape_width_mm = 0xff; |
700 | 703 | } |
701 | unsigned char paper_kind = 0; | |
704 | unsigned char media_type = 0; | |
702 | 705 | unsigned int tape_length_mm = 0; |
703 | 706 | if (job_options->ql_series) { |
704 | 707 | if (job_options->print_quality_high == CUPS_TRUE) |
705 | 708 | valid |= PI_QUALITY; |
706 | 709 | valid |= PI_KIND | PI_LENGTH; |
707 | paper_kind = roll_fed_media ? 0x0A : 0x0B; | |
710 | media_type = roll_fed_media ? 0x0A : 0x0B; | |
708 | 711 | /* Get tape height in mm */ |
709 | 712 | if (!roll_fed_media) |
710 | 713 | tape_length_mm = lrint (header->cupsPageSize [1] * MM_PER_PT); |
715 | 718 | tape_length_mm = 0xff; |
716 | 719 | } |
717 | 720 | } |
721 | if (job_options->pt_series) { | |
722 | /* | |
723 | * On PT series printers, the media type must be set to 0x09 for | |
724 | * high-resolution and draft printing, but not for normal resolution | |
725 | * printing. | |
726 | */ | |
727 | if (header->HWResolution [0] == 360 && | |
728 | (header->HWResolution [1] == 180 || | |
729 | header->HWResolution [1] == 720)) { | |
730 | valid |= PI_KIND; | |
731 | media_type = 0x09; | |
732 | } | |
733 | } | |
718 | 734 | /* Combine & emit printer command code */ |
719 | 735 | putchar (ESC); putchar ('i'); putchar ('z'); |
720 | 736 | putchar (valid); |
721 | putchar (paper_kind); | |
737 | putchar (media_type); | |
722 | 738 | putchar (tape_width_mm & 0xff); |
723 | 739 | putchar (tape_length_mm); |
724 | 740 | putchar (image_height_px & 0xff); |
750 | 766 | default: break; |
751 | 767 | } |
752 | 768 | |
753 | /* Set width and resolution */ | |
754 | /* We only know how to select 360x360DPI or 360x720DPI */ | |
755 | if (header->HWResolution [0] == 360 | |
756 | && (header->HWResolution [1] == 360 | |
757 | || header->HWResolution [1] == 720)) { | |
758 | /* Get tape width in mm */ | |
759 | tape_width_mm = lrint (header->cupsPageSize [0] * MM_PER_PT); | |
760 | if (tape_width_mm > 0xff) { | |
761 | fprintf (stderr, | |
762 | "ERROR: Page width (%umm) exceeds 255mm\n", | |
763 | tape_width_mm); | |
764 | tape_width_mm = 0xff; | |
765 | } | |
766 | /* Emit printer commands */ | |
767 | putchar (ESC); putchar ('i'); putchar ('c'); | |
768 | if (header->HWResolution [1] == 360) { | |
769 | putchar (0x84); putchar (0x00); putchar (tape_width_mm & 0xff); | |
770 | putchar (0x00); putchar (0x00); | |
771 | } else { | |
772 | putchar (0x86); putchar (0x09); putchar (tape_width_mm & 0xff); | |
773 | putchar (0x00); putchar (0x01); | |
769 | if (job_options->legacy_hires) { | |
770 | /* Set width and resolution */ | |
771 | /* We only know how to select 360x360DPI or 360x720DPI */ | |
772 | if (header->HWResolution [0] == 360 | |
773 | && (header->HWResolution [1] == 360 | |
774 | || header->HWResolution [1] == 720)) { | |
775 | /* Get tape width in mm */ | |
776 | tape_width_mm = lrint (header->cupsPageSize [0] * MM_PER_PT); | |
777 | if (tape_width_mm > 0xff) { | |
778 | fprintf (stderr, | |
779 | "ERROR: Page width (%umm) exceeds 255mm\n", | |
780 | tape_width_mm); | |
781 | tape_width_mm = 0xff; | |
782 | } | |
783 | /* Emit printer commands */ | |
784 | putchar (ESC); putchar ('i'); putchar ('c'); | |
785 | if (header->HWResolution [1] == 360) { | |
786 | putchar (0x84); putchar (0x00); putchar (tape_width_mm & 0xff); | |
787 | putchar (0x00); putchar (0x00); | |
788 | } else { | |
789 | putchar (0x86); putchar (0x09); putchar (tape_width_mm & 0xff); | |
790 | putchar (0x00); putchar (0x01); | |
791 | } | |
774 | 792 | } |
775 | 793 | } |
776 | 794 | |
782 | 800 | putchar (ESC); putchar ('i'); putchar ('M'); putchar (various_mode); |
783 | 801 | |
784 | 802 | char advanced_mode = 0; |
803 | if (!job_options->legacy_hires) { | |
804 | if (header->HWResolution [0] == 360) { | |
805 | if (header->HWResolution [1] == 180) | |
806 | advanced_mode |= 0x01; /* draft printing */ | |
807 | if (header->HWResolution [1] == 720) | |
808 | advanced_mode |= 0x40; /* hires printing */ | |
809 | } | |
810 | if (header->HWResolution [0] == 300) { | |
811 | if (header->HWResolution [1] == 600) | |
812 | advanced_mode |= 0x40; /* hires printing */ | |
813 | } | |
814 | } | |
785 | 815 | if (job_options->half_cut) |
786 | 816 | advanced_mode |= 0x04; |
787 | 817 | if (!job_options->chain_printing) |