]> git.sur5r.net Git - ptouch-print/blobdiff - src/ptouch-print.c
added more devices, even though printing does NOT work with them
[ptouch-print] / src / ptouch-print.c
index b2965f56fb42f47a05122e2a978e1a3cc3df04b6..b2a08bea644222ddeffb58d4ada777ce56d25bcb 100644 (file)
@@ -59,11 +59,21 @@ void rasterline_setpixel(uint8_t rasterline[16], int pixel)
        return;
 }
 
+void unsupported_printer(ptouch_dev ptdev)
+{
+       printf(_("your printer unfortunately is not supported by this tool\n"));
+       printf(_("the rasterdata a transferred in some other (unknown) format\n"));
+       exit(1);
+}
+
 int print_img(ptouch_dev ptdev, gdImage *im)
 {
        int d,i,k,offset,tape_width;
        uint8_t rasterline[16];
 
+       if ((ptdev->devinfo->flags & FLAG_UNSUP_RASTER) == FLAG_UNSUP_RASTER) {
+               unsupported_printer(ptdev);
+       }
        tape_width=ptouch_getmaxwidth(ptdev);
        /* find out whether color 0 or color 1 is darker */
        d=(gdImageRed(im,1)+gdImageGreen(im,1)+gdImageBlue(im,1) < gdImageRed(im,0)+gdImageGreen(im,0)+gdImageBlue(im,0))?1:0;
@@ -141,7 +151,7 @@ int get_baselineoffset(char *text, char *font, int fsz)
 {
        int brect[8];
 
-       if (strpbrk(text, "QgjpqyQ") == NULL) { /* if we have none of these */
+       if (strpbrk(text, "QgjpqyQµ") == NULL) {       /* if we have none of these */
                return 0;               /* we don't need an baseline offset */
        }                               /* else we need to calculate it */
        gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o");
@@ -153,6 +163,7 @@ int get_baselineoffset(char *text, char *font, int fsz)
 /* --------------------------------------------------------------------
        Find out which fontsize we need for a given font to get a
        specified pixel size
+       NOTE: This does NOT work for some UTF-8 chars like µ
    -------------------------------------------------------------------- */
 int find_fontsize(int want_px, char *font, char *text)
 {
@@ -248,6 +259,7 @@ void usage(char *progname)
        printf("\t--text <text>\t\tPrint 1-4 lines of text.\n");
        printf("\t\t\t\tIf the text contains spaces, use quotation marks\n\t\t\t\taround it.\n");
        printf("\t--cutmark\t\tPrint a mark where the tape should be cut\n");
+       printf("\t--fontsize\t\tManually set fontsize\n");
        exit(1);
 }