Codebase list ptouch-driver / 1dac6e9
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
9 changed file(s) with 107 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
7272 opt/Brother-PTQL-SoftwareMirror.xml \
7373 opt/Brother-PTQL-TransferMode.xml \
7474 opt/Brother-PT-HalfCut.xml \
75 opt/Brother-PT-LegacyHires.xml \
7576 opt/Brother-PT-LegacyTransferMode.xml \
7677 opt/Brother-PT-Margin.xml \
7778 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>
5858 <option id="opt/Brother-PTQL-Resolution">
5959 <enum_val id="ev/360dpi" />
6060 </option>
61 <option id='opt/Brother-PT-LegacyHires' />
6162 <option id="opt/Brother-PTQL-BytesPerLine">
6263 <enum_val id="ev/48" />
6364 </option>
5757 <option id="opt/Brother-PTQL-Resolution">
5858 <enum_val id="ev/360dpi" />
5959 </option>
60 <option id='opt/Brother-PT-LegacyHires' />
6061 <option id="opt/Brother-PTQL-BytesPerLine">
6162 <enum_val id="ev/48" />
6263 </option>
5757 <option id="opt/Brother-PTQL-Resolution">
5858 <enum_val id="ev/360dpi" />
5959 </option>
60 <option id='opt/Brother-PT-LegacyHires' />
6061 <option id="opt/Brother-PTQL-BytesPerLine">
6162 <enum_val id="ev/48" />
6263 </option>
5757 <option id="opt/Brother-PTQL-Resolution">
5858 <enum_val id="ev/360dpi" />
5959 </option>
60 <option id='opt/Brother-PT-LegacyHires' />
6061 <option id="opt/Brother-PTQL-BytesPerLine">
6162 <enum_val id="ev/48" />
6263 </option>
6060 <enum_val id="ev/360dpi" />
6161 <enum_val id="ev/360x720dpi" />
6262 </option>
63 <option id='opt/Brother-PT-LegacyHires' />
6364 <option id="opt/Brother-PTQL-BytesPerLine">
6465 <enum_val id="ev/48" />
6566 </option>
5858 <option id="opt/Brother-PTQL-Resolution">
5959 <enum_val id="ev/360dpi" />
6060 </option>
61 <option id='opt/Brother-PT-LegacyHires' />
6162 <option id="opt/Brother-PTQL-BytesPerLine">
6263 <enum_val id="ev/48" />
6364 </option>
362362 int xfer_mode; /**< transfer mode (-1 = don't set) */
363363 bool label_preamble; /**< emit ESC i z ... */
364364 bool label_recoyery; /**< set PI_RECOVER flag */
365 bool legacy_hires;
365366 bool concat_pages; /**< remove interlabel margins */
366367 float margin; /**< top and bottom margin */
367368 unsigned int page; /**< The current page number */
393394 /* xfer_mode (don't set) */ -1,
394395 /* label_preamble */ false,
395396 /* label_recovery */ false,
397 /* legacy_hires */ false,
396398 /* concat_pages */ false,
397399 /* margin */ 0.0,
398400 };
423425 { "HalfCut", &options.half_cut },
424426 { "LabelPreamble", &options.label_preamble },
425427 { "LabelRecovery", &options.label_recoyery },
428 { "LegacyHires", &options.legacy_hires },
426429 { "MirrorPrint", &options.mirror_print },
427430 { "PT", &options.pt_series },
428431 { "QL", &options.ql_series },
698701 tape_width_mm);
699702 tape_width_mm = 0xff;
700703 }
701 unsigned char paper_kind = 0;
704 unsigned char media_type = 0;
702705 unsigned int tape_length_mm = 0;
703706 if (job_options->ql_series) {
704707 if (job_options->print_quality_high == CUPS_TRUE)
705708 valid |= PI_QUALITY;
706709 valid |= PI_KIND | PI_LENGTH;
707 paper_kind = roll_fed_media ? 0x0A : 0x0B;
710 media_type = roll_fed_media ? 0x0A : 0x0B;
708711 /* Get tape height in mm */
709712 if (!roll_fed_media)
710713 tape_length_mm = lrint (header->cupsPageSize [1] * MM_PER_PT);
715718 tape_length_mm = 0xff;
716719 }
717720 }
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 }
718734 /* Combine & emit printer command code */
719735 putchar (ESC); putchar ('i'); putchar ('z');
720736 putchar (valid);
721 putchar (paper_kind);
737 putchar (media_type);
722738 putchar (tape_width_mm & 0xff);
723739 putchar (tape_length_mm);
724740 putchar (image_height_px & 0xff);
750766 default: break;
751767 }
752768
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 }
774792 }
775793 }
776794
782800 putchar (ESC); putchar ('i'); putchar ('M'); putchar (various_mode);
783801
784802 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 }
785815 if (job_options->half_cut)
786816 advanced_mode |= 0x04;
787817 if (!job_options->chain_printing)