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
|
|
|
|
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-12 12:25:55 +12:00
|
|
|
/* Convert Ultracode rectangle colour to PostScript setrgbcolor/setcmykcolor format */
|
|
|
|
static void ps_colour(const int is_rgb, const int colour, char ps_color[21]) {
|
|
|
|
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) */
|
|
|
|
};
|
|
|
|
strcpy(ps_color, ps_rgbs[idx]);
|
|
|
|
strcpy(ps_color + 5, " setrgbcolor");
|
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) */
|
|
|
|
};
|
|
|
|
strcpy(ps_color, ps_cmyks[idx]);
|
|
|
|
strcpy(ps_color + 7, " setcmykcolor");
|
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;
|
|
|
|
case 0xC2: /* See `to_iso8859_1()` in raster.c */
|
|
|
|
*p++ = *++s;
|
|
|
|
break;
|
|
|
|
case 0xC3:
|
|
|
|
*p++ = *++s + 64;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (*s < 0x80) {
|
|
|
|
*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 */
|
|
|
|
static void ps_put_rect(const struct zint_symbol *symbol, const struct zint_vector_rect *rect, FILE *feps) {
|
|
|
|
out_putsf("", 2, rect->height, feps);
|
|
|
|
out_putsf(" ", 2, rect->width, feps);
|
|
|
|
out_putsf(" ", 2, rect->x, feps);
|
|
|
|
out_putsf(" ", 2, (symbol->vector->height - rect->y) - rect->height, feps);
|
|
|
|
fputs(" TR\n", feps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to output circle/disc */
|
|
|
|
static void ps_put_circle(const struct zint_symbol *symbol, const struct zint_vector_circle *circle,
|
|
|
|
const float radius, FILE *feps) {
|
|
|
|
out_putsf("", 2, circle->x, feps);
|
|
|
|
out_putsf(" ", 2, symbol->vector->height - circle->y, feps);
|
|
|
|
out_putsf(" ", 3, radius, feps);
|
|
|
|
if (circle->width) {
|
|
|
|
out_putsf(" ", 3, circle->width, feps);
|
|
|
|
fputs(" TC\n", feps);
|
|
|
|
} else {
|
|
|
|
fputs(" TD\n", feps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
float radius, half_radius, half_sqrt3_radius;
|
2021-07-27 02:29:05 +12:00
|
|
|
int colour_index, colour_rect_flag;
|
2023-06-12 12:25:55 +12:00
|
|
|
char ps_color[21]; /* max "1 0 0 0 setcmykcolor" = 20 + 1 */
|
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-06-12 12:25:55 +12:00
|
|
|
const int extendable = is_extendable(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) {
|
|
|
|
/* Disc: x y radius TD */
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("/TD { newpath 0 360 arc fill } bind def\n", feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
|
|
|
if (have_circles_with_width) {
|
|
|
|
/* Circle (ring): x y radius width TC (adapted from BWIPP renmaxicode.ps) */
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("/TC { newpath 4 1 roll 3 copy 0 360 arc closepath 4 -1 roll add 360 0 arcn closepath fill }"
|
|
|
|
" bind def\n", feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
|
|
|
if (symbol->vector->hexagons) {
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def\n", feps);
|
2021-08-23 00:59:01 +12:00
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
if (symbol->vector->rectangles || draw_background) {
|
|
|
|
/* Rectangle: h w x y */
|
|
|
|
fputs("/TR { newpath moveto dup 3 1 roll 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def\n",
|
|
|
|
feps);
|
|
|
|
}
|
2016-02-21 00:29:19 +13:00
|
|
|
|
2022-12-20 05:28:15 +13:00
|
|
|
fputs("newpath\n", feps);
|
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);
|
|
|
|
out_putsf(" ", 2, symbol->vector->width, feps);
|
|
|
|
fputs(" 0 0 TR\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) {
|
2021-07-27 02:29:05 +12:00
|
|
|
colour_rect_flag = 0;
|
|
|
|
rect = symbol->vector->rectangles;
|
|
|
|
while (rect) {
|
2022-07-15 03:01:30 +12:00
|
|
|
if (rect->colour == -1) { /* Foreground */
|
2021-07-27 02:29:05 +12:00
|
|
|
if (colour_rect_flag == 0) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Set foreground colour */
|
2023-06-12 12:25:55 +12:00
|
|
|
if (is_rgb) {
|
|
|
|
ps_put_rgbcolor(red_ink, green_ink, blue_ink, feps);
|
2021-07-27 02:29:05 +12:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_cmykcolor(cyan_ink, magenta_ink, yellow_ink, black_ink, feps);
|
2021-07-27 02:29:05 +12:00
|
|
|
}
|
|
|
|
colour_rect_flag = 1;
|
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_rect(symbol, rect, feps);
|
2021-07-27 02:29:05 +12:00
|
|
|
}
|
|
|
|
rect = rect->next;
|
|
|
|
}
|
|
|
|
for (colour_index = 1; colour_index <= 8; colour_index++) {
|
|
|
|
colour_rect_flag = 0;
|
2020-01-07 07:00:43 +13:00
|
|
|
rect = symbol->vector->rectangles;
|
|
|
|
while (rect) {
|
|
|
|
if (rect->colour == colour_index) {
|
2021-07-27 02:29:05 +12:00
|
|
|
if (colour_rect_flag == 0) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Set new colour */
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_colour(is_rgb, colour_index, ps_color);
|
2020-01-07 07:00:43 +13:00
|
|
|
fprintf(feps, "%s\n", ps_color);
|
2021-07-27 02:29:05 +12:00
|
|
|
colour_rect_flag = 1;
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_rect(symbol, rect, feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
}
|
|
|
|
rect = rect->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rect = symbol->vector->rectangles;
|
|
|
|
while (rect) {
|
2023-06-12 12:25:55 +12:00
|
|
|
ps_put_rect(symbol, rect, feps);
|
2020-01-07 07:00:43 +13:00
|
|
|
rect = rect->next;
|
|
|
|
}
|
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 */
|
2020-10-27 01:21:43 +13:00
|
|
|
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
|
2018-06-10 20:16:18 +12:00
|
|
|
hex = symbol->vector->hexagons;
|
|
|
|
while (hex) {
|
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;
|
|
|
|
radius = (float) (0.5 * previous_diameter);
|
|
|
|
half_radius = (float) (0.25 * previous_diameter);
|
|
|
|
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
|
|
|
|
}
|
2020-08-06 08:23:11 +12:00
|
|
|
if ((hex->rotation == 0) || (hex->rotation == 180)) {
|
2023-06-12 12:25:55 +12:00
|
|
|
out_putsf("", 2, hex->x, feps);
|
|
|
|
out_putsf(" ", 2, hy + radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x + half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy + half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x + half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy - half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x, feps);
|
|
|
|
out_putsf(" ", 2, hy - radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x - half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy - half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x - half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy + half_radius, feps);
|
2020-08-06 08:23:11 +12:00
|
|
|
} else {
|
2023-06-12 12:25:55 +12:00
|
|
|
out_putsf("", 2, hex->x - radius, feps);
|
|
|
|
out_putsf(" ", 2, hy, feps);
|
|
|
|
out_putsf(" ", 2, hex->x - half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy + half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x + half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy + half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x + radius, feps);
|
|
|
|
out_putsf(" ", 2, hy, feps);
|
|
|
|
out_putsf(" ", 2, hex->x + half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy - half_sqrt3_radius, feps);
|
|
|
|
out_putsf(" ", 2, hex->x - half_radius, feps);
|
|
|
|
out_putsf(" ", 2, hy - half_sqrt3_radius, feps);
|
2020-08-06 08:23:11 +12:00
|
|
|
}
|
2023-06-12 12:25:55 +12:00
|
|
|
fputs(" TH\n", feps);
|
2018-06-10 20:16:18 +12:00
|
|
|
hex = hex->next;
|
|
|
|
}
|
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;
|
2018-06-10 20:16:18 +12:00
|
|
|
circle = symbol->vector->circles;
|
|
|
|
while (circle) {
|
2021-08-23 00:59:01 +12:00
|
|
|
if (previous_diameter != circle->diameter - circle->width) {
|
|
|
|
previous_diameter = circle->diameter - circle->width;
|
2020-10-27 01:21:43 +13:00
|
|
|
radius = (float) (0.5 * previous_diameter);
|
|
|
|
}
|
- `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-12 12:25:55 +12:00
|
|
|
ps_put_circle(symbol, circle, radius, 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-12 12:25:55 +12:00
|
|
|
ps_put_circle(symbol, circle, radius, feps);
|
2016-06-19 22:59:09 +12:00
|
|
|
}
|
2018-06-10 20:16:18 +12:00
|
|
|
circle = circle->next;
|
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);
|
|
|
|
|
|
|
|
if ((symbol->output_options & BOLD_TEXT) && !extendable) {
|
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 */
|
|
|
|
out_putsf( " ", 2, extendable ? string->fsize * 1.07f : string->fsize, feps);
|
|
|
|
fputs(" scalefont setfont\n", feps);
|
|
|
|
previous_fsize = string->fsize;
|
|
|
|
}
|
|
|
|
out_putsf(" ", 2, string->x, feps);
|
|
|
|
out_putsf(" ", 2, symbol->vector->height - string->y, feps);
|
|
|
|
fputs(" moveto\n", feps);
|
2021-02-11 11:37:59 +13:00
|
|
|
if (string->halign == 0 || string->halign == 2) { /* Need width for middle or right align */
|
2023-06-12 12:25:55 +12:00
|
|
|
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
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
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 : */
|