2008-07-14 09:15:55 +12:00
|
|
|
/* ps.c - Post Script output */
|
|
|
|
/*
|
|
|
|
libzint - the open source barcode library
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
|
2013-05-17 05:26:38 +12:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
2016-02-21 00:29:19 +13:00
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
2013-05-17 05:26:38 +12:00
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
2016-02-21 00:29:19 +13:00
|
|
|
documentation and/or other materials provided with the distribution.
|
2013-05-17 05:26:38 +12:00
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
2016-02-21 00:29:19 +13:00
|
|
|
without specific prior written permission.
|
2013-05-17 05:26:38 +12:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
2016-02-21 00:29:19 +13:00
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2013-05-17 05:26:38 +12:00
|
|
|
SUCH DAMAGE.
|
2016-02-21 00:29:19 +13:00
|
|
|
*/
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2008-07-14 09:15:55 +12:00
|
|
|
|
2023-06-19 01:37:05 +12:00
|
|
|
#include <assert.h>
|
2021-06-10 22:15:39 +12:00
|
|
|
#include <errno.h>
|
2016-03-03 10:12:38 +13:00
|
|
|
#include <math.h>
|
2022-07-15 03:01:30 +12:00
|
|
|
#include <stdio.h>
|
2008-07-14 09:15:55 +12:00
|
|
|
#include "common.h"
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
#include "output.h"
|
2008-07-14 09:15:55 +12:00
|
|
|
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Output Ultracode rectangle colour as PostScript setrgbcolor/setcmykcolor */
|
|
|
|
static void ps_put_colour(const int is_rgb, const int colour, FILE *feps) {
|
2023-06-12 12:25:55 +12:00
|
|
|
const int idx = colour >= 1 && colour <= 8 ? colour - 1 : 6 /*black*/;
|
|
|
|
if (is_rgb) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Use RGB colour space */
|
2023-06-12 12:25:55 +12:00
|
|
|
static const char ps_rgbs[8][6] = {
|
|
|
|
"0 1 1", /* 0: Cyan (1) */
|
|
|
|
"0 0 1", /* 1: Blue (2) */
|
|
|
|
"1 0 1", /* 2: Magenta (3) */
|
|
|
|
"1 0 0", /* 3: Red (4) */
|
|
|
|
"1 1 0", /* 4: Yellow (5) */
|
|
|
|
"0 1 0", /* 5: Green (6) */
|
|
|
|
"0 0 0", /* 6: Black (7) */
|
|
|
|
"1 1 1", /* 7: White (8) */
|
|
|
|
};
|
2023-06-19 01:37:05 +12:00
|
|
|
fputs(ps_rgbs[idx], feps);
|
|
|
|
fputs(" setrgbcolor\n", feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
static const char ps_cmyks[8][8] = {
|
|
|
|
"1 0 0 0", /* 0: Cyan (1) */
|
|
|
|
"1 1 0 0", /* 1: Blue (2) */
|
|
|
|
"0 1 0 0", /* 2: Magenta (3) */
|
|
|
|
"0 1 1 0", /* 3: Red (4) */
|
|
|
|
"0 0 1 0", /* 4: Yellow (5) */
|
|
|
|
"1 0 1 0", /* 5: Green (6) */
|
|
|
|
"0 0 0 1", /* 6: Black (7) */
|
|
|
|
"0 0 0 0", /* 7: White (8) */
|
|
|
|
};
|
2023-06-19 01:37:05 +12:00
|
|
|
fputs(ps_cmyks[idx], feps);
|
|
|
|
fputs(" setcmykcolor\n", feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-12 12:25:55 +12:00
|
|
|
/* Escape special PostScript chars. Assumes valid UTF-8-encoded ISO/IEC 8859-1 */
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
static void ps_convert(const unsigned char *string, unsigned char *ps_string) {
|
2020-10-01 00:19:12 +13:00
|
|
|
const unsigned char *s;
|
|
|
|
unsigned char *p = ps_string;
|
|
|
|
|
|
|
|
for (s = string; *s; s++) {
|
|
|
|
switch (*s) {
|
|
|
|
case '(':
|
|
|
|
case ')':
|
|
|
|
case '\\':
|
|
|
|
*p++ = '\\';
|
|
|
|
*p++ = *s;
|
|
|
|
break;
|
2023-11-20 08:39:54 +13:00
|
|
|
case 0xC2:
|
|
|
|
*p++ = *++s; /* C2 80-BF -> 80-BF */
|
2020-10-01 00:19:12 +13:00
|
|
|
break;
|
|
|
|
case 0xC3:
|
2023-11-20 08:39:54 +13:00
|
|
|
*p++ = *++s + 0x40; /* C3 80-BF -> C0-FF */
|
2020-10-01 00:19:12 +13:00
|
|
|
break;
|
|
|
|
default:
|
2023-11-20 08:39:54 +13:00
|
|
|
if (*s < 0x80) { /* ASCII - all other Unicode points > U+00FF ignored */
|
2020-10-01 00:19:12 +13:00
|
|
|
*p++ = *s;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
#ifdef ZINT_TEST /* Wrapper for direct testing */
|
|
|
|
INTERNAL void ps_convert_test(const unsigned char *string, unsigned char *ps_string) {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_convert(string, ps_string);
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-06-12 12:25:55 +12:00
|
|
|
/* Helper to output RGB colour */
|
|
|
|
static void ps_put_rgbcolor(const float red, const float green, const float blue, FILE *feps) {
|
|
|
|
out_putsf("", 2, red, feps);
|
|
|
|
out_putsf(" ", 2, green, feps);
|
|
|
|
out_putsf(" ", 2, blue, feps);
|
|
|
|
fputs(" setrgbcolor\n", feps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to output CMYK colour */
|
|
|
|
static void ps_put_cmykcolor(const float cyan, const float magenta, const float yellow, const float black,
|
|
|
|
FILE *feps) {
|
|
|
|
out_putsf("", 2, cyan, feps);
|
|
|
|
out_putsf(" ", 2, magenta, feps);
|
|
|
|
out_putsf(" ", 2, yellow, feps);
|
|
|
|
out_putsf(" ", 2, black, feps);
|
|
|
|
fputs(" setcmykcolor\n", feps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to output rectangle */
|
2023-06-19 01:37:05 +12:00
|
|
|
static void ps_put_rect(const struct zint_symbol *symbol, const struct zint_vector_rect *rect, const int type,
|
|
|
|
FILE *feps) {
|
|
|
|
if (type == 0 || type == 1) {
|
|
|
|
out_putsf("", 2, rect->height, feps);
|
|
|
|
out_putsf(" ", 2, (symbol->vector->height - rect->y) - rect->height, feps);
|
|
|
|
}
|
|
|
|
out_putsf(type == 0 ? " " : type == 1 ? " I " : type == 2 ? "I " : "", 2, rect->x, feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
out_putsf(" ", 2, rect->width, feps);
|
2023-06-19 01:37:05 +12:00
|
|
|
fputs(" R\n", feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to output circle/disc */
|
|
|
|
static void ps_put_circle(const struct zint_symbol *symbol, const struct zint_vector_circle *circle,
|
2023-06-19 01:37:05 +12:00
|
|
|
const float radius, const int type, FILE *feps) {
|
2023-06-12 12:25:55 +12:00
|
|
|
if (circle->width) {
|
2023-06-19 01:37:05 +12:00
|
|
|
out_putsf("", 2, circle->x, feps);
|
|
|
|
out_putsf(" ", 2, symbol->vector->height - circle->y, feps);
|
|
|
|
out_putsf(" ", 4, radius, feps);
|
|
|
|
out_putsf(" ", 4, circle->width, feps);
|
|
|
|
fputs(" C\n", feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
} else {
|
2023-06-19 01:37:05 +12:00
|
|
|
if (type == 0 || type == 1) {
|
|
|
|
out_putsf("", 2, symbol->vector->height - circle->y, feps);
|
|
|
|
out_putsf(" ", 4, radius, feps);
|
|
|
|
}
|
|
|
|
out_putsf(type == 0 ? " " : type == 1 ? " I " : type == 2 ? "I " : "", 2, circle->x, feps);
|
|
|
|
fputs(" D\n", feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Helper to count rectangles */
|
|
|
|
static int ps_count_rectangles(const struct zint_symbol *symbol) {
|
|
|
|
int rectangles = 0;
|
|
|
|
const struct zint_vector_rect *rect;
|
|
|
|
|
|
|
|
for (rect = symbol->vector->rectangles; rect; rect = rect->next) {
|
|
|
|
rectangles++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rectangles;
|
|
|
|
}
|
|
|
|
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int ps_plot(struct zint_symbol *symbol) {
|
2016-02-21 00:29:19 +13:00
|
|
|
FILE *feps;
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
unsigned char fgred, fggrn, fgblu, bgred, bggrn, bgblu, bgalpha;
|
|
|
|
int fgcyan, fgmagenta, fgyellow, fgblack, bgcyan, bgmagenta, bgyellow, bgblack;
|
|
|
|
float red_ink = 0.0f, green_ink = 0.0f, blue_ink = 0.0f; /* Suppress `-Wmaybe-uninitialized` */
|
|
|
|
float red_paper = 0.0f, green_paper = 0.0f, blue_paper = 0.0f;
|
|
|
|
float cyan_ink = 0.0f, magenta_ink = 0.0f, yellow_ink = 0.0f, black_ink = 0.0f;
|
|
|
|
float cyan_paper = 0.0f, magenta_paper = 0.0f, yellow_paper = 0.0f, black_paper = 0.0f;
|
2016-02-21 00:29:19 +13:00
|
|
|
int error_number = 0;
|
2020-10-27 01:21:43 +13:00
|
|
|
float previous_diameter;
|
2023-07-06 08:55:59 +12:00
|
|
|
float radius;
|
2023-06-19 01:37:05 +12:00
|
|
|
int colour_rect_flag;
|
|
|
|
int type_latch;
|
2020-08-03 18:37:27 +12:00
|
|
|
int draw_background = 1;
|
2018-06-10 20:16:18 +12:00
|
|
|
struct zint_vector_rect *rect;
|
|
|
|
struct zint_vector_hexagon *hex;
|
|
|
|
struct zint_vector_circle *circle;
|
|
|
|
struct zint_vector_string *string;
|
2020-10-01 00:19:12 +13:00
|
|
|
int i, len;
|
|
|
|
int ps_len = 0;
|
|
|
|
int iso_latin1 = 0;
|
2021-08-23 00:59:01 +12:00
|
|
|
int have_circles_with_width = 0, have_circles_without_width = 0;
|
2023-11-20 08:39:54 +13:00
|
|
|
const int upcean = is_upcean(symbol->symbology);
|
2021-07-27 02:29:05 +12:00
|
|
|
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
|
2023-06-12 12:25:55 +12:00
|
|
|
const int is_rgb = (symbol->output_options & CMYK_COLOUR) == 0;
|
2016-02-21 00:29:19 +13:00
|
|
|
|
2021-07-27 02:29:05 +12:00
|
|
|
if (symbol->vector == NULL) {
|
|
|
|
strcpy(symbol->errtxt, "646: Vector header NULL");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output_to_stdout) {
|
2016-02-21 00:29:19 +13:00
|
|
|
feps = stdout;
|
|
|
|
} else {
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
if (!(feps = out_fopen(symbol->outfile, "w"))) {
|
2021-07-27 02:29:05 +12:00
|
|
|
sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
|
|
|
return ZINT_ERROR_FILE_ACCESS;
|
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
}
|
|
|
|
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
(void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, NULL /*alpha*/);
|
|
|
|
red_ink = fgred / 255.0f;
|
|
|
|
green_ink = fggrn / 255.0f;
|
|
|
|
blue_ink = fgblu / 255.0f;
|
2016-09-06 09:06:50 +12:00
|
|
|
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
(void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
|
|
|
|
red_paper = bgred / 255.0f;
|
|
|
|
green_paper = bggrn / 255.0f;
|
|
|
|
blue_paper = bgblu / 255.0f;
|
2016-06-20 01:14:30 +12:00
|
|
|
} else {
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
(void) out_colour_get_cmyk(symbol->fgcolour, &fgcyan, &fgmagenta, &fgyellow, &fgblack, NULL /*rgb_alpha*/);
|
|
|
|
cyan_ink = fgcyan / 100.0f;
|
|
|
|
magenta_ink = fgmagenta / 100.0f;
|
|
|
|
yellow_ink = fgyellow / 100.0f;
|
|
|
|
black_ink = fgblack / 100.0f;
|
2016-09-06 09:06:50 +12:00
|
|
|
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
(void) out_colour_get_cmyk(symbol->bgcolour, &bgcyan, &bgmagenta, &bgyellow, &bgblack, &bgalpha);
|
|
|
|
cyan_paper = bgcyan / 100.0f;
|
|
|
|
magenta_paper = bgmagenta / 100.0f;
|
|
|
|
yellow_paper = bgyellow / 100.0f;
|
|
|
|
black_paper = bgblack / 100.0f;
|
2016-06-20 01:14:30 +12:00
|
|
|
}
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
if (bgalpha == 0) {
|
|
|
|
draw_background = 0;
|
2016-06-20 01:14:30 +12:00
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
for (i = 0, len = (int) ustrlen(symbol->text); i < len; i++) {
|
|
|
|
switch (symbol->text[i]) {
|
|
|
|
case '(':
|
|
|
|
case ')':
|
|
|
|
case '\\':
|
|
|
|
ps_len += 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!iso_latin1 && symbol->text[i] >= 0x80) {
|
|
|
|
iso_latin1 = 1;
|
|
|
|
}
|
|
|
|
ps_len++; /* Will overcount 2 byte UTF-8 chars */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-23 00:59:01 +12:00
|
|
|
/* Check for circle widths */
|
|
|
|
for (circle = symbol->vector->circles; circle; circle = circle->next) {
|
|
|
|
if (circle->width) {
|
|
|
|
have_circles_with_width = 1;
|
2023-06-12 12:25:55 +12:00
|
|
|
if (have_circles_without_width) {
|
|
|
|
break;
|
|
|
|
}
|
2021-08-23 00:59:01 +12:00
|
|
|
} else {
|
|
|
|
have_circles_without_width = 1;
|
2023-06-12 12:25:55 +12:00
|
|
|
if (have_circles_with_width) {
|
|
|
|
break;
|
|
|
|
}
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-21 00:29:19 +13:00
|
|
|
/* Start writing the header */
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("%!PS-Adobe-3.0 EPSF-3.0\n", feps);
|
2020-09-05 03:38:11 +12:00
|
|
|
if (ZINT_VERSION_BUILD) {
|
2021-06-10 22:15:39 +12:00
|
|
|
fprintf(feps, "%%%%Creator: Zint %d.%d.%d.%d\n",
|
|
|
|
ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE, ZINT_VERSION_BUILD);
|
2020-09-05 03:38:11 +12:00
|
|
|
} else {
|
|
|
|
fprintf(feps, "%%%%Creator: Zint %d.%d.%d\n", ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
|
|
|
|
}
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("%%Title: Zint Generated Symbol\n"
|
|
|
|
"%%Pages: 0\n", feps);
|
2021-06-10 22:15:39 +12:00
|
|
|
fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n",
|
2021-07-27 02:29:05 +12:00
|
|
|
(int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height));
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("%%EndComments\n", feps);
|
2016-02-21 00:29:19 +13:00
|
|
|
|
|
|
|
/* Definitions */
|
2021-08-23 00:59:01 +12:00
|
|
|
if (have_circles_without_width) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Disc: y radius x D */
|
|
|
|
fputs("/D { newpath 3 1 roll 0 360 arc fill } bind def\n", feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
|
|
|
if (have_circles_with_width) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Circle (ring): x y radius width C (adapted from BWIPP renmaxicode.ps) */
|
|
|
|
fputs("/C { newpath 4 1 roll 3 copy 0 360 arc closepath 4 -1 roll add 360 0 arcn closepath fill }"
|
2022-12-20 05:28:15 +13:00
|
|
|
" bind def\n", feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
|
|
|
if (symbol->vector->hexagons) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Hexagon: radius half_radius half_sqrt3_radius x y */
|
|
|
|
if (symbol->vector->hexagons->rotation == 0 || symbol->vector->hexagons->rotation == 180) {
|
|
|
|
fputs("/H { newpath moveto 2 copy exch neg exch rmoveto 2 index neg 0 exch rlineto 2 copy neg rlineto"
|
|
|
|
" 2 copy rlineto 3 -1 roll 0 exch rlineto exch neg exch rlineto closepath fill }"
|
|
|
|
" bind def\n", feps);
|
|
|
|
} else {
|
|
|
|
fputs("/H { newpath moveto 2 copy neg exch neg rmoveto 2 index 0 rlineto 2 copy exch rlineto"
|
|
|
|
" 2 copy neg exch rlineto 3 -1 roll neg 0 rlineto neg exch neg rlineto closepath fill }"
|
|
|
|
" bind def\n", feps);
|
|
|
|
}
|
|
|
|
/* Copy r hr hsr for repeat use without having to specify them subsequently */
|
|
|
|
fputs("/J { 3 copy } bind def\n", feps);
|
|
|
|
/* TODO: Save repeating x also */
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
if (symbol->vector->rectangles || draw_background) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Rectangle: h y x w */
|
|
|
|
fputs("/R { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill }"
|
|
|
|
" bind def\n", feps);
|
|
|
|
}
|
|
|
|
if (symbol->vector->rectangles || have_circles_without_width) {
|
|
|
|
/* Copy h y (rect) or y r (disc) for repeat use without having to specify them subsequently */
|
|
|
|
fputs("/I { 2 copy } bind def\n", feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
|
|
|
|
/* Now the actual representation */
|
2021-07-27 02:29:05 +12:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Background */
|
2020-08-03 18:37:27 +12:00
|
|
|
if (draw_background) {
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_paper, green_paper, blue_paper, feps);
|
2020-08-03 18:37:27 +12:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_cmykcolor(cyan_paper, magenta_paper, yellow_paper, black_paper, feps);
|
2020-08-03 18:37:27 +12:00
|
|
|
}
|
2021-07-27 02:29:05 +12:00
|
|
|
|
2023-06-12 12:25:55 +12:00
|
|
|
out_putsf("", 2, symbol->vector->height, feps);
|
2023-06-19 01:37:05 +12:00
|
|
|
out_putsf(" 0 0 ", 2, symbol->vector->width, feps); /* y x w */
|
|
|
|
fputs(" R\n", feps);
|
2016-06-20 01:14:30 +12:00
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
|
2020-01-07 07:00:43 +13:00
|
|
|
if (symbol->symbology != BARCODE_ULTRA) {
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_ink, green_ink, blue_ink, feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_cmykcolor(cyan_ink, magenta_ink, yellow_ink, black_ink, feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
}
|
2020-01-06 00:27:24 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Rectangles */
|
2020-01-07 07:00:43 +13:00
|
|
|
if (symbol->symbology == BARCODE_ULTRA) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Group rectangles by colour */
|
2023-07-06 08:55:59 +12:00
|
|
|
const int rect_cnt = ps_count_rectangles(symbol);
|
2023-06-19 01:37:05 +12:00
|
|
|
struct zint_vector_rect **ultra_rects
|
2023-07-06 08:55:59 +12:00
|
|
|
= (struct zint_vector_rect **) z_alloca(sizeof(struct zint_vector_rect *) * (rect_cnt ? rect_cnt : 1));
|
2023-06-19 01:37:05 +12:00
|
|
|
int u_i = 0;
|
|
|
|
for (i = 0; i <= 8; i++) {
|
|
|
|
for (rect = symbol->vector->rectangles; rect; rect = rect->next) {
|
|
|
|
if ((i == 0 && rect->colour == -1) || rect->colour == i) {
|
|
|
|
ultra_rects[u_i++] = rect;
|
2021-07-27 02:29:05 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
assert(u_i == ps_count_rectangles(symbol));
|
|
|
|
|
|
|
|
colour_rect_flag = 0;
|
|
|
|
type_latch = 0;
|
|
|
|
for (i = 0; i < u_i; i++) {
|
|
|
|
rect = ultra_rects[i];
|
|
|
|
if (i == 0 || rect->colour != ultra_rects[i - 1]->colour) {
|
|
|
|
if (rect->colour == -1) {
|
2021-07-27 02:29:05 +12:00
|
|
|
if (colour_rect_flag == 0) {
|
2023-06-19 01:37:05 +12:00
|
|
|
/* Set foreground colour */
|
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_ink, green_ink, blue_ink, feps);
|
|
|
|
} else {
|
|
|
|
ps_put_cmykcolor(cyan_ink, magenta_ink, yellow_ink, black_ink, feps);
|
|
|
|
}
|
2021-07-27 02:29:05 +12:00
|
|
|
colour_rect_flag = 1;
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
} else {
|
|
|
|
/* Set new colour */
|
|
|
|
ps_put_colour(is_rgb, rect->colour, feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
}
|
|
|
|
if (i + 1 < u_i && rect->height == ultra_rects[i + 1]->height && rect->y == ultra_rects[i + 1]->y) {
|
|
|
|
ps_put_rect(symbol, rect, type_latch ? 2 : 1, feps);
|
|
|
|
type_latch = 1;
|
|
|
|
} else {
|
|
|
|
ps_put_rect(symbol, rect, type_latch ? 3 : 0, feps);
|
|
|
|
type_latch = 0;
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2023-06-19 01:37:05 +12:00
|
|
|
type_latch = 0;
|
|
|
|
for (rect = symbol->vector->rectangles; rect; rect = rect->next) {
|
|
|
|
if (rect->next && rect->height == rect->next->height && rect->y == rect->next->y) {
|
|
|
|
ps_put_rect(symbol, rect, type_latch ? 2 : 1, feps);
|
|
|
|
type_latch = 1;
|
|
|
|
} else {
|
|
|
|
ps_put_rect(symbol, rect, type_latch ? 3 : 0, feps);
|
|
|
|
type_latch = 0;
|
|
|
|
}
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
2018-06-10 20:16:18 +12:00
|
|
|
}
|
2020-01-06 00:27:24 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Hexagons */
|
2023-07-06 08:55:59 +12:00
|
|
|
previous_diameter = 0.0f;
|
2023-06-19 01:37:05 +12:00
|
|
|
for (hex = symbol->vector->hexagons; hex; hex = hex->next) {
|
2023-06-12 12:25:55 +12:00
|
|
|
float hy = symbol->vector->height - hex->y;
|
2020-10-27 01:21:43 +13:00
|
|
|
if (previous_diameter != hex->diameter) {
|
|
|
|
previous_diameter = hex->diameter;
|
2023-11-20 08:39:54 +13:00
|
|
|
out_putsf("", 4, 0.5f * previous_diameter /*radius*/, feps);
|
|
|
|
out_putsf(" ", 4, 0.43301270189221932338f * previous_diameter /*half_sqrt3_radius*/, feps);
|
|
|
|
out_putsf(" ", 4, 0.25f * previous_diameter /*half_radius*/, feps);
|
2023-06-19 01:37:05 +12:00
|
|
|
fputc('\n', feps);
|
2020-10-27 01:21:43 +13:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
if (hex->next) {
|
|
|
|
out_putsf("J ", 2, hex->x, feps);
|
2020-08-06 08:23:11 +12:00
|
|
|
} else {
|
2023-06-19 01:37:05 +12:00
|
|
|
out_putsf("", 2, hex->x, feps);
|
2020-08-06 08:23:11 +12:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
out_putsf(" ", 2, hy, feps);
|
|
|
|
fputs(" H\n", feps);
|
2018-06-10 20:16:18 +12:00
|
|
|
}
|
2020-01-06 00:27:24 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Circles */
|
2020-10-27 01:21:43 +13:00
|
|
|
previous_diameter = radius = 0.0f;
|
2023-06-19 01:37:05 +12:00
|
|
|
type_latch = 0;
|
|
|
|
for (circle = symbol->vector->circles; circle; circle = circle->next) {
|
2021-08-23 00:59:01 +12:00
|
|
|
if (previous_diameter != circle->diameter - circle->width) {
|
|
|
|
previous_diameter = circle->diameter - circle->width;
|
2023-11-20 08:39:54 +13:00
|
|
|
radius = 0.5f * previous_diameter;
|
2020-10-27 01:21:43 +13:00
|
|
|
}
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
if (circle->colour) { /* Legacy - no longer used */
|
2022-07-15 03:01:30 +12:00
|
|
|
/* A 'white' circle */
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_paper, green_paper, blue_paper, feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_cmykcolor(cyan_paper, magenta_paper, yellow_paper, black_paper, feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
ps_put_circle(symbol, circle, radius, 0 /*type*/, feps);
|
2018-06-10 20:16:18 +12:00
|
|
|
if (circle->next) {
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_ink, green_ink, blue_ink, feps);
|
2016-08-29 03:38:02 +12:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_cmykcolor(cyan_ink, magenta_ink, yellow_ink, black_ink, feps);
|
2016-08-29 03:38:02 +12:00
|
|
|
}
|
|
|
|
}
|
2016-06-20 01:14:30 +12:00
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* A 'black' circle */
|
2023-06-19 01:37:05 +12:00
|
|
|
if (circle->next && circle->y == circle->next->y && circle->diameter == circle->next->diameter) {
|
|
|
|
ps_put_circle(symbol, circle, radius, type_latch ? 2 : 1, feps);
|
|
|
|
type_latch = 1;
|
|
|
|
} else {
|
|
|
|
ps_put_circle(symbol, circle, radius, type_latch ? 3 : 0, feps);
|
|
|
|
type_latch = 0;
|
|
|
|
}
|
2016-06-19 22:59:09 +12:00
|
|
|
}
|
|
|
|
}
|
2020-01-06 00:27:24 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Text */
|
2020-10-01 00:19:12 +13:00
|
|
|
|
2018-06-10 20:16:18 +12:00
|
|
|
string = symbol->vector->strings;
|
2020-08-06 08:23:11 +12:00
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (string) {
|
2023-06-12 12:25:55 +12:00
|
|
|
float previous_fsize = 0.0f;
|
|
|
|
const char *font;
|
|
|
|
unsigned char *ps_string = (unsigned char *) z_alloca(ps_len + 1);
|
|
|
|
|
2023-11-20 08:39:54 +13:00
|
|
|
if ((symbol->output_options & BOLD_TEXT) && !upcean) {
|
2020-10-01 00:19:12 +13:00
|
|
|
font = "Helvetica-Bold";
|
|
|
|
} else {
|
|
|
|
font = "Helvetica";
|
|
|
|
}
|
2021-06-10 22:15:39 +12:00
|
|
|
if (iso_latin1) {
|
|
|
|
/* Change encoding to ISO 8859-1, see Postscript Language Reference Manual 2nd Edition Example 5.6 */
|
2020-10-01 00:19:12 +13:00
|
|
|
fprintf(feps, "/%s findfont\n", font);
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("dup length dict begin\n"
|
|
|
|
"{1 index /FID ne {def} {pop pop} ifelse} forall\n"
|
|
|
|
"/Encoding ISOLatin1Encoding def\n"
|
|
|
|
"currentdict\n"
|
|
|
|
"end\n"
|
|
|
|
"/Helvetica-ISOLatin1 exch definefont pop\n", feps);
|
2020-10-01 00:19:12 +13:00
|
|
|
font = "Helvetica-ISOLatin1";
|
|
|
|
}
|
2021-02-11 11:37:59 +13:00
|
|
|
do {
|
|
|
|
ps_convert(string->text, ps_string);
|
2023-06-12 12:25:55 +12:00
|
|
|
if (string->fsize != previous_fsize) {
|
|
|
|
fprintf(feps, "/%s findfont", font);
|
|
|
|
/* Compensate for Helvetica being smaller than Zint's OCR-B */
|
2023-11-20 08:39:54 +13:00
|
|
|
out_putsf( " ", 2, upcean ? string->fsize * 1.07f : string->fsize, feps);
|
2023-06-12 12:25:55 +12:00
|
|
|
fputs(" scalefont setfont\n", feps);
|
|
|
|
previous_fsize = string->fsize;
|
|
|
|
}
|
2023-12-15 23:51:51 +13:00
|
|
|
/* Unhack the guard whitespace `gws_left_fudge`/`gws_right_fudge` hack */
|
|
|
|
if (upcean && string->halign == 1 && string->text[0] == '<') {
|
2023-12-16 07:52:41 +13:00
|
|
|
const float gws_left_fudge = symbol->scale < 0.1f ? 0.1f : symbol->scale; /* 0.5 * 2 * scale */
|
|
|
|
out_putsf(" ", 2, string->x + gws_left_fudge, feps);
|
2023-12-15 23:51:51 +13:00
|
|
|
} else if (upcean && string->halign == 2 && string->text[0] == '>') {
|
2023-12-16 07:52:41 +13:00
|
|
|
const float gws_right_fudge = symbol->scale < 0.1f ? 0.1f : symbol->scale; /* 0.5 * 2 * scale */
|
|
|
|
out_putsf(" ", 2, string->x - gws_right_fudge, feps);
|
2023-12-15 23:51:51 +13:00
|
|
|
} else {
|
|
|
|
out_putsf(" ", 2, string->x, feps);
|
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
out_putsf(" ", 2, symbol->vector->height - string->y, feps);
|
|
|
|
fputs(" moveto\n", feps);
|
2021-02-11 11:37:59 +13:00
|
|
|
if (string->rotation != 0) {
|
2023-06-12 12:25:55 +12:00
|
|
|
fputs(" gsave\n", feps);
|
|
|
|
fprintf(feps, " %d rotate\n", 360 - string->rotation);
|
2021-02-11 11:37:59 +13:00
|
|
|
}
|
2023-06-19 01:37:05 +12:00
|
|
|
if (string->halign == 0 || string->halign == 2) { /* Need width for middle or right align */
|
|
|
|
fprintf(feps, " (%s) stringwidth pop" /* Returns "width height" - discard "height" */
|
|
|
|
" %s 0 rmoveto\n", ps_string, string->halign == 2 ? "neg" : "-2 div");
|
|
|
|
}
|
2021-02-11 11:37:59 +13:00
|
|
|
fprintf(feps, " (%s) show\n", ps_string);
|
|
|
|
if (string->rotation != 0) {
|
2023-06-12 12:25:55 +12:00
|
|
|
fputs(" grestore\n", feps);
|
2021-02-11 11:37:59 +13:00
|
|
|
}
|
|
|
|
string = string->next;
|
|
|
|
} while (string);
|
2016-02-21 00:29:19 +13:00
|
|
|
}
|
2020-01-06 00:27:24 +13:00
|
|
|
|
2022-12-20 05:28:15 +13:00
|
|
|
if (ferror(feps)) {
|
|
|
|
sprintf(symbol->errtxt, "647: Incomplete write to output (%d: %.30s)", errno, strerror(errno));
|
|
|
|
if (!output_to_stdout) {
|
|
|
|
(void) fclose(feps);
|
|
|
|
}
|
|
|
|
return ZINT_ERROR_FILE_WRITE;
|
|
|
|
}
|
|
|
|
|
2021-07-27 02:29:05 +12:00
|
|
|
if (output_to_stdout) {
|
2022-12-20 05:28:15 +13:00
|
|
|
if (fflush(feps) != 0) {
|
|
|
|
sprintf(symbol->errtxt, "648: Incomplete flush to output (%d: %.30s)", errno, strerror(errno));
|
|
|
|
return ZINT_ERROR_FILE_WRITE;
|
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
} else {
|
2022-12-20 05:28:15 +13:00
|
|
|
if (fclose(feps) != 0) {
|
|
|
|
sprintf(symbol->errtxt, "649: Failure on closing output file (%d: %.30s)", errno, strerror(errno));
|
|
|
|
return ZINT_ERROR_FILE_WRITE;
|
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
return error_number;
|
2008-07-14 09:15:55 +12:00
|
|
|
}
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et : */
|