summaryrefslogtreecommitdiff
path: root/pcl
diff options
context:
space:
mode:
Diffstat (limited to 'pcl')
-rw-r--r--pcl/pcbiptrn.c61
-rw-r--r--pcl/pccid.c44
-rw-r--r--pcl/pccolor.c22
-rw-r--r--pcl/pccprint.c10
-rw-r--r--pcl/pccrd.c10
-rw-r--r--pcl/pccrd.h12
-rw-r--r--pcl/pccsbase.c23
-rw-r--r--pcl/pccsbase.h2
-rw-r--r--pcl/pcdict.h1
-rw-r--r--pcl/pcdraw.c4
-rw-r--r--pcl/pcfont.c697
-rw-r--r--pcl/pcfont.h2
-rw-r--r--pcl/pcfontpg.c30
-rw-r--r--pcl/pcfrgrnd.c53
-rw-r--r--pcl/pcfrgrnd.h14
-rw-r--r--pcl/pcfsel.c420
-rw-r--r--pcl/pcfsel.h6
-rw-r--r--pcl/pcht.c214
-rw-r--r--pcl/pcht.h14
-rw-r--r--pcl/pcimpl.c5
-rw-r--r--pcl/pcindxed.c32
-rw-r--r--pcl/pcindxed.h7
-rw-r--r--pcl/pcjob.c270
-rw-r--r--pcl/pclookup.c4
-rw-r--r--pcl/pclookup.h2
-rw-r--r--pcl/pcmacros.c334
-rw-r--r--pcl/pcmisc.c34
-rw-r--r--pcl/pcmtx3.c2
-rw-r--r--pcl/pcmtx3.h17
-rw-r--r--pcl/pcommand.c1
-rw-r--r--pcl/pcommand.h14
-rw-r--r--pcl/pcpage.c7
-rw-r--r--pcl/pcpalet.c179
-rw-r--r--pcl/pcpalet.h9
-rw-r--r--pcl/pcparse.c936
-rw-r--r--pcl/pcparse.h8
-rw-r--r--pcl/pcpatrn.c141
-rw-r--r--pcl/pcpatrn.h154
-rw-r--r--pcl/pcpattyp.h1
-rw-r--r--pcl/pcpatxfm.c16
-rw-r--r--pcl/pcpatxfm.h7
-rw-r--r--pcl/pcrect.c34
-rw-r--r--pcl/pcsfont.c75
-rw-r--r--pcl/pcstate.h28
-rw-r--r--pcl/pcstatus.c979
-rw-r--r--pcl/pcsymbol.c450
-rw-r--r--pcl/pcsymbol.h2
-rw-r--r--pcl/pctext.c229
-rw-r--r--pcl/pctop.c302
-rw-r--r--pcl/pctop.h1
-rw-r--r--pcl/pctpm.h4
-rw-r--r--pcl/pcuptrn.c36
-rw-r--r--pcl/pcursor.c5
-rw-r--r--pcl/pcwhtidx.c6
-rw-r--r--pcl/pcxfmst.h6
-rw-r--r--pcl/pgchar.c582
-rw-r--r--pcl/pgcolor.c22
-rw-r--r--pcl/pgconfig.c758
-rw-r--r--pcl/pgdraw.c1480
-rw-r--r--pcl/pgdraw.h14
-rw-r--r--pcl/pgfdata.c93
-rw-r--r--pcl/pgfdata.h2
-rw-r--r--pcl/pgfont.c108
-rw-r--r--pcl/pgframe.c161
-rw-r--r--pcl/pggeom.c102
-rw-r--r--pcl/pggeom.h20
-rw-r--r--pcl/pglabel.c1024
-rw-r--r--pcl/pglfill.c522
-rw-r--r--pcl/pgmisc.c32
-rw-r--r--pcl/pgmisc.h4
-rw-r--r--pcl/pgparse.c524
-rw-r--r--pcl/pgpoly.c383
-rw-r--r--pcl/pgstate.h332
-rw-r--r--pcl/rtgmode.c105
-rw-r--r--pcl/rtgmode.h1
-rw-r--r--pcl/rtmisc.c76
-rw-r--r--pcl/rtraster.c155
-rw-r--r--pcl/rtrstcmp.c10
-rw-r--r--pcl/rtrstcmp.h4
-rw-r--r--pcl/rtrstst.h10
80 files changed, 6180 insertions, 6320 deletions
diff --git a/pcl/pcbiptrn.c b/pcl/pcbiptrn.c
index 5d351e693..1a5709a15 100644
--- a/pcl/pcbiptrn.c
+++ b/pcl/pcbiptrn.c
@@ -109,12 +109,11 @@ static const byte bi_data_array[(PCL_NUM_SHADE_PATTERNS + PCL_NUM_CROSSHATCH_PA
0x38, 0x1c, 0x70, 0x0e, 0xe0, 0x07, 0xc0, 0x03
};
-
#define make_pixmap(indx) \
{ (byte *)(bi_data_array + indx * 2 * 16), 2, {16, 16}, 0, 1, 1 }
static const gs_depth_bitmap bi_pixmap_array[PCL_NUM_CROSSHATCH_PATTERNS +
- PCL_NUM_SHADE_PATTERNS] = {
+ PCL_NUM_SHADE_PATTERNS] = {
make_pixmap(0),
make_pixmap(1),
make_pixmap(2),
@@ -222,7 +221,7 @@ pcl_pattern_clear_bi_patterns(pcl_state_t *pcs)
}
}
-/*
+/*
* pcl patterns are always always 300 dpi but we use the device
* resolution on devices lower than 300 dpi so we can at least see the
* patterns on screen resolution devices. We also provide a #define
@@ -240,19 +239,19 @@ pcl_get_pattern_resolution(pcl_state_t *pcs, gs_point *pattern_res)
pattern_res->y = 300;
/* get the current resolutions based on the device. */
{
- gs_point device_res;
- gx_device *pdev = gs_currentdevice(pcs->pgs);
- device_res.x = pdev->HWResolution[0];
- device_res.y = pdev->HWResolution[1];
+ gs_point device_res;
+ gx_device *pdev = gs_currentdevice(pcs->pgs);
+ device_res.x = pdev->HWResolution[0];
+ device_res.y = pdev->HWResolution[1];
#ifdef DEVICE_RES_PATTERNS
- pattern_res->x = device_res.x;
- pattern_res->y = device_res.y;
+ pattern_res->x = device_res.x;
+ pattern_res->y = device_res.y;
#else
- /* if both are less than 300 dpi override the 300 dpi default. */
- if ( (device_res.x < 300) && (device_res.y < 300) ) {
- pattern_res->x = device_res.x;
- pattern_res->y = device_res.y;
- }
+ /* if both are less than 300 dpi override the 300 dpi default. */
+ if ( (device_res.x < 300) && (device_res.y < 300) ) {
+ pattern_res->x = device_res.x;
+ pattern_res->y = device_res.y;
+ }
#endif
}
return 0;
@@ -265,13 +264,13 @@ pcl_get_pattern_resolution(pcl_state_t *pcs, gs_point *pattern_res)
get_bi_pattern(pcl_state_t *pcs, int indx)
{
if (pcs->bi_pattern_array[indx] == 0) {
- gs_point pattern_res;
- pcl_get_pattern_resolution(pcs, &pattern_res);
+ gs_point pattern_res;
+ pcl_get_pattern_resolution(pcs, &pattern_res);
(void)pcl_pattern_build_pattern( &(pcs->bi_pattern_array[indx]),
&(bi_pixmap_array[indx]),
pcl_pattern_uncolored,
- pattern_res.x,
- pattern_res.y,
+ pattern_res.x,
+ pattern_res.y,
pcs->memory
);
pcs->bi_pattern_array[indx]->ppat_data->storage = pcds_internal;
@@ -289,21 +288,21 @@ pcl_pattern_get_shade(pcl_state_t *pcs, int inten)
{
pcl_pattern_t *shade = 0;
if (inten <= 0)
- shade = 0;
+ shade = 0;
else if (inten <= 2)
- shade = get_bi_pattern(pcs, 0);
+ shade = get_bi_pattern(pcs, 0);
else if (inten <= 10)
- shade = get_bi_pattern(pcs, 1);
+ shade = get_bi_pattern(pcs, 1);
else if (inten <= 20)
- shade = get_bi_pattern(pcs, 2);
+ shade = get_bi_pattern(pcs, 2);
else if (inten <= 35)
- shade = get_bi_pattern(pcs, 3);
+ shade = get_bi_pattern(pcs, 3);
else if (inten <= 55)
- shade = get_bi_pattern(pcs, 4);
+ shade = get_bi_pattern(pcs, 4);
else if (inten <= 80)
- shade = get_bi_pattern(pcs, 5);
+ shade = get_bi_pattern(pcs, 5);
else if (inten <= 99)
- shade = get_bi_pattern(pcs, 6);
+ shade = get_bi_pattern(pcs, 6);
return shade;
}
@@ -328,8 +327,8 @@ pcl_pattern_get_cross(pcl_state_t *pcs, int indx)
pcl_pattern_get_solid_pattern(pcl_state_t *pcs)
{
if (pcs->psolid_pattern == 0) {
- gs_point pattern_res;
- pcl_get_pattern_resolution(pcs, &pattern_res);
+ gs_point pattern_res;
+ pcl_get_pattern_resolution(pcs, &pattern_res);
(void)pcl_pattern_build_pattern( &(pcs->psolid_pattern),
&solid_pattern_pixmap,
pcl_pattern_uncolored,
@@ -349,8 +348,8 @@ pcl_pattern_get_solid_pattern(pcl_state_t *pcs)
pcl_pattern_get_unsolid_pattern(pcl_state_t *pcs)
{
if (pcs->punsolid_pattern == 0) {
- gs_point pattern_res;
- pcl_get_pattern_resolution(pcs, &pattern_res);
+ gs_point pattern_res;
+ pcl_get_pattern_resolution(pcs, &pattern_res);
(void)pcl_pattern_build_pattern( &(pcs->punsolid_pattern),
&unsolid_pattern_pixmap,
pcl_pattern_uncolored,
@@ -362,5 +361,3 @@ pcl_pattern_get_unsolid_pattern(pcl_state_t *pcs)
}
return pcs->punsolid_pattern;
}
-
-
diff --git a/pcl/pccid.c b/pcl/pccid.c
index 159d19ed4..5ce542203 100644
--- a/pcl/pccid.c
+++ b/pcl/pccid.c
@@ -10,7 +10,7 @@
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, (415)492-9861, for further information. */
/*$Id$ */
-
+
/* pccid.c - PCL configure image data command and object implementation */
#include "gx.h"
#include "gsmemory.h"
@@ -31,7 +31,7 @@
/* CID accessors */
pcl_cspace_type_t
-pcl_cid_get_cspace(const pcl_cid_data_t *pcid)
+pcl_cid_get_cspace(const pcl_cid_data_t *pcid)
{
return pcid->u.hdr.cspace;
}
@@ -54,7 +54,6 @@ pcl_cid_get_bits_per_primary(const pcl_cid_data_t *pcid, int index)
return pcid->u.hdr.bits_per_primary[index];
}
-
/*
* Convert a 32-bit floating point number stored in HP's big-endian form
* into the native form required by the host processor.
@@ -137,7 +136,6 @@ convert_int16_array(
}
}
-
/*
* Build the various long-form configure image data structures.
* Returns 0 on success, < 0 in case of an error.
@@ -165,7 +163,7 @@ normalize_cid_minmax_valrange_long(float *minmax)
{
int i;
for ( i = 0; i < 6; i++ ) {
- minmax[i] /= 255;
+ minmax[i] /= 255;
}
}
@@ -247,7 +245,6 @@ check_cid_hdr(
if (pcidh->encoding == pcl_penc_direct_by_pixel)
pcidh->bits_per_index = 8;
-
/*
* Map zero values. Zero bits per index is equivalent to one bit per index;
* zero bits per primary is equivalent to 8 bits per primary.
@@ -257,12 +254,10 @@ check_cid_hdr(
for (i = 0; i < countof(pcidh->bits_per_primary); i++) {
if (pcidh->bits_per_primary[i] == 0)
pcidh->bits_per_primary[i] = 8;
- if ( pcs->personality == pcl5e && pcidh->bits_per_primary[i] != 1 )
- dprintf("pcl5e personality with color primaries\n" );
+ if ( pcs->personality == pcl5e && pcidh->bits_per_primary[i] != 1 )
+ dprintf("pcl5e personality with color primaries\n" );
}
-
-
switch (pcidh->encoding) {
case pcl_penc_indexed_by_pixel:
@@ -313,7 +308,7 @@ check_cid_hdr(
pcid->len = 6;
}
#endif
-
+
/* if the device handles color conversion remap the colorimetric color space to rgb */
if (pl_device_does_color_conversion() && pcidh->cspace == pcl_cspace_Colorimetric) {
pcidh->cspace = pcl_cspace_RGB;
@@ -325,8 +320,8 @@ check_cid_hdr(
static int
substitute_colorimetric_cs(
- pcl_state_t *pcs,
- pcl_cid_data_t *pcid
+ pcl_state_t *pcs,
+ pcl_cid_data_t *pcid
)
{
pcl_cid_col_long_t * pcol = &(pcid->u.col);
@@ -446,7 +441,6 @@ set_simple_color_mode(
return install_cid_data(6, pbuff, pcs, true, false);
}
-
/*
* ESC * v <nbytes> W
*
@@ -460,7 +454,7 @@ pcl_configure_image_data(
)
{
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
return install_cid_data( uint_arg(pargs),
arg_data(pargs),
pcs,
@@ -482,7 +476,7 @@ pcl_simple_color_space(
)
{
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
return set_simple_color_mode(int_arg(pargs), pcs);
}
@@ -509,7 +503,7 @@ set_view_illuminant(
gs_vector3 wht_pt;
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
if (len != 8)
return e_Range;
@@ -544,16 +538,16 @@ pcl_cid_IN(
)
{
static const byte cid_GL2_Color[6] = { (byte)pcl_cspace_RGB,
- (byte)pcl_penc_indexed_by_plane,
- 3, 8, 8, 8 };
+ (byte)pcl_penc_indexed_by_plane,
+ 3, 8, 8, 8 };
static const byte cid_GL2_Mono[6] = { (byte)pcl_cspace_RGB,
- (byte)pcl_penc_indexed_by_plane,
- 3, 1, 1, 1 };
+ (byte)pcl_penc_indexed_by_plane,
+ 3, 1, 1, 1 };
return install_cid_data(6,
- pcs->personality == pcl5e ? cid_GL2_Mono : cid_GL2_Color,
- pcs, false, true);
+ pcs->personality == pcl5e ? cid_GL2_Mono : cid_GL2_Color,
+ pcs, false, true);
}
/*
@@ -589,7 +583,7 @@ pcl_cid_do_reset(pcl_state_t * pcs,
pcl_reset_type_t type
)
{
- static const uint mask = (pcl_reset_initial |
+ static const uint mask = (pcl_reset_initial |
pcl_reset_cold |
pcl_reset_printer);
@@ -597,6 +591,6 @@ pcl_cid_do_reset(pcl_state_t * pcs,
pcs->useciecolor = !pjl_proc_compare(pcs->pjls,
pjl_proc_get_envvar(pcs->pjls, "useciecolor"), "on");
}
-}
+}
const pcl_init_t pcl_cid_init = { pcl_cid_do_registration, pcl_cid_do_reset, 0 };
diff --git a/pcl/pccolor.c b/pcl/pccolor.c
index 52c651cf2..081a227db 100644
--- a/pcl/pccolor.c
+++ b/pcl/pccolor.c
@@ -41,7 +41,7 @@ set_color_comp_1(
)
{
if ( pcs->personality == pcl5e )
- return 0;
+ return 0;
if (!pcs->raster_state.graphics_mode)
pcs->color_comps[0] = float_arg(pargs);
return 0;
@@ -57,7 +57,7 @@ set_color_comp_2(
)
{
if ( pcs->personality == pcl5e )
- return 0;
+ return 0;
if (!pcs->raster_state.graphics_mode)
pcs->color_comps[1] = float_arg(pargs);
return 0;
@@ -73,7 +73,7 @@ set_color_comp_3(
)
{
if ( pcs->personality == pcl5e )
- return 0;
+ return 0;
if (!pcs->raster_state.graphics_mode)
pcs->color_comps[2] = float_arg(pargs);
return 0;
@@ -88,7 +88,7 @@ set_color_comp_3(
* will not affect the palette, but will reset the color component registers.
* This matches the behavior of the HP Color Laser Jet 5/5M, but not that of
* the HP DeskJet 1600C/CM. For the latter, negative indices are ignored and
- * the color component registers are NOT cleared, while positive indices are
+ * the color component registers are NOT cleared, while positive indices are
* interpreted modulo the palette size.
*/
static int
@@ -100,7 +100,7 @@ assign_color_index(
int indx = int_arg(pargs);
if ( pcs->personality == pcl5e )
- return 0;
+ return 0;
if (!pcs->raster_state.graphics_mode) {
if ((indx >= 0) && (indx < pcl_palette_get_num_entries(pcs->ppalet)))
pcl_palette_set_color(pcs, indx, pcs->color_comps);
@@ -124,30 +124,30 @@ color_do_registration(
DEFINE_CLASS('*')
{
'v', 'A',
- PCL_COMMAND( "Color Component 1",
+ PCL_COMMAND( "Color Component 1",
set_color_comp_1,
- pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
+ pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
)
},
{
'v', 'B',
- PCL_COMMAND( "Color Component 2",
+ PCL_COMMAND( "Color Component 2",
set_color_comp_2,
- pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
+ pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
)
},
{
'v', 'C',
PCL_COMMAND( "Color Component 3",
set_color_comp_3,
- pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
+ pca_neg_ok | pca_big_error | pca_raster_graphics | pca_in_rtl
)
},
{
'v', 'I',
PCL_COMMAND( "Assign Color Index",
assign_color_index,
- pca_neg_ok | pca_big_ignore | pca_raster_graphics | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_raster_graphics | pca_in_rtl
)
},
END_CLASS
diff --git a/pcl/pccprint.c b/pcl/pccprint.c
index c37e71645..90713119f 100644
--- a/pcl/pccprint.c
+++ b/pcl/pccprint.c
@@ -37,7 +37,7 @@ pcl_logical_operation(
if (pcs->raster_state.graphics_mode)
return 0;
if (rop > 255)
- return e_Range;
+ return e_Range;
pcl_break_underline(pcs); /* use the 5c convention; in 5e, the
* underline is not broken by a change in
@@ -63,7 +63,7 @@ pcl_pixel_placement(
if (pcs->raster_state.graphics_mode)
return 0;
if (i > 1)
- return 0;
+ return 0;
pcs->pp_mode = i;
return 0;
}
@@ -81,16 +81,16 @@ pccprint_do_registration(
DEFINE_CLASS('*')
{
'l', 'O',
- PCL_COMMAND( "Logical Operation",
+ PCL_COMMAND( "Logical Operation",
pcl_logical_operation,
- pca_neg_ok | pca_big_error | pca_in_rtl | pca_raster_graphics
+ pca_neg_ok | pca_big_error | pca_in_rtl | pca_raster_graphics
)
},
{
'l', 'R',
PCL_COMMAND( "Pixel Placement",
pcl_pixel_placement,
- pca_neg_ok | pca_big_ignore | pca_in_rtl | pca_raster_graphics
+ pca_neg_ok | pca_big_ignore | pca_in_rtl | pca_raster_graphics
)
},
END_CLASS
diff --git a/pcl/pccrd.c b/pcl/pccrd.c
index 440eb8cb8..cb3f532c3 100644
--- a/pcl/pccrd.c
+++ b/pcl/pccrd.c
@@ -144,7 +144,7 @@ alloc_crd(
* and uses the device parameter "CRDName" to select the one that is to be
* used as a default.
*
- * Returns
+ * Returns
*/
static bool
read_device_CRD(
@@ -280,7 +280,7 @@ pcl_crd_set_view_illuminant(
if (pold == 0) {
pcs->dflt_TransformPQR = dflt_TransformPQR_proto;
return gs_cie_render1_initialize( pcs->memory,
- pcrd->pgscrd,
+ pcrd->pgscrd,
NULL,
pwht_pt,
NULL,
@@ -297,9 +297,9 @@ pcl_crd_set_view_illuminant(
);
}
code = gs_cie_render1_init_from( pcs->memory,
- pcrd->pgscrd,
+ pcrd->pgscrd,
NULL, /* for now */
- pold->pgscrd,
+ pold->pgscrd,
pwht_pt,
&(pold->pgscrd->points.BlackPoint),
&(pold->pgscrd->MatrixPQR),
@@ -315,7 +315,7 @@ pcl_crd_set_view_illuminant(
);
if (pcrd != pold)
- rc_decrement(pold, "pcl set viewing illuminant");
+ rc_decrement(pold, "pcl set viewing illuminant");
return code;
}
diff --git a/pcl/pccrd.h b/pcl/pccrd.h
index 9c922d8d5..33751f02f 100644
--- a/pcl/pccrd.h
+++ b/pcl/pccrd.h
@@ -29,11 +29,11 @@
/*
* In PCL, color rendering dictionaries are set by the device, but the
- * default white point is specified by the language, and the white point
+ * default white point is specified by the language, and the white point
* may be modified by the language via the "View Illuminant" command.
*
* Though trivial in principle, this arrangement is a bit awkward for the
- * graphic library as there is no make-unique functionality provided
+ * graphic library as there is no make-unique functionality provided
* for color rendering dictionaries (none is necessary for PostScript as
* color rendering dictionaries may not be modified once they are set).
*
@@ -42,13 +42,13 @@
*/
/*
- * The PCL id exists to provide an identifier for a color rendering
- * dictionary. Having such an identifier is important to avoid the need
- * to repeatedly re-insert the color rendering dictionary into the
+ * The PCL id exists to provide an identifier for a color rendering
+ * dictionary. Having such an identifier is important to avoid the need
+ * to repeatedly re-insert the color rendering dictionary into the
* graphic state.
*
* The is_dflt_illum flag is used to optimize the case in which a CRD that
- * already uses the default view illuminant is once again set to use this
+ * already uses the default view illuminant is once again set to use this
* view illuminant.
*/
struct pcl_crd_s {
diff --git a/pcl/pccsbase.c b/pcl/pccsbase.c
index 5df687d35..ca762aed8 100644
--- a/pcl/pccsbase.c
+++ b/pcl/pccsbase.c
@@ -131,7 +131,6 @@ private_st_cs_base_t();
val = min_val + val * range; \
END
-
/*
* Default Configure Image Data information for the various color spaces.
*
@@ -192,7 +191,6 @@ static const struct {
/* pcl_cspace_LumChrom */
};
-
/*
* Code for constructing/modifying the client data structure of PCL base
* color spaces.
@@ -275,7 +273,7 @@ build_client_data(
*/
static void
init_client_data_from( pcl_cs_client_data_t * pnew,
- const pcl_cs_client_data_t * pfrom
+ const pcl_cs_client_data_t * pfrom
)
{
*pnew = *pfrom;
@@ -304,7 +302,6 @@ update_lookup_tbls(
#define free_lookup_tbls(pdata) \
update_lookup_tbls((pdata), NULL, NULL)
-
/*
* The colorimetric case.
*
@@ -599,7 +596,7 @@ finish_colmet_cspace(
* a1 = a* / 500
* b1 = b* / 200
* - -
- * { a2, T1, b2 } = { T1, a1, b1 } * | 1 1 1 |
+ * { a2, T1, b2 } = { T1, a1, b1 } * | 1 1 1 |
* | 1 0 0 |
* | 0 0 -1 |
* - -
@@ -713,7 +710,6 @@ static const gs_cie_common_proc3 lab_DecodeLMN = {
static const gs_vector3 lab_WhitePoint = { .9504, 1.0, 1.0889 };
-
/*
* Finish the creation of a CIE L*a*b* color space.
*/
@@ -735,7 +731,6 @@ finish_lab_cspace(
return 0;
}
-
/*
* The luminance-chrominance color space
*
@@ -833,7 +828,6 @@ static const gs_cie_common_proc3 lumchrom_DecodeLMN = {
{ lumchrom_DecodeLMN_0, lumchrom_DecodeLMN_1, lumchrom_DecodeLMN_2 }
};
-
/*
* Build the MatrixABC value for a luminance/chrominance color space. Note that
* this is the inverse of the matrix provided in the Configure Image Data
@@ -848,7 +842,7 @@ build_lum_chrom_mtxABC(
)
{
int i;
- pcl_mtx3_t tmp_mtx;
+ pcl_mtx3_t tmp_mtx;
/* transpose the input to create a row-order matrix */
for (i = 0; i < 3; i++) {
@@ -912,7 +906,6 @@ static int (*const finish_cspace[(int)pcl_cspace_num])( gs_color_space *,
finish_lumchrom_cspace /* pcl_cspace_LumChrom */
};
-
/*
* Free a PCL base color space. This decrements the reference count for the
* GS color space, and frees any lookup tables that might have been
@@ -976,7 +969,7 @@ alloc_base_cspace(
);
if (code < 0 || pbase->pcspace == NULL)
free_base_cspace(pmem, pbase, "allocate pcl base color space");
- else
+ else
*ppbase = pbase;
return code;
}
@@ -1001,8 +994,8 @@ alloc_base_cspace(
* client data may have been changed).
*/
static int
-unshare_base_cspace(const gs_memory_t *mem,
- pcl_cs_base_t ** ppbase
+unshare_base_cspace(const gs_memory_t *mem,
+ pcl_cs_base_t ** ppbase
)
{
pcl_cs_base_t * pbase = *ppbase;
@@ -1124,7 +1117,7 @@ pcl_cs_base_update_lookup_tbl(
int code = 0;
if (plktbl == 0) {
- if ( (pbase->client_data.plktbl1 == 0) &&
+ if ( (pbase->client_data.plktbl1 == 0) &&
(pbase->client_data.plktbl2 == 0) )
return 0;
plktbl1 = 0;
@@ -1137,7 +1130,7 @@ pcl_cs_base_update_lookup_tbl(
/* lookup tables for "higher" color spaces are always ignored */
if ( (cstype < lktype) ||
(lktype == pcl_cspace_RGB) ||
- (lktype == pcl_cspace_CMY) )
+ (lktype == pcl_cspace_CMY) )
return 0;
/* CIE L*a*b* space and the L*a*b* lookup table must match */
diff --git a/pcl/pccsbase.h b/pcl/pccsbase.h
index 3f92e85b4..42497565b 100644
--- a/pcl/pccsbase.h
+++ b/pcl/pccsbase.h
@@ -25,7 +25,6 @@
#include "pccid.h"
#include "pclookup.h"
-
/*
* The client data structure for use with color-metric RGB, CIE L*a*b*, and
* luminanace-chrominance color spaces.
@@ -105,7 +104,6 @@ typedef struct pcl_cs_base_s {
#define pcl_cs_base_release(pbase) \
rc_decrement(pbase, "pcl_cs_base_release")
-
/*
* Build a PCL base color space. In principle this may be invoked at any time,
* but it should generally be called the first time a color space is required
diff --git a/pcl/pcdict.h b/pcl/pcdict.h
index 4eaa41527..c8755ff18 100644
--- a/pcl/pcdict.h
+++ b/pcl/pcdict.h
@@ -18,7 +18,6 @@
#include "gx.h"
-
/* Define the type for an ID key used in a dictionary. */
typedef struct pcl_id_s {
uint value;
diff --git a/pcl/pcdraw.c b/pcl/pcdraw.c
index 191ec51df..a71cf5369 100644
--- a/pcl/pcdraw.c
+++ b/pcl/pcdraw.c
@@ -25,7 +25,6 @@
#include "pcpatrn.h"
#include "pcdraw.h"
-
/*
* Set all necessary graphics state parameters for PCL drawing
* (currently only CTM and clipping region).
@@ -113,7 +112,7 @@ pcl_gsave(
if (pids == 0)
return e_Memory;
- pids->pht = 0;
+ pids->pht = 0;
pids->pcrd = 0;
pids->pccolor = 0;
@@ -177,4 +176,3 @@ pcl_free_gstate_stk(pcl_state_t *pcs)
{
gs_free_object(pcs->memory, pcs->pids, "PCL grestore");
}
-
diff --git a/pcl/pcfont.c b/pcl/pcfont.c
index 2a8d658d7..a64b1f398 100644
--- a/pcl/pcfont.c
+++ b/pcl/pcfont.c
@@ -38,38 +38,37 @@
* Decache the HMI after resetting the font. According to TRM 5-22,
* this always happens, regardless of how the HMI was set; formerly,
* we only invalidated the HMI if it was set from the font rather than
- * explicitly. TRM 7-14 any font characteristic change decaches HMI
+ * explicitly. TRM 7-14 any font characteristic change decaches HMI
*/
#define pcl_decache_hmi(pcs)\
do {\
pcs->hmi_cp = HMI_DEFAULT;\
} while (0)
-
/* Clear the font pointer cache after changing a font parameter. set
* indicates which font (0/1 for primary/secondary). -1 means both. */
void
pcl_decache_font(pcl_state_t *pcs, int set)
-{
- if ( set < 0 )
- {
- pcl_decache_font(pcs, 0);
- pcl_decache_font(pcs, 1);
- }
- else
- {
- pcs->font_selection[set].font = NULL;
- pcs->font_selection[set].selected_id = -1;
- pcs->g.font_selection[set].font = NULL;
- if ( pcs->font_selected == set )
- {
- pcs->font = NULL;
- pcs->map = NULL;
- pcs->g.font = NULL;
- pcs->g.map = NULL;
- pcl_decache_hmi(pcs);
- }
- }
+{
+ if ( set < 0 )
+ {
+ pcl_decache_font(pcs, 0);
+ pcl_decache_font(pcs, 1);
+ }
+ else
+ {
+ pcs->font_selection[set].font = NULL;
+ pcs->font_selection[set].selected_id = -1;
+ pcs->g.font_selection[set].font = NULL;
+ if ( pcs->font_selected == set )
+ {
+ pcs->font = NULL;
+ pcs->map = NULL;
+ pcs->g.font = NULL;
+ pcs->g.map = NULL;
+ pcl_decache_hmi(pcs);
+ }
+ }
}
/* set current font and symbol table to selected parameter's font and
@@ -77,9 +76,9 @@ pcl_decache_font(pcl_state_t *pcs, int set)
static int
pcl_set_font(pcl_state_t *pcs, pcl_font_selection_t *pfs)
{
- pcs->font = pfs->font;
- pcs->map = pfs->map;
- return 0;
+ pcs->font = pfs->font;
+ pcs->map = pfs->map;
+ return 0;
}
/* Recompute the current font from the descriptive parameters. */
@@ -89,32 +88,32 @@ pcl_recompute_font(pcl_state_t *pcs, bool internal_only)
{ pcl_font_selection_t *pfs = &pcs->font_selection[pcs->font_selected];
int code = pcl_reselect_font(pfs, pcs, internal_only);
- if ( code < 0 )
- return code;
- pcl_set_font(pcs, pfs);
- /* load it if necessary */
- return pl_load_resident_font_data_from_file(pcs->memory, pfs->font);
+ if ( code < 0 )
+ return code;
+ pcl_set_font(pcs, pfs);
+ /* load it if necessary */
+ return pl_load_resident_font_data_from_file(pcs->memory, pfs->font);
}
/* The font parameter commands all come in primary and secondary variants. */
static int
pcl_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint num = uint_arg(pargs);
- uint symset;
-
- if ( num > 1023 )
- return e_Range;
-
- pcl_decache_hmi(pcs);
- /* The following algorithm is from Appendix C of the */
- /* PCL5 Comparison Guide. */
- symset = (num << 5) + pargs->command - 64;
- if ( symset != pcs->font_selection[set].params.symbol_set )
- {
- pcs->font_selection[set].params.symbol_set = symset;
- pcl_decache_font(pcs, set);
- }
- return 0;
+ uint symset;
+
+ if ( num > 1023 )
+ return e_Range;
+
+ pcl_decache_hmi(pcs);
+ /* The following algorithm is from Appendix C of the */
+ /* PCL5 Comparison Guide. */
+ symset = (num << 5) + pargs->command - 64;
+ if ( symset != pcs->font_selection[set].params.symbol_set )
+ {
+ pcs->font_selection[set].params.symbol_set = symset;
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( <> others */
pcl_primary_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -129,16 +128,16 @@ static int
pcl_spacing(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint spacing = uint_arg(pargs);
- if ( spacing > 1 )
- return 0;
+ if ( spacing > 1 )
+ return 0;
- pcl_decache_hmi(pcs);
- if ( spacing != pcs->font_selection[set].params.proportional_spacing )
- {
- pcs->font_selection[set].params.proportional_spacing = spacing;
- pcl_decache_font(pcs, set);
- }
- return 0;
+ pcl_decache_hmi(pcs);
+ if ( spacing != pcs->font_selection[set].params.proportional_spacing )
+ {
+ pcs->font_selection[set].params.proportional_spacing = spacing;
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( s <prop_bool> P */
pcl_primary_spacing(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -152,24 +151,24 @@ pcl_secondary_spacing(pcl_args_t *pargs, pcl_state_t *pcs)
static int
pcl_pitch(floatp cpi, pcl_state_t *pcs, int set)
{ uint pitch_cp;
- pcl_font_selection_t *pfs = &pcs->font_selection[set];
-
- pcl_decache_hmi(pcs);
- if ( cpi < 0.1 )
- cpi = 0.1;
- /* Convert characters per inch to 100ths of design units. */
- pitch_cp = 7200.0 / cpi;
- if ( pitch_cp > 65535 )
- return e_Range;
- if ( pitch_cp < 1 )
- pitch_cp = 1;
- if ( pitch_cp != pl_fp_pitch_cp(&pfs->params) )
- {
- pl_fp_set_pitch_cp(&pfs->params, pitch_cp);
- if ( (int)pfs->selected_id < 0)
- pcl_decache_font(pcs, set);
- }
- return 0;
+ pcl_font_selection_t *pfs = &pcs->font_selection[set];
+
+ pcl_decache_hmi(pcs);
+ if ( cpi < 0.1 )
+ cpi = 0.1;
+ /* Convert characters per inch to 100ths of design units. */
+ pitch_cp = 7200.0 / cpi;
+ if ( pitch_cp > 65535 )
+ return e_Range;
+ if ( pitch_cp < 1 )
+ pitch_cp = 1;
+ if ( pitch_cp != pl_fp_pitch_cp(&pfs->params) )
+ {
+ pl_fp_set_pitch_cp(&pfs->params, pitch_cp);
+ if ( (int)pfs->selected_id < 0)
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( s <pitch> H */
pcl_primary_pitch(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -183,16 +182,16 @@ pcl_secondary_pitch(pcl_args_t *pargs, pcl_state_t *pcs)
static int
pcl_height(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint height_4ths = (uint)(float_arg(pargs) * 4 + 0.5);
- pcl_font_selection_t *pfs = &pcs->font_selection[set];
+ pcl_font_selection_t *pfs = &pcs->font_selection[set];
- pcl_decache_hmi(pcs);
- if ( height_4ths != pfs->params.height_4ths )
- {
- pfs->params.height_4ths = height_4ths;
- if ( (int)pfs->selected_id < 0)
- pcl_decache_font(pcs, set);
- }
- return 0;
+ pcl_decache_hmi(pcs);
+ if ( height_4ths != pfs->params.height_4ths )
+ {
+ pfs->params.height_4ths = height_4ths;
+ if ( (int)pfs->selected_id < 0)
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( s <height> V */
pcl_primary_height(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -207,13 +206,13 @@ static int
pcl_style(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint style = uint_arg(pargs);
- pcl_decache_hmi(pcs);
- if ( style != pcs->font_selection[set].params.style )
- {
- pcs->font_selection[set].params.style = style;
- pcl_decache_font(pcs, set);
- }
- return 0;
+ pcl_decache_hmi(pcs);
+ if ( style != pcs->font_selection[set].params.style )
+ {
+ pcs->font_selection[set].params.style = style;
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( s <style> S */
pcl_primary_style(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -228,18 +227,18 @@ static int
pcl_stroke_weight(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ int weight = int_arg(pargs);
- pcl_decache_hmi(pcs);
- if ( weight < -7 )
- weight = -7;
- else if ( weight > 7 )
- weight = 7;
- if ( weight != pcs->font_selection[set].params.stroke_weight )
- {
- pcs->font_selection[set].params.stroke_weight = weight;
- if ( (int)pcs->font_selection[set].selected_id < 0)
+ pcl_decache_hmi(pcs);
+ if ( weight < -7 )
+ weight = -7;
+ else if ( weight > 7 )
+ weight = 7;
+ if ( weight != pcs->font_selection[set].params.stroke_weight )
+ {
+ pcs->font_selection[set].params.stroke_weight = weight;
+ if ( (int)pcs->font_selection[set].selected_id < 0)
pcl_decache_font(pcs, set);
- }
- return 0;
+ }
+ return 0;
}
static int /* ESC ( s <weight> B */
pcl_primary_stroke_weight(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -254,13 +253,13 @@ static int
pcl_typeface(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint typeface = uint_arg(pargs);
- pcl_decache_hmi(pcs);
- if ( typeface != pcs->font_selection[set].params.typeface_family )
- {
- pcs->font_selection[set].params.typeface_family = typeface;
- pcl_decache_font(pcs, set);
- }
- return 0;
+ pcl_decache_hmi(pcs);
+ if ( typeface != pcs->font_selection[set].params.typeface_family )
+ {
+ pcs->font_selection[set].params.typeface_family = typeface;
+ pcl_decache_font(pcs, set);
+ }
+ return 0;
}
static int /* ESC ( s <typeface> T */
pcl_primary_typeface(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -274,19 +273,19 @@ pcl_secondary_typeface(pcl_args_t *pargs, pcl_state_t *pcs)
static int
pcl_font_selection_id(pcl_args_t *pargs, pcl_state_t *pcs, int set)
{ uint id = uint_arg(pargs);
- pcl_font_selection_t *pfs = &pcs->font_selection[set];
- int code = pcl_select_font_by_id(pfs, id, pcs);
-
- switch ( code )
- {
- default: /* error */
- return code;
- case 0:
- pcl_decache_font(pcs, -1);
- pfs->selected_id = id;
- case 1: /* not found */
- return 0;
- }
+ pcl_font_selection_t *pfs = &pcs->font_selection[set];
+ int code = pcl_select_font_by_id(pfs, id, pcs);
+
+ switch ( code )
+ {
+ default: /* error */
+ return code;
+ case 0:
+ pcl_decache_font(pcs, -1);
+ pfs->selected_id = id;
+ case 1: /* not found */
+ return 0;
+ }
}
static int /* ESC ( <font_id> X */
pcl_primary_font_selection_id(pcl_args_t *pargs, pcl_state_t *pcs)
@@ -299,16 +298,16 @@ pcl_secondary_font_selection_id(pcl_args_t *pargs, pcl_state_t *pcs)
static int
pcl_select_default_font(pcl_args_t *pargs, pcl_state_t *pcs, int set)
-{
+{
if ( int_arg(pargs) != 3 )
- return e_Range;
+ return e_Range;
pcs->font_selection[set].params.proportional_spacing = false;
pcs->font_selection[set].params.symbol_set = pcs->default_symbol_set_value;
pl_fp_set_pitch_per_inch(&pcs->font_selection[set].params,
- pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "pitch")));
+ pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "pitch")));
pcs->font_selection[set].params.height_4ths =
- pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "ptsize")) * 4.0;
+ pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "ptsize")) * 4.0;
pcs->font_selection[set].params.style = 0;
pcs->font_selection[set].params.stroke_weight = 0;
@@ -328,20 +327,20 @@ pcl_select_default_font_secondary(pcl_args_t *pargs, pcl_state_t *pcs)
static int /* SO */
pcl_SO(pcl_args_t *pargs, pcl_state_t *pcs)
-{
- if ( pcs->font_selected != 1 ) {
- pcs->font_selected = secondary;
- pcl_decache_font(pcs, secondary);
+{
+ if ( pcs->font_selected != 1 ) {
+ pcs->font_selected = secondary;
+ pcl_decache_font(pcs, secondary);
}
return 0;
}
static int /* SI */
pcl_SI(pcl_args_t *pargs, pcl_state_t *pcs)
-{
- if ( pcs->font_selected != 0 ) {
- pcs->font_selected = primary;
- pcl_decache_font(pcs, primary);
+{
+ if ( pcs->font_selected != 0 ) {
+ pcs->font_selected = primary;
+ pcl_decache_font(pcs, primary);
}
return 0;
}
@@ -350,20 +349,20 @@ pcl_SI(pcl_args_t *pargs, pcl_state_t *pcs)
static int /* ESC & k <mode> S */
pcl_set_pitch_mode(pcl_args_t *pargs, pcl_state_t *pcs)
{ int mode = int_arg(pargs);
- floatp cpi;
+ floatp cpi;
int code = 0;
- /*
- * The specification in the PCL5 Comparison Guide is:
- * 0 => 10.0, 2 => 16.67, 4 => 12.0.
- */
- switch ( mode )
- {
- case 0: cpi = 10.0; break;
- case 2: cpi = 16.67; break;
- case 4: cpi = 12.0; break;
- default: return e_Range;
- }
+ /*
+ * The specification in the PCL5 Comparison Guide is:
+ * 0 => 10.0, 2 => 16.67, 4 => 12.0.
+ */
+ switch ( mode )
+ {
+ case 0: cpi = 10.0; break;
+ case 2: cpi = 16.67; break;
+ case 4: cpi = 12.0; break;
+ default: return e_Range;
+ }
/* set the pitch in both primary and secondary font selection tables */
{
@@ -371,7 +370,7 @@ pcl_set_pitch_mode(pcl_args_t *pargs, pcl_state_t *pcs)
if (code == 0)
code = pcl_pitch(cpi, pcs, secondary);
}
- return code;
+ return code;
}
/* Initialization */
@@ -381,86 +380,86 @@ pcfont_do_registration(
gs_memory_t *mem
)
{ /* Register commands */
- { int chr;
- /*
- * The H-P manual only talks about A through Z, but it appears
- * that characters from A through ^ (94) can be used.
- */
- for ( chr = 'A'; chr <= '^'; ++chr )
- if ( chr != 'X' )
- { DEFINE_CLASS_COMMAND_ARGS('(', 0, chr, "Primary Symbol Set",
- pcl_primary_symbol_set,
- pca_neg_error|pca_big_error);
- DEFINE_CLASS_COMMAND_ARGS(')', 0, chr, "Secondary Symbol Set",
- pcl_secondary_symbol_set,
- pca_neg_error|pca_big_error);
- }
- }
- DEFINE_CLASS('(')
- {'s', 'P',
- PCL_COMMAND("Primary Spacing", pcl_primary_spacing,
- pca_neg_ignore|pca_big_ignore)},
- {'s', 'H',
- PCL_COMMAND("Primary Pitch", pcl_primary_pitch,
- pca_neg_error|pca_big_error)},
- {'s', 'V',
- PCL_COMMAND("Primary Height", pcl_primary_height,
- pca_neg_error|pca_big_error)},
- {'s', 'S',
- PCL_COMMAND("Primary Style", pcl_primary_style,
- pca_neg_error|pca_big_clamp)},
- {'s', 'B',
- PCL_COMMAND("Primary Stroke Weight", pcl_primary_stroke_weight,
- pca_neg_ok|pca_big_error)},
- {'s', 'T',
- PCL_COMMAND("Primary Typeface", pcl_primary_typeface,
- pca_neg_error|pca_big_ok)},
- {0, 'X',
- PCL_COMMAND("Primary Font Selection ID",
- pcl_primary_font_selection_id,
- pca_neg_error|pca_big_error)},
- {0, '@',
- PCL_COMMAND("Default Font Primary",
- pcl_select_default_font_primary,
- pca_neg_error|pca_big_error)},
- END_CLASS
- DEFINE_CLASS(')')
- {'s', 'P',
- PCL_COMMAND("Secondary Spacing", pcl_secondary_spacing,
- pca_neg_ignore|pca_big_ignore)},
- {'s', 'H',
- PCL_COMMAND("Secondary Pitch", pcl_secondary_pitch,
- pca_neg_error|pca_big_error)},
- {'s', 'V',
- PCL_COMMAND("Secondary Height", pcl_secondary_height,
- pca_neg_error|pca_big_error)},
- {'s', 'S',
- PCL_COMMAND("Secondary Style", pcl_secondary_style,
- pca_neg_error|pca_big_clamp)},
- {'s', 'B',
- PCL_COMMAND("Secondary Stroke Weight",
- pcl_secondary_stroke_weight,
- pca_neg_ok|pca_big_error)},
- {'s', 'T',
- PCL_COMMAND("Secondary Typeface", pcl_secondary_typeface,
- pca_neg_error|pca_big_ok)},
- {0, 'X',
- PCL_COMMAND("Secondary Font Selection ID",
- pcl_secondary_font_selection_id,
- pca_neg_error|pca_big_error)},
- {0, '@',
- PCL_COMMAND("Default Font Secondary",
- pcl_select_default_font_secondary,
- pca_neg_error|pca_big_error)},
- END_CLASS
- DEFINE_CONTROL(SO, "SO", pcl_SO)
- DEFINE_CONTROL(SI, "SI", pcl_SI)
- DEFINE_CLASS('&')
- {'k', 'S',
- PCL_COMMAND("Set Pitch Mode", pcl_set_pitch_mode,
- pca_neg_error|pca_big_error)},
- END_CLASS
- return 0;
+ { int chr;
+ /*
+ * The H-P manual only talks about A through Z, but it appears
+ * that characters from A through ^ (94) can be used.
+ */
+ for ( chr = 'A'; chr <= '^'; ++chr )
+ if ( chr != 'X' )
+ { DEFINE_CLASS_COMMAND_ARGS('(', 0, chr, "Primary Symbol Set",
+ pcl_primary_symbol_set,
+ pca_neg_error|pca_big_error);
+ DEFINE_CLASS_COMMAND_ARGS(')', 0, chr, "Secondary Symbol Set",
+ pcl_secondary_symbol_set,
+ pca_neg_error|pca_big_error);
+ }
+ }
+ DEFINE_CLASS('(')
+ {'s', 'P',
+ PCL_COMMAND("Primary Spacing", pcl_primary_spacing,
+ pca_neg_ignore|pca_big_ignore)},
+ {'s', 'H',
+ PCL_COMMAND("Primary Pitch", pcl_primary_pitch,
+ pca_neg_error|pca_big_error)},
+ {'s', 'V',
+ PCL_COMMAND("Primary Height", pcl_primary_height,
+ pca_neg_error|pca_big_error)},
+ {'s', 'S',
+ PCL_COMMAND("Primary Style", pcl_primary_style,
+ pca_neg_error|pca_big_clamp)},
+ {'s', 'B',
+ PCL_COMMAND("Primary Stroke Weight", pcl_primary_stroke_weight,
+ pca_neg_ok|pca_big_error)},
+ {'s', 'T',
+ PCL_COMMAND("Primary Typeface", pcl_primary_typeface,
+ pca_neg_error|pca_big_ok)},
+ {0, 'X',
+ PCL_COMMAND("Primary Font Selection ID",
+ pcl_primary_font_selection_id,
+ pca_neg_error|pca_big_error)},
+ {0, '@',
+ PCL_COMMAND("Default Font Primary",
+ pcl_select_default_font_primary,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ DEFINE_CLASS(')')
+ {'s', 'P',
+ PCL_COMMAND("Secondary Spacing", pcl_secondary_spacing,
+ pca_neg_ignore|pca_big_ignore)},
+ {'s', 'H',
+ PCL_COMMAND("Secondary Pitch", pcl_secondary_pitch,
+ pca_neg_error|pca_big_error)},
+ {'s', 'V',
+ PCL_COMMAND("Secondary Height", pcl_secondary_height,
+ pca_neg_error|pca_big_error)},
+ {'s', 'S',
+ PCL_COMMAND("Secondary Style", pcl_secondary_style,
+ pca_neg_error|pca_big_clamp)},
+ {'s', 'B',
+ PCL_COMMAND("Secondary Stroke Weight",
+ pcl_secondary_stroke_weight,
+ pca_neg_ok|pca_big_error)},
+ {'s', 'T',
+ PCL_COMMAND("Secondary Typeface", pcl_secondary_typeface,
+ pca_neg_error|pca_big_ok)},
+ {0, 'X',
+ PCL_COMMAND("Secondary Font Selection ID",
+ pcl_secondary_font_selection_id,
+ pca_neg_error|pca_big_error)},
+ {0, '@',
+ PCL_COMMAND("Default Font Secondary",
+ pcl_select_default_font_secondary,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ DEFINE_CONTROL(SO, "SO", pcl_SO)
+ DEFINE_CONTROL(SI, "SI", pcl_SI)
+ DEFINE_CLASS('&')
+ {'k', 'S',
+ PCL_COMMAND("Set Pitch Mode", pcl_set_pitch_mode,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ return 0;
}
/* look up pjl font number with data storage type. Return 0 on
@@ -470,7 +469,7 @@ pcfont_do_registration(
font for the active resource. */
static int
pcl_lookup_pjl_font(pcl_state_t *pcs, int pjl_font_number,
- pcl_data_storage_t pcl_data_storage, pl_font_params_t *params)
+ pcl_data_storage_t pcl_data_storage, pl_font_params_t *params)
{
pl_dict_enum_t dictp;
gs_const_string key;
@@ -479,15 +478,15 @@ pcl_lookup_pjl_font(pcl_state_t *pcs, int pjl_font_number,
pl_dict_enum_begin(&pcs->soft_fonts, &dictp);
while ( pl_dict_enum_next(&dictp, &key, &value) ) {
- pl_font_t *fp = (pl_font_t *)value;
- int ds = fp->storage;
- if ( (int)pcl_data_storage == ds ) {
- found_resource = true;
- *params = fp->params;
- if ( fp->params.pjl_font_number == pjl_font_number ) {
- return 0;
- }
- }
+ pl_font_t *fp = (pl_font_t *)value;
+ int ds = fp->storage;
+ if ( (int)pcl_data_storage == ds ) {
+ found_resource = true;
+ *params = fp->params;
+ if ( fp->params.pjl_font_number == pjl_font_number ) {
+ return 0;
+ }
+ }
}
return (found_resource ? 1 : -1);
}
@@ -500,102 +499,102 @@ pcl_set_current_font_environment(pcl_state_t *pcs)
pcl's storage identifier to mirror pjl's */
pcl_data_storage_t pcl_data_storage;
while( 1 ) {
- /* get current font source */
- pjl_envvar_t *fontsource = pjl_proc_get_envvar(pcs->pjls, "fontsource");
- switch (fontsource[0]) {
- case 'I':
- /* NB what happens if pjl command is not I - hmmph? */
- if (!pl_load_built_in_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
- pcs->memory,
- &pcs->built_in_fonts,
- pcs->font_dir, (int)pcds_internal,
- false /* do not use unicode font names for keys */ ))
+ /* get current font source */
+ pjl_envvar_t *fontsource = pjl_proc_get_envvar(pcs->pjls, "fontsource");
+ switch (fontsource[0]) {
+ case 'I':
+ /* NB what happens if pjl command is not I - hmmph? */
+ if (!pl_load_built_in_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
+ pcs->memory,
+ &pcs->built_in_fonts,
+ pcs->font_dir, (int)pcds_internal,
+ false /* do not use unicode font names for keys */ ))
/* simply continue without fonts if none are found */
return 0;
- pcl_data_storage = pcds_internal;
- break;
- case 'S':
- /* nothing to load */
- pcl_data_storage = pcds_permanent;
- break;
- /* NB we incorrectly treat C, C1, C2... as one collective resource */
- case 'C':
- if ( !pl_load_cartridge_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
- pcs->memory,
- &pcs->cartridge_fonts,
- pcs->font_dir, (int)pcds_all_cartridges)) {
- pjl_proc_set_next_fontsource(pcs->pjls);
- continue; /* try next resource */
- }
- pcl_data_storage = pcds_all_cartridges;
- break;
- /* NB we incorrectly treat M, M1, M2... as one collective resource */
- case 'M':
- if ( !pl_load_simm_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
- pcs->memory,
- &pcs->simm_fonts,
- pcs->font_dir, (int)pcds_all_simms)) {
-
- continue; /* try next resource */
- }
- pcl_data_storage = pcds_all_simms;
- break;
- default:
- dprintf("pcfont.c: unknown pjl resource\n");
- return -1;
- }
- {
- int code;
- pl_font_params_t params;
- code = pcl_lookup_pjl_font(pcs,
- pjl_proc_vartoi(pcs->pjls,
- pjl_proc_get_envvar(pcs->pjls, "fontnumber")),
- pcl_data_storage, &params);
- /* resource found, but if code is 1 we did not match the
+ pcl_data_storage = pcds_internal;
+ break;
+ case 'S':
+ /* nothing to load */
+ pcl_data_storage = pcds_permanent;
+ break;
+ /* NB we incorrectly treat C, C1, C2... as one collective resource */
+ case 'C':
+ if ( !pl_load_cartridge_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
+ pcs->memory,
+ &pcs->cartridge_fonts,
+ pcs->font_dir, (int)pcds_all_cartridges)) {
+ pjl_proc_set_next_fontsource(pcs->pjls);
+ continue; /* try next resource */
+ }
+ pcl_data_storage = pcds_all_cartridges;
+ break;
+ /* NB we incorrectly treat M, M1, M2... as one collective resource */
+ case 'M':
+ if ( !pl_load_simm_fonts(pjl_proc_fontsource_to_path(pcs->pjls, fontsource),
+ pcs->memory,
+ &pcs->simm_fonts,
+ pcs->font_dir, (int)pcds_all_simms)) {
+
+ continue; /* try next resource */
+ }
+ pcl_data_storage = pcds_all_simms;
+ break;
+ default:
+ dprintf("pcfont.c: unknown pjl resource\n");
+ return -1;
+ }
+ {
+ int code;
+ pl_font_params_t params;
+ code = pcl_lookup_pjl_font(pcs,
+ pjl_proc_vartoi(pcs->pjls,
+ pjl_proc_get_envvar(pcs->pjls, "fontnumber")),
+ pcl_data_storage, &params);
+ /* resource found, but if code is 1 we did not match the
font number. NB unsure what to do when code == 1. */
- if ( code >= 0 ) {
- /* copy parameters to the requested font and
- apply the other pjl settings to construct the
- initial font request from pjltrm: "The recommended
- order for setting FONTNUMBER, FONTSOURCE, and
- SYMSET is SYMSET first, then FONTSOURCE, then
- FONTNUMBER". Perhaps this is a clue as to how
- these interact. We search for the font number in
- the fontsource and apply pjl's SYMSET, PTSIZE and
- PITCH to the font we found. That in turn becomes
- the default requested font */
- pcs->font_selection[0].params = params;
- pcs->default_symbol_set_value = pcs->font_selection[0].params.symbol_set;
- /* NB: The fontsource and fontnumber selection
+ if ( code >= 0 ) {
+ /* copy parameters to the requested font and
+ apply the other pjl settings to construct the
+ initial font request from pjltrm: "The recommended
+ order for setting FONTNUMBER, FONTSOURCE, and
+ SYMSET is SYMSET first, then FONTSOURCE, then
+ FONTNUMBER". Perhaps this is a clue as to how
+ these interact. We search for the font number in
+ the fontsource and apply pjl's SYMSET, PTSIZE and
+ PITCH to the font we found. That in turn becomes
+ the default requested font */
+ pcs->font_selection[0].params = params;
+ pcs->default_symbol_set_value = pcs->font_selection[0].params.symbol_set;
+ /* NB: The fontsource and fontnumber selection
parameters get stepped on next, unless pjl symset,
pitch and ptsize are properly updated by the PJL
interpreter when the font changes. Our pjl
interpreter does not currently do this.
Consequently wrong selections are possible. */
- pcs->default_symbol_set_value = pcs->font_selection[0].params.symbol_set =
- pjl_proc_map_pjl_sym_to_pcl_sym(pcs->pjls,
+ pcs->default_symbol_set_value = pcs->font_selection[0].params.symbol_set =
+ pjl_proc_map_pjl_sym_to_pcl_sym(pcs->pjls,
pjl_proc_get_envvar(pcs->pjls, "symset"));
- pl_fp_set_pitch_per_inch(&pcs->font_selection[0].params,
- pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "pitch")));
- pcs->font_selection[0].params.height_4ths =
+ pl_fp_set_pitch_per_inch(&pcs->font_selection[0].params,
+ pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "pitch")));
+ pcs->font_selection[0].params.height_4ths =
pjl_proc_vartof(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "ptsize")) * 4.0;
- pcs->font_selection[0].font = 0;
- pcs->font_selection[0].selected_id = (uint)-1;
- pcs->font_selection[1] = pcs->font_selection[0];
- pcs->font_selected = primary;
- pcs->font = 0;
- }
- else {
- /* no resouce found - Note for everything but 'S' this
- is a double check, since we should have failed when
- checking for the resource Note this is fatal for
- internal resources but should be caught above. */
- pjl_proc_set_next_fontsource(pcs->pjls);
- continue; /* try next resource */
-
- }
- }
- return 0; /* done */
+ pcs->font_selection[0].font = 0;
+ pcs->font_selection[0].selected_id = (uint)-1;
+ pcs->font_selection[1] = pcs->font_selection[0];
+ pcs->font_selected = primary;
+ pcs->font = 0;
+ }
+ else {
+ /* no resouce found - Note for everything but 'S' this
+ is a double check, since we should have failed when
+ checking for the resource Note this is fatal for
+ internal resources but should be caught above. */
+ pjl_proc_set_next_fontsource(pcs->pjls);
+ continue; /* try next resource */
+
+ }
+ }
+ return 0; /* done */
}
}
@@ -615,48 +614,48 @@ pcl_unload_resident_fonts(pcl_state_t *pcs)
affect soft fonts */
pl_dict_enum_begin(&pcs->soft_fonts, &dictp);
while ( pl_dict_enum_next(&dictp, &key, &value) ) {
- pl_font_t *plfont = (pl_font_t *)value;
- if ( plfont->font_file )
- if ( pl_store_resident_font_data_in_file(plfont->font_file, pcs->memory, plfont) < 0 )
- dprintf1("%s", "could not store data" );
-
+ pl_font_t *plfont = (pl_font_t *)value;
+ if ( plfont->font_file )
+ if ( pl_store_resident_font_data_in_file(plfont->font_file, pcs->memory, plfont) < 0 )
+ dprintf1("%s", "could not store data" );
+
}
}
static void
pcfont_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
-{
+{
if ((type & pcl_reset_initial) != 0) {
- pcs->font_dir = gs_font_dir_alloc(pcs->memory);
+ pcs->font_dir = gs_font_dir_alloc(pcs->memory);
/* disable hinting at high res */
if (gs_currentdevice(pcs->pgs)->HWResolution[0] >= 300)
gs_setgridfittt(pcs->font_dir, 0);
- pcs->font = 0;
- pcs->font_selection[0].font =
- pcs->font_selection[1].font = 0;
- pcs->font_selected = primary;
- pl_dict_init(&pcs->built_in_fonts, pcs->memory, pl_free_font);
- pl_dict_init(&pcs->soft_fonts, pcs->memory, pl_free_font);
- pl_dict_init(&pcs->cartridge_fonts, pcs->memory, pl_free_font);
- pl_dict_init(&pcs->simm_fonts, pcs->memory, pl_free_font);
- pl_dict_set_parent(&pcs->soft_fonts, &pcs->built_in_fonts);
- pl_dict_set_parent(&pcs->cartridge_fonts, &pcs->soft_fonts);
- pl_dict_set_parent(&pcs->simm_fonts, &pcs->cartridge_fonts);
+ pcs->font = 0;
+ pcs->font_selection[0].font =
+ pcs->font_selection[1].font = 0;
+ pcs->font_selected = primary;
+ pl_dict_init(&pcs->built_in_fonts, pcs->memory, pl_free_font);
+ pl_dict_init(&pcs->soft_fonts, pcs->memory, pl_free_font);
+ pl_dict_init(&pcs->cartridge_fonts, pcs->memory, pl_free_font);
+ pl_dict_init(&pcs->simm_fonts, pcs->memory, pl_free_font);
+ pl_dict_set_parent(&pcs->soft_fonts, &pcs->built_in_fonts);
+ pl_dict_set_parent(&pcs->cartridge_fonts, &pcs->soft_fonts);
+ pl_dict_set_parent(&pcs->simm_fonts, &pcs->cartridge_fonts);
}
if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay) ) {
- int code = 0;
- if ( pcs->personality != rtl )
- code = pcl_set_current_font_environment(pcs);
- /* corrupt configuration */
- if ( code != 0 )
- exit( 1 );
+ int code = 0;
+ if ( pcs->personality != rtl )
+ code = pcl_set_current_font_environment(pcs);
+ /* corrupt configuration */
+ if ( code != 0 )
+ exit( 1 );
}
if ( type & pcl_reset_permanent ) {
- pcl_unload_resident_fonts(pcs);
- pl_dict_release(&pcs->soft_fonts);
- pl_dict_release(&pcs->built_in_fonts);
- pl_dict_release(&pcs->cartridge_fonts);
- pl_dict_release(&pcs->simm_fonts);
+ pcl_unload_resident_fonts(pcs);
+ pl_dict_release(&pcs->soft_fonts);
+ pl_dict_release(&pcs->built_in_fonts);
+ pl_dict_release(&pcs->cartridge_fonts);
+ pl_dict_release(&pcs->simm_fonts);
}
}
diff --git a/pcl/pcfont.h b/pcl/pcfont.h
index e0c12b7e9..3995b2a2c 100644
--- a/pcl/pcfont.h
+++ b/pcl/pcfont.h
@@ -38,7 +38,7 @@ int pcl_recompute_font(pcl_state_t * pcs, bool internal_only);
#define pcl_break_underline(pcs) \
BEGIN \
if (pcs->underline_enabled) \
- pcl_do_underline(pcs); \
+ pcl_do_underline(pcs); \
END
/* ...and then, after repositioning, restart underlining if necessary... */
diff --git a/pcl/pcfontpg.c b/pcl/pcfontpg.c
index 4f63afae1..4b08c0708 100644
--- a/pcl/pcfontpg.c
+++ b/pcl/pcfontpg.c
@@ -28,8 +28,8 @@ static inline void
print_blank_lines(pcl_state_t *pcs, int count)
{
while( count-- ) {
- pcl_do_CR(pcs);
- pcl_do_LF(pcs);
+ pcl_do_CR(pcs);
+ pcl_do_LF(pcs);
}
}
@@ -105,19 +105,19 @@ pcl_print_font_page(pcl_args_t *pargs, pcl_state_t *pcs)
/* font page header */
{
- const char *header_str = "PCL Font List";
- const char *sample_str = "Sample";
- const char *select_str = "Font Selection Command";
- uint hlen = strlen(header_str);
- /* assume the pcl font list string is 1 inch 7200 units */
- uint pos = pcs->margins.right / 2 - 7200 / 2;
- pcl_set_cap_x(pcs, pos, false, false);
- pcl_text((byte *)header_str, hlen, pcs, false);
- print_blank_lines(pcs, 2);
- pcl_text((byte *)sample_str, strlen(sample_str), pcs, false);
- pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
- pcl_text((byte *)select_str, strlen(select_str), pcs, false);
- print_blank_lines(pcs, 2);
+ const char *header_str = "PCL Font List";
+ const char *sample_str = "Sample";
+ const char *select_str = "Font Selection Command";
+ uint hlen = strlen(header_str);
+ /* assume the pcl font list string is 1 inch 7200 units */
+ uint pos = pcs->margins.right / 2 - 7200 / 2;
+ pcl_set_cap_x(pcs, pos, false, false);
+ pcl_text((byte *)header_str, hlen, pcs, false);
+ print_blank_lines(pcs, 2);
+ pcl_text((byte *)sample_str, strlen(sample_str), pcs, false);
+ pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
+ pcl_text((byte *)select_str, strlen(select_str), pcs, false);
+ print_blank_lines(pcs, 2);
}
/* enumerate all non-resident fonts.*/
diff --git a/pcl/pcfrgrnd.c b/pcl/pcfrgrnd.c
index 979cf0c6f..ffb02df1d 100644
--- a/pcl/pcfrgrnd.c
+++ b/pcl/pcfrgrnd.c
@@ -20,7 +20,6 @@
/* GC routines */
private_st_frgrnd_t();
-
/*
* Free a pcl foreground object.
*/
@@ -49,7 +48,7 @@ free_foreground(
*/
static int
alloc_foreground(
- pcl_state_t *pcs,
+ pcl_state_t *pcs,
pcl_frgrnd_t ** ppfrgrnd,
gs_memory_t * pmem
)
@@ -95,7 +94,7 @@ build_foreground(
bool is_default = false;
int code = 0;
- /*
+ /*
* Check for a request for the default foreground. Since there are only
* three fixed palettes, it is sufficient to check that the palette provided
* is fixed and has two entries. The default foreground is black, which is
@@ -124,15 +123,15 @@ build_foreground(
/* pal_entry is interpreted modulo the current palette size */
if ((pal_entry < 0) || (pal_entry >= num_entries)) {
- if (pindexed->is_GL) {
- int max_pen = num_entries -1;
- while (pal_entry > max_pen)
- pal_entry -= max_pen;
- } else {
- pal_entry %= num_entries;
- if (pal_entry < 0)
- pal_entry += num_entries;
- }
+ if (pindexed->is_GL) {
+ int max_pen = num_entries -1;
+ while (pal_entry > max_pen)
+ pal_entry -= max_pen;
+ } else {
+ pal_entry %= num_entries;
+ if (pal_entry < 0)
+ pal_entry += num_entries;
+ }
}
pfrgrnd->is_cmy = (ppalet->pindexed->original_cspace == 1);
@@ -166,7 +165,7 @@ pcl_frgrnd_set_default_foreground(
return code;
return build_foreground( pcs,
- &(pcs->pfrgrnd),
+ &(pcs->pfrgrnd),
pcs->ppalet,
1,
pcs->memory
@@ -187,21 +186,20 @@ set_foreground(
int code;
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
/* check that the palette is complete */
if ((code = pcl_palette_check_complete(pcs)) < 0)
return code;
return build_foreground( pcs,
- &(pcs->pfrgrnd),
+ &(pcs->pfrgrnd),
pcs->ppalet,
int_arg(pargs),
pcs->memory
);
}
-
/*
* Initialization, reset, and copy procedures.
*
@@ -216,7 +214,7 @@ frgrnd_do_registration(
{
DEFINE_CLASS('*')
{
- 'v', 'S',
+ 'v', 'S',
PCL_COMMAND("Set Foreground", set_foreground, pca_neg_ok | pca_raster_graphics)
},
END_CLASS
@@ -229,7 +227,7 @@ frgrnd_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
if ( type & (pcl_reset_permanent) ) {
rc_decrement(pcs->pfrgrnd, "foreground reset pfrgrnd");
rc_decrement(pcs->pdflt_frgrnd, "foreground reset pdflt_frgrnd");
- rc_decrement(pcs->pwhite_cs, "foreground reset p_white_cs");
+ rc_decrement(pcs->pwhite_cs, "foreground reset p_white_cs");
}
}
@@ -248,21 +246,20 @@ frgrnd_do_copy(
}
/* (white pattern or white foreground color) and transparent pattern
- * is a NOP
+ * is a NOP
*/
-bool
-is_invisible_pattern( pcl_state_t *pcs )
+bool
+is_invisible_pattern( pcl_state_t *pcs )
{
if ( pcs->pattern_transparent ) {
- if (pcs->pattern_type == pcl_pattern_solid_white )
- return true;
- if ( pcs->pfrgrnd->color[0] == 0xff &&
- pcs->pfrgrnd->color[1] == 0xff &&
- pcs->pfrgrnd->color[2] == 0xff )
- return true; /* NB: depends on CMY conversion to internal RGB */
+ if (pcs->pattern_type == pcl_pattern_solid_white )
+ return true;
+ if ( pcs->pfrgrnd->color[0] == 0xff &&
+ pcs->pfrgrnd->color[1] == 0xff &&
+ pcs->pfrgrnd->color[2] == 0xff )
+ return true; /* NB: depends on CMY conversion to internal RGB */
}
return false;
}
-
const pcl_init_t pcl_frgrnd_init = { frgrnd_do_registration, frgrnd_do_reset, frgrnd_do_copy };
diff --git a/pcl/pcfrgrnd.h b/pcl/pcfrgrnd.h
index 95ea9f66d..fe4b8ea31 100644
--- a/pcl/pcfrgrnd.h
+++ b/pcl/pcfrgrnd.h
@@ -61,13 +61,13 @@
* uncolored patterns.
*
* HP Bug is_cmy is set when the base colorspace of the foreground color
- * is CMY.
- * if foreground colorspace is the different than palette's force black
+ * is CMY.
+ * if foreground colorspace is the different than palette's force black
* CMY foreground + RGB raster --> black + raster
* RGB foreground + CMY raster --> black + raster
* else same colorspaces:
* foreground + raster -> fg_color + raster
- * This is an HP bug in the 4550 4600.
+ * This is an HP bug in the 4550 4600.
*/
struct pcl_frgrnd_s {
rc_header rc;
@@ -128,11 +128,11 @@ typedef struct pcl_frgrnd_s pcl_frgrnd_t;
*/
int pcl_frgrnd_set_default_foreground(pcl_state_t * pcs);
-/* checks for:
+/* checks for:
* (white pattern or white foreground color) and transparent pattern
- * is a NOP
+ * is a NOP
*/
-bool
+bool
is_invisible_pattern( pcl_state_t *pcs );
-
+
#endif /* pcfrgrnd_INCLUDED */
diff --git a/pcl/pcfsel.c b/pcl/pcfsel.c
index a8059c95c..1ae47a9c9 100644
--- a/pcl/pcfsel.c
+++ b/pcl/pcfsel.c
@@ -64,21 +64,21 @@ static const char * const score_name[] = {
static void
dprint_cc(const byte *pcc)
{ dprintf8("cc=%02x %02x %02x %02x %02x %02x %02x %02x", pcc[0],
- pcc[1], pcc[2], pcc[3], pcc[4], pcc[5], pcc[6], pcc[7]);
+ pcc[1], pcc[2], pcc[3], pcc[4], pcc[5], pcc[6], pcc[7]);
}
void
dprint_font_params_t(const pl_font_params_t *pfp)
{ dprintf8("symset=%u %s pitch=%g ht=%u style=%u wt=%d face=%u:%u\n",
- pfp->symbol_set,
- (pfp->proportional_spacing ? "prop." : "fixed"),
- pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths / 4, pfp->style,
- pfp->stroke_weight, pfp->typeface_family, (0x07FF &pfp->typeface_family) );
+ pfp->symbol_set,
+ (pfp->proportional_spacing ? "prop." : "fixed"),
+ pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths / 4, pfp->style,
+ pfp->stroke_weight, pfp->typeface_family, (0x07FF &pfp->typeface_family) );
}
#include "plftable.h"
static void
-dprint_font_name(const pl_font_t *pfont)
+dprint_font_name(const pl_font_t *pfont)
{
int i;
bool found = false;
@@ -104,7 +104,7 @@ dprint_font_name(const pl_font_t *pfont)
static void
dprint_font_t(const pl_font_t *pfont)
-{
+{
dprint_font_name(pfont);
dprintf3("storage=%d scaling=%d type=%d ",
pfont->storage, pfont->scaling_technology, pfont->font_type);
@@ -165,7 +165,6 @@ check_support(const pcl_state_t *pcs, uint symbol_set, const pl_font_t *fp,
if (pl_font_is_bound(fp))
return fp->params.symbol_set == symbol_set ? 2 : 0;
-
if (*mapp == 0) {
/* selecting by id and did not find the symbol map specified
@@ -174,7 +173,7 @@ check_support(const pcl_state_t *pcs, uint symbol_set, const pl_font_t *fp,
if (id_selection || pl_wide_encoding(symbol_set))
return 2;
else {
- /*
+ /*
* Interestingly, if we look up a symbol set that does not
* exist the default symbol set is replaced with roman-8.
* This is certainly a bug in HP printers.
@@ -191,9 +190,9 @@ check_support(const pcl_state_t *pcs, uint symbol_set, const pl_font_t *fp,
if ( pcl_check_symbol_support((*mapp)->character_requirements,
fp->character_complement) )
- return 2; /* best */
+ return 2; /* best */
else
- return 1;
+ return 1;
}
/* Identify the internal lineprinter font */
@@ -211,97 +210,96 @@ font_is_scalable_selection_wise(const pl_font_t *fp)
else
return pl_font_is_scalable(fp);
}
-
-
+
/* Compute a font's score against selection parameters. TRM 8-27.
* Also set *mapp to the symbol map to be used if this font wins. */
static void
score_match(const pcl_state_t *pcs, const pcl_font_selection_t *pfs,
const pl_font_t *fp, pl_symbol_map_t **mapp, match_score_t score)
{
- int tscore;
+ int tscore;
- /* 1. Symbol set. 2 for exact match or full support, 1 for
- * default supported, 0 for no luck. */
+ /* 1. Symbol set. 2 for exact match or full support, 1 for
+ * default supported, 0 for no luck. */
score[score_symbol_set] = check_support(pcs, pfs->params.symbol_set, fp, mapp, false);
- /* 2. Spacing. */
- score[score_spacing] =
- pfs->params.proportional_spacing == fp->params.proportional_spacing;
-
- /* 3. Pitch. */
- /* Need to score this so that (1) exact match is highest, (2) any
- * higher-than-requested pitch is better than any lower-than-
- * requested pitch, (3) within these categories, nearer is better. */
- if ( pfs->params.proportional_spacing )
- score[score_pitch] = 0; /* should not influence score */
- else { /* fixed space selection */
+ /* 2. Spacing. */
+ score[score_spacing] =
+ pfs->params.proportional_spacing == fp->params.proportional_spacing;
+
+ /* 3. Pitch. */
+ /* Need to score this so that (1) exact match is highest, (2) any
+ * higher-than-requested pitch is better than any lower-than-
+ * requested pitch, (3) within these categories, nearer is better. */
+ if ( pfs->params.proportional_spacing )
+ score[score_pitch] = 0; /* should not influence score */
+ else { /* fixed space selection */
if ( fp->params.proportional_spacing )
/* scalable; match is worst possible */
score[score_pitch] = 0;
- else {
+ else {
int delta = pl_fp_pitch_per_inch_x100(&fp->params) -
- pl_fp_pitch_per_inch_x100(&pfs->params);
+ pl_fp_pitch_per_inch_x100(&pfs->params);
- /* If within one unit, call it exact; otherwise give
- * preference to higher pitch than requested. */
- if (font_is_scalable_selection_wise(fp) || (abs(delta) <= 10 ))
+ /* If within one unit, call it exact; otherwise give
+ * preference to higher pitch than requested. */
+ if (font_is_scalable_selection_wise(fp) || (abs(delta) <= 10 ))
score[score_pitch] = 0x2000000;
- else if ( delta > 0 )
+ else if ( delta > 0 )
score[score_pitch] = 0x2000000 - delta;
- else
+ else
score[score_pitch] = 0x1000000 + delta;
}
}
- /* 4. Height. */
- /* Closest match scores highest (no preference for + or -). Otherwise
- * similar to pitch, and again, values assigned have no meaning out-
- * side this code. */
- if ( font_is_scalable_selection_wise(fp) )
- score[score_height] = 0x1000000;
- else
- { int delta = abs(pfs->params.height_4ths - fp->params.height_4ths);
-
- /* As before, allow one unit of error to appear "exact". */
- if ( delta <= 1 )
- delta = 0;
- score[score_height] = 0x1000000 - delta;
- }
-
- /* 5. Style. */
- if ( pfs->params.style == fp->params.style )
- score[score_style] = 2;
- else if ( fp->params.style == 0 && pfs->params.style != 0 )
- score[score_style] = 1; /* prefer NO style fonts to wrong style */
- else
- score[score_style] = 0;
-
- /* 6. Stroke Weight. */
- /* If not exact match, prefer closest value away from 0 (more
- * extreme). If none, then prefer closest value nearer 0. Once
- * again, the actual values assigned here have no meaning outside
- * this chunk of code. */
- { /* Worst cases (font value toward zero from request) 0..13.
- * Nearest more extreme: 14..21. 21 is exact. */
- int fwt = fp->params.stroke_weight;
- int pwt = pfs->params.stroke_weight;
- int delta = pwt - fwt;
-
- /* With a little time, this could be collapsed. */
- if ( pwt >= 0 )
- if ( fwt >= pwt )
- tscore = 21 + delta;
- else
- tscore = 14 - delta;
- else
- if ( fwt <= pwt )
- tscore = 21 - delta;
- else
- tscore = 14 + delta;
- score[score_weight] = tscore;
- }
-
- /* 7. Typeface family. */
- {
+ /* 4. Height. */
+ /* Closest match scores highest (no preference for + or -). Otherwise
+ * similar to pitch, and again, values assigned have no meaning out-
+ * side this code. */
+ if ( font_is_scalable_selection_wise(fp) )
+ score[score_height] = 0x1000000;
+ else
+ { int delta = abs(pfs->params.height_4ths - fp->params.height_4ths);
+
+ /* As before, allow one unit of error to appear "exact". */
+ if ( delta <= 1 )
+ delta = 0;
+ score[score_height] = 0x1000000 - delta;
+ }
+
+ /* 5. Style. */
+ if ( pfs->params.style == fp->params.style )
+ score[score_style] = 2;
+ else if ( fp->params.style == 0 && pfs->params.style != 0 )
+ score[score_style] = 1; /* prefer NO style fonts to wrong style */
+ else
+ score[score_style] = 0;
+
+ /* 6. Stroke Weight. */
+ /* If not exact match, prefer closest value away from 0 (more
+ * extreme). If none, then prefer closest value nearer 0. Once
+ * again, the actual values assigned here have no meaning outside
+ * this chunk of code. */
+ { /* Worst cases (font value toward zero from request) 0..13.
+ * Nearest more extreme: 14..21. 21 is exact. */
+ int fwt = fp->params.stroke_weight;
+ int pwt = pfs->params.stroke_weight;
+ int delta = pwt - fwt;
+
+ /* With a little time, this could be collapsed. */
+ if ( pwt >= 0 )
+ if ( fwt >= pwt )
+ tscore = 21 + delta;
+ else
+ tscore = 14 - delta;
+ else
+ if ( fwt <= pwt )
+ tscore = 21 - delta;
+ else
+ tscore = 14 + delta;
+ score[score_weight] = tscore;
+ }
+
+ /* 7. Typeface family. */
+ {
uint diff = pfs->params.typeface_family - fp->params.typeface_family;
if (diff == 0)
score[score_typeface] = 2;
@@ -312,52 +310,52 @@ score_match(const pcl_state_t *pcs, const pcl_font_selection_t *pfs,
else
score[score_typeface] = 0;
}
- }
-
- /* 8. Location. */
- /* Rearrange the value from "storage" into priority for us. We
- * only care that we get the priority sequence: soft-font, cartridge,
- * SIMM, and internal, and that we order at least 2 cartridges. (TRM
- * implies that SIMMs are *not* to be ordered.) Once again, values
- * assigned here have no external meaning. */
- /* 1 bit at bottom for SIMM _vs_ internal, then cartridge-number
- * bits, then soft-font bit at top. */
- if ( fp->storage & pcds_downloaded )
- tscore = 1 << (pcds_cartridge_max + 1);
- else if ( fp->storage & pcds_all_cartridges )
- tscore = (fp->storage & pcds_all_cartridges) >>
- (pcds_cartridge_shift - 1);
- else
- /* no priority among SIMMs, and internal is 0 */
- tscore = (fp->storage & pcds_all_simms)? 1: 0;
- score[score_location] = tscore;
-
- /* 9. Orientation */
- if ( fp->scaling_technology != plfst_bitmap )
- score[score_orientation] = 1;
- else
- { pcl_font_header_t *fhp = (pcl_font_header_t *)(fp->header);
-
- score[score_orientation] = fhp?
- fhp->Orientation == pcs->xfm_state.lp_orient :
- 0;
- }
-
- /* 10. Location: 11 in the implementors Guide.
- * lower typeface ID's are better.
- * supposed to be ordered by bitmap/scalable and SoftFont ... Internal but
- * these didn't seem to have an effect.
- *
- * Lineprinter has a special case, making it harder to accidently select.
- */
-
- if (INTERNAL_LPFONT)
- score[score_fontnumber] = 0x100000 - fp->params.typeface_family;
- else
- score[score_fontnumber] = 0x200000 - fp->params.typeface_family;
+ }
+
+ /* 8. Location. */
+ /* Rearrange the value from "storage" into priority for us. We
+ * only care that we get the priority sequence: soft-font, cartridge,
+ * SIMM, and internal, and that we order at least 2 cartridges. (TRM
+ * implies that SIMMs are *not* to be ordered.) Once again, values
+ * assigned here have no external meaning. */
+ /* 1 bit at bottom for SIMM _vs_ internal, then cartridge-number
+ * bits, then soft-font bit at top. */
+ if ( fp->storage & pcds_downloaded )
+ tscore = 1 << (pcds_cartridge_max + 1);
+ else if ( fp->storage & pcds_all_cartridges )
+ tscore = (fp->storage & pcds_all_cartridges) >>
+ (pcds_cartridge_shift - 1);
+ else
+ /* no priority among SIMMs, and internal is 0 */
+ tscore = (fp->storage & pcds_all_simms)? 1: 0;
+ score[score_location] = tscore;
+
+ /* 9. Orientation */
+ if ( fp->scaling_technology != plfst_bitmap )
+ score[score_orientation] = 1;
+ else
+ { pcl_font_header_t *fhp = (pcl_font_header_t *)(fp->header);
+
+ score[score_orientation] = fhp?
+ fhp->Orientation == pcs->xfm_state.lp_orient :
+ 0;
+ }
+
+ /* 10. Location: 11 in the implementors Guide.
+ * lower typeface ID's are better.
+ * supposed to be ordered by bitmap/scalable and SoftFont ... Internal but
+ * these didn't seem to have an effect.
+ *
+ * Lineprinter has a special case, making it harder to accidently select.
+ */
+
+ if (INTERNAL_LPFONT)
+ score[score_fontnumber] = 0x100000 - fp->params.typeface_family;
+ else
+ score[score_fontnumber] = 0x200000 - fp->params.typeface_family;
#ifdef DEBUG
- if ( gs_debug_c('=') )
+ if ( gs_debug_c('=') )
dprintf_font_scoring("candidate", fp, *mapp, score);
#endif
@@ -368,64 +366,64 @@ score_match(const pcl_state_t *pcs, const pcl_font_selection_t *pfs,
int
pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool internal_only)
{ if ( pfs->font == 0 )
- { pl_dict_enum_t dictp;
- gs_const_string key;
- void *value;
- pl_font_t *best_font = 0;
- pl_symbol_map_t *best_map = 0;
- pl_symbol_map_t *mapp = 0;
- match_score_t best_match;
+ { pl_dict_enum_t dictp;
+ gs_const_string key;
+ void *value;
+ pl_font_t *best_font = 0;
+ pl_symbol_map_t *best_map = 0;
+ pl_symbol_map_t *mapp = 0;
+ match_score_t best_match;
score_index_t i;
#ifdef DEBUG
- if ( gs_debug_c('=') )
- { dputs("[=]request: ");
- dprint_font_params_t(&pfs->params);
- }
+ if ( gs_debug_c('=') )
+ { dputs("[=]request: ");
+ dprint_font_params_t(&pfs->params);
+ }
#endif
- /* if the font table is set up to select character by id
+ /* if the font table is set up to select character by id
we attempt to reselect the font by id. As a fallback
we use family selection. NB We do not correctly handle
the fonts with alphanumeric id's */
- if ( (int)pfs->selected_id >= 0 ) {
- byte id_key[2];
- void *value;
- id_key[0] = pfs->selected_id >> 8;
- id_key[1] = (byte)(pfs->selected_id);
- if ( pl_dict_find((pl_dict_t *)&pcs->soft_fonts, id_key, 2, &value) ) {
-
- pfs->font = (pl_font_t *)value;
+ if ( (int)pfs->selected_id >= 0 ) {
+ byte id_key[2];
+ void *value;
+ id_key[0] = pfs->selected_id >> 8;
+ id_key[1] = (byte)(pfs->selected_id);
+ if ( pl_dict_find((pl_dict_t *)&pcs->soft_fonts, id_key, 2, &value) ) {
+
+ pfs->font = (pl_font_t *)value;
(void)check_support(pcs, pfs->params.symbol_set, pfs->font, &pfs->map, true);
return 0;
- }
- }
- /* Initialize the best match to be worse than any real font. */
+ }
+ }
+ /* Initialize the best match to be worse than any real font. */
for (i=(score_index_t)0; i<score_limit; i++)
best_match[i] = -1;
- pl_dict_enum_begin(&pcs->soft_fonts, &dictp);
- while ( pl_dict_enum_next(&dictp, &key, &value) )
- { pl_font_t *fp = (pl_font_t *)value;
- match_score_t match;
+ pl_dict_enum_begin(&pcs->soft_fonts, &dictp);
+ while ( pl_dict_enum_next(&dictp, &key, &value) )
+ { pl_font_t *fp = (pl_font_t *)value;
+ match_score_t match;
if ((internal_only) && fp->storage != pcds_internal)
continue;
- score_match(pcs, pfs, fp, &mapp, match);
+ score_match(pcs, pfs, fp, &mapp, match);
#ifdef DEBUG
if ( gs_debug_c('=') ) {
if (best_match[0] != -1) /* skip sentinel */
dprintf_font_scoring("best", best_font, mapp, best_match);
}
#endif
- for (i=(score_index_t)0; i<score_limit; i++)
- if ( match[i] != best_match[i] )
- {
- if ( match[i] > best_match[i] )
- {
- best_font = fp;
- best_map = mapp;
- memcpy((void*)best_match, (void*)match,
- sizeof(match));
+ for (i=(score_index_t)0; i<score_limit; i++)
+ if ( match[i] != best_match[i] )
+ {
+ if ( match[i] > best_match[i] )
+ {
+ best_font = fp;
+ best_map = mapp;
+ memcpy((void*)best_match, (void*)match,
+ sizeof(match));
#ifdef DEBUG
if ( gs_debug_c('=') ) {
dprintf_font_scoring("usurper", fp, mapp, best_match);
@@ -434,11 +432,11 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
}
#endif
- }
- break;
- }
- }
- if ( best_font == 0 )
+ }
+ break;
+ }
+ }
+ if ( best_font == 0 )
return -1; /* no fonts */
#ifdef DEBUG
if ( gs_debug_c('=') ) {
@@ -446,61 +444,61 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
}
#endif
- pfs->font = best_font;
- pfs->map = best_map;
- }
- pfs->selected_id = (uint)-1;
- return 0;
+ pfs->font = best_font;
+ pfs->map = best_map;
+ }
+ pfs->selected_id = (uint)-1;
+ return 0;
}
/* set font parameters after an id selection */
void
-pcl_set_id_parameters(const pcl_state_t *pcs,
- pcl_font_selection_t *pfs, pl_font_t *fp, uint id)
+pcl_set_id_parameters(const pcl_state_t *pcs,
+ pcl_font_selection_t *pfs, pl_font_t *fp, uint id)
{
- /* Transfer parameters from the selected font into the selection
- * parameters, being careful with the softer parameters. */
- pfs->font = fp;
- pfs->selected_id = id;
- pfs->map = 0;
- if ( pl_font_is_bound(fp) )
- pfs->params.symbol_set = fp->params.symbol_set;
-
- if ( check_support(pcs, pfs->params.symbol_set, fp, &pfs->map, true) )
- DO_NOTHING;
+ /* Transfer parameters from the selected font into the selection
+ * parameters, being careful with the softer parameters. */
+ pfs->font = fp;
+ pfs->selected_id = id;
+ pfs->map = 0;
+ if ( pl_font_is_bound(fp) )
+ pfs->params.symbol_set = fp->params.symbol_set;
+
+ if ( check_support(pcs, pfs->params.symbol_set, fp, &pfs->map, true) )
+ DO_NOTHING;
else if ( check_support(pcs, pcs->default_symbol_set_value,
fp, &pfs->map, true)
- )
+ )
DO_NOTHING;
else { /*
- * This font doesn't support the required symbol set.
- * Punt -- map 1-for-1.
- */
+ * This font doesn't support the required symbol set.
+ * Punt -- map 1-for-1.
+ */
}
- pfs->params.proportional_spacing = fp->params.proportional_spacing;
- if ( !pfs->params.proportional_spacing && !pl_font_is_scalable(fp) )
- pfs->params.pitch = fp->params.pitch;
- if ( !pl_font_is_scalable(fp) )
- pfs->params.height_4ths = fp->params.height_4ths;
- pfs->params.style = fp->params.style;
- pfs->params.stroke_weight = fp->params.stroke_weight;
- pfs->params.typeface_family = fp->params.typeface_family;
- return;
+ pfs->params.proportional_spacing = fp->params.proportional_spacing;
+ if ( !pfs->params.proportional_spacing && !pl_font_is_scalable(fp) )
+ pfs->params.pitch = fp->params.pitch;
+ if ( !pl_font_is_scalable(fp) )
+ pfs->params.height_4ths = fp->params.height_4ths;
+ pfs->params.style = fp->params.style;
+ pfs->params.stroke_weight = fp->params.stroke_weight;
+ pfs->params.typeface_family = fp->params.typeface_family;
+ return;
}
-
+
/* Select a font by ID, updating the selection parameters. */
/* Return 0 normally, 1 if no font was found, or an error code. */
int
pcl_select_font_by_id(pcl_font_selection_t *pfs, uint id, pcl_state_t *pcs)
{ byte id_key[2];
- void *value;
- pl_font_t *fp;
-
- id_key[0] = id >> 8;
- id_key[1] = (byte)id;
- if ( !pl_dict_find(&pcs->soft_fonts, id_key, 2, &value) )
- return 1; /* font not found */
- fp = (pl_font_t *)value;
- pcl_set_id_parameters(pcs, pfs, fp, id);
- return 0;
+ void *value;
+ pl_font_t *fp;
+
+ id_key[0] = id >> 8;
+ id_key[1] = (byte)id;
+ if ( !pl_dict_find(&pcs->soft_fonts, id_key, 2, &value) )
+ return 1; /* font not found */
+ fp = (pl_font_t *)value;
+ pcl_set_id_parameters(pcs, pfs, fp, id);
+ return 0;
}
diff --git a/pcl/pcfsel.h b/pcl/pcfsel.h
index 605f74a4f..e83e87bdf 100644
--- a/pcl/pcfsel.h
+++ b/pcl/pcfsel.h
@@ -19,7 +19,6 @@
#include "pcstate.h"
-
/* Recompute the font from the parameters if necessary. */
/* This is used by both PCL and HP-GL/2. */
int pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intenal_only);
@@ -34,8 +33,7 @@ int pcl_select_font_by_id(pcl_font_selection_t *pfs, uint id,
/* set font parameters after an id selection */
void
-pcl_set_id_parameters(const pcl_state_t *pcs,
- pcl_font_selection_t *pfs, pl_font_t *fp, uint id);
-
+pcl_set_id_parameters(const pcl_state_t *pcs,
+ pcl_font_selection_t *pfs, pl_font_t *fp, uint id);
#endif /* pcfsel_INCLUDED */
diff --git a/pcl/pcht.c b/pcl/pcht.c
index f2e3fbc3c..8b8ec1493 100644
--- a/pcl/pcht.c
+++ b/pcl/pcht.c
@@ -61,7 +61,6 @@ RELOC_PTRS_END
private_st_ht_builtin_dither_t();
-
static
ENUM_PTRS_BEGIN(ht_enum_ptrs)
return 0;
@@ -97,40 +96,40 @@ private_st_ht_t();
* with logical operations (raster-ops).
*/
static const byte ordered_dither_data[16 * 16] = {
- 142, 46, 174, 6, 134, 38, 166, 12, 140, 44, 172, 4, 132, 36, 164, 14,
- 78, 238, 110, 198, 70, 230, 102, 204, 76, 236, 108, 196, 68, 228, 100, 206,
- 190, 30, 158, 54, 182, 22, 150, 60, 188, 28, 156, 52, 180, 20, 148, 62,
- 126, 222, 94, 246, 118, 214, 86, 252, 124, 220, 92, 244, 116, 212, 84, 254,
- 129, 33, 161, 9, 137, 41, 169, 3, 131, 35, 163, 11, 139, 43, 171, 1,
- 65, 225, 97, 201, 73, 233, 105, 195, 67, 227, 99, 203, 75, 235, 107, 193,
- 177, 17, 145, 57, 185, 25, 153, 51, 179, 19, 147, 59, 187, 27, 155, 49,
- 113, 209, 81, 249, 121, 217, 89, 243, 115, 211, 83, 251, 123, 219, 91, 241,
- 141, 45, 173, 5, 133, 37, 165, 15, 143, 47, 175, 7, 135, 39, 167, 13,
- 77, 237, 109, 197, 69, 229, 101, 207, 79, 239, 111, 199, 71, 231, 103, 205,
- 189, 29, 157, 53, 181, 21, 149, 63, 191, 31, 159, 55, 183, 23, 151, 61,
- 125, 221, 93, 245, 117, 213, 85, 255, 127, 223, 95, 247, 119, 215, 87, 253,
- 130, 34, 162, 10, 138, 42, 170, 1, 128, 32, 160, 8, 136, 40, 168, 2,
- 66, 226, 98, 202, 74, 234, 106, 192, 64, 224, 96, 200, 72, 232, 104, 194,
- 178, 18, 146, 58, 186, 26, 154, 48, 176, 16, 144, 56, 184, 24, 152, 50,
+ 142, 46, 174, 6, 134, 38, 166, 12, 140, 44, 172, 4, 132, 36, 164, 14,
+ 78, 238, 110, 198, 70, 230, 102, 204, 76, 236, 108, 196, 68, 228, 100, 206,
+ 190, 30, 158, 54, 182, 22, 150, 60, 188, 28, 156, 52, 180, 20, 148, 62,
+ 126, 222, 94, 246, 118, 214, 86, 252, 124, 220, 92, 244, 116, 212, 84, 254,
+ 129, 33, 161, 9, 137, 41, 169, 3, 131, 35, 163, 11, 139, 43, 171, 1,
+ 65, 225, 97, 201, 73, 233, 105, 195, 67, 227, 99, 203, 75, 235, 107, 193,
+ 177, 17, 145, 57, 185, 25, 153, 51, 179, 19, 147, 59, 187, 27, 155, 49,
+ 113, 209, 81, 249, 121, 217, 89, 243, 115, 211, 83, 251, 123, 219, 91, 241,
+ 141, 45, 173, 5, 133, 37, 165, 15, 143, 47, 175, 7, 135, 39, 167, 13,
+ 77, 237, 109, 197, 69, 229, 101, 207, 79, 239, 111, 199, 71, 231, 103, 205,
+ 189, 29, 157, 53, 181, 21, 149, 63, 191, 31, 159, 55, 183, 23, 151, 61,
+ 125, 221, 93, 245, 117, 213, 85, 255, 127, 223, 95, 247, 119, 215, 87, 253,
+ 130, 34, 162, 10, 138, 42, 170, 1, 128, 32, 160, 8, 136, 40, 168, 2,
+ 66, 226, 98, 202, 74, 234, 106, 192, 64, 224, 96, 200, 72, 232, 104, 194,
+ 178, 18, 146, 58, 186, 26, 154, 48, 176, 16, 144, 56, 184, 24, 152, 50,
114, 210, 82, 250, 122, 218, 90, 240, 112, 208, 80, 248, 120, 216, 88, 242
};
static const byte clustered_dither_data[16 * 16] = {
- 228, 164, 40, 8, 24, 152, 199, 247, 231, 167, 43, 11, 27, 155, 196, 244,
- 116, 52, 96, 176, 80, 64, 135, 215, 119, 55, 99, 179, 83, 67, 132, 212,
- 20, 148, 192, 240, 224, 160, 39, 7, 23, 151, 195, 243, 227, 163, 36, 4,
- 94, 78, 128, 208, 112, 48, 109, 189, 93, 77, 131, 211, 115, 51, 111, 190,
- 238, 174, 32, 1, 16, 144, 205, 253, 237, 173, 35, 3, 19, 147, 206, 254,
- 126, 62, 106, 186, 90, 74, 141, 221, 125, 61, 105, 185, 89, 73, 142, 222,
- 30, 158, 202, 250, 234, 170, 45, 13, 29, 157, 201, 249, 233, 169, 46, 14,
- 86, 70, 138, 218, 122, 58, 101, 181, 85, 69, 137, 217, 121, 57, 102, 182,
- 230, 166, 42, 10, 26, 154, 197, 245, 229, 165, 41, 9, 25, 153, 198, 246,
- 118, 54, 98, 178, 82, 66, 133, 213, 117, 53, 97, 177, 81, 65, 134, 214,
- 22, 150, 194, 242, 226, 162, 37, 5, 21, 149, 193, 241, 225, 161, 38, 6,
- 92, 76, 130, 210, 114, 50, 111, 191, 95, 79, 129, 209, 113, 49, 108, 188,
- 236, 172, 34, 2, 18, 146, 207, 255, 239, 175, 33, 1, 17, 145, 204, 252,
- 124, 60, 104, 184, 88, 72, 143, 223, 127, 63, 107, 187, 91, 75, 140, 220,
- 28, 156, 200, 248, 232, 168, 47, 15, 31, 159, 203, 251, 235, 171, 44, 12,
+ 228, 164, 40, 8, 24, 152, 199, 247, 231, 167, 43, 11, 27, 155, 196, 244,
+ 116, 52, 96, 176, 80, 64, 135, 215, 119, 55, 99, 179, 83, 67, 132, 212,
+ 20, 148, 192, 240, 224, 160, 39, 7, 23, 151, 195, 243, 227, 163, 36, 4,
+ 94, 78, 128, 208, 112, 48, 109, 189, 93, 77, 131, 211, 115, 51, 111, 190,
+ 238, 174, 32, 1, 16, 144, 205, 253, 237, 173, 35, 3, 19, 147, 206, 254,
+ 126, 62, 106, 186, 90, 74, 141, 221, 125, 61, 105, 185, 89, 73, 142, 222,
+ 30, 158, 202, 250, 234, 170, 45, 13, 29, 157, 201, 249, 233, 169, 46, 14,
+ 86, 70, 138, 218, 122, 58, 101, 181, 85, 69, 137, 217, 121, 57, 102, 182,
+ 230, 166, 42, 10, 26, 154, 197, 245, 229, 165, 41, 9, 25, 153, 198, 246,
+ 118, 54, 98, 178, 82, 66, 133, 213, 117, 53, 97, 177, 81, 65, 134, 214,
+ 22, 150, 194, 242, 226, 162, 37, 5, 21, 149, 193, 241, 225, 161, 38, 6,
+ 92, 76, 130, 210, 114, 50, 111, 191, 95, 79, 129, 209, 113, 49, 108, 188,
+ 236, 172, 34, 2, 18, 146, 207, 255, 239, 175, 33, 1, 17, 145, 204, 252,
+ 124, 60, 104, 184, 88, 72, 143, 223, 127, 63, 107, 187, 91, 75, 140, 220,
+ 28, 156, 200, 248, 232, 168, 47, 15, 31, 159, 203, 251, 235, 171, 44, 12,
84, 68, 136, 216, 120, 56, 103, 183, 87, 71, 139, 219, 123, 59, 100, 180
};
@@ -1180,18 +1179,18 @@ static const pcl_ht_builtin_threshold_t noise_dither_thresh = {
noise_dither_data
};
-/* table used to map color rendering modes into monochrome
+/* table used to map color rendering modes into monochrome
*/
static const byte monochrome_remap[20] = { 5, 5, 2, 5,
- 6, 5, 6, 8,
- 8, 10, 10, 12,
- 12, 14, 14, 17,
- 16, 17, 19, 19 };
+ 6, 5, 6, 8,
+ 8, 10, 10, 12,
+ 12, 14, 14, 17,
+ 16, 17, 19, 19 };
/* if true an all gray palette will automatically map
- * itself to a monochrome rendering mode using the monochrome_remap
+ * itself to a monochrome rendering mode using the monochrome_remap
* if false all render algorithms are are left alone
- *
+ *
* This is an optimization that if only gray is used on a page the page is printed with
* only the K plane. This is a work around for PCL not having a gray colorspace.
* Should match the behavior of hp clj 4500, 4550 printers.
@@ -1357,7 +1356,7 @@ pcl_ht_init_render_methods(
pcs->rendering_info[0].pbidither = &pcs->ordered_dither;
- /* 1 - dither doesn't matter */
+ /* 1 - dither doesn't matter */
pcs->rendering_info[1].flags = HT_FIXED | HT_DEVCSPACE;
pcs->rendering_info[1].pbidither = &pcs->ordered_dither;
@@ -1403,7 +1402,7 @@ pcl_ht_init_render_methods(
/* 12 */
pcs->rendering_info[12].flags = HT_FIXED;
pcs->rendering_info[12].pbidither = &pcs->ordered_dither;
-
+
/* 13 - device should override */
pcs->rendering_info[13].flags = HT_NONE;
pcs->rendering_info[13].pbidither = &pcs->noise_dither;
@@ -1411,7 +1410,7 @@ pcl_ht_init_render_methods(
/* 14 - device should override */
pcs->rendering_info[14].flags = HT_NONE;
pcs->rendering_info[14].pbidither = &pcs->noise_dither;
-
+
/* 15 - device should override */
pcs->rendering_info[15].flags = HT_NONE;
pcs->rendering_info[15].pbidither = &pcs->ordered_dither;
@@ -1432,23 +1431,23 @@ pcl_ht_init_render_methods(
pcs->rendering_info[19].flags = HT_NONE;
pcs->rendering_info[19].pbidither = &pcs->ordered_dither;
- {
- /*
- * Remap the the rendering methods. This will generally be
- * selected from the device; the default value provided below
- * maps all methods to ones that are supported in the default
- * system.
- */
- static const byte rendering_remap[20] = {
- 0, 1, 2, 3, /* 0 - 3 */
- 3, 5, 5, 7, /* 4 - 7 */
- 8, 9, 10, 11, /* 8 - 11 */
- 12, 13, 14, 3, /* 12 - 15 */
- 5, 5, 3, 5 /* 16 - 19 */
- };
- for ( i = 0; i < countof(rendering_remap); i++ )
- pcs->dflt_rendering_remap[i] =
- pcs->rendering_remap[i] = rendering_remap[i];
+ {
+ /*
+ * Remap the the rendering methods. This will generally be
+ * selected from the device; the default value provided below
+ * maps all methods to ones that are supported in the default
+ * system.
+ */
+ static const byte rendering_remap[20] = {
+ 0, 1, 2, 3, /* 0 - 3 */
+ 3, 5, 5, 7, /* 4 - 7 */
+ 8, 9, 10, 11, /* 8 - 11 */
+ 12, 13, 14, 3, /* 12 - 15 */
+ 5, 5, 3, 5 /* 16 - 19 */
+ };
+ for ( i = 0; i < countof(rendering_remap); i++ )
+ pcs->dflt_rendering_remap[i] =
+ pcs->rendering_remap[i] = rendering_remap[i];
}
/* get any dither information from the current device */
@@ -1459,7 +1458,7 @@ pcl_ht_init_render_methods(
continue;
gs_c_param_list_write(&list, pmem);
sprintf(nbuff, "Dither_%d", i);
- if ( (param_request((gs_param_list *)&list, nbuff) >= 0) &&
+ if ( (param_request((gs_param_list *)&list, nbuff) >= 0) &&
(gs_getdeviceparams(pcur_dev, (gs_param_list *)&list) >= 0) ) {
gs_param_dict dict;
@@ -1507,12 +1506,11 @@ pcl_ht_set_print_mode(
memcpy(pcs->rendering_remap, pcs->dflt_rendering_remap, sizeof(pcs->rendering_remap));
if (monochrome) {
int i;
- for (i = 0; i < countof(pcs->rendering_remap); i++)
+ for (i = 0; i < countof(pcs->rendering_remap); i++)
pcs->rendering_remap[i] = monochrome_remap[pcs->rendering_remap[i]];
}
}
-
/*
* Free the graphic library halftone objects associated with a PCL halftone
* object.
@@ -1604,8 +1602,8 @@ alloc_pcl_ht(
pht->pdither = 0;
pht->render_method = 3; /* HP specified default value */
- pht->orig_render_method = 3;
- pht->is_gray_render_method = false;
+ pht->orig_render_method = 3;
+ pht->is_gray_render_method = false;
pht->pfg_ht = 0;
pht->pim_ht = 0;
@@ -1623,7 +1621,6 @@ alloc_pcl_ht(
return 0;
}
-
/*
* Make a unique copy of a PCL halftone object.
*
@@ -1682,35 +1679,35 @@ unshare_pcl_ht(
}
/* return true if all palette entries are gray
- * return false if any entry is color
+ * return false if any entry is color
* checks the entire palette
* all gray palette ONLY has meaning if ENABLE_AUTO_GRAY_RENDER_METHODS is true
* otherwise this is a NOP that always returns false.
*/
-bool
+bool
pcl_ht_is_all_gray_palette(pcl_state_t *pcs)
{
- if ( pcs->monochrome_mode )
+ if ( pcs->monochrome_mode )
return true;
if ( ENABLE_AUTO_GRAY_RENDER_METHODS ) {
- bool is_gray = true;
- const char *pb = 0;
- pcl_palette_t * ppalet = pcs->ppalet;
- pcl_cs_indexed_t * pindexed = ppalet->pindexed;
- int i;
-
- for ( i = 0; i < pindexed->num_entries; i++ ) {
- pb = pindexed->palette.data + (3 * i);
- if ( pb[0] == pb[1] && pb[0] == pb[2] ) {
- continue;
- }
- else {
- is_gray = false;
- break;
- }
- }
- return is_gray;
+ bool is_gray = true;
+ const char *pb = 0;
+ pcl_palette_t * ppalet = pcs->ppalet;
+ pcl_cs_indexed_t * pindexed = ppalet->pindexed;
+ int i;
+
+ for ( i = 0; i < pindexed->num_entries; i++ ) {
+ pb = pindexed->palette.data + (3 * i);
+ if ( pb[0] == pb[1] && pb[0] == pb[2] ) {
+ continue;
+ }
+ else {
+ is_gray = false;
+ break;
+ }
+ }
+ return is_gray;
}
return false; /* feature disabled, concider it color */
}
@@ -1734,11 +1731,11 @@ pcl_ht_set_render_method(
return 0;
/* normal rendering remap */
- color_render_method = pcs->rendering_remap[render_method];
-
+ color_render_method = pcs->rendering_remap[render_method];
+
if (color_render_method == (*ppht)->orig_render_method)
return 0;
-
+
if ((code = unshare_pcl_ht(ppht)) < 0)
return code;
@@ -1747,15 +1744,15 @@ pcl_ht_set_render_method(
(*ppht)->is_gray_render_method = false;
/* remap render algo based on is the palette gray palette check */
- return pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- pcl_ht_is_all_gray_palette(pcs));
+ return pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ pcl_ht_is_all_gray_palette(pcs));
}
/* if the palette is gray remap the render_algorithm to a gray algo
* if the palette is color use the original "color" render_algorithm
* degenerates to NOP if ENABLE_AUTO_GRAY_RENDER_METHODS is false
- */
+ */
int
pcl_ht_remap_render_method(
pcl_state_t * pcs,
@@ -1765,21 +1762,21 @@ pcl_ht_remap_render_method(
{
if ( ENABLE_AUTO_GRAY_RENDER_METHODS ) {
uint render_method = (*ppht)->orig_render_method;
- int code = 0;
- if (is_gray != (*ppht)->is_gray_render_method ) {
- if( is_gray ) {
- render_method = monochrome_remap[pcs->rendering_remap[render_method]];
- (*ppht)->is_gray_render_method = is_gray;
- }
- else {
- render_method = (*ppht)->orig_render_method;
- }
-
- if ((code = unshare_pcl_ht(ppht)) < 0)
- return code;
-
- (*ppht)->render_method = render_method;
- }
+ int code = 0;
+ if (is_gray != (*ppht)->is_gray_render_method ) {
+ if( is_gray ) {
+ render_method = monochrome_remap[pcs->rendering_remap[render_method]];
+ (*ppht)->is_gray_render_method = is_gray;
+ }
+ else {
+ render_method = (*ppht)->orig_render_method;
+ }
+
+ if ((code = unshare_pcl_ht(ppht)) < 0)
+ return code;
+
+ (*ppht)->render_method = render_method;
+ }
}
/* else feature disabled NOP */
return 0;
@@ -1801,7 +1798,7 @@ pcl_ht_set_gamma(
int code = 0;
int i;
- /*
+ /*
* All of the gamma correction factors and lookup table pointers are the
* same, so just check the first of these. If nothing has changed, just
* return.
@@ -1938,7 +1935,6 @@ identity_transfer(floatp tint, const gx_transfer_map *ignore_map)
{ return tint;
}
-
#ifdef DEVICE_HAS_CRD
/*
* Get the rendering information corresponding to a given rendering method.
@@ -1956,7 +1952,7 @@ get_rendering_info(
{
pcl_rend_info_t * pinfo = &(pcs->rendering_info[sel_method]);
uint flags = pinfo->flags;
-
+
/* check for methods that require device-dependent color spaces */
if ( (((flags & HT_DEVCSPACE) != 0) && (cstype > pcl_cspace_CMY)) ||
(((flags & HT_IMONLY) != 0) && !for_image) )
diff --git a/pcl/pcht.h b/pcl/pcht.h
index aff54b65a..1e0cd2047 100644
--- a/pcl/pcht.h
+++ b/pcl/pcht.h
@@ -26,7 +26,6 @@
#include "pclookup.h"
#include "pcdither.h"
-
/*
* Structure for built-in dither methods. "built-in" in this case refers to
* items that cannot be modifiied by the user via the PCL interpreter; there
@@ -47,7 +46,7 @@
* should be provided as:
*
* red(0, 0), red(1, 0), red(0, 1), red(1, 1), green(0, 0), ..., blue(1, 1)
- *
+ *
* For table dithers, data is organized by (device-space) row, then column,
* then level (the intensity level to which the given color plane corresponds),
* then color plane. Data is one bit per pixel, high-order-bit leftmost, and
@@ -122,7 +121,7 @@ typedef struct pcl_ht_builtin_dither_s {
*
* The HT_FIXED flag indicates which methods may not be changed by the output
* device. The ordered, clustered ordered, and user-defined dithers (both
- * color and monochrome versions) are in this category, because they must
+ * color and monochrome versions) are in this category, because they must
* have predictable matrices for the logical operations to produce predictable
* results.
*
@@ -268,14 +267,13 @@ void pcl_ht_set_print_mode(pcl_state_t *pcs, bool monochrome);
*/
int pcl_ht_set_render_method(pcl_state_t *pcs, pcl_ht_t ** ppht, uint render_method);
-
-/**
- * Remap render method to a gray render method iff enabled && palette is all gray
+/**
+ * Remap render method to a gray render method iff enabled && palette is all gray
*
* if the palette is gray remap the render_algorithm to a gray algo
* if the palette is color use the original "color" render_algorithm
* degenerates to NOP if ENABLE_AUTO_GRAY_RENDER_METHODS is false
- */
+ */
int pcl_ht_remap_render_method(pcl_state_t * pcs,
pcl_ht_t **ppht,
bool is_gray
@@ -285,7 +283,7 @@ int pcl_ht_remap_render_method(pcl_state_t * pcs,
* Checks if all palette entries are gray iff enabled.
*
* Returns true if all palette entries are gray
- * Returns false if any entry is color
+ * Returns false if any entry is color
* checks the entire palette
* all gray palette ONLY has meaning if ENABLE_AUTO_GRAY_RENDER_METHODS is true
* otherwise this is a NOP that always returns false.
diff --git a/pcl/pcimpl.c b/pcl/pcimpl.c
index 6f43868b9..2735e3db8 100644
--- a/pcl/pcimpl.c
+++ b/pcl/pcimpl.c
@@ -22,7 +22,6 @@ extern const pl_interp_implementation_t pcl_implementation;
/* Zero-terminated list of pointers to implementations */
pl_interp_implementation_t const * const pdl_implementation[] = {
- &pcl_implementation,
- 0
+ &pcl_implementation,
+ 0
};
-
diff --git a/pcl/pcindxed.c b/pcl/pcindxed.c
index 2ec174566..dff9185f7 100644
--- a/pcl/pcindxed.c
+++ b/pcl/pcindxed.c
@@ -51,9 +51,8 @@ RELOC_PTRS_END
private_st_cs_indexed_t();
-
/*
- * Find the smallest non-negative integral exponent of 2 larger than
+ * Find the smallest non-negative integral exponent of 2 larger than
* or equal to the given number; 8 => 2^3 12 => 2^4
* Note: in/out should be unsigned.
*/
@@ -65,8 +64,8 @@ get_pow_2(
int i;
unsigned power_2 = 1;
- for (i = 0; (unsigned)num > power_2; ++i)
- power_2 <<= 1;
+ for (i = 0; (unsigned)num > power_2; ++i)
+ power_2 <<= 1;
return i;
}
@@ -212,7 +211,6 @@ unshare_indexed_cspace(
return 0;
}
-
/*
* Fill in the default entries in a color palette. This is handled separately
* for each color space type.
@@ -340,7 +338,7 @@ set_colmet_default_palette(
* a somewhat different output is produced, but this is as close as we can
* come to a "device independent" set of default entries.
*
- * The code provides some compensation for range: if the desired value is
+ * The code provides some compensation for range: if the desired value is
* within the permitted range, the palette entry intensity (always in the range
* [0, 1]) will be adjusted so as to achieve it; otherwise the intensity will
* be set to the appropriate bound. Obviously, none of this works if a
@@ -389,7 +387,7 @@ set_CIELab_default_palette(
* and we provide those primaries in the default palette. Since the
* palette entries themselves are in the luminance-chrominance color space,
* the default values must be converted to that color space.
- *
+ *
* An adjustment is made for the specified ranges.
*/
static void
@@ -407,7 +405,7 @@ set_lumchrom_default_palette(
pcl_mtx3_t tmp_mtx;
int i;
static const pcl_vec3_t lumchrom_default[8] = {
- { 1.0, 1.0, 1.0 }, /* white */
+ { 1.0, 1.0, 1.0 }, /* white */
{ 0.0, 1.0, 1.0 }, /* cyan */
{ 1.0, 0.0, 1.0 }, /* magenta */
{ 0.0, 0.0, 1.0 }, /* blue */
@@ -457,7 +455,7 @@ set_default_entries(
byte * palette,
const byte * porder,
int start,
- int num
+ int num
) = {
set_dev_specific_default_palette, /* RGB */
set_dev_specific_default_palette, /* CMY */
@@ -710,7 +708,7 @@ pcl_cs_indexed_set_num_entries(
* Set new_num to the smallest larger power of 2 less than
* pcl_cs_indexed_palette_size.
*/
- bits = ( bits > pcl_cs_indexed_palette_size_log
+ bits = ( bits > pcl_cs_indexed_palette_size_log
? pcl_cs_indexed_palette_size_log
: bits );
new_num = 1L << bits;
@@ -798,7 +796,7 @@ pcl_cs_indexed_update_lookup_tbl(
(gs_const_string *)&(pindexed->palette),
pindexed->rc.memory
);
-
+
}
/*
@@ -833,7 +831,7 @@ pcl_cs_indexed_set_palette_entry(
/* get a unique copy of the indexed color space */
if ((code = unshare_indexed_cspace(ppindexed)) < 0)
return code;
- pindexed = *ppindexed;
+ pindexed = *ppindexed;
/* normalize and store the entry */
indx *= 3;
@@ -842,7 +840,7 @@ pcl_cs_indexed_set_palette_entry(
floatp val = comps[i];
if (pn->inv_range == 0)
- val = (val >= pn->blkref ? 255.0 : 0.0);
+ val = (val >= pn->blkref ? 255.0 : 0.0);
else {
val = (val - pn->blkref) * pn->inv_range;
val = (val < 0.0 ? 0.0 : (val > 255.0 ? 255.0 : val));
@@ -880,7 +878,7 @@ pcl_cs_indexed_set_default_palette_entry(
/* get a unique copy of the indexed color space */
if ((code = unshare_indexed_cspace(ppindexed)) < 0)
return code;
- pindexed = *ppindexed;
+ pindexed = *ppindexed;
return set_default_entries(*ppindexed, indx, 1, true);
}
@@ -997,7 +995,7 @@ pcl_cs_indexed_build_cspace(
int i;
for (i = 0; i < 3; i++) {
- wht_ref[i] = (1L << pcl_cid_get_bits_per_primary(pcid, i)) - 1;
+ wht_ref[i] = (1L << pcl_cid_get_bits_per_primary(pcid, i)) - 1;
blk_ref[i] = 0.0;
}
@@ -1035,7 +1033,7 @@ pcl_cs_indexed_build_cspace(
* Build the default indexed color space. This function is usually called only
* once, at initialization time.
*
- * Returns 0 on success, < 0
+ * Returns 0 on success, < 0
*/
int
pcl_cs_indexed_build_default_cspace(
@@ -1049,7 +1047,7 @@ pcl_cs_indexed_build_default_cspace(
pcs->dflt_cid_data.u.hdr = dflt_cid_hdr;
pcs->dflt_cid_data.original_cspace = pcl_cspace_num;
return pcl_cs_indexed_build_cspace( pcs,
- ppindexed,
+ ppindexed,
&pcs->dflt_cid_data,
true,
false,
diff --git a/pcl/pcindxed.h b/pcl/pcindxed.h
index d0639cd68..9412c4c1d 100644
--- a/pcl/pcindxed.h
+++ b/pcl/pcindxed.h
@@ -26,7 +26,6 @@
#include "pclookup.h"
#include "pccsbase.h"
-
/*
* Size of a PCL color palette. All palettes are allocated at this size, as
* GL/2 may change the size of a palette after it has been created.
@@ -40,7 +39,6 @@
#define pcl_cs_indexed_palette_size_log 8
#define pcl_cs_indexed_palette_size (1 << pcl_cs_indexed_palette_size_log)
-
/*
* Structure to hold the parameters that normalize raw color values to values
* usable for the base color space. The formula used is:
@@ -60,7 +58,6 @@ typedef struct pcl_cs_indexed_norm_s {
float inv_range; /* 255 / (whtref - blkref) */
} pcl_cs_indexed_norm_t;
-
/*
* PCL indexed color space. This consists of:
*
@@ -294,7 +291,7 @@ int pcl_cs_indexed_set_pen_width(
* Returns 0 if successful, < 0 in case of error.
*/
int pcl_cs_indexed_build_cspace(
- pcl_state_t * pcs,
+ pcl_state_t * pcs,
pcl_cs_indexed_t ** ppindexed,
const pcl_cid_data_t * pcid,
bool fixed,
@@ -306,7 +303,7 @@ int pcl_cs_indexed_build_cspace(
* Build the default indexed color space. This function is usually called only
* once, at initialization time.
*
- * Returns 0 on success, < 0
+ * Returns 0 on success, < 0
*/
int pcl_cs_indexed_build_default_cspace(
pcl_state_t * pcs,
diff --git a/pcl/pcjob.c b/pcl/pcjob.c
index 1304bf212..539281185 100644
--- a/pcl/pcjob.c
+++ b/pcl/pcjob.c
@@ -31,207 +31,207 @@ int
pcl_do_printer_reset(pcl_state_t *pcs)
{
if ( pcs->macro_level )
- return e_Range; /* not allowed inside macro */
+ return e_Range; /* not allowed inside macro */
/* reset the other parser in case we have gotten the
pcl_printer_reset while in gl/2 mode. */
pcl_implicit_gl2_finish(pcs);
/* Print any partial page if not pclxl snippet mode. */
if (pcs->end_page == pcl_end_page_top) {
- int code = pcl_end_page_if_marked(pcs);
- if ( code < 0 )
- return code;
- /* if duplex start on the front side of the paper */
- if ( pcs->duplex )
- put_param1_bool(pcs, "FirstSide", true);
+ int code = pcl_end_page_if_marked(pcs);
+ if ( code < 0 )
+ return code;
+ /* if duplex start on the front side of the paper */
+ if ( pcs->duplex )
+ put_param1_bool(pcs, "FirstSide", true);
}
/* unload fonts */
-
+
/* Reset to user default state. */
return pcl_do_resets(pcs, pcl_reset_printer);
}
-
+
static int /* ESC E */
pcl_printer_reset(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
return pcl_do_printer_reset(pcs);
}
static int /* ESC % -12345 X */
pcl_exit_language(pcl_args_t *pargs, pcl_state_t *pcs)
{ if ( int_arg(pargs) != -12345 )
- return e_Range;
- { int code = pcl_printer_reset(pargs, pcs);
- return (code < 0 ? code : e_ExitLanguage);
- }
+ return e_Range;
+ { int code = pcl_printer_reset(pargs, pcs);
+ return (code < 0 ? code : e_ExitLanguage);
+ }
}
static int /* ESC & l <num_copies> X */
pcl_number_of_copies(pcl_args_t *pargs, pcl_state_t *pcs)
{ int i = int_arg(pargs);
- if ( i < 1 )
- return 0;
- pcs->num_copies = i;
- return put_param1_int(pcs, "NumCopies", i);
+ if ( i < 1 )
+ return 0;
+ pcs->num_copies = i;
+ return put_param1_int(pcs, "NumCopies", i);
}
static int /* ESC & l <sd_enum> S */
pcl_simplex_duplex_print(pcl_args_t *pargs, pcl_state_t *pcs)
{ int code;
- bool reopen = false;
+ bool reopen = false;
- /* oddly the command goes to the next page irrespective of
+ /* oddly the command goes to the next page irrespective of
arguments */
- code = pcl_end_page_if_marked(pcs);
- if ( code < 0 )
- return code;
- pcl_home_cursor(pcs);
- switch ( int_arg(pargs) )
- {
- case 0:
- pcs->duplex = false;
- break;
- case 1:
- pcs->duplex = true;
- pcs->bind_short_edge = false;
- break;
- case 2:
- pcs->duplex = true;
- pcs->bind_short_edge = true;
- break;
- default:
- return 0;
- }
- code = put_param1_bool(pcs, "Duplex", pcs->duplex);
- switch ( code )
- {
- case 1: /* reopen device */
- reopen = true;
- case 0:
- break;
- case gs_error_undefined:
- return 0;
- default: /* error */
- if ( code < 0 )
- return code;
- }
- code = put_param1_bool(pcs, "BindShortEdge", pcs->bind_short_edge);
- switch ( code )
- {
- case 1: /* reopen device */
- reopen = true;
- case 0:
- case gs_error_undefined:
- break;
- default: /* error */
- if ( code < 0 )
- return code;
- }
- return (reopen ? gs_setdevice_no_erase(pcs->pgs,
- gs_currentdevice(pcs->pgs)) :
- 0);
+ code = pcl_end_page_if_marked(pcs);
+ if ( code < 0 )
+ return code;
+ pcl_home_cursor(pcs);
+ switch ( int_arg(pargs) )
+ {
+ case 0:
+ pcs->duplex = false;
+ break;
+ case 1:
+ pcs->duplex = true;
+ pcs->bind_short_edge = false;
+ break;
+ case 2:
+ pcs->duplex = true;
+ pcs->bind_short_edge = true;
+ break;
+ default:
+ return 0;
+ }
+ code = put_param1_bool(pcs, "Duplex", pcs->duplex);
+ switch ( code )
+ {
+ case 1: /* reopen device */
+ reopen = true;
+ case 0:
+ break;
+ case gs_error_undefined:
+ return 0;
+ default: /* error */
+ if ( code < 0 )
+ return code;
+ }
+ code = put_param1_bool(pcs, "BindShortEdge", pcs->bind_short_edge);
+ switch ( code )
+ {
+ case 1: /* reopen device */
+ reopen = true;
+ case 0:
+ case gs_error_undefined:
+ break;
+ default: /* error */
+ if ( code < 0 )
+ return code;
+ }
+ return (reopen ? gs_setdevice_no_erase(pcs->pgs,
+ gs_currentdevice(pcs->pgs)) :
+ 0);
}
static int /* ESC & a <side_enum> G */
pcl_duplex_page_side_select(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint i = uint_arg(pargs);
- int code;
+ int code;
- /* oddly the command goes to the next page irrespective of
+ /* oddly the command goes to the next page irrespective of
arguments */
- code = pcl_end_page_if_marked(pcs);
- if ( code < 0 )
- return code;
- pcl_home_cursor(pcs);
+ code = pcl_end_page_if_marked(pcs);
+ if ( code < 0 )
+ return code;
+ pcl_home_cursor(pcs);
- if ( i > 2 )
- return 0;
+ if ( i > 2 )
+ return 0;
- if ( i > 0 && pcs->duplex )
- put_param1_bool(pcs, "FirstSide", i == 1);
- return 0;
+ if ( i > 0 && pcs->duplex )
+ put_param1_bool(pcs, "FirstSide", i == 1);
+ return 0;
}
static int /* ESC & l 1 T */
pcl_job_separation(pcl_args_t *pargs, pcl_state_t *pcs)
{ int i = int_arg(pargs);
- if ( i != 1 )
- return 0;
- /**** NEED A DRIVER PROCEDURE FOR END-OF-JOB ****/
- return 0;
+ if ( i != 1 )
+ return 0;
+ /**** NEED A DRIVER PROCEDURE FOR END-OF-JOB ****/
+ return 0;
}
static int /* ESC & l <bin_enum> G */
pcl_output_bin_selection(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint i = uint_arg(pargs);
- if ( i < 1 || i > 2 )
- return e_Range;
- return put_param1_int(pcs, "OutputBin", i);
+ if ( i < 1 || i > 2 )
+ return e_Range;
+ return put_param1_int(pcs, "OutputBin", i);
}
static int /* ESC & u <upi> B */
pcl_set_unit_of_measure(pcl_args_t *pargs, pcl_state_t *pcs)
{ int num = int_arg(pargs);
- if ( num <= 96 )
- num = 96;
- else if ( num >= 7200 )
- num = 7200;
- else if ( 7200 % num != 0 )
- { /* Pick the exact divisor of 7200 with the smallest */
- /* relative error. */
- static const int values[] = {
- 96, 100, 120, 144, 150, 160, 180, 200, 225, 240, 288,
- 300, 360, 400, 450, 480, 600, 720, 800, 900,
- 1200, 1440, 1800, 2400, 3600, 7200
- };
- const int *p = values;
+ if ( num <= 96 )
+ num = 96;
+ else if ( num >= 7200 )
+ num = 7200;
+ else if ( 7200 % num != 0 )
+ { /* Pick the exact divisor of 7200 with the smallest */
+ /* relative error. */
+ static const int values[] = {
+ 96, 100, 120, 144, 150, 160, 180, 200, 225, 240, 288,
+ 300, 360, 400, 450, 480, 600, 720, 800, 900,
+ 1200, 1440, 1800, 2400, 3600, 7200
+ };
+ const int *p = values;
- while ( num > p[1] ) p++;
- /* Now *p < num < p[1]. */
- if ( (p[1] - (float)num) / p[1] < ((float)num - *p) / *p )
- p++;
- num = *p;
- }
- pcs->uom_cp = pcl_coord_scale / num;
- return 0;
+ while ( num > p[1] ) p++;
+ /* Now *p < num < p[1]. */
+ if ( (p[1] - (float)num) / p[1] < ((float)num - *p) / *p )
+ p++;
+ num = *p;
+ }
+ pcs->uom_cp = pcl_coord_scale / num;
+ return 0;
}
/* Initialization */
static int
pcjob_do_registration(pcl_parser_state_t *pcl_parser_state, gs_memory_t *mem)
{ /* Register commands */
- DEFINE_ESCAPE_ARGS('E', "Printer Reset", pcl_printer_reset, pca_in_rtl)
- DEFINE_CLASS('%')
- {0, 'X', {pcl_exit_language, pca_neg_ok|pca_big_error|pca_in_rtl}},
- END_CLASS
- DEFINE_CLASS('&')
- {'l', 'X',
- PCL_COMMAND("Number of Copies", pcl_number_of_copies,
- pca_neg_ignore|pca_big_clamp)},
- {'l', 'S',
- PCL_COMMAND("Simplex/Duplex Print", pcl_simplex_duplex_print,
- pca_neg_ignore|pca_big_ignore)},
- {'a', 'G',
- PCL_COMMAND("Duplex Page Side Select",
- pcl_duplex_page_side_select,
- pca_neg_ignore|pca_big_ignore)},
- {'l', 'T',
- PCL_COMMAND("Job Separation", pcl_job_separation,
- pca_neg_error|pca_big_error)},
- {'l', 'G',
- PCL_COMMAND("Output Bin Selection", pcl_output_bin_selection,
- pca_neg_error|pca_big_error)},
- {'u', 'D',
- PCL_COMMAND("Set Unit of Measure", pcl_set_unit_of_measure,
- pca_neg_error|pca_big_error)},
- END_CLASS
- return 0;
+ DEFINE_ESCAPE_ARGS('E', "Printer Reset", pcl_printer_reset, pca_in_rtl)
+ DEFINE_CLASS('%')
+ {0, 'X', {pcl_exit_language, pca_neg_ok|pca_big_error|pca_in_rtl}},
+ END_CLASS
+ DEFINE_CLASS('&')
+ {'l', 'X',
+ PCL_COMMAND("Number of Copies", pcl_number_of_copies,
+ pca_neg_ignore|pca_big_clamp)},
+ {'l', 'S',
+ PCL_COMMAND("Simplex/Duplex Print", pcl_simplex_duplex_print,
+ pca_neg_ignore|pca_big_ignore)},
+ {'a', 'G',
+ PCL_COMMAND("Duplex Page Side Select",
+ pcl_duplex_page_side_select,
+ pca_neg_ignore|pca_big_ignore)},
+ {'l', 'T',
+ PCL_COMMAND("Job Separation", pcl_job_separation,
+ pca_neg_error|pca_big_error)},
+ {'l', 'G',
+ PCL_COMMAND("Output Bin Selection", pcl_output_bin_selection,
+ pca_neg_error|pca_big_error)},
+ {'u', 'D',
+ PCL_COMMAND("Set Unit of Measure", pcl_set_unit_of_measure,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ return 0;
}
static void
pcjob_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
-{
- if ( type & (pcl_reset_initial | pcl_reset_printer) ) {
+{
+ if ( type & (pcl_reset_initial | pcl_reset_printer) ) {
pcs->num_copies = pjl_proc_vartoi(pcs->pjls,
pjl_proc_get_envvar(pcs->pjls, "copies"));
pcs->duplex = !pjl_proc_compare(pcs->pjls,
diff --git a/pcl/pclookup.c b/pcl/pclookup.c
index 7ac39166c..a39fa7bc5 100644
--- a/pcl/pclookup.c
+++ b/pcl/pclookup.c
@@ -53,7 +53,7 @@ set_lookup_tbl(
int code = 0;
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
/* check for clearing of lookup tables, and for incorrect size */
if (len == 0)
@@ -122,7 +122,7 @@ set_gamma_correction(
float gamma = float_arg(pargs);
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
if ((gamma < 0.0) || (gamma > (float)((1L << 15) - 1)))
return 0;
else
diff --git a/pcl/pclookup.h b/pcl/pclookup.h
index 8ba5c2434..d05393bce 100644
--- a/pcl/pclookup.h
+++ b/pcl/pclookup.h
@@ -153,7 +153,7 @@ typedef struct pcl__lookup_tbl_s {
* The pcl_lookup_t structure provides a reference-count header for a lookup
* table. This is necessary because there is a way that lookup tables can
* shared between PCL base color spaces (this could occur in the case of a
- * luminance-chrominance color space, which might have an instantiation with
+ * luminance-chrominance color space, which might have an instantiation with
* two color tables that shares one of these color tables with another
* instantiation).
*/
diff --git a/pcl/pcmacros.c b/pcl/pcmacros.c
index be95b444e..49db5bd8f 100644
--- a/pcl/pcmacros.c
+++ b/pcl/pcmacros.c
@@ -27,43 +27,43 @@ static int
do_copies(pcl_state_t *psaved, pcl_state_t *pcs,
pcl_copy_operation_t copy)
{ const pcl_init_t **init = pcl_init_table;
- int code = 0;
+ int code = 0;
- for ( ; *init && code >= 0; ++init )
- if ( (*init)->do_copy )
- code = (*(*init)->do_copy)(psaved, pcs, copy);
- return code;
+ for ( ; *init && code >= 0; ++init )
+ if ( (*init)->do_copy )
+ code = (*(*init)->do_copy)(psaved, pcs, copy);
+ return code;
}
int
pcl_execute_macro(const pcl_macro_t *pmac, pcl_state_t *pcs,
pcl_copy_operation_t before, pcl_reset_type_t reset,
pcl_copy_operation_t after)
-{
+{
pcl_parser_state_t state;
hpgl_parser_state_t gstate;
pcl_state_t saved;
stream_cursor_read r;
int code;
- if ( before ) {
- memcpy(&saved, pcs, sizeof(*pcs));
- do_copies(&saved, pcs, before);
- pcs->saved = &saved;
+ if ( before ) {
+ memcpy(&saved, pcs, sizeof(*pcs));
+ do_copies(&saved, pcs, before);
+ pcs->saved = &saved;
}
if ( reset )
- pcl_do_resets(pcs, reset);
+ pcl_do_resets(pcs, reset);
state.definitions = pcs->pcl_commands;
state.hpgl_parser_state=&gstate;
pcl_process_init(&state);
r.ptr = (const byte *)(pmac + 1) - 1;
r.limit =
- (const byte *)pmac + (gs_object_size(pcs->memory, pmac) - 1);
+ (const byte *)pmac + (gs_object_size(pcs->memory, pmac) - 1);
pcs->macro_level++;
code = pcl_process(&state, pcs, &r);
pcs->macro_level--;
- if ( after ) {
- do_copies(&saved, pcs, after);
- memcpy(pcs, &saved, sizeof(*pcs));
+ if ( after ) {
+ do_copies(&saved, pcs, after);
+ memcpy(pcs, &saved, sizeof(*pcs));
}
return code;
}
@@ -81,128 +81,128 @@ enum {
static int /* ESC & f <mc_enum> X */
pcl_macro_control(pcl_args_t *pargs, pcl_state_t *pcs)
{ int i = int_arg(pargs);
- gs_const_string key;
- void *value;
- pl_dict_enum_t denum;
+ gs_const_string key;
+ void *value;
+ pl_dict_enum_t denum;
- if ( i == macro_end_definition )
- { if ( pcs->defining_macro )
- { /* The parser has included everything through this command */
- /* in the macro_definition, so we can finish things up. */
- int code;
- code = pl_dict_put(&pcs->macros, current_macro_id,
- current_macro_id_size, pcs->macro_definition);
- pcs->defining_macro = false;
- pcs->macro_definition = 0;
- return code;
- }
- }
- else if ( pcs->defining_macro )
- return 0; /* don't execute other macro operations */
- else if ( i == macro_execute || i == macro_call )
- { /*
- * TRM 12-9 says that "two levels of nesting are allowed",
- * which means 3 levels of macros (1 non-nested, 2 nested).
- */
- if ( pcs->macro_level > 2 )
- return 0;
- }
- else if ( pcs->macro_level )
- return e_Range; /* macro operations not allowed inside macro */
- switch ( i )
- {
- case 0:
- { /* Start defining <macro_id>. */
- pcl_macro_t *pmac;
+ if ( i == macro_end_definition )
+ { if ( pcs->defining_macro )
+ { /* The parser has included everything through this command */
+ /* in the macro_definition, so we can finish things up. */
+ int code;
+ code = pl_dict_put(&pcs->macros, current_macro_id,
+ current_macro_id_size, pcs->macro_definition);
+ pcs->defining_macro = false;
+ pcs->macro_definition = 0;
+ return code;
+ }
+ }
+ else if ( pcs->defining_macro )
+ return 0; /* don't execute other macro operations */
+ else if ( i == macro_execute || i == macro_call )
+ { /*
+ * TRM 12-9 says that "two levels of nesting are allowed",
+ * which means 3 levels of macros (1 non-nested, 2 nested).
+ */
+ if ( pcs->macro_level > 2 )
+ return 0;
+ }
+ else if ( pcs->macro_level )
+ return e_Range; /* macro operations not allowed inside macro */
+ switch ( i )
+ {
+ case 0:
+ { /* Start defining <macro_id>. */
+ pcl_macro_t *pmac;
- pl_dict_undef_purge_synonyms(&pcs->macros, current_macro_id, current_macro_id_size);
- pmac = (pcl_macro_t *)
- gs_alloc_bytes(pcs->memory, sizeof(pcl_macro_t),
- "begin macro definition");
- if ( pmac == 0 )
- return_error(e_Memory);
- pmac->storage = pcds_temporary;
- pcs->macro_definition = (byte *)pmac;
- pcs->defining_macro = true;
- return 0;
- }
- case macro_end_definition: /* 1 */
- { /* Stop defining macro. Outside a macro, this is an error. */
- return e_Range;
- }
- case macro_execute: /* 2 */
- { /* Execute <macro_id>. */
- void *value;
- if ( !pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size,
- &value)
- )
- return 0;
- return pcl_execute_macro((const pcl_macro_t *)value, pcs,
- pcl_copy_none, pcl_reset_none, pcl_copy_none);
- }
- case macro_call: /* 3 */
- { /* Call <macro_id>, saving and restoring environment. */
- void *value;
- if ( !pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size,
- &value)
- )
- return 0;
- return pcl_execute_macro((const pcl_macro_t *)value, pcs,
- pcl_copy_before_call, pcl_reset_none,
- pcl_copy_after_call);
- }
- case 4:
- { /* Define <macro_id> as automatic overlay. */
- pcs->overlay_macro_id = pcs->macro_id;
- pcs->overlay_enabled = true;
- return 0;
- }
- case 5:
- { /* Cancel automatic overlay. */
- pcs->overlay_enabled = false;
- return 0;
- }
- case 6:
- { /* Delete all macros. */
- pl_dict_release(&pcs->macros);
- return 0;
- }
- case macro_delete_temporary: /* 7 */
- { /* Delete temporary macros. */
- pl_dict_enum_stack_begin(&pcs->macros, &denum, false);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- if ( ((pcl_macro_t *)value)->storage == pcds_temporary )
- pl_dict_undef_purge_synonyms(&pcs->macros, key.data, key.size);
- return 0;
- }
- case 8:
- { /* Delete <macro_id>. */
- pl_dict_undef_purge_synonyms(&pcs->macros, current_macro_id, current_macro_id_size);
- return 0;
- }
- case 9:
- { /* Make <macro_id> temporary. */
- if ( pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size, &value) )
- ((pcl_macro_t *)value)->storage = pcds_temporary;
- return 0;
- }
- case 10:
- { /* Make <macro_id> permanent. */
- if ( pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size, &value) )
- ((pcl_macro_t *)value)->storage = pcds_permanent;
- return 0;
- }
- default:
- return e_Range;
- }
+ pl_dict_undef_purge_synonyms(&pcs->macros, current_macro_id, current_macro_id_size);
+ pmac = (pcl_macro_t *)
+ gs_alloc_bytes(pcs->memory, sizeof(pcl_macro_t),
+ "begin macro definition");
+ if ( pmac == 0 )
+ return_error(e_Memory);
+ pmac->storage = pcds_temporary;
+ pcs->macro_definition = (byte *)pmac;
+ pcs->defining_macro = true;
+ return 0;
+ }
+ case macro_end_definition: /* 1 */
+ { /* Stop defining macro. Outside a macro, this is an error. */
+ return e_Range;
+ }
+ case macro_execute: /* 2 */
+ { /* Execute <macro_id>. */
+ void *value;
+ if ( !pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size,
+ &value)
+ )
+ return 0;
+ return pcl_execute_macro((const pcl_macro_t *)value, pcs,
+ pcl_copy_none, pcl_reset_none, pcl_copy_none);
+ }
+ case macro_call: /* 3 */
+ { /* Call <macro_id>, saving and restoring environment. */
+ void *value;
+ if ( !pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size,
+ &value)
+ )
+ return 0;
+ return pcl_execute_macro((const pcl_macro_t *)value, pcs,
+ pcl_copy_before_call, pcl_reset_none,
+ pcl_copy_after_call);
+ }
+ case 4:
+ { /* Define <macro_id> as automatic overlay. */
+ pcs->overlay_macro_id = pcs->macro_id;
+ pcs->overlay_enabled = true;
+ return 0;
+ }
+ case 5:
+ { /* Cancel automatic overlay. */
+ pcs->overlay_enabled = false;
+ return 0;
+ }
+ case 6:
+ { /* Delete all macros. */
+ pl_dict_release(&pcs->macros);
+ return 0;
+ }
+ case macro_delete_temporary: /* 7 */
+ { /* Delete temporary macros. */
+ pl_dict_enum_stack_begin(&pcs->macros, &denum, false);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ if ( ((pcl_macro_t *)value)->storage == pcds_temporary )
+ pl_dict_undef_purge_synonyms(&pcs->macros, key.data, key.size);
+ return 0;
+ }
+ case 8:
+ { /* Delete <macro_id>. */
+ pl_dict_undef_purge_synonyms(&pcs->macros, current_macro_id, current_macro_id_size);
+ return 0;
+ }
+ case 9:
+ { /* Make <macro_id> temporary. */
+ if ( pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size, &value) )
+ ((pcl_macro_t *)value)->storage = pcds_temporary;
+ return 0;
+ }
+ case 10:
+ { /* Make <macro_id> permanent. */
+ if ( pl_dict_find(&pcs->macros, current_macro_id, current_macro_id_size, &value) )
+ ((pcl_macro_t *)value)->storage = pcds_permanent;
+ return 0;
+ }
+ default:
+ return e_Range;
+ }
}
static int /* ESC & f <id> Y */
pcl_assign_macro_id(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint id = uint_arg(pargs);
- id_set_value(pcs->macro_id, id);
- pcs->macro_id_type = numeric_id;
- return 0;
+ id_set_value(pcs->macro_id, id);
+ pcs->macro_id_type = numeric_id;
+ return 0;
}
/* Initialization */
@@ -211,56 +211,56 @@ pcmacros_do_registration(
pcl_parser_state_t *pcl_parser_state,
gs_memory_t *mem)
{ /* Register commands */
- DEFINE_CLASS('&')
- {'f', 'X',
- PCL_COMMAND("Macro Control", pcl_macro_control,
- pca_neg_error|pca_big_error|pca_in_macro)},
- {'f', 'Y',
- PCL_COMMAND("Assign Macro ID", pcl_assign_macro_id,
- pca_neg_error|pca_big_error)},
- END_CLASS
- return 0;
+ DEFINE_CLASS('&')
+ {'f', 'X',
+ PCL_COMMAND("Macro Control", pcl_macro_control,
+ pca_neg_error|pca_big_error|pca_in_macro)},
+ {'f', 'Y',
+ PCL_COMMAND("Assign Macro ID", pcl_assign_macro_id,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ return 0;
}
static void
pcmacros_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
{ if ( type & (pcl_reset_initial | pcl_reset_printer) )
- { pcs->overlay_enabled = false;
- pcs->macro_level = 0;
- pcs->defining_macro = false;
- pcs->saved = 0;
- pcs->macro_definition = 0;
+ { pcs->overlay_enabled = false;
+ pcs->macro_level = 0;
+ pcs->defining_macro = false;
+ pcs->saved = 0;
+ pcs->macro_definition = 0;
- if ( type & pcl_reset_initial )
- pl_dict_init(&pcs->macros, pcs->memory, NULL);
- else
- { pcl_args_t args;
- arg_set_uint(&args, macro_delete_temporary);
- pcl_macro_control(&args, pcs);
- if ( pcs->alpha_macro_id.id != 0 )
- gs_free_object(pcs->memory,
- pcs->alpha_macro_id.id,
- "pcmacros_do_reset");
- }
- }
+ if ( type & pcl_reset_initial )
+ pl_dict_init(&pcs->macros, pcs->memory, NULL);
+ else
+ { pcl_args_t args;
+ arg_set_uint(&args, macro_delete_temporary);
+ pcl_macro_control(&args, pcs);
+ if ( pcs->alpha_macro_id.id != 0 )
+ gs_free_object(pcs->memory,
+ pcs->alpha_macro_id.id,
+ "pcmacros_do_reset");
+ }
+ }
- if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay | pcl_reset_permanent) )
+ if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay | pcl_reset_permanent) )
{
- pcs->alpha_macro_id.size = 0;
- pcs->macro_id_type = numeric_id;
- id_set_value(pcs->macro_id, 0);
- pcs->alpha_macro_id.id = 0;
+ pcs->alpha_macro_id.size = 0;
+ pcs->macro_id_type = numeric_id;
+ id_set_value(pcs->macro_id, 0);
+ pcs->alpha_macro_id.id = 0;
}
- if ( type & pcl_reset_permanent )
- pl_dict_release(&pcs->macros);
+ if ( type & pcl_reset_permanent )
+ pl_dict_release(&pcs->macros);
}
static int
pcmacros_do_copy(pcl_state_t *psaved, const pcl_state_t *pcs,
pcl_copy_operation_t operation)
{ if ( operation & pcl_copy_after )
- { /* Don't restore the macro dictionary. */
- psaved->macros = pcs->macros;
- }
- return 0;
+ { /* Don't restore the macro dictionary. */
+ psaved->macros = pcs->macros;
+ }
+ return 0;
}
const pcl_init_t pcmacros_init = {
pcmacros_do_registration, pcmacros_do_reset, pcmacros_do_copy
diff --git a/pcl/pcmisc.c b/pcl/pcmisc.c
index bb2b2796b..062c4b9f3 100644
--- a/pcl/pcmisc.c
+++ b/pcl/pcmisc.c
@@ -21,23 +21,23 @@ static int /* ESC & s <bool> C */
pcl_end_of_line_wrap(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint i = uint_arg(pargs);
- if ( i > 1 )
- return e_Range;
- pcs->end_of_line_wrap = i == 0;
- return 0;
+ if ( i > 1 )
+ return e_Range;
+ pcs->end_of_line_wrap = i == 0;
+ return 0;
}
static int /* ESC Y */
pcl_enable_display_functions(pcl_args_t *pargs, pcl_state_t *pcs)
{ pcs->display_functions = true;
- return 0;
+ return 0;
}
/* We export this procedure so we can detect the end of display fns mode. */
int /* ESC Z */
pcl_disable_display_functions(pcl_args_t *pargs, pcl_state_t *pcs)
{ pcs->display_functions = false;
- return 0;
+ return 0;
}
/* Initialization */
@@ -46,21 +46,21 @@ pcmisc_do_registration(
pcl_parser_state_t *pcl_parser_state,
gs_memory_t *mem)
{ /* Register commands */
- DEFINE_CLASS_COMMAND_ARGS('&', 's', 'C', "End of Line Wrap",
- pcl_end_of_line_wrap,
- pca_neg_error|pca_big_error)
- DEFINE_ESCAPE_ARGS('Y', "Enable Display Functions",
- pcl_enable_display_functions, pca_in_macro)
- DEFINE_ESCAPE_ARGS('Z', "Disable Display Functions",
- pcl_disable_display_functions, pca_in_macro)
- return 0;
+ DEFINE_CLASS_COMMAND_ARGS('&', 's', 'C', "End of Line Wrap",
+ pcl_end_of_line_wrap,
+ pca_neg_error|pca_big_error)
+ DEFINE_ESCAPE_ARGS('Y', "Enable Display Functions",
+ pcl_enable_display_functions, pca_in_macro)
+ DEFINE_ESCAPE_ARGS('Z', "Disable Display Functions",
+ pcl_disable_display_functions, pca_in_macro)
+ return 0;
}
static void
pcmisc_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
{ if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay) )
- { pcs->end_of_line_wrap = false;
- pcs->display_functions = false;
- }
+ { pcs->end_of_line_wrap = false;
+ pcs->display_functions = false;
+ }
}
const pcl_init_t pcmisc_init = {
pcmisc_do_registration, pcmisc_do_reset
diff --git a/pcl/pcmtx3.c b/pcl/pcmtx3.c
index e857dab20..064c8308f 100644
--- a/pcl/pcmtx3.c
+++ b/pcl/pcmtx3.c
@@ -19,7 +19,6 @@
#include "pcommand.h"
#include "pcmtx3.h"
-
/*
* Calculate the co-factor for the (i, j) component of a 3 x 3 matrix,
* including the sign. Note that i and j range from 0 to 2.
@@ -67,7 +66,6 @@ make_cofactor_mtx(
}
}
-
/*
* Add and subtract 3 dimensional vectors. These are not currently needed,
* but are included for completeness. No inner-product is provided because
diff --git a/pcl/pcmtx3.h b/pcl/pcmtx3.h
index 264b6148a..350d3b958 100644
--- a/pcl/pcmtx3.h
+++ b/pcl/pcmtx3.h
@@ -23,7 +23,6 @@
#include "gscolor2.h"
#include "gscie.h"
-
/*
* To support device independent color spaces, PCL performs a number of
* calculations with 3 x 3 matrices. The CIE color space code in the graphic
@@ -31,21 +30,21 @@
* unusual and no corresponding utilities are provided. Hence, a separate
* (though logically identical) format is provided here.
*
- * Essentially all of the literature on color spaces deals with column
- * vectors, EXCEPT that specific to PostScript. The latter deals with row
- * vectors to remain consistent with the use of matrices for geometric
+ * Essentially all of the literature on color spaces deals with column
+ * vectors, EXCEPT that specific to PostScript. The latter deals with row
+ * vectors to remain consistent with the use of matrices for geometric
* transformations. The graphics library code, being based on PostScript,
* uses the latter arrangement of components. The CIE code in the library is
* documented for column vectors, but specifies matrices in the less usual
- * column-first order. The current code takes the logically equivalent and
- * no less intuitive approach of using row vectors, and specifying
+ * column-first order. The current code takes the logically equivalent and
+ * no less intuitive approach of using row vectors, and specifying
* matrices in the more normal row-first order.
*
* There is actually some reason for these alternate approaches. The CIE code
* is primarily concerned with transformation of color vectors, and performs
- * relatively few other matrix operations. The current code infrequently
- * transforms color vectors, but does perform other matrix operations.
- * Each code module uses the format that is more intuitive for its more
+ * relatively few other matrix operations. The current code infrequently
+ * transforms color vectors, but does perform other matrix operations.
+ * Each code module uses the format that is more intuitive for its more
* common operation.
*/
typedef union {
diff --git a/pcl/pcommand.c b/pcl/pcommand.c
index afefa698c..892991fa7 100644
--- a/pcl/pcommand.c
+++ b/pcl/pcommand.c
@@ -57,7 +57,6 @@ float_value(
: (float)int_value(pv) );
}
-
/*
* "put" parameters to the device.
*/
diff --git a/pcl/pcommand.h b/pcl/pcommand.h
index fe2d3e7e3..161074747 100644
--- a/pcl/pcommand.h
+++ b/pcl/pcommand.h
@@ -35,7 +35,7 @@ typedef ulong uint32;
typedef enum {
pcv_none = 0,
- /* The following masks merge together: */
+ /* The following masks merge together: */
pcv_int = 1,
pcv_float = 2,
pcv_neg = 4,
@@ -50,9 +50,9 @@ typedef enum {
#define value_is_signed(pv)\
((pv)->type & (pcv_neg | pcv_pos))
typedef struct pcl_value_s {
- pcl_value_type_t type;
- uint i; /* integer part */
- float fraction;
+ pcl_value_type_t type;
+ uint i; /* integer part */
+ float fraction;
} pcl_value_t;
#define value_set_uint(pv, ui)\
((pv)->type = pcv_int, (pv)->i = (ui))
@@ -235,12 +235,12 @@ typedef enum {
} pcl_copy_operation_t;
/* Define the structure for per-module implementation procedures. */
typedef struct pcl_init_s {
- /* Register commands */
+ /* Register commands */
int (*do_registration)(pcl_parser_state_t *pcl_parser_state,
gs_memory_t *mem);
- /* Initialize state at startup, printer reset, and other times. */
+ /* Initialize state at startup, printer reset, and other times. */
void (*do_reset)(pcl_state_t *pcs, pcl_reset_type_t type);
- /* Partially copy the state for macro call, overlay, and exit. */
+ /* Partially copy the state for macro call, overlay, and exit. */
int (*do_copy)(pcl_state_t *psaved, const pcl_state_t *pcs,
pcl_copy_operation_t operation);
} pcl_init_t;
diff --git a/pcl/pcpage.c b/pcl/pcpage.c
index 6339d3efd..1edc69292 100644
--- a/pcl/pcpage.c
+++ b/pcl/pcpage.c
@@ -46,7 +46,6 @@
#define round(x) (((x) < 0.0) ? (ceil ((x) - 0.5)) : (floor ((x) + 0.5)))
-
/* Procedures */
/*
@@ -243,7 +242,6 @@ update_xfm_state(
*/
}
-
/* default margins, relative to the logical page boundaries */
#define DFLT_TOP_MARGIN inch2coord(0.5)
#define DFLT_LEFT_MARGIN inch2coord(0.0)
@@ -366,7 +364,6 @@ new_page_size(
changed_page_size = !(old_page_size[0] == pcs->xfm_state.paper_size->width &&
old_page_size[1] == pcs->xfm_state.paper_size->height);
-
/*
* make sure underlining is disabled (homing the cursor may cause
* an underline to be put out.
@@ -464,8 +461,6 @@ pcl_new_logical_page_for_passthrough(pcl_state_t *pcs, int orient, gs_point *pdi
}
-
-
/* page marking routines */
/* set page marked for path drawing commands. NB doesn't handle 0 width - lenghth */
@@ -607,7 +602,6 @@ pcl_end_page(
return (code < 0 ? code : 1);
}
-
/* Commands */
/*
@@ -851,7 +845,6 @@ clear_horizontal_margins(
return 0;
}
-
/*
* ESC & l <line> E
*
diff --git a/pcl/pcpalet.c b/pcl/pcpalet.c
index 7e84b7ab8..81c1c3e61 100644
--- a/pcl/pcpalet.c
+++ b/pcl/pcpalet.c
@@ -51,8 +51,8 @@ free_palette(
gs_free_object(pmem, pvpalet, cname);
}
-void
-pcl_free_default_objects(
+void
+pcl_free_default_objects(
gs_memory_t * mem,
pcl_state_t * pcs
)
@@ -62,14 +62,14 @@ pcl_free_default_objects(
rc_decrement(pcs->pdflt_cs_indexed, "free_default_palette(pdflt_cs_indexed)");
if (ppalette != 0) {
-
+
rc_decrement(ppalette->pindexed, "free_default_palette cs indexed released");
- if (ppalette->pht)
- rc_decrement(ppalette->pht, "free_default_palette ht released");
- if (ppalette->pcrd)
- rc_decrement(ppalette->pcrd, "free_default_palette pcl_crd_release");
- gs_free_object(mem, ppalette, "free_default_palette ppalette free");
- pcs->pdflt_palette = 0;
+ if (ppalette->pht)
+ rc_decrement(ppalette->pht, "free_default_palette ht released");
+ if (ppalette->pcrd)
+ rc_decrement(ppalette->pcrd, "free_default_palette pcl_crd_release");
+ gs_free_object(mem, ppalette, "free_default_palette ppalette free");
+ pcs->pdflt_palette = 0;
}
rc_decrement(pcs->pdflt_ht, "free_default_palette pdflt_ht release");
rc_decrement(pcs->pdflt_ht, "free_default_palette pdflt_ht release");
@@ -203,7 +203,7 @@ build_default_palette(
code = alloc_palette(pcs, &ppalet, pmem);
if (code == 0)
code = pcl_cs_indexed_build_default_cspace( pcs,
- &(ppalet->pindexed),
+ &(ppalet->pindexed),
pmem
);
if ((code == 0) && (pcs->pcl_default_crd == 0))
@@ -221,7 +221,6 @@ build_default_palette(
} else
pcl_palette_init_from(ppalet, pcs->pdflt_palette);
-
/* NB: definitions do NOT record a referece */
id_set_value(key, pcs->sel_palette_id);
code = pl_dict_put(&pcs->palette_store, id_key(key), 2, ppalet);
@@ -270,7 +269,7 @@ push_pop_palette(
int action = uint_arg(pargs);
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
if (action == 0) {
pstack_entry_t * pentry;
@@ -324,7 +323,7 @@ push_pop_palette(
* Returns 0 on success, < 0 in the event of an error.
*/
-int pcl_palette_CR(
+int pcl_palette_CR(
pcl_state_t * pcs,
floatp wht0,
floatp wht1,
@@ -344,10 +343,9 @@ int pcl_palette_CR(
return pcl_cs_indexed_set_norm_and_Decode( &(pcs->ppalet->pindexed),
wht0, wht1, wht2,
blk0, blk1, blk2
- );
+ );
}
-
/*
* Set the number of entries in a color palette. This is needed only for the
* GL/2 NP command; PCL sets the number of entries in a palette via the
@@ -374,9 +372,9 @@ pcl_palette_NP(
);
/* shrinking a palette may make it gray, growing may make it color */
if (code == 0)
- code = pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- pcl_ht_is_all_gray_palette(pcs));
+ code = pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ pcl_ht_is_all_gray_palette(pcs));
return code;
}
@@ -462,7 +460,7 @@ pcl_palette_set_lookup_tbl(
if ((code == 0) && (pcs->ppalet->pindexed == 0))
code = pcl_cs_indexed_build_default_cspace( pcs,
- &(pcs->ppalet->pindexed),
+ &(pcs->ppalet->pindexed),
pcs->memory
);
if ((code == 0) && (pcs->ppalet->pht == 0))
@@ -506,30 +504,30 @@ pcl_palette_set_color(
indx,
comps
);
-
+
if ( pcs->monochrome_mode == 0 ) {
was_gray = pcs->ppalet->pht->is_gray_render_method;
-
- now_gray = ((pcs->ppalet->pindexed->palette.data[indx*3 + 0] ==
- pcs->ppalet->pindexed->palette.data[indx*3 + 1]) &&
- (pcs->ppalet->pindexed->palette.data[indx*3 + 1] ==
- pcs->ppalet->pindexed->palette.data[indx*3 + 2]) );
-
- if ( !was_gray && now_gray ) {
- /* change one entry from color to gray,
- * check entire palette for grey
- */
- code = pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- pcl_ht_is_all_gray_palette(pcs));
- }
- else if ( was_gray && !now_gray ) {
- /* one color entry in gray palette makes it color
- */
- code = pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- false);
- }
+
+ now_gray = ((pcs->ppalet->pindexed->palette.data[indx*3 + 0] ==
+ pcs->ppalet->pindexed->palette.data[indx*3 + 1]) &&
+ (pcs->ppalet->pindexed->palette.data[indx*3 + 1] ==
+ pcs->ppalet->pindexed->palette.data[indx*3 + 2]) );
+
+ if ( !was_gray && now_gray ) {
+ /* change one entry from color to gray,
+ * check entire palette for grey
+ */
+ code = pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ pcl_ht_is_all_gray_palette(pcs));
+ }
+ else if ( was_gray && !now_gray ) {
+ /* one color entry in gray palette makes it color
+ */
+ code = pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ false);
+ }
}
return code;
}
@@ -557,9 +555,9 @@ pcl_palette_set_default_color(
indx
);
if (code == 0)
- code = pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- pcl_ht_is_all_gray_palette(pcs));
+ code = pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ pcl_ht_is_all_gray_palette(pcs));
return code;
}
@@ -663,22 +661,22 @@ pcl_palette_set_cid(
/* pcl_cspace_bnuild_indexed_cspace will release the old space */
code = pcl_cs_indexed_build_cspace( pcs,
- &(ppalet->pindexed),
+ &(ppalet->pindexed),
pcid,
fixed,
gl2,
pcs->memory
);
if (code == 0) {
- bool is_gray = false;
+ bool is_gray = false;
/* direct raster is always color */
- if ( pcl_cid_get_encoding(pcid) <= 1 ) {
- /* indexed used palette which maybe gray or color */
- is_gray = pcl_ht_is_all_gray_palette(pcs);
+ if ( pcl_cid_get_encoding(pcid) <= 1 ) {
+ /* indexed used palette which maybe gray or color */
+ is_gray = pcl_ht_is_all_gray_palette(pcs);
}
- code = pcl_ht_remap_render_method(pcs,
- &(pcs->ppalet->pht),
- is_gray);
+ code = pcl_ht_remap_render_method(pcs,
+ &(pcs->ppalet->pht),
+ is_gray);
}
/* if a halftone exist, inform it of the update and discard lookup tables */
@@ -741,7 +739,7 @@ pcl_palette_check_complete(
ppalet = pcs->ppalet;
if (ppalet->pindexed == 0)
code = pcl_cs_indexed_build_default_cspace( pcs,
- &(ppalet->pindexed),
+ &(ppalet->pindexed),
pcs->memory
);
if ((code == 0) && (ppalet->pcrd == 0)) {
@@ -753,7 +751,6 @@ pcl_palette_check_complete(
return code;
}
-
/*
* ESC & p # S
*
@@ -770,13 +767,13 @@ set_sel_palette_id(
pcl_id_t key;
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
/* ignore attempts to select non-existent palettes */
id_set_value(key, id);
if ( pl_dict_lookup( &pcs->palette_store,
id_key(key),
- 2,
+ 2,
(void **)&(pcs->ppalet),
false,
NULL
@@ -797,7 +794,7 @@ set_ctrl_palette_id(
)
{
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode)
- return 0;
+ return 0;
pcs->ctrl_palette_id = uint_arg(pargs);
return 0;
@@ -826,7 +823,7 @@ clear_palette_store(
int id = (((int)plkey.data[0]) << 8) + plkey.data[1];
if (id == sel_id) {
- if (pvalue != pcs->pdflt_palette)
+ if (pvalue != pcs->pdflt_palette)
build_default_palette(pcs); /* will redefine sel_id */
} else
pl_dict_undef(&pcs->palette_store, plkey.data, plkey.size);
@@ -847,7 +844,7 @@ palette_control(
uint action = uint_arg(pargs);
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
switch (action) {
@@ -882,7 +879,7 @@ palette_control(
if (code < 0)
return code;
rc_increment(pcs->ppalet);
-
+
}
break;
@@ -907,7 +904,7 @@ set_render_algorithm(
)
{
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
return pcl_palette_set_render_method(pcs, uint_arg(pargs));
}
@@ -948,7 +945,6 @@ pcl_mono_color_mapping_procs(const gx_device * dev)
return &pcl_mono_procs;
}
-
/* set monochrome page device parameter. NB needs testing. We don't
currently have a device that does what we need with
ProcessColorModel. We assume non color devices will simply ignore
@@ -974,15 +970,15 @@ pcl_update_mono(pcl_state_t *pcs)
gx_unset_dev_color(pcs->pgs);
return 0;
}
-
+
/*
* ESC & b # M
*
- * Set monochrome or normal print mode.
- * Note ForceMono=1 is similar to monochrome mode locked on.
+ * Set monochrome or normal print mode.
+ * Note ForceMono=1 is similar to monochrome mode locked on.
*
* The monochrome print mode command is ignored if the page is dirty.
- *
+ *
*/
static int
set_print_mode(
@@ -993,7 +989,7 @@ set_print_mode(
uint mode = uint_arg(pargs);
if ( pcs->personality == pcl5e || pcs->raster_state.graphics_mode )
- return 0;
+ return 0;
if (mode > 1)
return 0;
@@ -1030,7 +1026,7 @@ palette_do_registration(
't', 'J',
PCL_COMMAND( "Render Algorithm",
set_render_algorithm,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
END_CLASS
@@ -1040,28 +1036,28 @@ palette_do_registration(
'b', 'M',
PCL_COMMAND( "Monochrome Printing",
set_print_mode,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
{
'p', 'S',
PCL_COMMAND( "Select Palette",
set_sel_palette_id,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
{
'p', 'I',
PCL_COMMAND( "Palette Control ID",
set_ctrl_palette_id,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
{
'p', 'C',
PCL_COMMAND( "Palette Control",
palette_control,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
END_CLASS
@@ -1081,9 +1077,7 @@ palette_do_reset(
| pcl_reset_cold
| pcl_reset_printer
| pcl_reset_overlay
- | pcl_reset_permanent);
-
-
+ | pcl_reset_permanent);
if ((type & mask) == 0)
return;
@@ -1094,34 +1088,33 @@ palette_do_reset(
pcs->ppalet = 0;
pcs->pfrgrnd = 0;
- /* set up the built-in render methods and dithers matrices */
- pcl_ht_init_render_methods(pcs, pcs->memory);
-
+ /* set up the built-in render methods and dithers matrices */
+ pcl_ht_init_render_methods(pcs, pcs->memory);
} else if ((type & (pcl_reset_cold | pcl_reset_printer | pcl_reset_permanent)) != 0) {
- pcs->monochrome_mode = 0;
+ pcs->monochrome_mode = 0;
pcl_update_mono(pcs);
/* clear the palette stack and store */
clear_palette_stack(pcs, pcs->memory);
- clear_palette_store(pcs);
+ clear_palette_store(pcs);
}
if ( type & pcl_reset_permanent ) {
- pl_dict_release(&pcs->palette_store);
- if (pcs->ppalet != pcs->pdflt_palette) {
- /* stefan foo: free or decrement reference counts? */
- gs_free_object(pcs->memory, pcs->ppalet->pindexed, "palette cs indexed released permanent reset");
- gs_free_object(pcs->memory, pcs->ppalet->pht, "palette ht released permanent reset");
- gs_free_object(pcs->memory, pcs->ppalet->pcrd, "palette ht released permanent reset");
- gs_free_object(pcs->memory, pcs->ppalet, "palette released permanent reset");
- }
+ pl_dict_release(&pcs->palette_store);
+ if (pcs->ppalet != pcs->pdflt_palette) {
+ /* stefan foo: free or decrement reference counts? */
+ gs_free_object(pcs->memory, pcs->ppalet->pindexed, "palette cs indexed released permanent reset");
+ gs_free_object(pcs->memory, pcs->ppalet->pht, "palette ht released permanent reset");
+ gs_free_object(pcs->memory, pcs->ppalet->pcrd, "palette ht released permanent reset");
+ gs_free_object(pcs->memory, pcs->ppalet, "palette released permanent reset");
+ }
}
/* select and control palette ID's must be set back to 0 */
pcs->sel_palette_id = 0;
pcs->ctrl_palette_id = 0;
if ( !(type & pcl_reset_permanent) ) {
- (void)build_default_palette(pcs);
- (void)pcl_frgrnd_set_default_foreground(pcs);
+ (void)build_default_palette(pcs);
+ (void)pcl_frgrnd_set_default_foreground(pcs);
}
}
@@ -1157,9 +1150,9 @@ palette_do_copy(
if ((operation & (pcl_copy_before_call | pcl_copy_before_overlay)) != 0)
pcl_palette_init_from(psaved->ppalet, pcs->ppalet);
else if ((operation & pcl_copy_after) != 0) {
- pcl_id_t key;
- /* fix the compiler warning resulting from overuse of const */
- pcl_state_t *pcs2 = (pcl_state_t *)pcs;
+ pcl_id_t key;
+ /* fix the compiler warning resulting from overuse of const */
+ pcl_state_t *pcs2 = (pcl_state_t *)pcs;
id_set_value(key, psaved->sel_palette_id);
pl_dict_put(&pcs2->palette_store, id_key(key), 2, psaved->ppalet);
psaved->palette_stack = pcs2->palette_stack;
diff --git a/pcl/pcpalet.h b/pcl/pcpalet.h
index 4df5b4924..62ff13656 100644
--- a/pcl/pcpalet.h
+++ b/pcl/pcpalet.h
@@ -75,7 +75,6 @@ typedef struct pcl_palette_s pcl_palette_t;
pht \
)
-
/*
* The usual init, copy,and release macros.
*/
@@ -97,7 +96,6 @@ typedef struct pcl_palette_s pcl_palette_t;
#define pcl_palette_release(pbase) \
rc_decrement(pbase, "pcl_frgrnd_release")
-
/*
* Get the color space type for the base color space of a palette.
*/
@@ -293,7 +291,6 @@ int pcl_palette_set_view_illuminant(
*/
int pcl_palette_check_complete(pcl_state_t * pcs);
-
#define private_st_pstack_entry_t() \
gs_private_st_ptrs1( st_pstack_entry_t, \
pstack_entry_t, \
@@ -309,11 +306,9 @@ int pcl_palette_check_complete(pcl_state_t * pcs);
extern const pcl_init_t pcl_palette_init;
extern const pcl_init_t pcl_color_init;
-
-/* free default objects (pcs->pdfl_*)
+/* free default objects (pcs->pdfl_*)
* called at end of process.
*/
void pcl_free_default_objects(gs_memory_t *mem, pcl_state_t *pcs);
-
-#endif /* pcpalet_INCLUDED */
+#endif /* pcpalet_INCLUDED */
diff --git a/pcl/pcparse.c b/pcl/pcparse.c
index ab4a896ae..e3db977ee 100644
--- a/pcl/pcparse.c
+++ b/pcl/pcparse.c
@@ -32,56 +32,56 @@
/* Register a command. Return true if this is a redefinition. */
static bool
-pcl_register_command(byte *pindex, const pcl_command_definition_t *pcmd,
- pcl_parser_state_t *pcl_parser_state)
+pcl_register_command(byte *pindex, const pcl_command_definition_t *pcmd,
+ pcl_parser_state_t *pcl_parser_state)
{ int index = pcl_parser_state->definitions->pcl_command_next_index;
- byte prev = *pindex;
+ byte prev = *pindex;
- if ( prev != 0 && prev <= index && pcl_parser_state->definitions->pcl_command_list[prev] == pcmd )
- index = prev;
- else if ( index != 0 && pcl_parser_state->definitions->pcl_command_list[index] == pcmd )
- ;
- else
+ if ( prev != 0 && prev <= index && pcl_parser_state->definitions->pcl_command_list[prev] == pcmd )
+ index = prev;
+ else if ( index != 0 && pcl_parser_state->definitions->pcl_command_list[index] == pcmd )
+ ;
+ else
pcl_parser_state->definitions->pcl_command_list[pcl_parser_state->definitions->pcl_command_next_index = ++index] = (pcl_command_definition_t *)pcmd;
- *pindex = index;
- return (prev != 0 && prev != index);
+ *pindex = index;
+ return (prev != 0 && prev != index);
}
/* Define a command or list of commands. */
void
pcl_define_control_command(int/*char*/ chr, const pcl_command_definition_t *pcmd,
- pcl_parser_state_t *pcl_parser_state)
+ pcl_parser_state_t *pcl_parser_state)
{
#ifdef DEBUG
- if ( chr < 0 || chr >= countof(pcl_parser_state->definitions->pcl_control_command_indices) )
- if_debug1('I', "Invalid control character %d\n", chr);
- else if (
+ if ( chr < 0 || chr >= countof(pcl_parser_state->definitions->pcl_control_command_indices) )
+ if_debug1('I', "Invalid control character %d\n", chr);
+ else if (
#endif
- pcl_register_command(&pcl_parser_state->definitions->pcl_control_command_indices[chr], pcmd, pcl_parser_state)
+ pcl_register_command(&pcl_parser_state->definitions->pcl_control_command_indices[chr], pcmd, pcl_parser_state)
#ifdef DEBUG
- )
- if_debug1('I', "Redefining control character %d\n", chr);
+ )
+ if_debug1('I', "Redefining control character %d\n", chr);
#endif
- ;
+ ;
}
void
pcl_define_escape_command(int/*char*/ chr,
- const pcl_command_definition_t *pcmd,
- pcl_parser_state_t *pcl_parser_state)
+ const pcl_command_definition_t *pcmd,
+ pcl_parser_state_t *pcl_parser_state)
{
#ifdef DEBUG
if ( chr < min_escape_2char || chr > max_escape_2char )
- if_debug1('I', "Invalid escape character %c\n", chr);
+ if_debug1('I', "Invalid escape character %c\n", chr);
else if (
#endif
- pcl_register_command(&pcl_parser_state->definitions->pcl_escape_command_indices
- [chr - min_escape_2char], pcmd,
- pcl_parser_state)
+ pcl_register_command(&pcl_parser_state->definitions->pcl_escape_command_indices
+ [chr - min_escape_2char], pcmd,
+ pcl_parser_state)
#ifdef DEBUG
- )
- if_debug1('I', "Redefining ESC %c\n", chr)
+ )
+ if_debug1('I', "Redefining ESC %c\n", chr)
#endif
- ;
+ ;
}
/*
@@ -93,40 +93,40 @@ static const byte pcl_escape_class_indices[max_escape_class - min_escape_class +
void
pcl_define_class_command(int/*char*/ class, int/*char*/ group,
- int/*char*/ command,
- const pcl_command_definition_t *pcmd,
- pcl_parser_state_t *pcl_parser_state)
+ int/*char*/ command,
+ const pcl_command_definition_t *pcmd,
+ pcl_parser_state_t *pcl_parser_state)
{
#ifdef DEBUG
- if ( class < min_escape_class || class > max_escape_class ||
- pcl_escape_class_indices[class - min_escape_class] == 0 ||
- (group != 0 && (group < min_escape_group || group > max_escape_group)) ||
- command < min_escape_command || command > max_escape_command
- )
- if_debug3('I', "Invalid command %c %c %c\n", class, group, command);
- else if (
+ if ( class < min_escape_class || class > max_escape_class ||
+ pcl_escape_class_indices[class - min_escape_class] == 0 ||
+ (group != 0 && (group < min_escape_group || group > max_escape_group)) ||
+ command < min_escape_command || command > max_escape_command
+ )
+ if_debug3('I', "Invalid command %c %c %c\n", class, group, command);
+ else if (
#endif
- pcl_register_command(&pcl_parser_state->definitions->pcl_grouped_command_indices
- [pcl_escape_class_indices[class - min_escape_class] - 1]
- [group == 0 ? 0 : group - min_escape_group + 1]
- [command - min_escape_command], pcmd,
- pcl_parser_state)
+ pcl_register_command(&pcl_parser_state->definitions->pcl_grouped_command_indices
+ [pcl_escape_class_indices[class - min_escape_class] - 1]
+ [group == 0 ? 0 : group - min_escape_group + 1]
+ [command - min_escape_command], pcmd,
+ pcl_parser_state)
#ifdef DEBUG
- )
- if_debug3('I', "Redefining ESC %c %c %c\n", class,
- (group == 0 ? ' ' : group), command)
+ )
+ if_debug3('I', "Redefining ESC %c %c %c\n", class,
+ (group == 0 ? ' ' : group), command)
#endif
- ;
+ ;
}
void
pcl_define_class_commands(int/*char*/ class,
- const pcl_grouped_command_definition_t *pgroup,
- pcl_parser_state_t *pcl_parser_state)
+ const pcl_grouped_command_definition_t *pgroup,
+ pcl_parser_state_t *pcl_parser_state)
{ const pcl_grouped_command_definition_t *pgc = pgroup;
- for ( ; pgc->command != 0; ++pgc )
- pcl_define_class_command(class, pgc->group, pgc->command,
- &pgc->defn, pcl_parser_state);
+ for ( ; pgc->command != 0; ++pgc )
+ pcl_define_class_command(class, pgc->group, pgc->command,
+ &pgc->defn, pcl_parser_state);
}
/*
@@ -137,37 +137,37 @@ pcl_define_class_commands(int/*char*/ class,
* The caller is responsible for providing valid arguments.
*/
static const pcl_command_definition_t *
-pcl_get_command_definition(pcl_parser_state_t *pcl_parser_state,
- int/*char*/ class,
- int/*char*/ group,
+pcl_get_command_definition(pcl_parser_state_t *pcl_parser_state,
+ int/*char*/ class,
+ int/*char*/ group,
int/*char*/ command)
{ const pcl_command_definition_t *cdefn = 0;
- if ( class == 0 )
- {if ( command >= min_escape_2char && command <= max_escape_2char )
- cdefn = pcl_parser_state->definitions->pcl_command_list
- [pcl_parser_state->definitions->pcl_escape_command_indices[command - min_escape_2char]];
- }
- else
- { int class_index = pcl_escape_class_indices[class - min_escape_class];
- if ( class_index )
- cdefn = pcl_parser_state->definitions->pcl_command_list
- [pcl_parser_state->definitions->pcl_grouped_command_indices[class_index - 1]
- [group ? group - min_escape_group + 1 : 0]
- [command - min_escape_command]
- ];
- }
+ if ( class == 0 )
+ {if ( command >= min_escape_2char && command <= max_escape_2char )
+ cdefn = pcl_parser_state->definitions->pcl_command_list
+ [pcl_parser_state->definitions->pcl_escape_command_indices[command - min_escape_2char]];
+ }
+ else
+ { int class_index = pcl_escape_class_indices[class - min_escape_class];
+ if ( class_index )
+ cdefn = pcl_parser_state->definitions->pcl_command_list
+ [pcl_parser_state->definitions->pcl_grouped_command_indices[class_index - 1]
+ [group ? group - min_escape_group + 1 : 0]
+ [command - min_escape_command]
+ ];
+ }
#ifdef DEBUG
- if ( cdefn == 0 )
- { if ( class == 0 )
- if_debug1('I', "ESC %c undefined\n", command);
- else if ( group == 0 )
- if_debug2('I', "ESC %c %c undefined\n", class, command);
- else
- if_debug3('I', "ESC %c %c %c undefined\n", class, group, command);
- }
+ if ( cdefn == 0 )
+ { if ( class == 0 )
+ if_debug1('I', "ESC %c undefined\n", command);
+ else if ( group == 0 )
+ if_debug2('I', "ESC %c %c undefined\n", class, command);
+ else
+ if_debug3('I', "ESC %c %c %c undefined\n", class, group, command);
+ }
#endif
- return cdefn;
+ return cdefn;
}
/* ---------------- Parsing ---------------- */
@@ -184,61 +184,61 @@ static int
pcl_adjust_arg(pcl_args_t *pargs, const pcl_command_definition_t *pdefn)
{ uint acts = pdefn->actions;
- if ( value_is_neg(&pargs->value) )
- { switch ( acts & pca_neg_action )
- {
- case pca_neg_clamp:
- arg_set_uint(pargs, 0); break;
- case pca_neg_error:
- return e_Range;
- case pca_neg_ignore:
- return 1;
- default: /* case pca_neg_ok */
- ;
- }
- }
- else if ( pargs->value.i > 32767 ) /* overflowed int range */
- switch ( acts & pca_big_action )
- {
- case pca_big_clamp:
- arg_set_uint(pargs, 32767); break;
- case pca_big_error:
- return e_Range;
- case pca_big_ignore:
- return 1;
- default: /* case pca_big_ok */
- ;
- }
- return 0;
+ if ( value_is_neg(&pargs->value) )
+ { switch ( acts & pca_neg_action )
+ {
+ case pca_neg_clamp:
+ arg_set_uint(pargs, 0); break;
+ case pca_neg_error:
+ return e_Range;
+ case pca_neg_ignore:
+ return 1;
+ default: /* case pca_neg_ok */
+ ;
+ }
+ }
+ else if ( pargs->value.i > 32767 ) /* overflowed int range */
+ switch ( acts & pca_big_action )
+ {
+ case pca_big_clamp:
+ arg_set_uint(pargs, 32767); break;
+ case pca_big_error:
+ return e_Range;
+ case pca_big_ignore:
+ return 1;
+ default: /* case pca_big_ok */
+ ;
+ }
+ return 0;
}
/* Append some just-scanned input data to the macro being defined. */
static int
append_macro(const byte *from, const byte *to, pcl_state_t *pcs)
{ uint count = to - from;
- uint size = gs_object_size(pcs->memory, pcs->macro_definition);
- byte *new_defn =
- gs_resize_object(pcs->memory, pcs->macro_definition, size + count,
- "append_macro");
+ uint size = gs_object_size(pcs->memory, pcs->macro_definition);
+ byte *new_defn =
+ gs_resize_object(pcs->memory, pcs->macro_definition, size + count,
+ "append_macro");
- if ( new_defn == 0 )
- return_error(e_Memory);
- memcpy(new_defn + size, from + 1, count);
- pcs->macro_definition = new_defn;
- return 0;
+ if ( new_defn == 0 )
+ return_error(e_Memory);
+ memcpy(new_defn + size, from + 1, count);
+ pcs->macro_definition = new_defn;
+ return 0;
}
/* Process a buffer of PCL commands. */
int
pcl_process(pcl_parser_state_t *pst, pcl_state_t *pcs, stream_cursor_read *pr)
{ const byte *p = pr->ptr;
- const byte *rlimit = pr->limit;
- int code = 0;
- int bytelen = 0;
- bool in_macro = pcs->defining_macro;
- /* Record how much of the input we've copied into a macro */
- /* in the process of being defined. */
- const byte *macro_p = p;
+ const byte *rlimit = pr->limit;
+ int code = 0;
+ int bytelen = 0;
+ bool in_macro = pcs->defining_macro;
+ /* Record how much of the input we've copied into a macro */
+ /* in the process of being defined. */
+ const byte *macro_p = p;
/* Reset the parameter scanner */
#define avalue pst->args.value
@@ -251,373 +251,373 @@ pcl_process(pcl_parser_state_t *pst, pcl_state_t *pcs, stream_cursor_read *pr)
# define do_display_functions() (!in_macro)
#endif
- while ( p < rlimit )
- { byte chr;
- const pcl_command_definition_t *cdefn = NULL;
+ while ( p < rlimit )
+ { byte chr;
+ const pcl_command_definition_t *cdefn = NULL;
- switch ( pst->scan_type )
- {
- case scanning_data:
- { /* Accumulate command data in a buffer. */
- uint count = uint_arg(&pst->args);
- uint pos = pst->data_pos;
+ switch ( pst->scan_type )
+ {
+ case scanning_data:
+ { /* Accumulate command data in a buffer. */
+ uint count = uint_arg(&pst->args);
+ uint pos = pst->data_pos;
- if ( pos < count )
- { uint avail = rlimit - p;
- uint copy = min(count - pos, avail);
+ if ( pos < count )
+ { uint avail = rlimit - p;
+ uint copy = min(count - pos, avail);
- memcpy(pst->args.data + pos, p + 1, copy);
- pst->data_pos += copy;
- p += copy;
- continue;
- }
- /* Invoke the command. */
- cdefn = pcl_get_command_definition(pst,
- pst->param_class,
- pst->param_group,
- pst->args.command);
- pst->scan_type = scanning_none;
- break;
- }
- case scanning_display:
- { /* Display, don't execute, all characters. */
- chr = *++p;
- if ( chr == ESC )
- { int index;
- if ( p >= rlimit )
- goto x;
- if ( p[1] >= min_escape_2char && p[1] <= max_escape_2char &&
- (index = pst->definitions->pcl_escape_command_indices[p[1] - min_escape_2char]) != 0 &&
- pst->definitions->pcl_command_list[index]->proc ==
- pcl_disable_display_functions
- )
- { if ( do_display_functions() )
- { pst->args.command = chr;
- code = pcl_plain_char(&pst->args, pcs);
- if ( code < 0 )
- goto x;
- }
- pst->args.command = chr = *++p;
- pcl_disable_display_functions(&pst->args, pcs);
- pst->scan_type = scanning_none;
- }
- }
- if ( do_display_functions() )
- { if ( chr == CR )
- { pcl_do_CR(pcs);
- code = pcl_do_LF(pcs);
- }
- else
- { pst->args.command = chr;
- code = pcl_plain_char(&pst->args, pcs);
- }
- if ( code < 0 )
- goto x;
- }
- continue;
- }
- case scanning_parameter:
- for ( ; ; )
- { if ( p >= rlimit )
- goto x;
- chr = *++p;
- /*
- * The parser for numbers is very lenient, and accepts
- * many strings that aren't valid numbers. If this
- * ever becomes a problem, we can tighten it up....
- */
- if ( chr >= '0' && chr <= '9' )
- { chr -= '0';
- if ( value_is_float(&avalue) )
- avalue.fraction += (chr / (pst->scale *= 10));
- else
- avalue.type |= pcv_int,
- avalue.i = avalue.i * 10 + chr;
- }
- else if ( chr == '-' )
- avalue.type |= pcv_neg;
- else if ( chr == '+' )
- avalue.type |= pcv_pos;
- else if ( chr == '.' )
- avalue.type |= pcv_float,
- avalue.fraction = 0,
- pst->scale = 1.0;
- else if ( chr >= ' ' && chr <= '?' )
- { /* Ignore garbage nearby in the code space. */
- continue;
- }
- else
- break;
- }
+ memcpy(pst->args.data + pos, p + 1, copy);
+ pst->data_pos += copy;
+ p += copy;
+ continue;
+ }
+ /* Invoke the command. */
+ cdefn = pcl_get_command_definition(pst,
+ pst->param_class,
+ pst->param_group,
+ pst->args.command);
+ pst->scan_type = scanning_none;
+ break;
+ }
+ case scanning_display:
+ { /* Display, don't execute, all characters. */
+ chr = *++p;
+ if ( chr == ESC )
+ { int index;
+ if ( p >= rlimit )
+ goto x;
+ if ( p[1] >= min_escape_2char && p[1] <= max_escape_2char &&
+ (index = pst->definitions->pcl_escape_command_indices[p[1] - min_escape_2char]) != 0 &&
+ pst->definitions->pcl_command_list[index]->proc ==
+ pcl_disable_display_functions
+ )
+ { if ( do_display_functions() )
+ { pst->args.command = chr;
+ code = pcl_plain_char(&pst->args, pcs);
+ if ( code < 0 )
+ goto x;
+ }
+ pst->args.command = chr = *++p;
+ pcl_disable_display_functions(&pst->args, pcs);
+ pst->scan_type = scanning_none;
+ }
+ }
+ if ( do_display_functions() )
+ { if ( chr == CR )
+ { pcl_do_CR(pcs);
+ code = pcl_do_LF(pcs);
+ }
+ else
+ { pst->args.command = chr;
+ code = pcl_plain_char(&pst->args, pcs);
+ }
+ if ( code < 0 )
+ goto x;
+ }
+ continue;
+ }
+ case scanning_parameter:
+ for ( ; ; )
+ { if ( p >= rlimit )
+ goto x;
+ chr = *++p;
+ /*
+ * The parser for numbers is very lenient, and accepts
+ * many strings that aren't valid numbers. If this
+ * ever becomes a problem, we can tighten it up....
+ */
+ if ( chr >= '0' && chr <= '9' )
+ { chr -= '0';
+ if ( value_is_float(&avalue) )
+ avalue.fraction += (chr / (pst->scale *= 10));
+ else
+ avalue.type |= pcv_int,
+ avalue.i = avalue.i * 10 + chr;
+ }
+ else if ( chr == '-' )
+ avalue.type |= pcv_neg;
+ else if ( chr == '+' )
+ avalue.type |= pcv_pos;
+ else if ( chr == '.' )
+ avalue.type |= pcv_float,
+ avalue.fraction = 0,
+ pst->scale = 1.0;
+ else if ( chr >= ' ' && chr <= '?' )
+ { /* Ignore garbage nearby in the code space. */
+ continue;
+ }
+ else
+ break;
+ }
#ifdef DEBUG
- if ( gs_debug_c('i') )
- { dprintf2("(ESC %c %c)",
- pst->param_class, pst->param_group);
- if ( value_is_present(&avalue) )
- { dputc(' ');
- if ( value_is_signed(&avalue) )
- dputc((value_is_neg(&avalue) ? '-' : '+'));
- if ( value_is_float(&avalue) )
- dprintf1("%g", avalue.i + avalue.fraction);
- else
- dprintf1("%u", avalue.i);
- }
- dprintf1(" %c\n", chr);
- }
+ if ( gs_debug_c('i') )
+ { dprintf2("(ESC %c %c)",
+ pst->param_class, pst->param_group);
+ if ( value_is_present(&avalue) )
+ { dputc(' ');
+ if ( value_is_signed(&avalue) )
+ dputc((value_is_neg(&avalue) ? '-' : '+'));
+ if ( value_is_float(&avalue) )
+ dprintf1("%g", avalue.i + avalue.fraction);
+ else
+ dprintf1("%u", avalue.i);
+ }
+ dprintf1(" %c\n", chr);
+ }
#endif
- if ( chr >= min_escape_command + 32 &&
- chr <= max_escape_command + 32
- )
- chr -= 32;
- else if ( chr >= min_escape_command &&
- chr <= max_escape_command
- )
- pst->scan_type = scanning_none;
- else
- { pst->scan_type = scanning_none;
- /* Rescan the out-of-place character. */
- --p;
- continue;
- }
- /* Dispatch on param_class, param_group, and chr. */
- cdefn = pcl_get_command_definition(pst,
- pst->param_class,
- pst->param_group,
- chr);
- if ( cdefn )
- { if_debug1('i', " [%s]\n", cdefn->cname);
- code = pcl_adjust_arg(&pst->args, cdefn);
- if ( code < 0 )
- goto x;
- if ( cdefn->actions & pca_byte_data ) {
- uint count = uint_arg(&pst->args);
- if ( (count > 0 ) && (rlimit - p <= count) ) {
- pst->args.data =
- gs_alloc_bytes(pcs->memory, count,
- "command data");
- if ( pst->args.data == 0 )
- { --p;
- code = gs_note_error(e_Memory);
- goto x;
- }
- pst->args.data_on_heap = true;
- pst->args.command = chr;
- pst->data_pos = 0;
- pst->scan_type = scanning_data;
- continue;
- }
- pst->args.data = (byte *)(p + 1);
- pst->args.data_on_heap = false;
- p += count;
- }
- break;
- }
- param_init();
- continue;
- case scanning_none:
- if ( pcs->parse_other )
- { /*
- * Hand off the data stream
- * to another parser (HP-GL/2).
- */
- pr->ptr = p;
- code = (*pcs->parse_other)
- (pcs->parse_data, pcs, pr);
- p = pr->ptr;
- if ( code < 0 || (code == 0 && pcs->parse_other) )
- goto x;
- }
- chr = *++p;
- /* check for multi-byte scanning */
- bytelen = pcl_char_bytelen( chr, pcs->text_parsing_method );
- if ( bytelen == 0 ) {
- bytelen = 1; /* invalid utf-8 leading char */
- }
- if ( bytelen > 1 ) {
- /* check if we need more data */
- if ( (p + bytelen - 1) > rlimit ) {
- --p;
- goto x;
- }
- if_debug2('i', "%x%x\n", p[0], p[1]);
- code = pcl_text(p, bytelen, pcs, false);
- if ( code < 0 ) goto x;
- /* now pass over the remaining bytes */
- p += (bytelen - 1);
- cdefn = NULL;
- } else if ( chr != ESC )
- { if_debug1('i',
- (chr == '\\' ? "\\%c\n" :
- chr >= 33 && chr <= 126 ?
- "%c\n" : "\\%03o\n"),
- chr);
- cdefn = pst->definitions->pcl_command_list
- [chr < 33 ?
- pst->definitions->pcl_control_command_indices[chr] :
- pst->definitions->pcl_control_command_indices[1]];
- if ( (cdefn == 0 ||
- cdefn->proc == pcl_plain_char) &&
- !in_macro &&
- !pcs->parse_other &&
- !pcs->raster_state.graphics_mode
- )
- { /*
- * Look ahead for a run of plain text.
- * We can be very conservative about this,
- * because this is only a performance
- * enhancement.
- */
- const byte *str = p;
- while ( p < rlimit && p[1] >= 32 &&
- p[1] <= 127
- )
- { if_debug1('i', "%c", p[1]);
- ++p;
- }
+ if ( chr >= min_escape_command + 32 &&
+ chr <= max_escape_command + 32
+ )
+ chr -= 32;
+ else if ( chr >= min_escape_command &&
+ chr <= max_escape_command
+ )
+ pst->scan_type = scanning_none;
+ else
+ { pst->scan_type = scanning_none;
+ /* Rescan the out-of-place character. */
+ --p;
+ continue;
+ }
+ /* Dispatch on param_class, param_group, and chr. */
+ cdefn = pcl_get_command_definition(pst,
+ pst->param_class,
+ pst->param_group,
+ chr);
+ if ( cdefn )
+ { if_debug1('i', " [%s]\n", cdefn->cname);
+ code = pcl_adjust_arg(&pst->args, cdefn);
+ if ( code < 0 )
+ goto x;
+ if ( cdefn->actions & pca_byte_data ) {
+ uint count = uint_arg(&pst->args);
+ if ( (count > 0 ) && (rlimit - p <= count) ) {
+ pst->args.data =
+ gs_alloc_bytes(pcs->memory, count,
+ "command data");
+ if ( pst->args.data == 0 )
+ { --p;
+ code = gs_note_error(e_Memory);
+ goto x;
+ }
+ pst->args.data_on_heap = true;
+ pst->args.command = chr;
+ pst->data_pos = 0;
+ pst->scan_type = scanning_data;
+ continue;
+ }
+ pst->args.data = (byte *)(p + 1);
+ pst->args.data_on_heap = false;
+ p += count;
+ }
+ break;
+ }
+ param_init();
+ continue;
+ case scanning_none:
+ if ( pcs->parse_other )
+ { /*
+ * Hand off the data stream
+ * to another parser (HP-GL/2).
+ */
+ pr->ptr = p;
+ code = (*pcs->parse_other)
+ (pcs->parse_data, pcs, pr);
+ p = pr->ptr;
+ if ( code < 0 || (code == 0 && pcs->parse_other) )
+ goto x;
+ }
+ chr = *++p;
+ /* check for multi-byte scanning */
+ bytelen = pcl_char_bytelen( chr, pcs->text_parsing_method );
+ if ( bytelen == 0 ) {
+ bytelen = 1; /* invalid utf-8 leading char */
+ }
+ if ( bytelen > 1 ) {
+ /* check if we need more data */
+ if ( (p + bytelen - 1) > rlimit ) {
+ --p;
+ goto x;
+ }
+ if_debug2('i', "%x%x\n", p[0], p[1]);
+ code = pcl_text(p, bytelen, pcs, false);
+ if ( code < 0 ) goto x;
+ /* now pass over the remaining bytes */
+ p += (bytelen - 1);
+ cdefn = NULL;
+ } else if ( chr != ESC )
+ { if_debug1('i',
+ (chr == '\\' ? "\\%c\n" :
+ chr >= 33 && chr <= 126 ?
+ "%c\n" : "\\%03o\n"),
+ chr);
+ cdefn = pst->definitions->pcl_command_list
+ [chr < 33 ?
+ pst->definitions->pcl_control_command_indices[chr] :
+ pst->definitions->pcl_control_command_indices[1]];
+ if ( (cdefn == 0 ||
+ cdefn->proc == pcl_plain_char) &&
+ !in_macro &&
+ !pcs->parse_other &&
+ !pcs->raster_state.graphics_mode
+ )
+ { /*
+ * Look ahead for a run of plain text.
+ * We can be very conservative about this,
+ * because this is only a performance
+ * enhancement.
+ */
+ const byte *str = p;
+ while ( p < rlimit && p[1] >= 32 &&
+ p[1] <= 127
+ )
+ { if_debug1('i', "%c", p[1]);
+ ++p;
+ }
- if_debug0('i', "\n");
- code = pcl_text(str, (uint)(p + 1 - str),
- pcs, false);
- if ( code < 0 )
- goto x;
- cdefn = NULL;
- }
- }
- else
- { if ( p >= rlimit ) { --p; goto x; }
- chr = *++p;
- if ( chr < min_escape_class ||
- chr > max_escape_class
- )
- { if_debug1('i',
- (chr >= 33 && chr <= 126 ?
- "ESC %c\n" :
- "ESC \\%03o\n"),
- chr);
- cdefn =
- pcl_get_command_definition(pst, 0, 0, chr);
- if ( !cdefn )
- {
+ if_debug0('i', "\n");
+ code = pcl_text(str, (uint)(p + 1 - str),
+ pcs, false);
+ if ( code < 0 )
+ goto x;
+ cdefn = NULL;
+ }
+ }
+ else
+ { if ( p >= rlimit ) { --p; goto x; }
+ chr = *++p;
+ if ( chr < min_escape_class ||
+ chr > max_escape_class
+ )
+ { if_debug1('i',
+ (chr >= 33 && chr <= 126 ?
+ "ESC %c\n" :
+ "ESC \\%03o\n"),
+ chr);
+ cdefn =
+ pcl_get_command_definition(pst, 0, 0, chr);
+ if ( !cdefn )
+ {
/* Skip the ESC, back up
to the char following the
ESC. */
--p;
- continue;
- }
- if_debug1('i', " [%s]\n",
- cdefn->cname);
- }
- else
- { if ( p >= rlimit ) { p -= 2; goto x; }
- pst->param_class = chr;
- chr = *++p;
- if ( chr < min_escape_group ||
- chr > max_escape_group
- )
- { /* Class but no group */
- --p;
- chr = 0;
- }
- pst->param_group = chr;
- if_debug2('i', "ESC %c %c\n",
- pst->param_class, chr);
- pst->scan_type = scanning_parameter;
- param_init();
- continue;
- }
- }
- break;
- }
- if ( cdefn == NULL )
- { param_init();
- continue;
- }
- if ( !in_macro || (cdefn->actions & pca_in_macro) )
- { /* This might be the end-of-macro command. */
- /* Make sure all the data through this point */
- /* has been captured in the macro definition. */
- if ( in_macro )
- { code = append_macro(macro_p, p, pcs);
- macro_p = p;
- if ( code < 0 )
- goto x;
- }
- pst->args.command = chr;
- if ( !pcs->raster_state.graphics_mode ||
- (cdefn->actions & pca_raster_graphics) ||
- (code = pcl_end_graphics_mode(pcs)) >= 0
- ) {
- if ( (pcs->personality != rtl) ||
- ((pcs->personality == rtl) && (cdefn->actions & pca_in_rtl)) )
- code = (*cdefn->proc)(&pst->args, pcs);
- }
- /*
- * If we allocated a buffer for command data,
- * and the command didn't take possession of it,
- * free it now. */
- if ( pst->args.data_on_heap && pst->args.data )
- { gs_free_object(pcs->memory, pst->args.data,
- "command data");
- pst->args.data = 0;
- }
- if ( code == e_Unimplemented )
- {
+ continue;
+ }
+ if_debug1('i', " [%s]\n",
+ cdefn->cname);
+ }
+ else
+ { if ( p >= rlimit ) { p -= 2; goto x; }
+ pst->param_class = chr;
+ chr = *++p;
+ if ( chr < min_escape_group ||
+ chr > max_escape_group
+ )
+ { /* Class but no group */
+ --p;
+ chr = 0;
+ }
+ pst->param_group = chr;
+ if_debug2('i', "ESC %c %c\n",
+ pst->param_class, chr);
+ pst->scan_type = scanning_parameter;
+ param_init();
+ continue;
+ }
+ }
+ break;
+ }
+ if ( cdefn == NULL )
+ { param_init();
+ continue;
+ }
+ if ( !in_macro || (cdefn->actions & pca_in_macro) )
+ { /* This might be the end-of-macro command. */
+ /* Make sure all the data through this point */
+ /* has been captured in the macro definition. */
+ if ( in_macro )
+ { code = append_macro(macro_p, p, pcs);
+ macro_p = p;
+ if ( code < 0 )
+ goto x;
+ }
+ pst->args.command = chr;
+ if ( !pcs->raster_state.graphics_mode ||
+ (cdefn->actions & pca_raster_graphics) ||
+ (code = pcl_end_graphics_mode(pcs)) >= 0
+ ) {
+ if ( (pcs->personality != rtl) ||
+ ((pcs->personality == rtl) && (cdefn->actions & pca_in_rtl)) )
+ code = (*cdefn->proc)(&pst->args, pcs);
+ }
+ /*
+ * If we allocated a buffer for command data,
+ * and the command didn't take possession of it,
+ * free it now. */
+ if ( pst->args.data_on_heap && pst->args.data )
+ { gs_free_object(pcs->memory, pst->args.data,
+ "command data");
+ pst->args.data = 0;
+ }
+ if ( code == e_Unimplemented )
+ {
#if e_Unimplemented != 0
- if_debug0('i', "Unimplemented\n");
+ if_debug0('i', "Unimplemented\n");
#endif
- }
- else if ( code < 0 )
- break;
- if ( pcs->display_functions )
- { /* This calls for a special parsing state. */
- pst->scan_type = scanning_display;
- }
- if ( pcs->defining_macro && !in_macro )
- { /* We just started a macro definition. */
- if (pst->scan_type != scanning_none)
- { /* combinded command started macro */
- /* start definition of macro with esc& preloaded */
- static const byte macro_prefix[3] = " \033&";
- append_macro(&macro_prefix[0], &macro_prefix[2], pcs);
- }
- macro_p = p;
- }
- in_macro = pcs->defining_macro;
- }
- else
- { /*
- * If we allocated a buffer for command data,
- * free it now.
- */
- if ( pst->args.data_on_heap && pst->args.data )
- { gs_free_object(pcs->memory, pst->args.data,
- "command data");
- pst->args.data = 0;
- }
- }
- param_init();
- }
+ }
+ else if ( code < 0 )
+ break;
+ if ( pcs->display_functions )
+ { /* This calls for a special parsing state. */
+ pst->scan_type = scanning_display;
+ }
+ if ( pcs->defining_macro && !in_macro )
+ { /* We just started a macro definition. */
+ if (pst->scan_type != scanning_none)
+ { /* combinded command started macro */
+ /* start definition of macro with esc& preloaded */
+ static const byte macro_prefix[3] = " \033&";
+ append_macro(&macro_prefix[0], &macro_prefix[2], pcs);
+ }
+ macro_p = p;
+ }
+ in_macro = pcs->defining_macro;
+ }
+ else
+ { /*
+ * If we allocated a buffer for command data,
+ * free it now.
+ */
+ if ( pst->args.data_on_heap && pst->args.data )
+ { gs_free_object(pcs->memory, pst->args.data,
+ "command data");
+ pst->args.data = 0;
+ }
+ }
+ param_init();
+ }
x: pr->ptr = p;
- /* Append the last bit of data to the macro, if defining. */
- if ( in_macro )
- { int mcode = append_macro(macro_p, p, pcs);
- if ( mcode < 0 && code >= 0 )
- code = mcode;
- }
- return code;
+ /* Append the last bit of data to the macro, if defining. */
+ if ( in_macro )
+ { int mcode = append_macro(macro_p, p, pcs);
+ if ( mcode < 0 && code >= 0 )
+ code = mcode;
+ }
+ return code;
}
/* inialize the pcl command counter */
int
pcl_init_command_index(pcl_parser_state_t *pcl_parser_state, pcl_state_t *pcs)
{
- pcl_command_definitions_t *definitions =
- (pcl_command_definitions_t *)gs_alloc_bytes(pcs->memory,
- sizeof(pcl_command_definitions_t),
- "pcl_init_command_index");
+ pcl_command_definitions_t *definitions =
+ (pcl_command_definitions_t *)gs_alloc_bytes(pcs->memory,
+ sizeof(pcl_command_definitions_t),
+ "pcl_init_command_index");
/* fatal */
if ( definitions == 0 )
- return -1;
+ return -1;
/* we should set these individually but each field is properly
initialized to zero */
memset(definitions, 0, sizeof(pcl_command_definitions_t));
@@ -635,16 +635,16 @@ pcl_init_command_index(pcl_parser_state_t *pcl_parser_state, pcl_state_t *pcs)
pcl_parser_shutdown(pcl_parser_state_t *pcl_parser_state, gs_memory_t *mem)
{
gs_free_object(mem, pcl_parser_state->definitions,
- "pcl_parser_shutdown");
+ "pcl_parser_shutdown");
return 0;
}
/* ---------------- Initialization ---------------- */
void
pcparse_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
-{
+{
if ( type & (pcl_reset_initial | pcl_reset_printer) )
- pcs->parse_other = 0;
+ pcs->parse_other = 0;
}
const pcl_init_t pcparse_init = {
diff --git a/pcl/pcparse.h b/pcl/pcparse.h
index 747882925..23c6cc89b 100644
--- a/pcl/pcparse.h
+++ b/pcl/pcparse.h
@@ -23,10 +23,10 @@
/* Define the lexical state of the scanner. */
typedef enum {
- scanning_none,
- scanning_parameter,
- scanning_display, /* display_functions mode */
- scanning_data /* data following a command */
+ scanning_none,
+ scanning_parameter,
+ scanning_display, /* display_functions mode */
+ scanning_data /* data following a command */
} pcl_scan_type_t;
#define min_escape_2char '0'
diff --git a/pcl/pcpatrn.c b/pcl/pcpatrn.c
index 6c1d63ba8..53b7d39b0 100644
--- a/pcl/pcpatrn.c
+++ b/pcl/pcpatrn.c
@@ -31,8 +31,6 @@
#include "pcuptrn.h"
#include "pcpatxfm.h"
-
-
/*
* The base color space for setting the color white. Unlike all other color
* spaces in PCL, this uses the DeviceGray color space in the graphic library.
@@ -47,7 +45,6 @@ static const gs_paint_color white_paint = {{ 1.0, 0.0, 0.0, 0.0 }};
/* GC routines */
private_st_ccolor_t();
-
/*
* Convert a color value specified as a three-element byte array, or an index
* to a palette, into a gs_paint_color structure.
@@ -124,7 +121,6 @@ set_ht_crd_from_foreground(
return code;
}
-
/*
* Free a PCL client color structure.
*/
@@ -218,7 +214,7 @@ unshare_ccolor(
}
/*
- * Set a solid color (unpattered) color. This is handled separately from
+ * Set a solid color (unpattered) color. This is handled separately from
* patterns as it will usually not be necessary to build a PCL client color
* structure in this case.
*
@@ -237,9 +233,9 @@ set_unpatterned_color(
pcl_ccolor_type_t type;
if ( pcur != 0 )
- type = pcur->type;
+ type = pcur->type;
else
- type = pcl_ccolor_unpatterned;
+ type = pcl_ccolor_unpatterned;
if ( (pcur != 0) &&
(type == pcl_ccolor_unpatterned) &&
@@ -301,7 +297,7 @@ set_patterned_color(
if ( (pnew->pindexed != 0) &&
((pcur == 0) || (pcur->pindexed != pnew->pindexed)) )
code = pcl_cs_indexed_install(&(pnew->pindexed), pcs);
-
+
if ( (pnew->pbase != 0) &&
((pcur == 0) || (pcur->pbase != pnew->pbase)) )
code = pcl_cs_base_install(&(pnew->pbase), pcs);
@@ -440,7 +436,7 @@ render_pattern(
pcl_ccolor_release(pptrn->pmask_ccolor);
pptrn->pmask_ccolor = 0;
}
- }
+ }
/* un-share, or allocate, the appropriate client color */
if (type == pcl_ccolor_mask_pattern) {
@@ -485,9 +481,9 @@ render_pattern(
pixinfo = pptrn->ppat_data->pixinfo;
if (pcspace != 0)
- code = pcl_cs_indexed_install(&pindexed, pcs);
+ code = pcl_cs_indexed_install(&pindexed, pcs);
if ( code < 0 )
- return code;
+ return code;
/* the following is placed here until we have time to properly
address this. The makepixmappattern() procedure detects a
@@ -728,7 +724,7 @@ set_colored_pattern(
* Note that this routine does NOT set the current
* line width (it does not have sufficient
* information to convert the dimensions).
- *
+ *
* pattern_set_frgrnd One additional operands. Sets currect base
* color space as the color space, and the
* foreground color as the current color.
@@ -755,12 +751,12 @@ set_colored_pattern(
* foreground.
*
* Special considerations apply if the pattern is
- * being set to render a PCL raster. See the
+ * being set to render a PCL raster. See the
* paragraphs at the bottom of this comment for
* additional information.
*
* pattern_set_shade_gl Two additional operands; the first provides
- * the pattern intensity, the latter the pen
+ * the pattern intensity, the latter the pen
* number to be be used as the foreground color.
* This routine generates the pattern using a two
* entry palette consisting of canonical white in
@@ -917,8 +913,8 @@ pattern_set_pen(
/* put the pen number in the proper range */
if ( (pen >= num_entries) &&
- ((pen = (pen % num_entries) + 1) == num_entries) )
- pen = 1;
+ ((pen = (pen % num_entries) + 1) == num_entries) )
+ pen = 1;
/* check if the current pen is white; if so, use the "unsolid" pattern */
@@ -926,7 +922,7 @@ pattern_set_pen(
/* Optimization for a special case where we don't need the
unsolid pattern, drawing an opaque white rectangle with
simple rops (we only check for 2 common rops). */
- if (!pcs->g.source_transparent &&
+ if (!pcs->g.source_transparent &&
(pcs->logical_op == rop3_default || pcs->logical_op == rop3_T))
goto skip_unsolid;
else
@@ -962,25 +958,25 @@ pattern_set_frgrnd(
/* check if a solid pattern should be substituted */
if ( for_image ) {
- if ((pfrgrnd->pht != ppalet->pht) ||
- (pfrgrnd->pcrd != ppalet->pcrd) ) {
- code = set_frgrnd_pattern(pcs, pcl_pattern_get_solid_pattern(pcs), true);
- if (code >= 0)
- code = set_ht_crd_from_palette(pcs);
- return code;
- }
- else if ( (ppalet->pindexed->original_cspace == 1 && !pfrgrnd->is_cmy ) ||
- (ppalet->pindexed->original_cspace != 1 && pfrgrnd->is_cmy ) ) {
- const byte blk[] = {0, 0, 0};
- gs_paint_color paint;
-
- /* NB: HP forces black foreground, as they can't handle different
- * colorspaces in foreground and raster palette
- */
- convert_color_to_paint(blk, &paint);
- code = set_unpatterned_color(pcs, NULL, pfrgrnd->pbase, &paint);
- return code;
- }
+ if ((pfrgrnd->pht != ppalet->pht) ||
+ (pfrgrnd->pcrd != ppalet->pcrd) ) {
+ code = set_frgrnd_pattern(pcs, pcl_pattern_get_solid_pattern(pcs), true);
+ if (code >= 0)
+ code = set_ht_crd_from_palette(pcs);
+ return code;
+ }
+ else if ( (ppalet->pindexed->original_cspace == 1 && !pfrgrnd->is_cmy ) ||
+ (ppalet->pindexed->original_cspace != 1 && pfrgrnd->is_cmy ) ) {
+ const byte blk[] = {0, 0, 0};
+ gs_paint_color paint;
+
+ /* NB: HP forces black foreground, as they can't handle different
+ * colorspaces in foreground and raster palette
+ */
+ convert_color_to_paint(blk, &paint);
+ code = set_unpatterned_color(pcs, NULL, pfrgrnd->pbase, &paint);
+ return code;
+ }
}
{
gs_paint_color paint;
@@ -1009,7 +1005,7 @@ pattern_set_shade_pcl(
pcl_xfm_pcl_set_pat_ref_pt(pcs);
code = set_frgrnd_pattern(pcs, pptrn, for_image);
-
+
if (for_image && (code >= 0))
code = set_ht_crd_from_palette(pcs);
return code;
@@ -1031,7 +1027,7 @@ pattern_set_shade_gl(
else if (pptrn == 0)
return ( inten > 0 ? pattern_set_pen(pcs, pen, false)
: pattern_set_white(pcs, 0, 0) );
-
+
pcl_xfm_gl_set_pat_ref_pt(pcs);
return set_uncolored_palette_pattern(pcs, pptrn, pen);
}
@@ -1117,7 +1113,7 @@ pattern_set_user_gl(
pcl_xfm_gl_set_pat_ref_pt(pcs);
if (pptrn->ppat_data->type == pcl_pattern_uncolored) {
- /* check if the current pen is white */
+ /* check if the current pen is white */
if (pcl_cs_indexed_is_white(pcs->ppalet->pindexed, pen))
pptrn = pcl_pattern_get_unsolid_pattern(pcs);
return set_uncolored_palette_pattern(pcs, pptrn, pen);
@@ -1160,7 +1156,6 @@ pattern_set_gl_RF(
}
}
-
/*
* Return the appropriate "set" procedure, given a PCL pattern type.
*/
@@ -1226,7 +1221,6 @@ pcl_pattern_get_proc_SV(
return 0;
}
-
/*
* ESC * c <#/id> G
*
@@ -1310,7 +1304,7 @@ select_current_pattern(
* that we are parsing the command correctly. The lightness and
* saturation parameters are not documented so we do not believe this
* command will be used by an application or driver.
- *
+ *
*/
typedef struct driver_configuration_s {
@@ -1329,42 +1323,42 @@ set_driver_configuration(
driver_configuration_t *driver = (driver_configuration_t *)arg_data(pargs);
if ( pcs->personality == pcl5e )
- return 0;
+ return 0;
if ( count != sizeof(driver_configuration_t) )
- return e_Range;
+ return e_Range;
/* the only device known to support this command */
- if ( ( driver->device_id < 6 ) /* 6 == hp color laserjet */
- || /* 7 == hp clj 5 */
+ if ( ( driver->device_id < 6 ) /* 6 == hp color laserjet */
+ || /* 7 == hp clj 5 */
( driver->device_id > 8 ) ) /* 8 == hp 4500 - 4550 */ {
dprintf1("unknown device id %d\n", driver->device_id );
- return e_Range;
+ return e_Range;
}
switch (driver->function_index) {
case 0: /* lightness */
- {
- int code;
- if ( driver->arguments < -100 || driver->arguments > 100 )
- return e_Range;
- /* map -100..100 to gamma setting 0.05..4.05 */
- code = pcl_palette_set_gamma(pcs, ((driver->arguments + 100.0) / 200.0) + 0.05);
- if ( code < 0 )
- return code;
- }
- break;
+ {
+ int code;
+ if ( driver->arguments < -100 || driver->arguments > 100 )
+ return e_Range;
+ /* map -100..100 to gamma setting 0.05..4.05 */
+ code = pcl_palette_set_gamma(pcs, ((driver->arguments + 100.0) / 200.0) + 0.05);
+ if ( code < 0 )
+ return code;
+ }
+ break;
case 1: /* saturation */
- {
- int code;
- if ( driver->arguments < -100 || driver->arguments > 100 )
- return e_Range;
- /* map -100..100 to gamma setting 0.05..4.05 */
- code = pcl_palette_set_gamma(pcs, ((driver->arguments + 100.0) / 200.0) + 0.05);
- if ( code < 0 )
- return code;
- }
- break;
+ {
+ int code;
+ if ( driver->arguments < -100 || driver->arguments > 100 )
+ return e_Range;
+ /* map -100..100 to gamma setting 0.05..4.05 */
+ code = pcl_palette_set_gamma(pcs, ((driver->arguments + 100.0) / 200.0) + 0.05);
+ if ( code < 0 )
+ return code;
+ }
+ break;
case 4:
/* driver arguments 3 & 6 are parsed, but not implemented. In
our model where all data is treated as sRGB and color
@@ -1382,12 +1376,11 @@ set_driver_configuration(
return e_Range;
break;
default:
- return e_Range;
+ return e_Range;
}
return 0;
}
-
/*
* Initialization and reset routines.
*/
@@ -1435,7 +1428,7 @@ pattern_do_registration(
},
END_CLASS
return 0;
-
+
}
static void
@@ -1464,11 +1457,11 @@ pattern_do_reset(
gs_state *pgs = pcs->pgs;
(gstate_pattern_cache(pgs)->free_all)(gstate_pattern_cache(pgs));
- gs_free_object(pcs->memory,
- gstate_pattern_cache(pgs)->tiles,
+ gs_free_object(pcs->memory,
+ gstate_pattern_cache(pgs)->tiles,
"pattern_do_reset(tiles)");
- gs_free_object(pcs->memory,
- gstate_pattern_cache(pgs),
+ gs_free_object(pcs->memory,
+ gstate_pattern_cache(pgs),
"pattern_do_reset(struct)");
while (pgs) {
gstate_set_pattern_cache(pgs, 0);
diff --git a/pcl/pcpatrn.h b/pcl/pcpatrn.h
index e81265615..ab4264402 100644
--- a/pcl/pcpatrn.h
+++ b/pcl/pcpatrn.h
@@ -26,8 +26,8 @@
* PCL pattern types.
*
* There are two types of patterns used in PCL, colored and uncolored. In
- * order to support transparency, both types are implemented as colored
- * patterns in the graphics library (which does not support opaque
+ * order to support transparency, both types are implemented as colored
+ * patterns in the graphics library (which does not support opaque
* uncolored patterns).
*
* The values used are defined by HP.
@@ -95,8 +95,6 @@ typedef struct pcl_pattern_data_s {
#define pcl_pattern_data_release(ppat_data) \
rc_decrement(ppat_data, "pcl_pattern_data_release")
-
-
/* forward declaration */
#ifndef pcl_ccolor_DEFINED
#define pcl_ccolor_DEFINED
@@ -111,7 +109,7 @@ typedef struct pcl_ccolor_s pcl_ccolor_t;
* instances. There are potentially two rendered instances of a pattern,
* one as a mask (uncolored) pattern and one as a colored pattern.
*
- * A "colored" pattern in the PCL sense will never have a mask rendering, but
+ * A "colored" pattern in the PCL sense will never have a mask rendering, but
* an "uncolored" PCL pattern may have both a mask and a colored rendering,
* because mask patterns in the graphic library cannot be opaque, and cannot
* use a halftone or color redering dictionary that differs from that being
@@ -130,7 +128,7 @@ typedef struct pcl_ccolor_s pcl_ccolor_t;
* the range 0 to 3.
*
* The pen field applies only to the colored pattern rendering and is used
- * only for patterns that are uncolored in the PCL sense and rendered
+ * only for patterns that are uncolored in the PCL sense and rendered
* from GL/2. The pen field indicates the palette entry used as the
* foreground for the pattern. For PCL colored patterns or uncolored
* patterns rendered from PCL, this field will be 0. The value 0 is
@@ -175,7 +173,6 @@ typedef struct pcl_pattern_t {
pmask_ccolor \
)
-
/*
* The PCL structure corresponding to the graphic library's client color
* structure. The latter potentially contains a client data structure pointer
@@ -205,7 +202,7 @@ typedef struct pcl_pattern_t {
*
* one of pindexed or pbase points to the base color space of the
* pattern color space (the other is NULL)
- *
+ *
* ccolor.paint.values[0] or ccolor.paint.values[0..2] holds the
* color values to be use for the pattern foreground
*
@@ -243,7 +240,7 @@ typedef enum {
struct pcl_ccolor_s {
rc_header rc;
pcl_ccolor_type_t type;
- pcl_pattern_data_t * ppat_data;
+ pcl_pattern_data_t * ppat_data;
pcl_cs_indexed_t * pindexed;
pcl_cs_base_t * pbase;
const byte * prast;
@@ -283,7 +280,6 @@ struct pcl_ccolor_s {
#define pcl_ccolor_release(pccolor) \
rc_decrement(pccolor, "pcl_ccolor_release")
-
/*
* Create a colored pcl_pattern_t object from a gs_depth_bitmap object. This
* object will be considered "temporary" in the sense of a PCL resource, and
@@ -317,8 +313,8 @@ int pcl_pattern_RF(
* the graphic state in different situations. The chart below characterizes
* what the operands are interpreted to mean, and what the source of the
* (graphic state) color space, color, color rendering dictionary, and
- * halftone (including transfer function) are for each case. Note in
- * particular that uncolored patterns (including the built-in shades and
+ * halftone (including transfer function) are for each case. Note in
+ * particular that uncolored patterns (including the built-in shades and
* cross-hatch patterns) must be handled separately for PCL and GL.
*
* solid white (PCL or GL)
@@ -329,7 +325,7 @@ int pcl_pattern_RF(
*
* cspace DeviceGray (irrespective of current space)
* color 1,0 (irrespective of current color)
- * CRD unchanged (irrelevant since DeviceGray is
+ * CRD unchanged (irrelevant since DeviceGray is
* the color space)
* halftone Fixed halftone with null transfer function
*
@@ -367,17 +363,17 @@ int pcl_pattern_RF(
* pattern source built-in shade patterns
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current foreground and a 2-entry palette. The
- * palette contains the canonical white color and
- * the foreground color. The color rendering
- * dictionary and halftone also are taken from
+ * palette contains the canonical white color and
+ * the foreground color. The color rendering
+ * dictionary and halftone also are taken from
* the current color.
- * CRD from current foreground (only relevant for
+ * CRD from current foreground (only relevant for
* pattern rendering)
- * halftone from current foreground (only relevant for
+ * halftone from current foreground (only relevant for
* pattern rendering).
*
* shade pattern (GL only)
@@ -387,17 +383,17 @@ int pcl_pattern_RF(
* pattern source built-in shade patterns
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current palette and a 2-entry palette. The
- * palette contains the canonical white color and
- * the color corresponding to the given pen. The
- * color rendering dictionary and halftone are
+ * palette contains the canonical white color and
+ * the color corresponding to the given pen. The
+ * color rendering dictionary and halftone are
* taken from the given palette.
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for
+ * halftone from current palette (only relevant for
* pattern rendering).
*
* cross-hatch pattern (PCL only)
@@ -407,17 +403,17 @@ int pcl_pattern_RF(
* pattern-source built-in cross-hatch patterns
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current foreground and a 2-entry palette. The
- * palette contains the canonical white color and
- * the foreground color. The color rendering
- * dictionary and halftone also are taken from the
+ * palette contains the canonical white color and
+ * the foreground color. The color rendering
+ * dictionary and halftone also are taken from the
* current color.
- * CRD from current foreground (only relevant for
+ * CRD from current foreground (only relevant for
* pattern rendering)
- * halftone from current foreground (only relevant for
+ * halftone from current foreground (only relevant for
* pattern rendering).
*
* cross-hatch pattern (GL only)
@@ -427,17 +423,17 @@ int pcl_pattern_RF(
* pattern source built-in cross-hatch patterns
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current palette und and a 2-entry palette. The
- * palette contains the canonical white color and
- * the color corresponding to the given pen. The
- * color rendering dictionary and halftone are
+ * palette contains the canonical white color and
+ * the color corresponding to the given pen. The
+ * color rendering dictionary and halftone are
* taken from the given palette.
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for
+ * halftone from current palette (only relevant for
* pattern rendering).
*
* PCL user-defined pattern (PCL only)
@@ -448,31 +444,31 @@ int pcl_pattern_RF(
*
* Handling depends on the pattern type. For uncolored patterns, the
* settings are:
- *
+ *
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current foreground and a 2-entry palette. The
- * palette contains the canonical white color and
- * the foreground color. The color rendering
- * dictionary and halftone also are taken from the
+ * palette contains the canonical white color and
+ * the foreground color. The color rendering
+ * dictionary and halftone also are taken from the
* current color.
- * CRD from current foreground (only relevant for
+ * CRD from current foreground (only relevant for
* pattern rendering)
- * halftone from current foreground (only relevant for
+ * halftone from current foreground (only relevant for
* pattern rendering).
*
* For colored patterns, the settings are:
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and the indexed color space in the
- * current palette, along with the halftone and
+ * color Colored pattern generated from the pixmap data
+ * provided and the indexed color space in the
+ * current palette, along with the halftone and
* color rendering dictionary in the current palette
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for color
+ * halftone from current palette (only relevant for color
* generation)
*
* PCL user-defined pattern (GL only)
@@ -483,31 +479,31 @@ int pcl_pattern_RF(
*
* Handling depends on the pattern type. For uncolored patterns, the
* settings are:
- *
+ *
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and a special indexed color space
- * which utilizes the base color space in the
+ * color Colored pattern generated from the pixmap data
+ * provided and a special indexed color space
+ * which utilizes the base color space in the
* current palette and a 2-entry palette. The
- * palette contains the canonical white color and
- * the color corresponding to the given pen. The
- * color rendering dictionary and halftone are
+ * palette contains the canonical white color and
+ * the color corresponding to the given pen. The
+ * color rendering dictionary and halftone are
* taken from the given palette.
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for
+ * halftone from current palette (only relevant for
* pattern rendering).
- *
+ *
* For colored patterns, the settings are:
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and the indexed color space in the
- * current palette, along with the halftone and
+ * color Colored pattern generated from the pixmap data
+ * provided and the indexed color space in the
+ * current palette, along with the halftone and
* color rendering dictionary in the current palette
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for color
+ * halftone from current palette (only relevant for color
* generation)
*
* RF pattern (GL only)
@@ -517,13 +513,13 @@ int pcl_pattern_RF(
* pattern source GL user defined patterns
*
* cspace Pattern color space without base color space
- * color Colored pattern generated from the pixmap data
- * provided and the indexed color space in the
- * current palette, along with the halftone and
+ * color Colored pattern generated from the pixmap data
+ * provided and the indexed color space in the
+ * current palette, along with the halftone and
* color rendering dictionary in the current palette
- * CRD from current palette (only relevant for
+ * CRD from current palette (only relevant for
* pattern rendering)
- * halftone from current palette (only relevant for color
+ * halftone from current palette (only relevant for color
* generation)
*
* These routines will also set the pattern reference point appropriatel for
diff --git a/pcl/pcpattyp.h b/pcl/pcpattyp.h
index 82875599f..89d0657ed 100644
--- a/pcl/pcpattyp.h
+++ b/pcl/pcpattyp.h
@@ -50,7 +50,6 @@ typedef enum {
hpgl_SV_pattern_cross_hatch = 21,
hpgl_SV_pattern_user_defined = 22
} hpgl_SV_pattern_source_t;
-
/*
* Opaque definitions of palettes, foregrounds, client colors, halftones,
diff --git a/pcl/pcpatxfm.c b/pcl/pcpatxfm.c
index 6723110e3..e08b912f8 100644
--- a/pcl/pcpatxfm.c
+++ b/pcl/pcpatxfm.c
@@ -19,7 +19,6 @@
#include "pcfont.h"
#include "pcpatxfm.h"
-
/*
* The four rotation matrices used by PCL. Note that rotations in PCL are
* always multiples of 90 degrees, and map the positive x-axis to the negative
@@ -35,10 +34,9 @@ static const gs_matrix rot_mtx[4] = {
{ 0.0, 1.0, -1.0, 0.0, 0.0, 0.0 } /* 270 degrees */
};
-
/*
* Inverst a diagonal 2-dimensional affine transformation. This is much simpler
- * than inverting a general 2-dimensional affine transformation, hence a
+ * than inverting a general 2-dimensional affine transformation, hence a
* separate routine is provided for this purpose.
*
* Note that both operands may point to the same matrix.
@@ -66,7 +64,7 @@ pcl_invert_mtx(
pmtx2->yy = 0.0;
pmtx2->tx = -ty / xy;
pmtx2->ty = -tx / yx;
-
+
} else {
float yy = pmtx1->yy;
@@ -88,9 +86,9 @@ pcl_invert_mtx(
*/
void
pcl_transform_rect(const gs_memory_t *mem,
- const gs_rect * prect1,
- gs_rect * prect2,
- const gs_matrix * pmtx
+ const gs_rect * prect1,
+ gs_rect * prect2,
+ const gs_matrix * pmtx
)
{
gs_point_transform(prect1->p.x, prect1->p.y, pmtx, &(prect2->p));
@@ -275,7 +273,7 @@ pcl_xfm_pcl_set_pat_ref_pt(
);
pcs->pat_ref_pt.x = floor(pcs->pat_ref_pt.x + 0.5);
pcs->pat_ref_pt.y = floor(pcs->pat_ref_pt.y + 0.5);
- pcs->pat_orient = (pxfmst->lp_orient
+ pcs->pat_orient = (pxfmst->lp_orient
+ (pcs->rotate_patterns ? pxfmst->print_dir : 0)) & 0x3;
}
@@ -299,7 +297,6 @@ pcl_xfm_gl_set_pat_ref_pt(
pcs->pat_orient = (pcs->xfm_state.lp_orient + (pcs->g.rotation / 90)) & 0x3;
}
-
/*
* ESC * p # R
*
@@ -326,7 +323,6 @@ set_pat_ref_pt(
return 0;
}
-
/*
* Initializaton and reset routines. There is currently no copy routine, as the
* desired transformation is reset for each object printed. No special reset
diff --git a/pcl/pcpatxfm.h b/pcl/pcpatxfm.h
index f12ee6064..502482b3f 100644
--- a/pcl/pcpatxfm.h
+++ b/pcl/pcpatxfm.h
@@ -23,15 +23,14 @@
#include "pcommand.h"
#include "pcpatrn.h"
-
/* invert a diagonal matrix (assumed to be non-signular) */
void pcl_invert_mtx(const gs_matrix * pmtx1, gs_matrix * pmtx2);
/* transform a rectangel via a diagonal matrix */
void pcl_transform_rect(const gs_memory_t *mem,
- const gs_rect * prect1,
- gs_rect * prect2,
- const gs_matrix * pmtx
+ const gs_rect * prect1,
+ gs_rect * prect2,
+ const gs_matrix * pmtx
);
/*
diff --git a/pcl/pcrect.c b/pcl/pcrect.c
index 64c54782f..bb8c8ba8e 100644
--- a/pcl/pcrect.c
+++ b/pcl/pcrect.c
@@ -26,12 +26,10 @@
#include "gspaint.h"
#include "gsrop.h"
-
-
/*
* The graphic library is, unfortunately, not equipped to produce accurate
* PCL rectangles on its own. These rectangles must always be rendered with
- * the same pixel dimensions, regardless of location (ignoring clipping),
+ * the same pixel dimensions, regardless of location (ignoring clipping),
* in the "grid intersection" pixel placement mode, must always add one
* additional pixel in the "right" and "down" directions, relative to print
* direction 0.
@@ -231,37 +229,37 @@ pcrect_do_registration(
DEFINE_CLASS('*')
{
'c', 'H',
- PCL_COMMAND( "Horizontal Rectangle Size Decipoints",
- pcl_horiz_rect_size_decipoints,
- pca_neg_error | pca_big_error | pca_in_rtl
+ PCL_COMMAND( "Horizontal Rectangle Size Decipoints",
+ pcl_horiz_rect_size_decipoints,
+ pca_neg_error | pca_big_error | pca_in_rtl
)
},
{
'c', 'A',
- PCL_COMMAND( "Horizontal Rectangle Size Units",
- pcl_horiz_rect_size_units,
- pca_neg_error | pca_big_error | pca_in_rtl
+ PCL_COMMAND( "Horizontal Rectangle Size Units",
+ pcl_horiz_rect_size_units,
+ pca_neg_error | pca_big_error | pca_in_rtl
)
},
{
'c', 'V',
- PCL_COMMAND( "Vertical Rectangle Size Decipoint",
- pcl_vert_rect_size_decipoints,
- pca_neg_error | pca_big_error | pca_in_rtl
+ PCL_COMMAND( "Vertical Rectangle Size Decipoint",
+ pcl_vert_rect_size_decipoints,
+ pca_neg_error | pca_big_error | pca_in_rtl
)
},
{
'c', 'B',
- PCL_COMMAND( "Vertical Rectangle Size Units",
- pcl_vert_rect_size_units,
- pca_neg_error | pca_big_error | pca_in_rtl
+ PCL_COMMAND( "Vertical Rectangle Size Units",
+ pcl_vert_rect_size_units,
+ pca_neg_error | pca_big_error | pca_in_rtl
)
},
{
'c', 'P',
PCL_COMMAND( "Fill Rectangular Area",
pcl_fill_rect_area,
- pca_neg_ignore | pca_big_ignore | pca_in_rtl
+ pca_neg_ignore | pca_big_ignore | pca_in_rtl
)
},
END_CLASS
@@ -278,8 +276,8 @@ pcrect_do_reset(
| pcl_reset_printer
| pcl_reset_overlay );
if ((type & mask) != 0) {
- pcs->rectangle.x = 0;
- pcs->rectangle.y = 0;
+ pcs->rectangle.x = 0;
+ pcs->rectangle.y = 0;
}
}
diff --git a/pcl/pcsfont.c b/pcl/pcsfont.c
index 2ed6ade3f..09f88d02a 100644
--- a/pcl/pcsfont.c
+++ b/pcl/pcsfont.c
@@ -124,10 +124,9 @@ pcl_make_resident_font_copy(pcl_state_t *pcs)
return 0;
}
-
static int /* ESC * c <fc_enum> F */
pcl_font_control(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
gs_const_string key;
void *value;
pl_dict_enum_t denum;
@@ -149,17 +148,17 @@ pcl_font_control(pcl_args_t *pargs, pcl_state_t *pcs)
pl_dict_release(&pcs->soft_fonts);
break;
case 1:
- /* Delete all temporary soft fonts. */
- pl_dict_enum_stack_begin(&pcs->soft_fonts, &denum, false);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- if ( ((pl_font_t *)value)->storage == pcds_temporary )
- pcl_delete_soft_font(pcs, key.data, key.size, value);
+ /* Delete all temporary soft fonts. */
+ pl_dict_enum_stack_begin(&pcs->soft_fonts, &denum, false);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ if ( ((pl_font_t *)value)->storage == pcds_temporary )
+ pcl_delete_soft_font(pcs, key.data, key.size, value);
break;
case 2:
- /* Delete soft font <font_id>. */
- pcl_delete_soft_font(pcs, current_font_id, current_font_id_size, NULL);
- /* decache the currently selected font in case we deleted it. */
- pcl_decache_font(pcs, -1);
+ /* Delete soft font <font_id>. */
+ pcl_delete_soft_font(pcs, current_font_id, current_font_id_size, NULL);
+ /* decache the currently selected font in case we deleted it. */
+ pcl_decache_font(pcs, -1);
break;
case 3:
@@ -167,26 +166,26 @@ pcl_font_control(pcl_args_t *pargs, pcl_state_t *pcs)
if ( pl_dict_find_no_stack(&pcs->soft_fonts, current_font_id, current_font_id_size, &value) )
pl_font_remove_glyph((pl_font_t *)value, pcs->character_code);
return 0;
-
+
break;
case 4:
/* Make soft font <font_id> temporary. */
if ( pl_dict_find_no_stack(&pcs->soft_fonts, current_font_id, current_font_id_size, &value) )
((pl_font_t *)value)->storage = pcds_temporary;
-
+
break;
case 5:
/* Make soft font <font_id> permanent. */
if ( pl_dict_find_no_stack(&pcs->soft_fonts, current_font_id, current_font_id_size, &value) ) {
((pl_font_t *)value)->storage = pcds_permanent;
- ((pl_font_t *)value)->params.pjl_font_number =
+ ((pl_font_t *)value)->params.pjl_font_number =
pjl_proc_register_permanent_soft_font_addition(pcs->pjls);
}
break;
case 6:
{
int code;
- if ( pcs->font == 0 ) {
+ if ( pcs->font == 0 ) {
code = pcl_recompute_font(pcs, false);
if ( code < 0 )
return code;
@@ -230,7 +229,7 @@ pcl_font_header(pcl_args_t *pargs, pcl_state_t *pcs)
int code;
bool has_checksum;
if ( count < 64 && pfh->HeaderFormat != pcfh_bitmap)
- return e_Range; /* pcfh_bitmap defaults short headers to 0 except underline position = 5; */
+ return e_Range; /* pcfh_bitmap defaults short headers to 0 except underline position = 5; */
desc_size =
(pfh->FontDescriptorSize[0] << 8) + pfh->FontDescriptorSize[1];
/* Dispatch on the header format. */
@@ -378,7 +377,7 @@ bitmap: pfont = gs_alloc_struct(mem, gs_font_base, &st_gs_font_base,
if ( ( pfh->HeaderFormat == pcfh_truetype_large ) &&
( plfont->scaling_technology == plfst_bitmap ) )
goto bitmap;
-
+
}
pfont = gs_alloc_struct(mem, gs_font_type42, &st_gs_font_type42,
"pcl_font_header(truetype font)");
@@ -445,14 +444,14 @@ bitmap: pfont = gs_alloc_struct(mem, gs_font_base, &st_gs_font_base,
static int /* ESC * c <char_code> E */
pcl_character_code(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
pcs->character_code = uint_arg(pargs);
return 0;
}
static int /* ESC ( s <count> W */
pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
uint count = uint_arg(pargs);
uint font_data_size = count;
const byte *data = arg_data(pargs);
@@ -511,20 +510,20 @@ pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
return e_Range;
height = pl_get_uint16(data + 12);
if (height < 1 || height > 16384)
- return e_Range;
+ return e_Range;
/* more error checking of offsets, delta, width and height. */
{
int toff, loff;
int deltax;
loff = pl_get_int16(data + 6);
if ((-16384 > loff) || (loff > 16384))
- return e_Range;
+ return e_Range;
toff = pl_get_int16(data + 8);
if ((-16384 > toff) || (toff > 16384))
- return e_Range;
+ return e_Range;
deltax = pl_get_int16(data + 14);
if ((-32768 > deltax) || (deltax > 32767))
- return e_Range;
+ return e_Range;
/* also reject if width * height larger than 1MByte */
if ((width * height / 8) > 1024 *1024) return e_Range;
}
@@ -592,7 +591,7 @@ pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
/* See TRM Figure 11-16 (p. 11-67) for the following. */
if ( count < 14 )
return e_Range;
- {
+ {
uint data_size = pl_get_uint16(data + 4);
uint contour_offset = pl_get_uint16(data + 6);
uint metric_offset = pl_get_uint16(data + 8);
@@ -640,7 +639,7 @@ pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
/**** FREE PREVIOUS DEFINITION ****/
/* Compressed bitmaps have already allocated and filled in */
/* the character data structure. */
- if ( char_data == 0 ) {
+ if ( char_data == 0 ) {
char_data = gs_alloc_bytes(pcs->memory, font_data_size,
"pcl_character_data");
if ( char_data == 0 )
@@ -649,7 +648,7 @@ pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
/* if count > font_data_size extra data is ignored */
memcpy(char_data, data, min(count, font_data_size) );
/* NB we only handle continuation for uncompressed bitmap characters */
- if ( data[0] == pccd_bitmap &&
+ if ( data[0] == pccd_bitmap &&
data[3] == 1 &&
font_data_size > count /* expecting continuation */
) {
@@ -682,11 +681,11 @@ typedef struct alphanumeric_data_s {
byte string_id[512];
} alphanumeric_data_t;
-typedef enum resource_type_enum {
+typedef enum resource_type_enum {
macro_resource,
font_resource
} resource_type_t;
-
+
/* look up a macro in the macro dictionary, if it is not found search
on disk and add the macro to the macro dictionary */
static void *
@@ -696,7 +695,7 @@ pcl_find_resource(pcl_state_t *pcs,
resource_type_t resource_type
)
{
- pl_dict_t *dict = (resource_type == macro_resource ?
+ pl_dict_t *dict = (resource_type == macro_resource ?
&pcs->macros :
&pcs->soft_fonts);
void *value = NULL;
@@ -743,12 +742,12 @@ static int /* ESC & n <count> W [operation][string ID] */
pcl_alphanumeric_id_data(pcl_args_t *pargs, pcl_state_t *pcs)
{
uint count = uint_arg(pargs);
- const alphanumeric_data_t *alpha_data =
+ const alphanumeric_data_t *alpha_data =
(const alphanumeric_data_t *)arg_data(pargs);
int string_id_size = (count - 1); /* size of id data size - operation size */
- if ( count == 0 )
+ if ( count == 0 )
return 0;
- if ( count < 1 || count > 512 )
+ if ( count < 1 || count > 512 )
return e_Range;
switch ( alpha_data->operation )
{
@@ -757,7 +756,7 @@ pcl_alphanumeric_id_data(pcl_args_t *pargs, pcl_state_t *pcs)
{
char *new_id = (char *)gs_alloc_bytes(pcs->memory, string_id_size,
"pcl_alphanumeric_id_data");
- if ( new_id == 0 )
+ if ( new_id == 0 )
return_error(e_Memory);
/* release the previous id, if necessary */
if ( pcs->alpha_font_id.id )
@@ -826,7 +825,7 @@ pcl_alphanumeric_id_data(pcl_args_t *pargs, pcl_state_t *pcs)
/* sets the current macro id to the string id */
char *new_id = (char *)gs_alloc_bytes(pcs->memory, string_id_size,
"pcl_alphanumeric_id_data");
- if ( new_id == 0 )
+ if ( new_id == 0 )
return_error(e_Memory);
/* release the previous id, if necessary */
if ( pcs->alpha_macro_id.id )
@@ -878,7 +877,7 @@ pcl_alphanumeric_id_data(pcl_args_t *pargs, pcl_state_t *pcs)
}
return 0;
}
-
+
/* Initialization */
static int
pcsfont_do_registration(
@@ -906,14 +905,14 @@ pcsfont_do_registration(
}
static void
pcsfont_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
-{
- if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay) ) {
+{
+ if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay) ) {
pcs->soft_font_char_data = 0;
pcs->soft_font_count = 0;
id_set_value(pcs->font_id, 0);
pcs->character_code = 0;
pcs->font_id_type = numeric_id;
- if ( (type & pcl_reset_printer) != 0 ) {
+ if ( (type & pcl_reset_printer) != 0 ) {
pcl_args_t args;
arg_set_uint(&args, 1); /* delete temporary fonts */
pcl_font_control(&args, pcs);
diff --git a/pcl/pcstate.h b/pcl/pcstate.h
index a894cfe25..095338a07 100644
--- a/pcl/pcstate.h
+++ b/pcl/pcstate.h
@@ -37,7 +37,7 @@
#include "rtrstst.h" /* raster state information */
#include "pcht.h"
#include "pcident.h"
-#include "pccsbase.h"
+#include "pccsbase.h"
/*#include "pgstate.h"*/ /* HP-GL/2 state, included below */
#include "pjtop.h"
@@ -64,7 +64,7 @@ typedef enum personality_enum { /* NB document */
/*
* Palette stack. This is implemented as a simple linked list. NB
- * needs to be moved.
+ * needs to be moved.
*/
typedef struct pstack_entry_s {
struct pstack_entry_s * pnext;
@@ -96,7 +96,6 @@ void pcl_free_gstate_stk(pcl_state_t * pcs);
*/
void pcl_init_state(pcl_state_t * pcs, gs_memory_t * pmem);
-
#include "pgstate.h" /* HP-GL/2 state */
#ifndef pcl_pattern_data_DEFINED
@@ -132,7 +131,7 @@ struct pcl_state_s {
/* Define an optional procedure for parsing non-ESC data. */
int (*parse_other)( void * parse_data,
pcl_state_t * pcs,
- stream_cursor_read * pr
+ stream_cursor_read * pr
);
void * parse_data; /* closure data for parse_other */
@@ -163,7 +162,7 @@ struct pcl_state_s {
pcl_font_selection_t font_selection[2];
enum {
primary = 0,
- secondary = 1
+ secondary = 1
} font_selected;
pl_font_t * font; /* 0 means recompute from params */
pl_dict_t built_in_fonts; /* "built-in", known at start-up */
@@ -261,7 +260,6 @@ struct pcl_state_s {
* known as source transparent */
bool pcl_pattern_transparent;
-
/* Chapter 14 (pcrect.c) */
coord_point_t rectangle;
@@ -272,10 +270,10 @@ struct pcl_state_s {
int location_type;
int location_unit;
struct _sb {
- byte internal_buffer[80]; /* enough for an error message */
- byte * buffer;
- uint write_pos;
- uint read_pos;
+ byte internal_buffer[80]; /* enough for an error message */
+ byte * buffer;
+ uint write_pos;
+ uint read_pos;
} status;
/* Chapter 24 (pcmisc.c) */
@@ -283,7 +281,7 @@ struct pcl_state_s {
bool display_functions;
int (*configure_appletalk)( const byte * key,
uint key_length,
- const byte * value,
+ const byte * value,
uint value_length
);
@@ -297,7 +295,7 @@ struct pcl_state_s {
colors see pcident.h */
pcl_frgrnd_t * pfrgrnd;
pcl_gsid_t frgnd_cache_id;
-
+
pcl_gstate_ids_t * pids;
/*
* Unlike other elements of the PCL "palette", color rendering dictionaries
@@ -306,7 +304,7 @@ struct pcl_state_s {
* are determined by the output device rather than the language.
*/
pcl_crd_t * pcl_default_crd;
-
+
/* internal dithers */
pcl_ht_builtin_dither_t ordered_dither;
pcl_ht_builtin_dither_t clustered_dither;
@@ -347,13 +345,13 @@ struct pcl_state_s {
/* the current language personality */
pcl_personality_t personality;
-
+
/* enable image interpolation */
bool interpolate;
/* store a pointer to the command definitions for use by macros */
void *pcl_commands;
-
+
/* indicates page has been written to with a drawing command */
bool page_marked;
diff --git a/pcl/pcstatus.c b/pcl/pcstatus.c
index e5091b93b..267de7383 100644
--- a/pcl/pcstatus.c
+++ b/pcl/pcstatus.c
@@ -36,28 +36,27 @@
static int status_add_symbol_id(ushort *, int, ushort);
-
/* Read out from the status buffer. */
/* Return the number of bytes read. */
uint
pcl_status_read(byte *data, uint max_data, pcl_state_t *pcs)
{ uint count = min(max_data,
- pcs->status.write_pos - pcs->status.read_pos);
- if ( count )
- memcpy(data, pcs->status.buffer + pcs->status.read_pos, count);
- pcs->status.read_pos += count;
- if ( pcs->status.read_pos == pcs->status.write_pos )
- { gs_free_object(pcs->memory, pcs->status.buffer, "status buffer");
- pcs->status.write_pos = pcs->status.read_pos = 0;
- }
- return count;
+ pcs->status.write_pos - pcs->status.read_pos);
+ if ( count )
+ memcpy(data, pcs->status.buffer + pcs->status.read_pos, count);
+ pcs->status.read_pos += count;
+ if ( pcs->status.read_pos == pcs->status.write_pos )
+ { gs_free_object(pcs->memory, pcs->status.buffer, "status buffer");
+ pcs->status.write_pos = pcs->status.read_pos = 0;
+ }
+ return count;
}
/* Write a string on a stream. */
static void
stputs(stream *s, const char *str)
{ uint ignore_count;
- sputs(s, (const byte *)str, strlen(str), &ignore_count);
+ sputs(s, (const byte *)str, strlen(str), &ignore_count);
}
/* printf on a stream. */
@@ -65,12 +64,12 @@ stputs(stream *s, const char *str)
void
stprintf(stream *s, const char *fmt, ...)
{ uint count;
- va_list args;
- char buf[1024];
+ va_list args;
+ char buf[1024];
- va_start(args, fmt);
- count = vsprintf(buf, fmt, args);
- sputs(s, (const byte *)buf, count, &count);
+ va_start(args, fmt);
+ count = vsprintf(buf, fmt, args);
+ sputs(s, (const byte *)buf, count, &count);
}
/* Set up a stream for writing into the status buffer. */
@@ -78,79 +77,76 @@ static void
status_begin(stream *s, pcl_state_t *pcs)
{ byte *buffer = pcs->status.buffer;
- if ( pcs->status.read_pos > 0 )
- { memmove(buffer, buffer + pcs->status.read_pos,
- pcs->status.write_pos - pcs->status.read_pos);
- pcs->status.write_pos -= pcs->status.read_pos;
- pcs->status.read_pos = 0;
- }
- if ( buffer == 0 )
- { buffer = gs_alloc_bytes(pcs->memory, STATUS_BUFFER_SIZE,
- "status buffer");
- pcs->status.buffer = buffer;
- }
- if ( buffer == 0 )
- swrite_string(s, pcs->status.internal_buffer,
- sizeof(pcs->status.internal_buffer));
- else
- swrite_string(s, buffer, gs_object_size(pcs->memory, buffer));
- sseek(s, pcs->status.write_pos);
- stputs(s, "PCL\r\n");
+ if ( pcs->status.read_pos > 0 )
+ { memmove(buffer, buffer + pcs->status.read_pos,
+ pcs->status.write_pos - pcs->status.read_pos);
+ pcs->status.write_pos -= pcs->status.read_pos;
+ pcs->status.read_pos = 0;
+ }
+ if ( buffer == 0 )
+ { buffer = gs_alloc_bytes(pcs->memory, STATUS_BUFFER_SIZE,
+ "status buffer");
+ pcs->status.buffer = buffer;
+ }
+ if ( buffer == 0 )
+ swrite_string(s, pcs->status.internal_buffer,
+ sizeof(pcs->status.internal_buffer));
+ else
+ swrite_string(s, buffer, gs_object_size(pcs->memory, buffer));
+ sseek(s, pcs->status.write_pos);
+ stputs(s, "PCL\r\n");
}
/* Add an ID to a list being written. */
static void
status_put_id(stream *s, const char *title, const char *id)
{ /* HACK: we know that there's at least one character in the buffer. */
- if ( *s->cursor.w.ptr == '\n' )
- { /* We haven't started the list yet. */
- stprintf(s, "%s=\"%s", title, id);
- }
- else
- { stprintf(s, ",%s", id);
- }
+ if ( *s->cursor.w.ptr == '\n' )
+ { /* We haven't started the list yet. */
+ stprintf(s, "%s=\"%s", title, id);
+ }
+ else
+ { stprintf(s, ",%s", id);
+ }
}
-
/* Finish writing an ID list. */
static void
status_end_id_list(stream *s)
{ /* HACK: we know that there's at least one character in the buffer. */
- if ( *s->cursor.w.ptr != '\n' )
- stputs(s, "\"\r\n");
+ if ( *s->cursor.w.ptr != '\n' )
+ stputs(s, "\"\r\n");
}
-
static void
status_print_idlist(stream *s, const ushort *idlist, int nid, const char *title)
{
- int i;
-
- for ( i = 0; i < nid; i++ )
- { char idstr[6]; /* ddddL and a null */
- int n, l;
- n = idlist[i] >> 6;
- l = (idlist[i] & 077) + 'A' - 1;
- sprintf(idstr, "%d%c", n, l);
- status_put_id(s, title, idstr);
- }
- status_end_id_list(s);
+ int i;
+
+ for ( i = 0; i < nid; i++ )
+ { char idstr[6]; /* ddddL and a null */
+ int n, l;
+ n = idlist[i] >> 6;
+ l = (idlist[i] & 077) + 'A' - 1;
+ sprintf(idstr, "%d%c", n, l);
+ status_put_id(s, title, idstr);
+ }
+ status_end_id_list(s);
}
-
/* Output a number, at most two decimal places, but trimming trailing 0's
* and possibly the ".". Want to match HP's output as closely as we can. */
static void
status_put_floating(stream *s, double v)
{ /* Figure the format--easier than printing and chipping out the
- * chars we need. */
- int vf = (int)(v * 100 + ((v < 0)? -0.5: 0.5));
- if ( vf / 100 * 100 == vf )
- stprintf(s, "%d", vf / 100);
- else if ( vf / 10 * 10 == vf )
- stprintf(s, "%.1f", v);
- else
- stprintf(s, "%.2f", v);
+ * chars we need. */
+ int vf = (int)(v * 100 + ((v < 0)? -0.5: 0.5));
+ if ( vf / 100 * 100 == vf )
+ stprintf(s, "%d", vf / 100);
+ else if ( vf / 10 * 10 == vf )
+ stprintf(s, "%.1f", v);
+ else
+ stprintf(s, "%.2f", v);
}
/* Print font status information. */
@@ -160,143 +156,143 @@ status_put_font(stream *s, pcl_state_t *pcs,
uint font_id, uint internal_id,
pl_font_t *plfont, int font_set, bool extended)
{ char paren = (font_set > 0 ? ')' : '(');
- bool proportional = plfont->params.proportional_spacing;
-
- /* first escape sequence: symbol-set selection */
- stputs(s, "SELECT=\"");
- if ( pl_font_is_bound(plfont) || font_set > 0 )
- { /* Bound or current font, put out the symbol set. */
- uint symbol_set = font_set > 0?
- pcs->font_selection[font_set].params.symbol_set:
- plfont->params.symbol_set;
- stprintf(s, "<Esc>%c%u%c", paren, symbol_set >> 5,
- (symbol_set & 31) + 'A' - 1);
- }
-
- /* second escape sequence: font selection */
- stprintf(s, "<Esc>%cs%dp", paren, proportional);
- if ( plfont->scaling_technology == plfst_bitmap )
- { /* Bitmap font */
- status_put_floating(s, pl_fp_pitch_per_inch(&plfont->params));
- stputs(s, "h");
- status_put_floating(s, plfont->params.height_4ths / 4.0);
- stputs(s, "v");
- }
- else
- { /* Scalable font: output depends on whether selected */
- if ( font_set > 0 )
- { /* If selected, we have to cheat and reach up for info;
- * plfont is below where the scaled values exist. */
- if ( proportional )
- { status_put_floating(s,
- pcs->font_selection[font_set].params.height_4ths / 4.0);
- stputs(s, "h");
- }
- else
- { status_put_floating(s,
- pl_fp_pitch_per_inch(&pcs->font_selection[font_set].
- params));
- stputs(s, "v");
- }
- }
- else
- {
- stputs(s, proportional? "__v": "__h");
- }
- }
- stprintf(s, "%ds%db%uT", plfont->params.style,
- plfont->params.stroke_weight, plfont->params.typeface_family);
- if ( plfont->storage & pcds_downloaded )
- stprintf(s, "<Esc>%c%uX", paren, font_id);
- stputs(s, "\"\r\n");
- if ( !pl_font_is_bound(plfont) && font_set < 0 )
- { int nid;
- ushort *idlist;
- pl_dict_enum_t denum;
- gs_const_string key;
- void *value;
-
- idlist = (ushort *)gs_alloc_bytes(pcs->memory,
- pl_dict_length(&pcs->soft_symbol_sets, false) +
- pl_dict_length(&pcs->built_in_symbol_sets, false),
- "status_fonts(idlist)");
- if ( idlist == NULL )
- return e_Memory;
- nid = 0;
- /* Current fonts show the symbol set bound to them, above. */
-
- /* NOTE: Temporarily chain soft, built-in symbol sets. DON'T
- * exit this section without unchaining them. */
- pl_dict_set_parent(&pcs->soft_symbol_sets,
- &pcs->built_in_symbol_sets);
- pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- { pcl_symbol_set_t *ssp = (pcl_symbol_set_t *)value;
- pl_glyph_vocabulary_t gx;
-
- for ( gx = plgv_MSL; gx < plgv_next; gx++ )
- if ( ssp->maps[gx] != NULL &&
- pcl_check_symbol_support(
- ssp->maps[gx]->character_requirements,
- plfont->character_complement) )
- {
- nid = status_add_symbol_id(idlist, nid,
- (ssp->maps[gx]->id[0] << 8) + ssp->maps[gx]->id[1]);
- break; /* one will suffice */
- }
- }
- pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);
- /* Symbol sets are back to normal. */
-
- gs_free_object(pcs->memory, (void*)idlist,
- "status_fonts(idlist)");
- }
- if ( extended )
- { /* Put out the "internal ID number". */
- if ( plfont->storage & pcds_temporary )
- stputs(s, "DEFID=NONE\r\n");
- else
- {
- stputs(s, "DEFID=\"");
- if ( plfont->storage & pcds_all_cartridges )
- { int c;
- int n = (plfont->storage & pcds_all_cartridges) >>
- pcds_cartridge_shift;
-
- /* pick out the bit index of the cartridge */
- for (c = 0; (n & 1) == 0; c++)
- n >>= 1;
- stprintf(s, "C%d ", c);
- }
- else if ( plfont->storage & pcds_all_simms )
- { int m;
- int n = (plfont->storage & pcds_all_simms) >>
- pcds_simm_shift;
-
- /* pick out the bit index of the SIMM */
- for (m = 0; (n & 1) == 0; m++)
- n >>= 1;
- stprintf(s, "M%d ", m);
- }
- else
- /* internal _vs_ permanent soft */
- stputs(s, (plfont->storage & pcds_internal)? "I ": "S ");
- stprintf(s, "%d\"\r\n", internal_id);
- }
-
- /* XXX Put out the font name - we need a way to get the name
- * for fonts that weren't downloaded, hence lack the known
- * header field. */
- if ( (plfont->storage & pcds_downloaded) &&
- plfont->header != NULL )
- { /* Wire in the size of the FontName field (16)--it can't
- * change anyway, and this saves work. */
- pcl_font_header_t *hdr = (pcl_font_header_t *)(plfont->header);
-
- stprintf(s, "NAME=\"%.16s\"\r\n", hdr->FontName);
- }
- }
- return 0;
+ bool proportional = plfont->params.proportional_spacing;
+
+ /* first escape sequence: symbol-set selection */
+ stputs(s, "SELECT=\"");
+ if ( pl_font_is_bound(plfont) || font_set > 0 )
+ { /* Bound or current font, put out the symbol set. */
+ uint symbol_set = font_set > 0?
+ pcs->font_selection[font_set].params.symbol_set:
+ plfont->params.symbol_set;
+ stprintf(s, "<Esc>%c%u%c", paren, symbol_set >> 5,
+ (symbol_set & 31) + 'A' - 1);
+ }
+
+ /* second escape sequence: font selection */
+ stprintf(s, "<Esc>%cs%dp", paren, proportional);
+ if ( plfont->scaling_technology == plfst_bitmap )
+ { /* Bitmap font */
+ status_put_floating(s, pl_fp_pitch_per_inch(&plfont->params));
+ stputs(s, "h");
+ status_put_floating(s, plfont->params.height_4ths / 4.0);
+ stputs(s, "v");
+ }
+ else
+ { /* Scalable font: output depends on whether selected */
+ if ( font_set > 0 )
+ { /* If selected, we have to cheat and reach up for info;
+ * plfont is below where the scaled values exist. */
+ if ( proportional )
+ { status_put_floating(s,
+ pcs->font_selection[font_set].params.height_4ths / 4.0);
+ stputs(s, "h");
+ }
+ else
+ { status_put_floating(s,
+ pl_fp_pitch_per_inch(&pcs->font_selection[font_set].
+ params));
+ stputs(s, "v");
+ }
+ }
+ else
+ {
+ stputs(s, proportional? "__v": "__h");
+ }
+ }
+ stprintf(s, "%ds%db%uT", plfont->params.style,
+ plfont->params.stroke_weight, plfont->params.typeface_family);
+ if ( plfont->storage & pcds_downloaded )
+ stprintf(s, "<Esc>%c%uX", paren, font_id);
+ stputs(s, "\"\r\n");
+ if ( !pl_font_is_bound(plfont) && font_set < 0 )
+ { int nid;
+ ushort *idlist;
+ pl_dict_enum_t denum;
+ gs_const_string key;
+ void *value;
+
+ idlist = (ushort *)gs_alloc_bytes(pcs->memory,
+ pl_dict_length(&pcs->soft_symbol_sets, false) +
+ pl_dict_length(&pcs->built_in_symbol_sets, false),
+ "status_fonts(idlist)");
+ if ( idlist == NULL )
+ return e_Memory;
+ nid = 0;
+ /* Current fonts show the symbol set bound to them, above. */
+
+ /* NOTE: Temporarily chain soft, built-in symbol sets. DON'T
+ * exit this section without unchaining them. */
+ pl_dict_set_parent(&pcs->soft_symbol_sets,
+ &pcs->built_in_symbol_sets);
+ pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ { pcl_symbol_set_t *ssp = (pcl_symbol_set_t *)value;
+ pl_glyph_vocabulary_t gx;
+
+ for ( gx = plgv_MSL; gx < plgv_next; gx++ )
+ if ( ssp->maps[gx] != NULL &&
+ pcl_check_symbol_support(
+ ssp->maps[gx]->character_requirements,
+ plfont->character_complement) )
+ {
+ nid = status_add_symbol_id(idlist, nid,
+ (ssp->maps[gx]->id[0] << 8) + ssp->maps[gx]->id[1]);
+ break; /* one will suffice */
+ }
+ }
+ pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);
+ /* Symbol sets are back to normal. */
+
+ gs_free_object(pcs->memory, (void*)idlist,
+ "status_fonts(idlist)");
+ }
+ if ( extended )
+ { /* Put out the "internal ID number". */
+ if ( plfont->storage & pcds_temporary )
+ stputs(s, "DEFID=NONE\r\n");
+ else
+ {
+ stputs(s, "DEFID=\"");
+ if ( plfont->storage & pcds_all_cartridges )
+ { int c;
+ int n = (plfont->storage & pcds_all_cartridges) >>
+ pcds_cartridge_shift;
+
+ /* pick out the bit index of the cartridge */
+ for (c = 0; (n & 1) == 0; c++)
+ n >>= 1;
+ stprintf(s, "C%d ", c);
+ }
+ else if ( plfont->storage & pcds_all_simms )
+ { int m;
+ int n = (plfont->storage & pcds_all_simms) >>
+ pcds_simm_shift;
+
+ /* pick out the bit index of the SIMM */
+ for (m = 0; (n & 1) == 0; m++)
+ n >>= 1;
+ stprintf(s, "M%d ", m);
+ }
+ else
+ /* internal _vs_ permanent soft */
+ stputs(s, (plfont->storage & pcds_internal)? "I ": "S ");
+ stprintf(s, "%d\"\r\n", internal_id);
+ }
+
+ /* XXX Put out the font name - we need a way to get the name
+ * for fonts that weren't downloaded, hence lack the known
+ * header field. */
+ if ( (plfont->storage & pcds_downloaded) &&
+ plfont->header != NULL )
+ { /* Wire in the size of the FontName field (16)--it can't
+ * change anyway, and this saves work. */
+ pcl_font_header_t *hdr = (pcl_font_header_t *)(plfont->header);
+
+ stprintf(s, "NAME=\"%.16s\"\r\n", hdr->FontName);
+ }
+ }
+ return 0;
}
/* Finish writing status. */
@@ -304,23 +300,23 @@ status_put_font(stream *s, pcl_state_t *pcs,
static void
status_end(stream *s, pcl_state_t *pcs)
{ if ( sendwp(s) )
- { /* Overrun. Scan back to the last EOL that leaves us */
- /* enough room for the error line. */
- static const char *error_line = "ERROR=INTERNAL ERROR\r\n";
- int error_size = strlen(error_line) + 1;
- uint limit = gs_object_size(pcs->memory, pcs->status.buffer);
- uint wpos = stell(s);
-
- while ( limit - wpos < error_size ||
- pcs->status.buffer[wpos - 1] != '\n'
- )
- --wpos;
- s->end_status = 0; /**** SHOULDN'T BE NECESSARY ****/
- sseek(s, wpos);
- stputs(s, error_line);
- }
- sputc(s, FF);
- pcs->status.write_pos = stell(s);
+ { /* Overrun. Scan back to the last EOL that leaves us */
+ /* enough room for the error line. */
+ static const char *error_line = "ERROR=INTERNAL ERROR\r\n";
+ int error_size = strlen(error_line) + 1;
+ uint limit = gs_object_size(pcs->memory, pcs->status.buffer);
+ uint wpos = stell(s);
+
+ while ( limit - wpos < error_size ||
+ pcs->status.buffer[wpos - 1] != '\n'
+ )
+ --wpos;
+ s->end_status = 0; /**** SHOULDN'T BE NECESSARY ****/
+ sseek(s, wpos);
+ stputs(s, error_line);
+ }
+ sputc(s, FF);
+ pcs->status.write_pos = stell(s);
}
/* Status readouts */
@@ -330,22 +326,22 @@ static int
status_do_fonts(stream *s, pcl_state_t *pcs,
pcl_data_storage_t storage, bool extended)
{ gs_const_string key;
- void *value;
- pl_dict_enum_t denum;
- int res;
-
- pl_dict_enum_begin(&pcs->soft_fonts, &denum);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- { uint id = (key.data[0] << 8) + key.data[1];
- if ( (((pl_font_t *)value)->storage & storage) != 0 ||
- (storage == 0 && pcs->font == (pl_font_t *)value)
- )
- res = status_put_font(s, pcs, id, id, (pl_font_t *)value,
- (storage != 0 ? -1 : pcs->font_selected), extended);
- if ( res != 0 )
- return res;
- }
- return 0;
+ void *value;
+ pl_dict_enum_t denum;
+ int res;
+
+ pl_dict_enum_begin(&pcs->soft_fonts, &denum);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ { uint id = (key.data[0] << 8) + key.data[1];
+ if ( (((pl_font_t *)value)->storage & storage) != 0 ||
+ (storage == 0 && pcs->font == (pl_font_t *)value)
+ )
+ res = status_put_font(s, pcs, id, id, (pl_font_t *)value,
+ (storage != 0 ? -1 : pcs->font_selected), extended);
+ if ( res != 0 )
+ return res;
+ }
+ return 0;
}
static int
@@ -358,20 +354,20 @@ static int
status_macros(stream *s, pcl_state_t *pcs,
pcl_data_storage_t storage)
{ gs_const_string key;
- void *value;
- pl_dict_enum_t denum;
-
- if ( storage == 0 )
- return 0; /* no "currently selected" macro */
- pl_dict_enum_begin(&pcs->macros, &denum);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- if ( ((pcl_macro_t *)value)->storage & storage )
- { char id_string[6];
- sprintf(id_string, "%u", (key.data[0] << 8) + key.data[1]);
- status_put_id(s, "IDLIST", id_string);
- }
- status_end_id_list(s);
- return 0;
+ void *value;
+ pl_dict_enum_t denum;
+
+ if ( storage == 0 )
+ return 0; /* no "currently selected" macro */
+ pl_dict_enum_begin(&pcs->macros, &denum);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ if ( ((pcl_macro_t *)value)->storage & storage )
+ { char id_string[6];
+ sprintf(id_string, "%u", (key.data[0] << 8) + key.data[1]);
+ status_put_id(s, "IDLIST", id_string);
+ }
+ status_end_id_list(s);
+ return 0;
}
/*
@@ -393,15 +389,15 @@ status_patterns(
if ((pptrn != 0) && (pcs->pattern_type == pcl_pattern_user_defined)) {
char id_string[6];
- sprintf(id_string, "%u", id);
- status_put_id(s, "IDLIST", id_string);
- }
+ sprintf(id_string, "%u", id);
+ status_put_id(s, "IDLIST", id_string);
+ }
} else {
int id;
for (id = 0; id < (1L << 15) - 1; id++) {
pcl_pattern_t * pptrn = pcl_pattern_get_pcl_uptrn(pcs, id);
-
+
if (pptrn != 0) {
char id_string[6];
@@ -414,103 +410,102 @@ status_patterns(
return 0;
}
-
static bool /* Is this symbol map supported by any relevant font? */
status_check_symbol_set(pcl_state_t *pcs, pl_symbol_map_t *mapp,
pcl_data_storage_t storage)
{ gs_const_string key;
- void *value;
- pl_dict_enum_t fenum;
-
- pl_dict_enum_begin(&pcs->soft_fonts, &fenum);
- while ( pl_dict_enum_next(&fenum, &key, &value) )
- { pl_font_t *fp = (pl_font_t *)value;
-
- if ( fp->storage != storage )
- continue;
- if ( pcl_check_symbol_support(mapp->character_requirements,
- fp->character_complement) )
- return true;
- }
- return false;
+ void *value;
+ pl_dict_enum_t fenum;
+
+ pl_dict_enum_begin(&pcs->soft_fonts, &fenum);
+ while ( pl_dict_enum_next(&fenum, &key, &value) )
+ { pl_font_t *fp = (pl_font_t *)value;
+
+ if ( fp->storage != storage )
+ continue;
+ if ( pcl_check_symbol_support(mapp->character_requirements,
+ fp->character_complement) )
+ return true;
+ }
+ return false;
}
static int /* add symbol set ID to list (insertion), return new length */
status_add_symbol_id(ushort *idlist, int nid, ushort new_id)
{ int i;
- ushort *idp;
- ushort t1, t2;
-
- for ( i = 0, idp = idlist; i < nid; i++ )
- if ( new_id <= *idp )
- break;
- if ( new_id == *idp ) /* duplicate item */
- return nid;
- /* insert new_id in front of *idp */
- for ( t1 = new_id; i < nid; i++ )
- {
- t2 = *idp;
- *idp++ = t1;
- t1 = t2;
- }
- *idp = t1;
- return nid + 1;
+ ushort *idp;
+ ushort t1, t2;
+
+ for ( i = 0, idp = idlist; i < nid; i++ )
+ if ( new_id <= *idp )
+ break;
+ if ( new_id == *idp ) /* duplicate item */
+ return nid;
+ /* insert new_id in front of *idp */
+ for ( t1 = new_id; i < nid; i++ )
+ {
+ t2 = *idp;
+ *idp++ = t1;
+ t1 = t2;
+ }
+ *idp = t1;
+ return nid + 1;
}
static int
status_symbol_sets(stream *s, pcl_state_t *pcs, pcl_data_storage_t storage)
{ gs_const_string key;
- void *value;
- pl_dict_enum_t denum;
- ushort *idlist;
- int nid;
-
- if ( storage == 0 )
- return 0; /* no "currently selected" symbol set */
-
- /* Note carefully the meaning of this status inquiry. First,
- * we return only symbol sets applicable to unbound fonts. Second,
- * the "storage" value refers to the location of fonts. */
-
- /* total up built-in symbol sets, downloaded ones */
- nid = pl_dict_length(&pcs->soft_symbol_sets, false) +
- pl_dict_length(&pcs->built_in_symbol_sets, false);
- idlist = (ushort *)gs_alloc_bytes(pcs->memory, nid * sizeof(ushort),
- "status_symbol_sets(idlist)");
- if ( idlist == NULL )
- return e_Memory;
- nid = 0;
-
- /* For each symbol set,
- * for each font in appropriate storage,
- * if the font supports that symbol set, list the symbol set
- * and break (because we only need to find one such font). */
-
- /* NOTE: Temporarily chain soft, built-in symbol sets. DON'T
- * exit this section without unchaining them. */
- pl_dict_set_parent(&pcs->soft_symbol_sets,
- &pcs->built_in_symbol_sets);
- pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- { pcl_symbol_set_t *ssp = (pcl_symbol_set_t *)value;
- pl_glyph_vocabulary_t gx;
-
- for ( gx = plgv_MSL; gx < plgv_next; gx++ )
- if ( ssp->maps[gx] != NULL &&
- status_check_symbol_set(pcs, ssp->maps[gx], storage) )
- {
- nid = status_add_symbol_id(idlist, nid,
- (ssp->maps[gx]->id[0] << 8) + ssp->maps[gx]->id[1]);
- break; /* one will suffice */
- }
- }
- pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);
- /* Symbol sets are back to normal. */
-
- status_print_idlist(s, idlist, nid, "IDLIST");
- gs_free_object(pcs->memory, (void*)idlist,
- "status_symbol_sets(idlist)");
- return 0;
+ void *value;
+ pl_dict_enum_t denum;
+ ushort *idlist;
+ int nid;
+
+ if ( storage == 0 )
+ return 0; /* no "currently selected" symbol set */
+
+ /* Note carefully the meaning of this status inquiry. First,
+ * we return only symbol sets applicable to unbound fonts. Second,
+ * the "storage" value refers to the location of fonts. */
+
+ /* total up built-in symbol sets, downloaded ones */
+ nid = pl_dict_length(&pcs->soft_symbol_sets, false) +
+ pl_dict_length(&pcs->built_in_symbol_sets, false);
+ idlist = (ushort *)gs_alloc_bytes(pcs->memory, nid * sizeof(ushort),
+ "status_symbol_sets(idlist)");
+ if ( idlist == NULL )
+ return e_Memory;
+ nid = 0;
+
+ /* For each symbol set,
+ * for each font in appropriate storage,
+ * if the font supports that symbol set, list the symbol set
+ * and break (because we only need to find one such font). */
+
+ /* NOTE: Temporarily chain soft, built-in symbol sets. DON'T
+ * exit this section without unchaining them. */
+ pl_dict_set_parent(&pcs->soft_symbol_sets,
+ &pcs->built_in_symbol_sets);
+ pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ { pcl_symbol_set_t *ssp = (pcl_symbol_set_t *)value;
+ pl_glyph_vocabulary_t gx;
+
+ for ( gx = plgv_MSL; gx < plgv_next; gx++ )
+ if ( ssp->maps[gx] != NULL &&
+ status_check_symbol_set(pcs, ssp->maps[gx], storage) )
+ {
+ nid = status_add_symbol_id(idlist, nid,
+ (ssp->maps[gx]->id[0] << 8) + ssp->maps[gx]->id[1]);
+ break; /* one will suffice */
+ }
+ }
+ pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);
+ /* Symbol sets are back to normal. */
+
+ status_print_idlist(s, idlist, nid, "IDLIST");
+ gs_free_object(pcs->memory, (void*)idlist,
+ "status_symbol_sets(idlist)");
+ return 0;
}
static int
@@ -520,7 +515,7 @@ status_fonts_extended(stream *s, pcl_state_t *pcs,
}
static int (*const status_write[])(stream *s, pcl_state_t *pcs,
- pcl_data_storage_t storage) = {
+ pcl_data_storage_t storage) = {
status_fonts, status_macros, status_patterns, status_symbol_sets,
status_fonts_extended
};
@@ -530,160 +525,160 @@ static int (*const status_write[])(stream *s, pcl_state_t *pcs,
static int /* ESC * s <enum> T */
pcl_set_readback_loc_type(pcl_args_t *pargs, pcl_state_t *pcs)
{ pcs->location_type = uint_arg(pargs);
- return 0;
+ return 0;
}
static int /* ESC * s <enum> U */
pcl_set_readback_loc_unit(pcl_args_t *pargs, pcl_state_t *pcs)
{ pcs->location_unit = uint_arg(pargs);
- return 0;
+ return 0;
}
static int /* ESC * s <enum> I */
pcl_inquire_readback_entity(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint i = uint_arg(pargs);
- int unit = pcs->location_unit;
- stream st;
- static const char *entity_types[] = {
- "FONTS", "MACROS", "PATTERNS", "SYMBOLSETS", "FONTS EXTENDED"
- };
- pcl_data_storage_t storage;
- int code = 0;
- long pos;
-
- if ( i > 4 )
- return e_Range;
- status_begin(&st, pcs);
- stprintf(&st, "INFO %s\r\n", entity_types[i]);
- switch ( pcs->location_type )
- {
- case 0: /* invalid location */
- code = -1;
- break;
- case 1: /* currently selected */
- storage = (pcl_data_storage_t)0; /* indicates currently selected */
- break;
- case 2: /* all locations */
- storage = (pcl_data_storage_t)~0;
- break;
- case 3: /* internal */
- if ( unit != 0 )
- { code = -1;
- break;
- }
- storage = pcds_internal;
- break;
- case 4: /* downloaded */
- if ( unit > 2 )
- code = -1;
- else
- { static const pcl_data_storage_t dl_masks[] =
- { pcds_downloaded, pcds_temporary, pcds_permanent
- };
- storage = dl_masks[unit];
- }
- break;
- case 5: /* cartridges */
- if ( unit == 0 )
- storage = (pcl_data_storage_t)pcds_all_cartridges;
- else if ( unit <= pcds_cartridge_max )
- storage = (pcl_data_storage_t)
+ int unit = pcs->location_unit;
+ stream st;
+ static const char *entity_types[] = {
+ "FONTS", "MACROS", "PATTERNS", "SYMBOLSETS", "FONTS EXTENDED"
+ };
+ pcl_data_storage_t storage;
+ int code = 0;
+ long pos;
+
+ if ( i > 4 )
+ return e_Range;
+ status_begin(&st, pcs);
+ stprintf(&st, "INFO %s\r\n", entity_types[i]);
+ switch ( pcs->location_type )
+ {
+ case 0: /* invalid location */
+ code = -1;
+ break;
+ case 1: /* currently selected */
+ storage = (pcl_data_storage_t)0; /* indicates currently selected */
+ break;
+ case 2: /* all locations */
+ storage = (pcl_data_storage_t)~0;
+ break;
+ case 3: /* internal */
+ if ( unit != 0 )
+ { code = -1;
+ break;
+ }
+ storage = pcds_internal;
+ break;
+ case 4: /* downloaded */
+ if ( unit > 2 )
+ code = -1;
+ else
+ { static const pcl_data_storage_t dl_masks[] =
+ { pcds_downloaded, pcds_temporary, pcds_permanent
+ };
+ storage = dl_masks[unit];
+ }
+ break;
+ case 5: /* cartridges */
+ if ( unit == 0 )
+ storage = (pcl_data_storage_t)pcds_all_cartridges;
+ else if ( unit <= pcds_cartridge_max )
+ storage = (pcl_data_storage_t)
(1 << (pcds_cartridge_shift + unit - 1));
- else
- code = -1;
- break;
- case 6: /* SIMMs */
- if ( unit == 0 )
- storage = (pcl_data_storage_t)pcds_all_simms;
- else if ( unit <= pcds_simm_max )
- storage = (pcl_data_storage_t)(1 << (pcds_simm_shift + unit - 1));
- else
- code = -1;
- break;
- default:
- stputs(&st, "ERROR=INVALID ENTITY\r\n");
- break;
- }
- if ( code >= 0 )
- { pos = stell(&st);
- code = (*status_write[i])(&st, pcs, storage);
- if ( code >= 0 )
- { if ( stell(&st) == pos )
- stputs(&st, "ERROR=NONE\r\n");
- else if ( storage == 0 ) /* currently selected */
- stprintf(&st, "LOCTYPE=%d\r\nLOCUNIT=%d\r\n",
- pcs->location_type, unit);
- }
- }
- if ( code < 0 )
- {
- if ( code == e_Memory )
- stputs(&st, "ERROR=INTERNAL ERROR\r\n");
- else
- stputs(&st, "ERROR=INVALID LOCATION\r\n");
- }
- status_end(&st, pcs);
- return 0;
+ else
+ code = -1;
+ break;
+ case 6: /* SIMMs */
+ if ( unit == 0 )
+ storage = (pcl_data_storage_t)pcds_all_simms;
+ else if ( unit <= pcds_simm_max )
+ storage = (pcl_data_storage_t)(1 << (pcds_simm_shift + unit - 1));
+ else
+ code = -1;
+ break;
+ default:
+ stputs(&st, "ERROR=INVALID ENTITY\r\n");
+ break;
+ }
+ if ( code >= 0 )
+ { pos = stell(&st);
+ code = (*status_write[i])(&st, pcs, storage);
+ if ( code >= 0 )
+ { if ( stell(&st) == pos )
+ stputs(&st, "ERROR=NONE\r\n");
+ else if ( storage == 0 ) /* currently selected */
+ stprintf(&st, "LOCTYPE=%d\r\nLOCUNIT=%d\r\n",
+ pcs->location_type, unit);
+ }
+ }
+ if ( code < 0 )
+ {
+ if ( code == e_Memory )
+ stputs(&st, "ERROR=INTERNAL ERROR\r\n");
+ else
+ stputs(&st, "ERROR=INVALID LOCATION\r\n");
+ }
+ status_end(&st, pcs);
+ return 0;
}
static int /* ESC * s 1 M */
pcl_free_space(pcl_args_t *pargs, pcl_state_t *pcs)
{ stream st;
- status_begin(&st, pcs);
- stprintf(&st, "INFO MEMORY\r\n");
- if ( int_arg(pargs) != 1 )
- stprintf(&st, "ERROR=INVALID UNIT\r\n");
- else
- { gs_memory_status_t mstat;
- gs_memory_status(pcs->memory, &mstat);
- if ( pcs->memory != pcs->memory->non_gc_memory )
- { gs_memory_status_t dstat;
- gs_memory_status(pcs->memory->non_gc_memory, &dstat);
- mstat.allocated += dstat.allocated;
- mstat.used += dstat.used;
- }
- stprintf(&st, "TOTAL=%ld\r\n", mstat.allocated - mstat.used);
- /* We don't currently have an API for determining */
- /* the largest contiguous block. */
- /**** RETURN SOMETHING RANDOM ****/
- stprintf(&st, "LARGEST=%ld\r\n",
- (mstat.allocated - mstat.used) >> 2);
- }
- status_end(&st, pcs);
- return 0;
+ status_begin(&st, pcs);
+ stprintf(&st, "INFO MEMORY\r\n");
+ if ( int_arg(pargs) != 1 )
+ stprintf(&st, "ERROR=INVALID UNIT\r\n");
+ else
+ { gs_memory_status_t mstat;
+ gs_memory_status(pcs->memory, &mstat);
+ if ( pcs->memory != pcs->memory->non_gc_memory )
+ { gs_memory_status_t dstat;
+ gs_memory_status(pcs->memory->non_gc_memory, &dstat);
+ mstat.allocated += dstat.allocated;
+ mstat.used += dstat.used;
+ }
+ stprintf(&st, "TOTAL=%ld\r\n", mstat.allocated - mstat.used);
+ /* We don't currently have an API for determining */
+ /* the largest contiguous block. */
+ /**** RETURN SOMETHING RANDOM ****/
+ stprintf(&st, "LARGEST=%ld\r\n",
+ (mstat.allocated - mstat.used) >> 2);
+ }
+ status_end(&st, pcs);
+ return 0;
}
static int /* ESC & r <bool> F */
pcl_flush_all_pages(pcl_args_t *pargs, pcl_state_t *pcs)
{ switch ( uint_arg(pargs) )
- {
- case 0:
- { /* Flush all complete pages. */
- /* This is a driver function.... */
- return 0;
- }
- case 1:
- { /* Flush all pages, including an incomplete one. */
- int code = pcl_end_page_if_marked(pcs);
+ {
+ case 0:
+ { /* Flush all complete pages. */
+ /* This is a driver function.... */
+ return 0;
+ }
+ case 1:
+ { /* Flush all pages, including an incomplete one. */
+ int code = pcl_end_page_if_marked(pcs);
if (code >= 0)
pcl_home_cursor(pcs);
- return code;
- }
- default:
- return e_Range;
- }
+ return code;
+ }
+ default:
+ return e_Range;
+ }
}
static int /* ESC * s <int_id> X */
pcl_echo(pcl_args_t *pargs, pcl_state_t *pcs)
{ stream st;
- status_begin(&st, pcs);
- stprintf(&st, "ECHO %d\r\n", int_arg(pargs));
- status_end(&st, pcs);
- return 0;
+ status_begin(&st, pcs);
+ stprintf(&st, "ECHO %d\r\n", int_arg(pargs));
+ status_end(&st, pcs);
+ return 0;
}
/* Initialization */
@@ -693,42 +688,42 @@ pcstatus_do_registration(
gs_memory_t *mem
)
{ /* Register commands */
- DEFINE_CLASS('*')
- {'s', 'T',
- PCL_COMMAND("Set Readback Location Type",
- pcl_set_readback_loc_type,
- pca_neg_error|pca_big_error)},
- {'s', 'U',
- PCL_COMMAND("Set Readback Location Unit",
- pcl_set_readback_loc_unit,
- pca_neg_error|pca_big_error)},
- {'s', 'I',
- PCL_COMMAND("Inquire Readback Entity",
- pcl_inquire_readback_entity,
- pca_neg_error|pca_big_error)},
- {'s', 'M',
- PCL_COMMAND("Free Space", pcl_free_space,
- pca_neg_ok|pca_big_ok)},
- END_CLASS
- DEFINE_CLASS_COMMAND_ARGS('&', 'r', 'F', "Flush All Pages",
- pcl_flush_all_pages,
- pca_neg_error|pca_big_error)
- DEFINE_CLASS_COMMAND_ARGS('*', 's', 'X', "Echo",
- pcl_echo, pca_neg_ok|pca_big_error)
- return 0;
+ DEFINE_CLASS('*')
+ {'s', 'T',
+ PCL_COMMAND("Set Readback Location Type",
+ pcl_set_readback_loc_type,
+ pca_neg_error|pca_big_error)},
+ {'s', 'U',
+ PCL_COMMAND("Set Readback Location Unit",
+ pcl_set_readback_loc_unit,
+ pca_neg_error|pca_big_error)},
+ {'s', 'I',
+ PCL_COMMAND("Inquire Readback Entity",
+ pcl_inquire_readback_entity,
+ pca_neg_error|pca_big_error)},
+ {'s', 'M',
+ PCL_COMMAND("Free Space", pcl_free_space,
+ pca_neg_ok|pca_big_ok)},
+ END_CLASS
+ DEFINE_CLASS_COMMAND_ARGS('&', 'r', 'F', "Flush All Pages",
+ pcl_flush_all_pages,
+ pca_neg_error|pca_big_error)
+ DEFINE_CLASS_COMMAND_ARGS('*', 's', 'X', "Echo",
+ pcl_echo, pca_neg_ok|pca_big_error)
+ return 0;
}
static void
pcstatus_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
{ if ( type & (pcl_reset_initial | pcl_reset_printer) )
- { if ( type & pcl_reset_initial )
- { pcs->status.buffer = 0;
-
- pcs->status.write_pos = 0;
- pcs->status.read_pos = 0;
- }
- pcs->location_type = 0;
- pcs->location_unit = 0;
- }
+ { if ( type & pcl_reset_initial )
+ { pcs->status.buffer = 0;
+
+ pcs->status.write_pos = 0;
+ pcs->status.read_pos = 0;
+ }
+ pcs->location_type = 0;
+ pcs->location_unit = 0;
+ }
}
const pcl_init_t pcstatus_init = {
diff --git a/pcl/pcsymbol.c b/pcl/pcsymbol.c
index d46a661dc..8d376b9dd 100644
--- a/pcl/pcsymbol.c
+++ b/pcl/pcsymbol.c
@@ -20,8 +20,6 @@
#include "pcfont.h"
#include "pcsymbol.h"
-
-
/* HP printers will not convert MSL coded symbol table to unicode. An
MSL based font must be used with an MSL symbol set. We think this
is a bug. The following definition can be uncommented to support
@@ -32,8 +30,8 @@
static int /* ESC * c <id> R */
pcl_symbol_set_id_code(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint id = uint_arg(pargs);
- id_set_value(pcs->symbol_set_id, id);
- return 0;
+ id_set_value(pcs->symbol_set_id, id);
+ return 0;
}
#ifdef DEBUG
@@ -60,52 +58,52 @@ dump_dl_symbol_set(const pl_symbol_map_t *psm)
static int /* ESC ( f <count> W */
pcl_define_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs)
{ uint count = uint_arg(pargs);
- const pl_symbol_map_t *psm = (pl_symbol_map_t *)arg_data(pargs);
- uint header_size;
- uint first_code, last_code;
- gs_memory_t *mem = pcs->memory;
- pl_symbol_map_t *header;
- pcl_symbol_set_t *symsetp;
- pl_glyph_vocabulary_t gv;
+ const pl_symbol_map_t *psm = (pl_symbol_map_t *)arg_data(pargs);
+ uint header_size;
+ uint first_code, last_code;
+ gs_memory_t *mem = pcs->memory;
+ pl_symbol_map_t *header;
+ pcl_symbol_set_t *symsetp;
+ pl_glyph_vocabulary_t gv;
#define psm_header_size 18
- if ( count < psm_header_size )
- return e_Range;
- header_size = pl_get_uint16(psm->header_size);
- if ( header_size < psm_header_size ||
- psm->id[0] != id_key(pcs->symbol_set_id)[0] ||
- psm->id[1] != id_key(pcs->symbol_set_id)[1] ||
- psm->type > 2
- )
- return e_Range;
- switch ( psm->format )
- {
- case 1:
+ if ( count < psm_header_size )
+ return e_Range;
+ header_size = pl_get_uint16(psm->header_size);
+ if ( header_size < psm_header_size ||
+ psm->id[0] != id_key(pcs->symbol_set_id)[0] ||
+ psm->id[1] != id_key(pcs->symbol_set_id)[1] ||
+ psm->type > 2
+ )
+ return e_Range;
+ switch ( psm->format )
+ {
+ case 1:
gv = plgv_MSL;
break;
- case 3:
+ case 3:
gv = plgv_Unicode;
break;
- default:
- return e_Range;
- }
- first_code = pl_get_uint16(psm->first_code);
- last_code = pl_get_uint16(psm->last_code);
+ default:
+ return e_Range;
+ }
+ first_code = pl_get_uint16(psm->first_code);
+ last_code = pl_get_uint16(psm->last_code);
/* NB fixme should check psm->Format to identify the vocabulary. */
- { int num_codes = last_code - first_code + 1;
- int i;
-
- if ( num_codes <= 0 || last_code > 255 || (count != psm_header_size + num_codes * 2) )
- return e_Range;
-
- header =
- (pl_symbol_map_t *)gs_alloc_bytes(mem,
- sizeof(pl_symbol_map_t),
- "pcl_font_header(header)");
- if ( header == 0 )
- return_error(e_Memory);
- memcpy((void *)header, (void *)psm, psm_header_size);
- /* allow mapping to and from msl and unicode */
+ { int num_codes = last_code - first_code + 1;
+ int i;
+
+ if ( num_codes <= 0 || last_code > 255 || (count != psm_header_size + num_codes * 2) )
+ return e_Range;
+
+ header =
+ (pl_symbol_map_t *)gs_alloc_bytes(mem,
+ sizeof(pl_symbol_map_t),
+ "pcl_font_header(header)");
+ if ( header == 0 )
+ return_error(e_Memory);
+ memcpy((void *)header, (void *)psm, psm_header_size);
+ /* allow mapping to and from msl and unicode */
if (psm->format == 1)
#ifdef SUPPORT_MSL_TO_UNICODE
header->mapping_type = PLGV_M2U_MAPPING;
@@ -115,14 +113,14 @@ pcl_define_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs)
else
header->mapping_type = PLGV_U2M_MAPPING;
- /*
- * Byte swap the codes now, so that we don't have to byte swap
- * them every time we access them.
- */
- for ( i = num_codes; --i >= 0; )
- header->codes[i] =
- pl_get_uint16((byte *)psm + psm_header_size + i * 2);
- }
+ /*
+ * Byte swap the codes now, so that we don't have to byte swap
+ * them every time we access them.
+ */
+ for ( i = num_codes; --i >= 0; )
+ header->codes[i] =
+ pl_get_uint16((byte *)psm + psm_header_size + i * 2);
+ }
#undef psm_header_size
#ifdef DEBUG
@@ -130,150 +128,149 @@ pcl_define_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs)
dump_dl_symbol_set(psm);
#endif
- /* Symbol set may already exist; if so, we may be replacing one of
- * its existing maps or adding one for a new glyph vocabulary. */
- if ( pl_dict_find(&pcs->soft_symbol_sets, id_key(pcs->symbol_set_id),
- 2, (void **)&symsetp) )
- {
- if ( symsetp->maps[gv] != NULL )
- gs_free_object(mem, symsetp->maps[gv], "symset map");
- }
- else
- { pl_glyph_vocabulary_t gx;
- symsetp = (pcl_symbol_set_t *)gs_alloc_bytes(mem,
- sizeof(pcl_symbol_set_t), "symset dict value");
- if ( !symsetp )
- return_error(e_Memory);
- for ( gx = plgv_MSL; gx < plgv_next; gx++ )
- symsetp->maps[gx] = NULL;
- symsetp->storage = pcds_temporary;
- pl_dict_put(&pcs->soft_symbol_sets, id_key(pcs->symbol_set_id),
- 2, symsetp);
- }
- symsetp->maps[gv] = header;
-
- return 0;
+ /* Symbol set may already exist; if so, we may be replacing one of
+ * its existing maps or adding one for a new glyph vocabulary. */
+ if ( pl_dict_find(&pcs->soft_symbol_sets, id_key(pcs->symbol_set_id),
+ 2, (void **)&symsetp) )
+ {
+ if ( symsetp->maps[gv] != NULL )
+ gs_free_object(mem, symsetp->maps[gv], "symset map");
+ }
+ else
+ { pl_glyph_vocabulary_t gx;
+ symsetp = (pcl_symbol_set_t *)gs_alloc_bytes(mem,
+ sizeof(pcl_symbol_set_t), "symset dict value");
+ if ( !symsetp )
+ return_error(e_Memory);
+ for ( gx = plgv_MSL; gx < plgv_next; gx++ )
+ symsetp->maps[gx] = NULL;
+ symsetp->storage = pcds_temporary;
+ pl_dict_put(&pcs->soft_symbol_sets, id_key(pcs->symbol_set_id),
+ 2, symsetp);
+ }
+ symsetp->maps[gv] = header;
+
+ return 0;
}
static int /* ESC * c <ssc_enum> S */
pcl_symbol_set_control(pcl_args_t *pargs, pcl_state_t *pcs)
{ gs_const_string key;
- void *value;
- pl_dict_enum_t denum;
-
- switch ( int_arg(pargs) )
- {
- case 0:
- { /* Delete all user-defined symbol sets. */
- /* Note: When deleting symbol set(s), it is easier (safer?)
- * to decache and reselect fonts unconditionally. (Consider,
- * for example, deleting a downloaded overload of a built-in
- * which might be the default ID.) */
- pl_dict_release(&pcs->soft_symbol_sets);
- pcl_decache_font(pcs, -1);
- }
- return 0;
- case 1:
- { /* Delete all temporary symbol sets. */
- pl_dict_enum_stack_begin(&pcs->soft_symbol_sets, &denum, false);
- while ( pl_dict_enum_next(&denum, &key, &value) )
- if ( ((pcl_symbol_set_t *)value)->storage == pcds_temporary )
- pl_dict_undef(&pcs->soft_symbol_sets, key.data, key.size);
- pcl_decache_font(pcs, -1);
- }
- return 0;
- case 2:
- { /* Delete symbol set <symbol_set_id>. */
- pl_dict_undef(&pcs->soft_symbol_sets,
- id_key(pcs->symbol_set_id), 2);
- pcl_decache_font(pcs, -1);
- }
- return 0;
- case 4:
- { /* Make <symbol_set_id> temporary. */
- if ( pl_dict_find(&pcs->soft_symbol_sets,
- id_key(pcs->symbol_set_id), 2, &value) )
- ((pcl_symbol_set_t *)value)->storage = pcds_temporary;
- }
- return 0;
- case 5:
- { /* Make <symbol_set_id> permanent. */
- if ( pl_dict_find(&pcs->soft_symbol_sets,
- id_key(pcs->symbol_set_id), 2, &value) )
- ((pcl_symbol_set_t *)value)->storage = pcds_permanent;
- }
- return 0;
- default:
- return 0;
- }
+ void *value;
+ pl_dict_enum_t denum;
+
+ switch ( int_arg(pargs) )
+ {
+ case 0:
+ { /* Delete all user-defined symbol sets. */
+ /* Note: When deleting symbol set(s), it is easier (safer?)
+ * to decache and reselect fonts unconditionally. (Consider,
+ * for example, deleting a downloaded overload of a built-in
+ * which might be the default ID.) */
+ pl_dict_release(&pcs->soft_symbol_sets);
+ pcl_decache_font(pcs, -1);
+ }
+ return 0;
+ case 1:
+ { /* Delete all temporary symbol sets. */
+ pl_dict_enum_stack_begin(&pcs->soft_symbol_sets, &denum, false);
+ while ( pl_dict_enum_next(&denum, &key, &value) )
+ if ( ((pcl_symbol_set_t *)value)->storage == pcds_temporary )
+ pl_dict_undef(&pcs->soft_symbol_sets, key.data, key.size);
+ pcl_decache_font(pcs, -1);
+ }
+ return 0;
+ case 2:
+ { /* Delete symbol set <symbol_set_id>. */
+ pl_dict_undef(&pcs->soft_symbol_sets,
+ id_key(pcs->symbol_set_id), 2);
+ pcl_decache_font(pcs, -1);
+ }
+ return 0;
+ case 4:
+ { /* Make <symbol_set_id> temporary. */
+ if ( pl_dict_find(&pcs->soft_symbol_sets,
+ id_key(pcs->symbol_set_id), 2, &value) )
+ ((pcl_symbol_set_t *)value)->storage = pcds_temporary;
+ }
+ return 0;
+ case 5:
+ { /* Make <symbol_set_id> permanent. */
+ if ( pl_dict_find(&pcs->soft_symbol_sets,
+ id_key(pcs->symbol_set_id), 2, &value) )
+ ((pcl_symbol_set_t *)value)->storage = pcds_permanent;
+ }
+ return 0;
+ default:
+ return 0;
+ }
}
static void /* free any symbol maps as well as dict value entry */
pcsymbol_dict_value_free(gs_memory_t *mem, void *value, client_name_t cname)
{ pcl_symbol_set_t *ssp = (pcl_symbol_set_t *)value;
- pl_glyph_vocabulary_t gx;
-
- if ( ssp->storage != pcds_internal )
- {
- for ( gx = plgv_MSL; gx < plgv_next; gx++ )
- {
- if ( ssp->maps[gx] != NULL )
- gs_free_object(mem, (void*)ssp->maps[gx], cname);
- }
- }
- gs_free_object(mem, value, cname);
+ pl_glyph_vocabulary_t gx;
+
+ if ( ssp->storage != pcds_internal )
+ {
+ for ( gx = plgv_MSL; gx < plgv_next; gx++ )
+ {
+ if ( ssp->maps[gx] != NULL )
+ gs_free_object(mem, (void*)ssp->maps[gx], cname);
+ }
+ }
+ gs_free_object(mem, value, cname);
}
static int
pcl_load_built_in_symbol_sets(pcl_state_t *pcs)
{
- const pl_symbol_map_t **maplp;
- pcl_symbol_set_t *symsetp;
- pl_glyph_vocabulary_t gv;
-
- for ( maplp = &pl_built_in_symbol_maps[0]; *maplp; maplp++ )
- {
- const pl_symbol_map_t *mapp = *maplp;
- /* Create entry for symbol set if this is the first map for
- * that set. */
- if ( !pl_dict_find(&pcs->built_in_symbol_sets, mapp->id, 2,
- (void **)&symsetp) )
- { pl_glyph_vocabulary_t gx;
- symsetp = (pcl_symbol_set_t *)gs_alloc_bytes(pcs->memory,
- sizeof(pcl_symbol_set_t), "symset init dict value");
- if ( !symsetp )
- return_error(e_Memory);
- for ( gx = plgv_MSL; gx < plgv_next; gx++ )
- symsetp->maps[gx] = NULL;
- symsetp->storage = pcds_internal;
- }
- gv = (mapp->character_requirements[7] & 07)==1?
- plgv_Unicode: plgv_MSL;
- pl_dict_put(&pcs->built_in_symbol_sets, mapp->id, 2, symsetp);
- symsetp->maps[gv] = (pl_symbol_map_t *)mapp;
- }
- return 0;
+ const pl_symbol_map_t **maplp;
+ pcl_symbol_set_t *symsetp;
+ pl_glyph_vocabulary_t gv;
+
+ for ( maplp = &pl_built_in_symbol_maps[0]; *maplp; maplp++ )
+ {
+ const pl_symbol_map_t *mapp = *maplp;
+ /* Create entry for symbol set if this is the first map for
+ * that set. */
+ if ( !pl_dict_find(&pcs->built_in_symbol_sets, mapp->id, 2,
+ (void **)&symsetp) )
+ { pl_glyph_vocabulary_t gx;
+ symsetp = (pcl_symbol_set_t *)gs_alloc_bytes(pcs->memory,
+ sizeof(pcl_symbol_set_t), "symset init dict value");
+ if ( !symsetp )
+ return_error(e_Memory);
+ for ( gx = plgv_MSL; gx < plgv_next; gx++ )
+ symsetp->maps[gx] = NULL;
+ symsetp->storage = pcds_internal;
+ }
+ gv = (mapp->character_requirements[7] & 07)==1?
+ plgv_Unicode: plgv_MSL;
+ pl_dict_put(&pcs->built_in_symbol_sets, mapp->id, 2, symsetp);
+ symsetp->maps[gv] = (pl_symbol_map_t *)mapp;
+ }
+ return 0;
}
bool
pcl_check_symbol_support(const byte *symset_req, const byte *font_sup)
{ int i;
- /* if glyph vocabularies match, following will work on the
- * last 3 bits of last byte. Note that the font-support bits
- * are inverted (0 means available).
- */
- for ( i = 0; i < 7; i++ )
- if ( symset_req[i] & font_sup[i] )
- return false; /* something needed, not present */
- /* check the last byte but not the glyph vocabularies. */
- if ((symset_req[7] >> 3) & (font_sup[7] >> 3))
- return false;
-
- return true;
+ /* if glyph vocabularies match, following will work on the
+ * last 3 bits of last byte. Note that the font-support bits
+ * are inverted (0 means available).
+ */
+ for ( i = 0; i < 7; i++ )
+ if ( symset_req[i] & font_sup[i] )
+ return false; /* something needed, not present */
+ /* check the last byte but not the glyph vocabularies. */
+ if ((symset_req[7] >> 3) & (font_sup[7] >> 3))
+ return false;
+
+ return true;
}
-
/* Find the symbol map for a particular symbol set and glyph vocabulary,
* if it exists.
* There are two dictionaries--one for soft (downloaded) symbol sets and
@@ -282,34 +279,33 @@ pcl_check_symbol_support(const byte *symset_req, const byte *font_sup)
pl_symbol_map_t *
pcl_find_symbol_map(const pcl_state_t *pcs, const byte *id,
pl_glyph_vocabulary_t gv, bool wide16)
-{
+{
pcl_symbol_set_t *setp;
-
if ( pl_dict_find((pl_dict_t *)&pcs->soft_symbol_sets,
- id, 2, (void **)&setp) ||
+ id, 2, (void **)&setp) ||
pl_dict_find((pl_dict_t *)&pcs->built_in_symbol_sets,
- id, 2, (void**)&setp) ) {
+ id, 2, (void**)&setp) ) {
/* 16 bit sets are not supported, they aren't strictly
necessary, yet. */
if (wide16)
return NULL;
- /* simple case we found a matching symbol set */
- if ( setp->maps[gv] != NULL )
- return setp->maps[gv];
- /* we requested a unicode symbol set and found an msl
- symbol set that can be mapped to unicode */
- if ( (gv == plgv_Unicode) &&
- (setp->maps[plgv_MSL]) &&
- ((setp->maps[plgv_MSL])->mapping_type == PLGV_M2U_MAPPING) )
- return setp->maps[plgv_MSL];
- /* we requested an msl symbol set and found a unicode
- symbol set that can be mapped to msl */
- if ( (gv == plgv_MSL) &&
- (setp->maps[plgv_Unicode]) &&
- ((setp->maps[plgv_Unicode])->mapping_type == PLGV_U2M_MAPPING) )
- return setp->maps[plgv_Unicode];
+ /* simple case we found a matching symbol set */
+ if ( setp->maps[gv] != NULL )
+ return setp->maps[gv];
+ /* we requested a unicode symbol set and found an msl
+ symbol set that can be mapped to unicode */
+ if ( (gv == plgv_Unicode) &&
+ (setp->maps[plgv_MSL]) &&
+ ((setp->maps[plgv_MSL])->mapping_type == PLGV_M2U_MAPPING) )
+ return setp->maps[plgv_MSL];
+ /* we requested an msl symbol set and found a unicode
+ symbol set that can be mapped to msl */
+ if ( (gv == plgv_MSL) &&
+ (setp->maps[plgv_Unicode]) &&
+ ((setp->maps[plgv_Unicode])->mapping_type == PLGV_U2M_MAPPING) )
+ return setp->maps[plgv_Unicode];
}
return NULL;
}
@@ -321,45 +317,45 @@ pcsymbol_do_registration(
gs_memory_t *mem
)
{ /* Register commands */
- DEFINE_CLASS_COMMAND_ARGS('*', 'c', 'R', "Symbol Set ID Code",
- pcl_symbol_set_id_code,
- pca_neg_error|pca_big_error)
- DEFINE_CLASS_COMMAND_ARGS('(', 'f', 'W', "Define Symbol Set",
- pcl_define_symbol_set, pca_byte_data|pca_neg_error|pca_big_clamp)
- DEFINE_CLASS_COMMAND_ARGS('*', 'c', 'S', "Symbol Set Control",
- pcl_symbol_set_control,
- pca_neg_ignore|pca_big_ignore)
- return 0;
+ DEFINE_CLASS_COMMAND_ARGS('*', 'c', 'R', "Symbol Set ID Code",
+ pcl_symbol_set_id_code,
+ pca_neg_error|pca_big_error)
+ DEFINE_CLASS_COMMAND_ARGS('(', 'f', 'W', "Define Symbol Set",
+ pcl_define_symbol_set, pca_byte_data|pca_neg_error|pca_big_clamp)
+ DEFINE_CLASS_COMMAND_ARGS('*', 'c', 'S', "Symbol Set Control",
+ pcl_symbol_set_control,
+ pca_neg_ignore|pca_big_ignore)
+ return 0;
}
static void
pcsymbol_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
-{
+{
if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_overlay) ) {
- id_set_value(pcs->symbol_set_id, 0);
- if ( type & pcl_reset_initial ) {
- /* Don't set a parent relationship from soft to built-in
- * symbol sets. Although it is arguably useful, it's
- * better to avoid it and keep anyone who's looking at the
- * soft symbol sets from mucking up the permanent ones. */
- pl_dict_init(&pcs->soft_symbol_sets, pcs->memory,
- pcsymbol_dict_value_free);
- pl_dict_init(&pcs->built_in_symbol_sets, pcs->memory,
- pcsymbol_dict_value_free);
- /* NB. Symbol sets are require for RTL/HPGL/2 mode for
- * stickfonts but we shouldn't load all of them. */
- if ( pcl_load_built_in_symbol_sets(pcs) < 0 )
- dprintf("Internal error, no symbol sets found");
- }
- else if ( type & pcl_reset_printer ) {
- pcl_args_t args;
- arg_set_uint(&args, 1); /* delete temporary symbol sets */
- pcl_symbol_set_control(&args, pcs);
- }
+ id_set_value(pcs->symbol_set_id, 0);
+ if ( type & pcl_reset_initial ) {
+ /* Don't set a parent relationship from soft to built-in
+ * symbol sets. Although it is arguably useful, it's
+ * better to avoid it and keep anyone who's looking at the
+ * soft symbol sets from mucking up the permanent ones. */
+ pl_dict_init(&pcs->soft_symbol_sets, pcs->memory,
+ pcsymbol_dict_value_free);
+ pl_dict_init(&pcs->built_in_symbol_sets, pcs->memory,
+ pcsymbol_dict_value_free);
+ /* NB. Symbol sets are require for RTL/HPGL/2 mode for
+ * stickfonts but we shouldn't load all of them. */
+ if ( pcl_load_built_in_symbol_sets(pcs) < 0 )
+ dprintf("Internal error, no symbol sets found");
+ }
+ else if ( type & pcl_reset_printer ) {
+ pcl_args_t args;
+ arg_set_uint(&args, 1); /* delete temporary symbol sets */
+ pcl_symbol_set_control(&args, pcs);
+ }
}
if ( type & pcl_reset_permanent ) {
- pl_dict_release(&pcs->soft_symbol_sets);
- pl_dict_release(&pcs->built_in_symbol_sets);
+ pl_dict_release(&pcs->soft_symbol_sets);
+ pl_dict_release(&pcs->built_in_symbol_sets);
}
}
@@ -367,10 +363,10 @@ static int
pcsymbol_do_copy(pcl_state_t *psaved, const pcl_state_t *pcs,
pcl_copy_operation_t operation)
{ if ( operation & pcl_copy_after )
- { /* Don't restore the downloaded symbol set dictionary. */
- psaved->built_in_symbol_sets = pcs->built_in_symbol_sets;
- }
- return 0;
+ { /* Don't restore the downloaded symbol set dictionary. */
+ psaved->built_in_symbol_sets = pcs->built_in_symbol_sets;
+ }
+ return 0;
}
const pcl_init_t pcsymbol_init = {
diff --git a/pcl/pcsymbol.h b/pcl/pcsymbol.h
index f5c85f337..676ec4b1c 100644
--- a/pcl/pcsymbol.h
+++ b/pcl/pcsymbol.h
@@ -34,7 +34,7 @@ typedef struct pcl_symbol_set_s {
/* Check whether a symbol map's character requirements are supported by a
* font's character complement. */
bool pcl_check_symbol_support(const byte *symset_req,
- const byte *font_sup);
+ const byte *font_sup);
/* Find a symbol map, given its ID and glyph vocabulary. */
pl_symbol_map_t *pcl_find_symbol_map(const pcl_state_t *pcs,
diff --git a/pcl/pctext.c b/pcl/pctext.c
index bcd7c64f5..eb5cd0c82 100644
--- a/pcl/pctext.c
+++ b/pcl/pctext.c
@@ -40,7 +40,6 @@
/* pseudo-"dots" (actually 1/300" units) used in underline only */
#define dots(n) ((float)(7200 / 300 * n))
-
/*
* Install a font in the graphic state.
*/
@@ -61,7 +60,6 @@ pcl_downloaded_and_bound(pl_font_t *plfont)
return (plfont->storage != pcds_internal && pl_font_is_bound(plfont));
}
-
/* uncomment the following definition to treat map type 0 as defined
in the specification. The default is to use the behavior we have
observed on several HP devices. Map type 0 is treated as map type
@@ -312,11 +310,11 @@ get_next_char(
*pchr = 0xffff;
return 0;
}
-/*
- * return length of multibyte sequence from starting byte
+/*
+ * return length of multibyte sequence from starting byte
* replacement of macro pcl_char_is_2_byte, UTF-8 sequence length may be up to 6 bytes
*
- * Returns 0 for invalid byte, byte length > 0 of multibyte character sequence
+ * Returns 0 for invalid byte, byte length > 0 of multibyte character sequence
*/
int
pcl_char_bytelen(byte ch, pcl_text_parsing_method_t tpm)
@@ -324,71 +322,71 @@ pcl_char_bytelen(byte ch, pcl_text_parsing_method_t tpm)
int bytelen = 1;
- switch(tpm) {
- default:
- /* byte length defaults to 1 */
- break;
-
- case tpm_21_DBCS7:
- /* 0x21-0xff are double-byte */
- bytelen = (ch < 0x21) ? 1 : 2;
- break;
-
- case tpm_31_sjis:
- /* 0x81-0x9f, 0xe0-0xfc are double-byte */
- bytelen = (ch < 0x81 || (ch > 0x9f && ch < 0xe0) || ch > 0xfc) ? 1 : 2;
- break;
-
- case tpm_38_DBCS8:
- /* 0x80-0xff are double-byte */
- bytelen = (ch < 0x80) ? 1 : 2;
- break;
+ switch(tpm) {
+ default:
+ /* byte length defaults to 1 */
+ break;
+
+ case tpm_21_DBCS7:
+ /* 0x21-0xff are double-byte */
+ bytelen = (ch < 0x21) ? 1 : 2;
+ break;
+
+ case tpm_31_sjis:
+ /* 0x81-0x9f, 0xe0-0xfc are double-byte */
+ bytelen = (ch < 0x81 || (ch > 0x9f && ch < 0xe0) || ch > 0xfc) ? 1 : 2;
+ break;
+
+ case tpm_38_DBCS8:
+ /* 0x80-0xff are double-byte */
+ bytelen = (ch < 0x80) ? 1 : 2;
+ break;
case tpm_83_utf8:
case tpm_1008_utf8:
- if (ch < 0x80) {
- /* 0xxxxxxx */
- bytelen = 1;
- break;
- }
- if (ch < 0xc2) {
- bytelen = 0; /* illegal */
- break;
- }
- if (ch < 0xe0) {
- /* 110XXXXx 10xxxxxx */
- bytelen = 2;
- break;
- }
- if (ch < 0xf0) {
- /* 1110XXXX 10Xxxxxx 10xxxxxx */
- bytelen = 3;
- break;
- }
- if (ch < 0xf8) {
- /* 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx */
- bytelen = 4;
- break;
- }
- if (ch < 0xfc) {
- /* 111110XX 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- bytelen = 5;
- break;
- }
- if (ch < 0xfe) {
- /* 1111110X 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- bytelen = 6;
- break;
- }
- bytelen = 0; /* illegal */
- break;
- }
- return bytelen;
+ if (ch < 0x80) {
+ /* 0xxxxxxx */
+ bytelen = 1;
+ break;
+ }
+ if (ch < 0xc2) {
+ bytelen = 0; /* illegal */
+ break;
+ }
+ if (ch < 0xe0) {
+ /* 110XXXXx 10xxxxxx */
+ bytelen = 2;
+ break;
+ }
+ if (ch < 0xf0) {
+ /* 1110XXXX 10Xxxxxx 10xxxxxx */
+ bytelen = 3;
+ break;
+ }
+ if (ch < 0xf8) {
+ /* 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx */
+ bytelen = 4;
+ break;
+ }
+ if (ch < 0xfc) {
+ /* 111110XX 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+ bytelen = 5;
+ break;
+ }
+ if (ch < 0xfe) {
+ /* 1111110X 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+ bytelen = 6;
+ break;
+ }
+ bytelen = 0; /* illegal */
+ break;
+ }
+ return bytelen;
}
-/*
+/*
* convert multibyte sequence to unicode (16-bit)
* Both the string pointer and the length are modified.
*
- * Returns 0 for invalid byte, byte length > 0 of multibyte character sequence
+ * Returns 0 for invalid byte, byte length > 0 of multibyte character sequence
*/
gs_char
pcl_char_get_char(pcl_text_parsing_method_t tpm, const byte ** psrc, int src_len)
@@ -404,66 +402,66 @@ pcl_char_get_char(pcl_text_parsing_method_t tpm, const byte ** psrc, int src_len
switch(tpm) {
default:
chr = src[0];
- break;
+ break;
case tpm_21_DBCS7:
- /* 0x21-0xff are double-byte */
- chr = (src[0] < 0x21) ? src[0] : (src[0] << 8 | src[1]);
- break;
+ /* 0x21-0xff are double-byte */
+ chr = (src[0] < 0x21) ? src[0] : (src[0] << 8 | src[1]);
+ break;
case tpm_31_sjis:
- /* 0x81-0x9f, 0xe0-0xfc are double-byte */
- chr = (src[0] < 0x81 || (src[0] > 0x9f && src[0] < 0xe0) || src[0] > 0xfc) ? src[0] : (src[0] << 8 | src[1]);
- break;
+ /* 0x81-0x9f, 0xe0-0xfc are double-byte */
+ chr = (src[0] < 0x81 || (src[0] > 0x9f && src[0] < 0xe0) || src[0] > 0xfc) ? src[0] : (src[0] << 8 | src[1]);
+ break;
case tpm_38_DBCS8:
- /* 0x80-0xff are double-byte */
- chr = (src[0] < 0x80) ? src[0] : (src[0] << 8 | src[1]);
- break;
+ /* 0x80-0xff are double-byte */
+ chr = (src[0] < 0x80) ? src[0] : (src[0] << 8 | src[1]);
+ break;
case tpm_83_utf8:
case tpm_1008_utf8:
- if (src[0] < 0x80) {
- /* 0xxxxxxx */
- chr = src[0];
- break;
- }
- if (src[0] < 0xc2) {
+ if (src[0] < 0x80) {
+ /* 0xxxxxxx */
+ chr = src[0];
+ break;
+ }
+ if (src[0] < 0xc2) {
chr = INVALID_UC;
- break;
- }
- if (src[0] < 0xe0) {
- /* 110XXXXx 10xxxxxx */
- chr = (src[0] & 0x1f);
- chr = (chr << 6) | (src[1] & 0x3f);
- break;
- }
- if (src[0] < 0xf0) {
- /* 1110XXXX 10Xxxxxx 10xxxxxx */
- chr = (src[0] & 0x0f);
- chr = (chr << 6) | (src[1] & 0x3f);
- chr = (chr << 6) | (src[2] & 0x3f);
- break;
- }
- if (src[0] < 0xf8) {
- /* 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx */
- /* chr is 16 bit: overflow */
+ break;
+ }
+ if (src[0] < 0xe0) {
+ /* 110XXXXx 10xxxxxx */
+ chr = (src[0] & 0x1f);
+ chr = (chr << 6) | (src[1] & 0x3f);
+ break;
+ }
+ if (src[0] < 0xf0) {
+ /* 1110XXXX 10Xxxxxx 10xxxxxx */
+ chr = (src[0] & 0x0f);
+ chr = (chr << 6) | (src[1] & 0x3f);
+ chr = (chr << 6) | (src[2] & 0x3f);
+ break;
+ }
+ if (src[0] < 0xf8) {
+ /* 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx */
+ /* chr is 16 bit: overflow */
chr = INVALID_UC;
- break;
- }
- if (src[0] < 0xfc) {
- /* 111110XX 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- /* chr is 16 bit: overflow */
+ break;
+ }
+ if (src[0] < 0xfc) {
+ /* 111110XX 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+ /* chr is 16 bit: overflow */
chr = INVALID_UC;
- break;
- }
- if (src[0] < 0xfe) {
- /* 1111110X 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- /* chr is 16 bit: overflow */
+ break;
+ }
+ if (src[0] < 0xfe) {
+ /* 1111110X 10XXxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+ /* chr is 16 bit: overflow */
chr = INVALID_UC;
- break;
- }
- chr = INVALID_UC;
- break;
+ break;
+ }
+ chr = INVALID_UC;
+ break;
}
*psrc += bytelen;
return chr;
@@ -974,7 +972,6 @@ pcl_text(
else
pcs->font->allow_vertical_substitutes = false;
-
/* Print remaining characters, restore the ctm */
code = pcl_show_chars_slow(pcs, &scale, str, size, literal);
gs_setmatrix(pgs, &user_ctm);
@@ -1254,10 +1251,10 @@ pctext_do_reset(
if ((type & mask) != 0) {
pcs->underline_enabled = false;
- pcs->last_was_BS = false;
- pcs->last_width = inch2coord(1.0 / 10.0);
+ pcs->last_was_BS = false;
+ pcs->last_width = inch2coord(1.0 / 10.0);
pcs->text_parsing_method = tpm_0_SBCS;
- pcs->text_path = 0;
+ pcs->text_path = 0;
}
}
diff --git a/pcl/pctop.c b/pcl/pctop.c
index 2b37f8340..6301f1412 100644
--- a/pcl/pctop.c
+++ b/pcl/pctop.c
@@ -39,43 +39,41 @@
#include "pcpalet.h"
#include "gsicc_manage.h"
-
-
/* Configuration table for modules */
-extern const pcl_init_t pcparse_init;
-extern const pcl_init_t rtmisc_init;
-extern const pcl_init_t rtraster_init;
-extern const pcl_init_t pcjob_init;
-extern const pcl_init_t pcpage_init;
-extern const pcl_init_t pcfont_init;
-extern const pcl_init_t pctext_init;
-extern const pcl_init_t pcsymbol_init;
-extern const pcl_init_t pcsfont_init;
-extern const pcl_init_t pcmacros_init;
-extern const pcl_init_t pcrect_init;
-extern const pcl_init_t pcstatus_init;
-extern const pcl_init_t pcmisc_init;
-extern const pcl_init_t pcursor_init;
-extern const pcl_init_t pcl_cid_init;
-extern const pcl_init_t pcl_color_init;
-extern const pcl_init_t pcl_udither_init;
-extern const pcl_init_t pcl_frgrnd_init;
-extern const pcl_init_t pcl_lookup_tbl_init;
-extern const pcl_init_t pcl_palette_init;
-extern const pcl_init_t pcl_pattern_init;
-extern const pcl_init_t pcl_xfm_init;
-extern const pcl_init_t pcl_upattern_init;
-extern const pcl_init_t rtgmode_init;
-extern const pcl_init_t pccprint_init;
-extern const pcl_init_t pginit_init;
-extern const pcl_init_t pgframe_init;
-extern const pcl_init_t pgconfig_init;
-extern const pcl_init_t pgvector_init;
-extern const pcl_init_t pgpoly_init;
-extern const pcl_init_t pglfill_init;
-extern const pcl_init_t pgchar_init;
-extern const pcl_init_t pglabel_init;
-extern const pcl_init_t pgcolor_init;
+extern const pcl_init_t pcparse_init;
+extern const pcl_init_t rtmisc_init;
+extern const pcl_init_t rtraster_init;
+extern const pcl_init_t pcjob_init;
+extern const pcl_init_t pcpage_init;
+extern const pcl_init_t pcfont_init;
+extern const pcl_init_t pctext_init;
+extern const pcl_init_t pcsymbol_init;
+extern const pcl_init_t pcsfont_init;
+extern const pcl_init_t pcmacros_init;
+extern const pcl_init_t pcrect_init;
+extern const pcl_init_t pcstatus_init;
+extern const pcl_init_t pcmisc_init;
+extern const pcl_init_t pcursor_init;
+extern const pcl_init_t pcl_cid_init;
+extern const pcl_init_t pcl_color_init;
+extern const pcl_init_t pcl_udither_init;
+extern const pcl_init_t pcl_frgrnd_init;
+extern const pcl_init_t pcl_lookup_tbl_init;
+extern const pcl_init_t pcl_palette_init;
+extern const pcl_init_t pcl_pattern_init;
+extern const pcl_init_t pcl_xfm_init;
+extern const pcl_init_t pcl_upattern_init;
+extern const pcl_init_t rtgmode_init;
+extern const pcl_init_t pccprint_init;
+extern const pcl_init_t pginit_init;
+extern const pcl_init_t pgframe_init;
+extern const pcl_init_t pgconfig_init;
+extern const pcl_init_t pgvector_init;
+extern const pcl_init_t pgpoly_init;
+extern const pcl_init_t pglfill_init;
+extern const pcl_init_t pgchar_init;
+extern const pcl_init_t pglabel_init;
+extern const pcl_init_t pgcolor_init;
extern const pcl_init_t fontpg_init;
const pcl_init_t * pcl_init_table[] = {
@@ -135,7 +133,7 @@ pcl_gstate_client_alloc(
/*
* set and get for pcl's target device. This is the device at the end
- * of the pipeline.
+ * of the pipeline.
*/
static int
pcl_gstate_client_copy_for(
@@ -187,7 +185,6 @@ typedef struct pcl_interp_instance_s {
void *post_page_closure;/* closure to call post_page_action with */
} pcl_interp_instance_t;
-
/* Get implemtation's characteristics */
const pl_interp_characteristics_t * /* always returns a descriptor */
pcl_impl_characteristics(
@@ -240,21 +237,21 @@ pcl_impl_allocate_interp_instance(
{
/* Allocate everything up front */
pcl_interp_instance_t *pcli /****** SHOULD HAVE A STRUCT DESCRIPTOR ******/
- = (pcl_interp_instance_t *)gs_alloc_bytes( mem,
- sizeof(pcl_interp_instance_t),
- "pcl_allocate_interp_instance(pcl_interp_instance_t)"
- );
- gs_state *pgs = gs_state_alloc(mem);
+ = (pcl_interp_instance_t *)gs_alloc_bytes( mem,
+ sizeof(pcl_interp_instance_t),
+ "pcl_allocate_interp_instance(pcl_interp_instance_t)"
+ );
+ gs_state *pgs = gs_state_alloc(mem);
gsicc_init_iccmanager(pgs);
/* If allocation error, deallocate & return */
if (!pcli || !pgs) {
- if (pcli)
- gs_free_object(mem, pcli, "pcl_allocate_interp_instance(pcl_interp_instance_t)");
- if (pgs)
- gs_state_free(pgs);
- return gs_error_VMerror;
+ if (pcli)
+ gs_free_object(mem, pcli, "pcl_allocate_interp_instance(pcl_interp_instance_t)");
+ if (pgs)
+ gs_state_free(pgs);
+ return gs_error_VMerror;
}
pcli->memory = mem;
@@ -265,16 +262,16 @@ pcl_impl_allocate_interp_instance(
pcl_init_state(&pcli->pcs, mem);
pcli->pcs.client_data = pcli;
pcli->pcs.pgs = pgs;
- pcli->pcs.xfm_state.paper_size = 0;
+ pcli->pcs.xfm_state.paper_size = 0;
/* provide an end page procedure */
pcli->pcs.end_page = pcl_end_page_top;
/* Init gstate to point to pcl state */
gs_state_set_client(pgs, &pcli->pcs, &pcl_gstate_procs, false);
/* register commands */
{
- int code = pcl_do_registrations(&pcli->pcs, &pcli->pst);
- if ( code < 0 )
- return(code);
+ int code = pcl_do_registrations(&pcli->pcs, &pcli->pst);
+ if ( code < 0 )
+ return(code);
}
/* Return success */
@@ -290,12 +287,12 @@ pcl_impl_set_client_instance(
pl_interp_instance_clients_t which_client
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
-
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+
if ( which_client == PJL_CLIENT )
pcli->pcs.pjls = client;
/* ignore unknown clients */
- return 0;
+ return 0;
}
/* Set an interpreter instance's pre-page action */
@@ -306,10 +303,10 @@ pcl_impl_set_pre_page_action(
void *closure /* closure to call action with */
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- pcli->pre_page_action = action;
- pcli->pre_page_closure = closure;
- return 0;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ pcli->pre_page_action = action;
+ pcli->pre_page_closure = closure;
+ return 0;
}
/* Set an interpreter instance's post-page action */
@@ -320,10 +317,10 @@ pcl_impl_set_post_page_action(
void *closure /* closure to call action with */
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- pcli->post_page_action = action;
- pcli->post_page_closure = closure;
- return 0;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ pcli->post_page_action = action;
+ pcli->post_page_closure = closure;
+ return 0;
}
/* if the device option string PCL is not given, the default
@@ -332,15 +329,15 @@ static pcl_personality_t
pcl_get_personality(pl_interp_instance_t *instance, gx_device *device)
{
if ( !strcmp(instance->pcl_personality, "PCL5C" ) )
- return pcl5c;
+ return pcl5c;
else if ( !strcmp(instance->pcl_personality, "PCL5E" ) )
- return pcl5e;
+ return pcl5e;
else if ( !strcmp(instance->pcl_personality, "RTL" ) )
- return rtl;
+ return rtl;
else if ( device->color_info.depth == 1 )
- return pcl5e;
+ return pcl5e;
else
- return pcl5c;
+ return pcl5c;
}
static bool
@@ -389,86 +386,85 @@ pcl_impl_set_device(
stage = Sgsave1;
if ( (code = gs_gsave(pcli->pcs.pgs)) < 0 )
- goto pisdEnd;
+ goto pisdEnd;
stage = Serase;
if ( (code = gs_erasepage(pcli->pcs.pgs)) < 0 )
- goto pisdEnd;
+ goto pisdEnd;
/* Do device-dependent pcl inits */
stage = Sreset;
if ((code = pcl_do_resets(&pcli->pcs, pcl_reset_initial)) < 0 )
- goto pisdEnd;
+ goto pisdEnd;
/* provide a PCL graphic state we can return to */
stage = Spclgsave;
if ( (code = pcl_gsave(&pcli->pcs)) < 0 )
- goto pisdEnd;
+ goto pisdEnd;
stage = Sdone; /* success */
/* Unwind any errors */
pisdEnd:
switch (stage) {
case Sdone: /* don't undo success */
case Sinitg: /* can't happen removes warning */
- break;
+ break;
case Spclgsave: /* 2nd gsave failed */
- /* fall thru to next */
+ /* fall thru to next */
case Sreset: /* pcl_do_resets failed */
case Serase: /* gs_erasepage failed */
- /* undo 1st gsave */
- gs_grestore_only(pcli->pcs.pgs); /* destroys gs_save stack */
- /* fall thru to next */
+ /* undo 1st gsave */
+ gs_grestore_only(pcli->pcs.pgs); /* destroys gs_save stack */
+ /* fall thru to next */
case Sgsave1: /* 1st gsave failed */
- /* undo setdevice */
- gs_nulldevice(pcli->pcs.pgs);
- /* fall thru to next */
+ /* undo setdevice */
+ gs_nulldevice(pcli->pcs.pgs);
+ /* fall thru to next */
case Ssetdevice: /* gs_setdevice failed */
case Sbegin: /* nothing left to undo */
- break;
+ break;
}
return code;
}
-static int
+static int
pcl_impl_get_device_memory(
pl_interp_instance_t *instance, /* interp instance to use */
gs_memory_t **pmem)
{
return 0;
}
-
/* Prepare interp instance for the next "job" */
static int /* ret 0 ok, else -ve error code */
pcl_impl_init_job(
- pl_interp_instance_t *instance /* interp instance to start job in */
+ pl_interp_instance_t *instance /* interp instance to start job in */
)
{
- int code = 0;
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- pcl_process_init(&pcli->pst);
- return code;
+ int code = 0;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ pcl_process_init(&pcli->pst);
+ return code;
}
/* Parse a cursor-full of data */
static int /* ret 0 or +ve if ok, else -ve error code */
pcl_impl_process(
- pl_interp_instance_t *instance, /* interp instance to process data job in */
- stream_cursor_read *cursor /* data to process */
+ pl_interp_instance_t *instance, /* interp instance to process data job in */
+ stream_cursor_read *cursor /* data to process */
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- int code = pcl_process(&pcli->pst, &pcli->pcs, cursor);
- return code;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ int code = pcl_process(&pcli->pst, &pcli->pcs, cursor);
+ return code;
}
/* Skip to end of job ret 1 if done, 0 ok but EOJ not found, else -ve error code */
-static int
+static int
pcl_impl_flush_to_eoj(
- pl_interp_instance_t *instance, /* interp instance to flush for */
- stream_cursor_read *cursor /* data to process */
+ pl_interp_instance_t *instance, /* interp instance to flush for */
+ stream_cursor_read *cursor /* data to process */
)
{
const byte *p = cursor->ptr;
@@ -476,16 +472,16 @@ pcl_impl_flush_to_eoj(
/* Skip to, but leave UEL in buffer for PJL to find later */
for (; p < rlimit; ++p)
- if (p[1] == '\033') {
- uint avail = rlimit - p;
-
- if (memcmp(p + 1, "\033%-12345X", min(avail, 9)))
- continue;
- if (avail < 9)
- break;
- cursor->ptr = p;
- return 1; /* found eoj */
- }
+ if (p[1] == '\033') {
+ uint avail = rlimit - p;
+
+ if (memcmp(p + 1, "\033%-12345X", min(avail, 9)))
+ continue;
+ if (avail < 9)
+ break;
+ cursor->ptr = p;
+ return 1; /* found eoj */
+ }
cursor->ptr = p;
return 0; /* need more data */
}
@@ -493,45 +489,45 @@ pcl_impl_flush_to_eoj(
/* Parser action for end-of-file */
static int /* ret 0 or +ve if ok, else -ve error code */
pcl_impl_process_eof(
- pl_interp_instance_t *instance /* interp instance to process data job in */
+ pl_interp_instance_t *instance /* interp instance to process data job in */
)
{
int code;
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- pcl_process_init(&pcli->pst);
- code = pcl_end_page_if_marked(&pcli->pcs);
- if ( code < 0 )
- return code;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ pcl_process_init(&pcli->pst);
+ code = pcl_end_page_if_marked(&pcli->pcs);
+ if ( code < 0 )
+ return code;
/* force restore & cleanup if unexpected data end was encountered */
- return 0;
+ return 0;
}
/* Report any errors after running a job */
static int /* ret 0 ok, else -ve error code */
pcl_impl_report_errors(
- pl_interp_instance_t *instance, /* interp instance to wrap up job in */
+ pl_interp_instance_t *instance, /* interp instance to wrap up job in */
int code, /* prev termination status */
long file_position, /* file position of error, -1 if unknown */
bool force_to_cout /* force errors to cout */
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- byte buf[200];
- uint count;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ byte buf[200];
+ uint count;
- while ( (count = pcl_status_read(buf, sizeof(buf), &pcli->pcs)) != 0 )
- errwrite(pcli->memory, (const char *)buf, count);
+ while ( (count = pcl_status_read(buf, sizeof(buf), &pcli->pcs)) != 0 )
+ errwrite(pcli->memory, (const char *)buf, count);
- return 0;
+ return 0;
}
/* Wrap up interp instance after a "job" */
static int /* ret 0 ok, else -ve error code */
pcl_impl_dnit_job(
- pl_interp_instance_t *instance /* interp instance to wrap up job in */
+ pl_interp_instance_t *instance /* interp instance to wrap up job in */
)
{
- return 0;
+ return 0;
}
/* Remove a device from an interperter instance */
@@ -541,23 +537,23 @@ pcl_impl_remove_device(
)
{
int code;
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
/* NB use the PXL code */
- /* return to the original graphic state w/color mapper, bbox, target */
- code = pcl_grestore(&pcli->pcs);
- if (code < 0 )
- dprintf1("error code %d restoring gstate, continuing\n", code );
- /* return to original gstate w/bbox, target */
- code = gs_grestore_only(pcli->pcs.pgs); /* destroys gs_save stack */
- if (code < 0 )
- dprintf1("error code %d destroying gstate, continuing\n", code );
-
- /* Deselect bbox. Bbox has been prevented from auto-closing/deleting */
- code = gs_nulldevice(pcli->pcs.pgs);
- if ( code < 0 )
- dprintf1("error code %d installing nulldevice, continuing\n", code );
- return pcl_do_resets(&pcli->pcs, pcl_reset_permanent);
+ /* return to the original graphic state w/color mapper, bbox, target */
+ code = pcl_grestore(&pcli->pcs);
+ if (code < 0 )
+ dprintf1("error code %d restoring gstate, continuing\n", code );
+ /* return to original gstate w/bbox, target */
+ code = gs_grestore_only(pcli->pcs.pgs); /* destroys gs_save stack */
+ if (code < 0 )
+ dprintf1("error code %d destroying gstate, continuing\n", code );
+
+ /* Deselect bbox. Bbox has been prevented from auto-closing/deleting */
+ code = gs_nulldevice(pcli->pcs.pgs);
+ if ( code < 0 )
+ dprintf1("error code %d installing nulldevice, continuing\n", code );
+ return pcl_do_resets(&pcli->pcs, pcl_reset_permanent);
}
/* Deallocate a interpreter instance */
@@ -566,27 +562,27 @@ pcl_impl_deallocate_interp_instance(
pl_interp_instance_t *instance /* instance to dealloc */
)
{
- pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
- gs_memory_t *mem = pcli->memory;
+ pcl_interp_instance_t *pcli = (pcl_interp_instance_t *)instance;
+ gs_memory_t *mem = pcli->memory;
/* free memory used by the parsers */
if ( pcl_parser_shutdown(&pcli->pst, mem ) < 0 ) {
dprintf("Undefined error shutting down parser, continuing\n" );
}
/* this should have a shutdown procedure like pcl above */
- gs_free_object(mem,
+ gs_free_object(mem,
pcli->pst.hpgl_parser_state,
"pcl_deallocate_interp_instance(pcl_interp_instance_t)");
/* free default, pdflt_* objects */
- pcl_free_default_objects( mem, &pcli->pcs);
-
- /* free halftone cache in gs state */
- gs_state_free(pcli->pcs.pgs);
- /* remove pcl's gsave grestore stack */
- pcl_free_gstate_stk(&pcli->pcs);
- gs_free_object(mem, pcli,
- "pcl_deallocate_interp_instance(pcl_interp_instance_t)");
- return 0;
+ pcl_free_default_objects( mem, &pcli->pcs);
+
+ /* free halftone cache in gs state */
+ gs_state_free(pcli->pcs.pgs);
+ /* remove pcl's gsave grestore stack */
+ pcl_free_gstate_stk(&pcli->pcs);
+ gs_free_object(mem, pcli,
+ "pcl_deallocate_interp_instance(pcl_interp_instance_t)");
+ return 0;
}
/* Do static deinit of PCL interpreter */
@@ -595,11 +591,11 @@ pcl_impl_deallocate_interp(
pl_interp_t *interp /* interpreter to deallocate */
)
{
- /* Deinit interp */
- return 0;
+ /* Deinit interp */
+ return 0;
}
-/*
+/*
* End-of-page called back by PCL - NB now exported.
*/
int
@@ -631,7 +627,7 @@ pcl_end_page_top(
if (pcli->post_page_action) {
code = pcli->post_page_action(instance, pcli->post_page_closure);
if (code < 0)
- return code;
+ return code;
}
return 0;
}
diff --git a/pcl/pctop.h b/pcl/pctop.h
index d77610854..8ae574fac 100644
--- a/pcl/pctop.h
+++ b/pcl/pctop.h
@@ -19,5 +19,4 @@
pcl_state_t * pcl_get_gstate(pl_interp_instance_t *instance);
-
#endif /* pctop_INCLUDED */
diff --git a/pcl/pctpm.h b/pcl/pctpm.h
index cdab7c349..15f121c00 100644
--- a/pcl/pctpm.h
+++ b/pcl/pctpm.h
@@ -23,7 +23,7 @@ typedef enum {
tpm_0_SBCS = 0,
tpm_21_DBCS7 = 21, /* e.g. GB_2312-80 (China), JIS_X0208-1983 (Japan), KSC_5601 (Korea) */
tpm_31_sjis = 31,
- tpm_38_DBCS8 = 38,
+ tpm_38_DBCS8 = 38,
tpm_83_utf8 = 83, /* http://docs.hp.com/en/5991-7956/5991-7956.pdf */
/* HP-UX 11i v3 International Printing Features */
tpm_1008_utf8 = 1008 /* http://www.lexmark.com/publications/pdfs/TRef_3Q01.pdf */
@@ -33,7 +33,7 @@ int pcl_char_bytelen(byte ch, pcl_text_parsing_method_t tpm);
gs_char pcl_char_get_char(pcl_text_parsing_method_t tpm, const byte ** psrc, int len);
/*
- * was 0xfffd
+ * was 0xfffd
*/
#define INVALID_UC 0xffff
diff --git a/pcl/pcuptrn.c b/pcl/pcuptrn.c
index da6ec5cf3..247d8c79b 100644
--- a/pcl/pcuptrn.c
+++ b/pcl/pcuptrn.c
@@ -53,7 +53,7 @@ free_pattern_data(
}
/*
- * Build a pattern data structure. This routine is static as pattern
+ * Build a pattern data structure. This routine is static as pattern
* data structures may only be built as part of a pattern.
*
* All pattern data structure are built as "temporary". Routines that build
@@ -99,7 +99,7 @@ build_pattern_data(
*/
static void
free_pattern_rendering(const gs_memory_t *mem,
- pcl_pattern_t * pptrn
+ pcl_pattern_t * pptrn
)
{
if (pptrn->pcol_ccolor != 0) {
@@ -260,7 +260,7 @@ delete_all_pcl_ptrns(
pl_dict_t * pdict[2];
int i;
- pdict[0] = &pcs->pcl_patterns;
+ pdict[0] = &pcs->pcl_patterns;
pdict[1] = &pcs->gl_patterns;
for (i = 0; i < 2; i++) {
@@ -330,17 +330,17 @@ pcl_pattern_RF(
if (ppixmap != 0) {
pcl_pattern_type_t type = ( ppixmap->pix_depth == 1
? pcl_pattern_uncolored
- : pcl_pattern_colored );
- /* RF appears to use the resolution of the device contrary to
+ : pcl_pattern_colored );
+ /* RF appears to use the resolution of the device contrary to
what the pcl documentation implies */
- gx_device *pdev = gs_currentdevice(pcs->pgs);
+ gx_device *pdev = gs_currentdevice(pcs->pgs);
int code = pcl_pattern_build_pattern( &pptrn,
- ppixmap,
- type,
- pdev->HWResolution[0],
- pdev->HWResolution[1],
- pcs->memory
- );
+ ppixmap,
+ type,
+ pdev->HWResolution[0],
+ pdev->HWResolution[1],
+ pcs->memory
+ );
if (code < 0)
return code;
@@ -362,7 +362,6 @@ pcl_pattern_RF(
return 0;
}
-
/*
* The PCL user-define pattern type. For memory management reasons, this has
* a transitory existence.
@@ -415,7 +414,7 @@ download_pcl_pattern(
int code = 0;
if (count < 8)
- return e_Range;
+ return e_Range;
format = puptrn0->format;
/* non data size - the size of the parameters that describe the data */
@@ -449,7 +448,6 @@ download_pcl_pattern(
if (pixinfo.data == 0)
return e_Memory;
-
if (format == 20) {
pcl_upattern1_t * puptrn1 = (pcl_upattern1_t *)puptrn0;
@@ -465,7 +463,7 @@ download_pcl_pattern(
/* build the pattern */
code = pcl_pattern_build_pattern( &(pptrn),
&pixinfo,
- (format == 1 ? pcl_pattern_colored
+ (format == 1 ? pcl_pattern_colored
: pcl_pattern_uncolored),
xres,
yres,
@@ -540,7 +538,7 @@ pattern_control(
static int
upattern_do_copy(pcl_state_t *psaved, const pcl_state_t *pcs,
pcl_copy_operation_t operation)
-{
+{
int i;
/* copy back any patterns created during macro invocation. */
if ((operation & pcl_copy_after) != 0) {
@@ -560,7 +558,7 @@ upattern_do_copy(pcl_state_t *psaved, const pcl_state_t *pcs,
/*
* Initialization and reset routines.
- */
+ */
static int
upattern_do_registration(
pcl_parser_state_t *pcl_parser_state,
@@ -574,7 +572,7 @@ upattern_do_registration(
},
{
'c', 'Q',
- PCL_COMMAND( "Pattern Control",
+ PCL_COMMAND( "Pattern Control",
pattern_control,
pca_neg_ignore | pca_big_ignore
)
diff --git a/pcl/pcursor.c b/pcl/pcursor.c
index 048a23fe1..99721ad90 100644
--- a/pcl/pcursor.c
+++ b/pcl/pcursor.c
@@ -305,7 +305,6 @@ do_horiz_motion(
return;
}
-
static inline int
do_vertical_move(pcl_state_t *pcs, pcl_args_t *pargs, float mul,
bool use_margins, bool by_row, bool by_row_command, bool truncate_arg)
@@ -418,7 +417,6 @@ pcl_updated_hmi(
return pcs->hmi_cp = hmi - (hmi % pcs->uom_cp);
}
-
/* Commands */
/*
@@ -507,7 +505,6 @@ set_line_termination(
return 0;
}
-
/*
* ESC & a <cols> C
*/
@@ -600,7 +597,6 @@ cmd_HT(
return 0;
}
-
/*
* ESC & a <rows> R
*/
@@ -685,7 +681,6 @@ cmd_FF(
return pcl_do_FF(pcs);
}
-
/*
* ESC & f <pp_enum> S
*
diff --git a/pcl/pcwhtidx.c b/pcl/pcwhtidx.c
index 93ac41836..e7cb63269 100644
--- a/pcl/pcwhtidx.c
+++ b/pcl/pcwhtidx.c
@@ -211,7 +211,7 @@ remap_raster_ary(
if (out_nbits > 8 * sizeof(ulong) - b_per_p) {
while (out_nbits >= 8) {
-
+
*outp++ = (out_accum >> (out_nbits - 8)) & 0xff;
out_nbits -= 8;
out_accum <<= 8;
@@ -267,7 +267,7 @@ pcl_cmap_map_raster(
/* see if any remapping is necessary */
*pout_pixinfo = *pin_pixinfo;
if ( !build_remap_array( pindexed->palette.data,
- pindexed->num_entries,
+ pindexed->num_entries,
remap,
pfirst_white,
pix_depth,
@@ -383,5 +383,5 @@ pcl_cmap_int_apply_ary(
remap_raster_ary8(prast, prast, npixels, b_per_p, (const byte *)vpmap);
else
remap_raster_ary(prast, prast, npixels, b_per_p, (const byte *)vpmap);
-
+
}
diff --git a/pcl/pcxfmst.h b/pcl/pcxfmst.h
index 624a71aa7..2e01771af 100644
--- a/pcl/pcxfmst.h
+++ b/pcl/pcxfmst.h
@@ -21,21 +21,21 @@
#include "gxfixed.h"
#include "pccoord.h"
-/*
+/*
* Structure for paper size parameters. Note that these values are all coords
* (centipoints).
*/
typedef struct pcl_paper_size_s {
coord width, height; /* physical page size */
coord offset_portrait; /* offset of logical page left edge from
- * the physical page in portrait orientations */
+ * the physical page in portrait orientations */
coord offset_landscape; /* ditto for landscape orientations */
} pcl_paper_size_t;
/*
* Geometric transformation structure for PCL.
*
- * Except for GL/2, PCL deals strictly in diagonal transformations: all
+ * Except for GL/2, PCL deals strictly in diagonal transformations: all
* transformations are compositions of 90 degree rotations, scaling, and
* translations. Thus, maintaining a full matrix representation is overkill.
* For the most part, however, any gains in performance from use of a simpler
diff --git a/pcl/pgchar.c b/pcl/pgchar.c
index 68dce6461..c229d1ec4 100644
--- a/pcl/pgchar.c
+++ b/pcl/pgchar.c
@@ -31,51 +31,51 @@
static int
hpgl_font_definition(hpgl_args_t *pargs, hpgl_state_t *pgls, int index)
{ /*
- * Since these commands take an arbitrary number of arguments,
- * we reset the argument bookkeeping after each group.
- * We reset phase to 1, 2, or 3 after seeing the first pair,
- * so we can tell whether there were any arguments at all.
- * (1 means no parameter changed, >1 means some parameter changed.)
- */
- pcl_font_selection_t *pfs = &pgls->g.font_selection[index];
+ * Since these commands take an arbitrary number of arguments,
+ * we reset the argument bookkeeping after each group.
+ * We reset phase to 1, 2, or 3 after seeing the first pair,
+ * so we can tell whether there were any arguments at all.
+ * (1 means no parameter changed, >1 means some parameter changed.)
+ */
+ pcl_font_selection_t *pfs = &pgls->g.font_selection[index];
#define pfp (&pfs->params)
- int kind;
- pfs->selected_id = (uint)-1;
- for ( ; hpgl_arg_c_int(pgls->memory, pargs, &kind); pargs->phase |= 1 )
- switch ( kind )
- {
- case 1: /* symbol set */
- { int32 sset;
- if ( !hpgl_arg_int(pgls->memory, pargs, &sset) )
- return e_Range;
- if ( pfp->symbol_set != (uint)sset )
- pfp->symbol_set = (uint)sset,
- pargs->phase |= 2;
- }
- break;
- case 2: /* spacing */
- { int spacing;
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &spacing) )
- return e_Range;
- if ( ((spacing == 1) || (spacing == 0)) && (pfp->proportional_spacing != spacing) )
- pfp->proportional_spacing = spacing,
- pargs->phase |= 2;
- }
- break;
- case 3: /* pitch */
- { hpgl_real_t pitch;
- if ( !hpgl_arg_c_real(pgls->memory, pargs, &pitch) )
- return e_Range;
- if ( (pl_fp_pitch_per_inch(pfp) != pitch) &&
+ int kind;
+ pfs->selected_id = (uint)-1;
+ for ( ; hpgl_arg_c_int(pgls->memory, pargs, &kind); pargs->phase |= 1 )
+ switch ( kind )
+ {
+ case 1: /* symbol set */
+ { int32 sset;
+ if ( !hpgl_arg_int(pgls->memory, pargs, &sset) )
+ return e_Range;
+ if ( pfp->symbol_set != (uint)sset )
+ pfp->symbol_set = (uint)sset,
+ pargs->phase |= 2;
+ }
+ break;
+ case 2: /* spacing */
+ { int spacing;
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &spacing) )
+ return e_Range;
+ if ( ((spacing == 1) || (spacing == 0)) && (pfp->proportional_spacing != spacing) )
+ pfp->proportional_spacing = spacing,
+ pargs->phase |= 2;
+ }
+ break;
+ case 3: /* pitch */
+ { hpgl_real_t pitch;
+ if ( !hpgl_arg_c_real(pgls->memory, pargs, &pitch) )
+ return e_Range;
+ if ( (pl_fp_pitch_per_inch(pfp) != pitch) &&
(pitch >= 0) && (pitch < 32768.0) ) {
pl_fp_set_pitch_per_inch(pfp, pitch > 7200.0 ? 7200.0 : pitch);
pargs->phase |= 2;
}
-
- }
- break;
- case 4: /* height */
- {
+
+ }
+ break;
+ case 4: /* height */
+ {
hpgl_real_t height;
if ( !hpgl_arg_c_real(pgls->memory, pargs, &height) )
return e_Range;
@@ -87,73 +87,73 @@ hpgl_font_definition(hpgl_args_t *pargs, hpgl_state_t *pgls, int index)
it probably should be rounded as in pcl but
doing so would change a lot of files for no
compelling reason so for now truncate. */
- uint trunc_height_4ths = (uint)(height * 4);
+ uint trunc_height_4ths = (uint)(height * 4);
pfp->height_4ths = (trunc_height_4ths == 0 ? 1 : trunc_height_4ths);
pargs->phase |= 2;
}
- }
- break;
- case 5: /* posture */
- { int posture;
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &posture) )
- return e_Range;
- if ( pfp->style != posture )
- pfp->style = posture,
- pargs->phase |= 2;
-
- }
- break;
- case 6: /* stroke weight */
- { int weight;
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &weight) )
- return e_Range;
- if ( pfp->stroke_weight != weight )
- if ( ((weight >= -7 ) && (weight <= 7)) || (weight == 9999 ) )
- pfp->stroke_weight = weight,
- pargs->phase |= 2;
- }
- break;
- case 7: /* typeface */
- { int32 face;
- if ( !hpgl_arg_int(pgls->memory, pargs, &face) )
- return e_Range;
- if ( pfp->typeface_family != (uint)face )
- pfp->typeface_family = (uint)face,
- pargs->phase |= 2;
- }
- break;
- default:
- return e_Range;
- }
- /* If there were no arguments at all, default all values. */
- if ( !pargs->phase )
- hpgl_default_font_params(pfs);
- if ( pargs->phase != 1 )
- { /* A value changed, or we are defaulting. Decache the font. */
- pfs->font = 0;
- if ( index == pgls->g.font_selected )
- pgls->g.font = 0;
- }
- return 0;
+ }
+ break;
+ case 5: /* posture */
+ { int posture;
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &posture) )
+ return e_Range;
+ if ( pfp->style != posture )
+ pfp->style = posture,
+ pargs->phase |= 2;
+
+ }
+ break;
+ case 6: /* stroke weight */
+ { int weight;
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &weight) )
+ return e_Range;
+ if ( pfp->stroke_weight != weight )
+ if ( ((weight >= -7 ) && (weight <= 7)) || (weight == 9999 ) )
+ pfp->stroke_weight = weight,
+ pargs->phase |= 2;
+ }
+ break;
+ case 7: /* typeface */
+ { int32 face;
+ if ( !hpgl_arg_int(pgls->memory, pargs, &face) )
+ return e_Range;
+ if ( pfp->typeface_family != (uint)face )
+ pfp->typeface_family = (uint)face,
+ pargs->phase |= 2;
+ }
+ break;
+ default:
+ return e_Range;
+ }
+ /* If there were no arguments at all, default all values. */
+ if ( !pargs->phase )
+ hpgl_default_font_params(pfs);
+ if ( pargs->phase != 1 )
+ { /* A value changed, or we are defaulting. Decache the font. */
+ pfs->font = 0;
+ if ( index == pgls->g.font_selected )
+ pgls->g.font = 0;
+ }
+ return 0;
}
/* Define label drawing direction (DI, DR). */
static int
hpgl_label_direction(hpgl_args_t *pargs, hpgl_state_t *pgls, bool relative)
{ hpgl_real_t run = 1, rise = 0;
- if ( hpgl_arg_c_real(pgls->memory, pargs, &run) )
- { if ( !hpgl_arg_c_real(pgls->memory, pargs, &rise) || (run == 0 && rise == 0) )
- return e_Range;
- { double hyp = hypot(run, rise);
- run /= hyp;
- rise /= hyp;
- }
- }
- pgls->g.character.direction.x = run;
- pgls->g.character.direction.y = rise;
- pgls->g.character.direction_relative = relative;
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- return 0;
+ if ( hpgl_arg_c_real(pgls->memory, pargs, &run) )
+ { if ( !hpgl_arg_c_real(pgls->memory, pargs, &rise) || (run == 0 && rise == 0) )
+ return e_Range;
+ { double hyp = hypot(run, rise);
+ run /= hyp;
+ rise /= hyp;
+ }
+ }
+ pgls->g.character.direction.x = run;
+ pgls->g.character.direction.y = rise;
+ pgls->g.character.direction_relative = relative;
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ return 0;
}
/* forward declaration */
@@ -163,27 +163,27 @@ static int hpgl_select_font(hpgl_state_t *pgls, int index);
static int
hpgl_select_font_by_id(hpgl_args_t *pargs, hpgl_state_t *pgls, int index)
{ pcl_font_selection_t *pfs = &pgls->g.font_selection[index];
- int32 id;
- int code;
-
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &id) || id < 0 )
- return e_Range;
- code = pcl_select_font_by_id(pfs, id, pgls /****** NOTA BENE ******/);
- switch ( code )
- {
- default: /* error */
- return code;
- case 1: /* ID not found, no effect */
- return 0;
- case 0: /* ID found */
- break;
- }
+ int32 id;
+ int code;
+
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &id) || id < 0 )
+ return e_Range;
+ code = pcl_select_font_by_id(pfs, id, pgls /****** NOTA BENE ******/);
+ switch ( code )
+ {
+ default: /* error */
+ return code;
+ case 1: /* ID not found, no effect */
+ return 0;
+ case 0: /* ID found */
+ break;
+ }
pgls->g.font_selection[index].font = pfs->font;
pgls->g.font_selection[index].map = pfs->map;
- /*
- * If we just selected a bitmap font, force the equivalent of SB1.
- * See TRM 23-65 and 23-81.
- */
+ /*
+ * If we just selected a bitmap font, force the equivalent of SB1.
+ * See TRM 23-65 and 23-81.
+ */
if ( pfs->font->scaling_technology == plfst_bitmap ) {
hpgl_args_t args;
hpgl_args_setup(&args);
@@ -213,8 +213,8 @@ hpgl_select_font(hpgl_state_t *pgls, int index)
/* AD [kind,value...]; */
int
hpgl_AD(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_font_definition(pargs, pgls, 1);
+{
+ return hpgl_font_definition(pargs, pgls, 1);
}
#define CHAR_EDGE_PEN_UNSET -1
@@ -228,12 +228,12 @@ hpgl_get_character_edge_pen(
/* if the character edge pen has not been set then we return the
current pen number, otherwise the state value as set in the CF
command is used. (see hpgl_CF) */
- return (pgls->g.character.edge_pen == CHAR_EDGE_PEN_UNSET ?
- hpgl_get_selected_pen(pgls) :
- pgls->g.character.edge_pen);
+ return (pgls->g.character.edge_pen == CHAR_EDGE_PEN_UNSET ?
+ hpgl_get_selected_pen(pgls) :
+ pgls->g.character.edge_pen);
}
-
+
/*
* CF [mode[,pen]];
*/
@@ -249,16 +249,16 @@ hpgl_CF(
if (hpgl_arg_c_int(pgls->memory, pargs, &mode)) {
if ((mode & ~3) != 0)
- return e_Range;
- /* With only 1 argument, we "unset" the current pen. This
+ return e_Range;
+ /* With only 1 argument, we "unset" the current pen. This
causes the drawing machinery to use the current pen when
the stroke is rendered (i.e. a subsequent SP will change
the character edge pen */
- if (hpgl_arg_int(pgls->memory, pargs, &pen)) {
+ if (hpgl_arg_int(pgls->memory, pargs, &pen)) {
if ((pen < 0) || (pen >= npen))
- return e_Range;
- } else
- pen = CHAR_EDGE_PEN_UNSET;
+ return e_Range;
+ } else
+ pen = CHAR_EDGE_PEN_UNSET;
}
pgls->g.character.fill_mode = mode;
pgls->g.character.edge_pen = pen;
@@ -270,52 +270,52 @@ hpgl_CF(
/* DI [run,rise]; */
int
hpgl_DI(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_label_direction(pargs, pgls, false);
+{
+ return hpgl_label_direction(pargs, pgls, false);
}
/* DR [run,rise]; */
int
hpgl_DR(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_label_direction(pargs, pgls, true);
+{
+ return hpgl_label_direction(pargs, pgls, true);
}
/* DT terminator[,mode]; */
int
hpgl_DT(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ const byte *p = pargs->source.ptr;
- const byte *rlimit = pargs->source.limit;
- byte ch = (byte)pargs->phase;
- int mode = 1;
-
- /* We use phase to remember the terminator character */
- /* in case we had to restart execution. */
- if ( p >= rlimit )
- return e_NeedData;
- if ( !ch )
- switch ( (ch = *++p) )
- {
- case ';':
- pargs->source.ptr = p;
- pgls->g.label.terminator = 3;
- pgls->g.label.print_terminator = false;
- return 0;
- case 0: case 5: case 27:
- return e_Range;
- default:
- if ( p >= rlimit )
- return e_NeedData;
- if ( *++p ==',' )
- { pargs->source.ptr = p;
- pargs->phase = ch;
- }
- }
- if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
- return e_Range;
- pgls->g.label.terminator = ch;
- pgls->g.label.print_terminator = !mode;
- return 0;
+ const byte *rlimit = pargs->source.limit;
+ byte ch = (byte)pargs->phase;
+ int mode = 1;
+
+ /* We use phase to remember the terminator character */
+ /* in case we had to restart execution. */
+ if ( p >= rlimit )
+ return e_NeedData;
+ if ( !ch )
+ switch ( (ch = *++p) )
+ {
+ case ';':
+ pargs->source.ptr = p;
+ pgls->g.label.terminator = 3;
+ pgls->g.label.print_terminator = false;
+ return 0;
+ case 0: case 5: case 27:
+ return e_Range;
+ default:
+ if ( p >= rlimit )
+ return e_NeedData;
+ if ( *++p ==',' )
+ { pargs->source.ptr = p;
+ pargs->phase = ch;
+ }
+ }
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
+ return e_Range;
+ pgls->g.label.terminator = ch;
+ pgls->g.label.print_terminator = !mode;
+ return 0;
}
/* DV [path[,line]]; */
@@ -323,14 +323,14 @@ hpgl_DT(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_DV(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int path = 0, line = 0;
- hpgl_arg_c_int(pgls->memory, pargs, &path);
- hpgl_arg_c_int(pgls->memory, pargs, &line);
- if ( (path & ~3) | (line & ~1) )
- return e_Range;
- pgls->g.character.text_path = path;
- pgls->g.character.line_feed_direction = (line ? -1 : 1);
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- return 0;
+ hpgl_arg_c_int(pgls->memory, pargs, &path);
+ hpgl_arg_c_int(pgls->memory, pargs, &line);
+ if ( (path & ~3) | (line & ~1) )
+ return e_Range;
+ pgls->g.character.text_path = path;
+ pgls->g.character.line_feed_direction = (line ? -1 : 1);
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ return 0;
}
/* ES [width[,height]]; */
@@ -338,25 +338,25 @@ hpgl_DV(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_ES(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t width = 0, height = 0;
- hpgl_arg_c_real(pgls->memory, pargs, &width);
- hpgl_arg_c_real(pgls->memory, pargs, &height);
- pgls->g.character.extra_space.x = width;
- pgls->g.character.extra_space.y = height;
- return 0;
+ hpgl_arg_c_real(pgls->memory, pargs, &width);
+ hpgl_arg_c_real(pgls->memory, pargs, &height);
+ pgls->g.character.extra_space.x = width;
+ pgls->g.character.extra_space.y = height;
+ return 0;
}
/* FI fontid; */
int
hpgl_FI(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_select_font_by_id(pargs, pgls, 0);
+{
+ return hpgl_select_font_by_id(pargs, pgls, 0);
}
/* FN fontid; */
int
hpgl_FN(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_select_font_by_id(pargs, pgls, 1);
+{
+ return hpgl_select_font_by_id(pargs, pgls, 1);
}
/* The following is an extension documented in the Comparison Guide. */
@@ -364,25 +364,25 @@ hpgl_FN(hpgl_args_t *pargs, hpgl_state_t *pgls)
int
hpgl_LM(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int mode = 0, row_number = 0;
- int old_mode =
- (pgls->g.label.double_byte ? 1 : 0) +
- (pgls->g.label.write_vertical ? 2 : 0);
-
- hpgl_arg_c_int(pgls->memory, pargs, &mode);
- hpgl_arg_c_int(pgls->memory, pargs, &row_number);
- pgls->g.label.row_offset =
- (row_number < 0 ? 0 : row_number > 255 ? 255 : row_number) << 8;
- mode &= 3;
- pgls->g.label.double_byte = (mode & 1) != 0;
- pgls->g.label.write_vertical = (mode & 2) != 0;
- /*
- * The documentation says "When LM switches modes, it turns off
- * symbol mode." We take this literally: LM only turns off
- * symbol mode if the new label mode differs from the old one.
- */
- if ( mode != old_mode )
- pgls->g.symbol_mode = 0;
- return 0;
+ int old_mode =
+ (pgls->g.label.double_byte ? 1 : 0) +
+ (pgls->g.label.write_vertical ? 2 : 0);
+
+ hpgl_arg_c_int(pgls->memory, pargs, &mode);
+ hpgl_arg_c_int(pgls->memory, pargs, &row_number);
+ pgls->g.label.row_offset =
+ (row_number < 0 ? 0 : row_number > 255 ? 255 : row_number) << 8;
+ mode &= 3;
+ pgls->g.label.double_byte = (mode & 1) != 0;
+ pgls->g.label.write_vertical = (mode & 2) != 0;
+ /*
+ * The documentation says "When LM switches modes, it turns off
+ * symbol mode." We take this literally: LM only turns off
+ * symbol mode if the new label mode differs from the old one.
+ */
+ if ( mode != old_mode )
+ pgls->g.symbol_mode = 0;
+ return 0;
}
/* LO [origin]; */
@@ -390,19 +390,19 @@ hpgl_LM(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_LO(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int origin = 1;
- hpgl_arg_c_int(pgls->memory, pargs, &origin);
- if ( origin < 1 || origin == 10 || origin == 20 || origin > 21 )
- return e_Range;
- pgls->g.label.origin = origin;
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- return 0;
+ hpgl_arg_c_int(pgls->memory, pargs, &origin);
+ if ( origin < 1 || origin == 10 || origin == 20 || origin > 21 )
+ return e_Range;
+ pgls->g.label.origin = origin;
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ return 0;
}
/* SA; */
int
hpgl_SA(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_select_font(pgls, 1);
+{
+ return hpgl_select_font(pgls, 1);
}
/* SB [mode]; */
@@ -410,37 +410,37 @@ hpgl_SA(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_SB(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int mode = 0;
- if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
- return e_Range;
- { int i;
-
- pgls->g.bitmap_fonts_allowed = mode;
- /*
- * A different set of fonts is now available for consideration.
- * Decache any affected font(s): those selected by parameter,
- * and bitmap fonts selected by ID if bitmap fonts are now
- * disallowed.
- */
- for ( i = 0; i < countof(pgls->g.font_selection); ++i ) {
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
+ return e_Range;
+ { int i;
+
+ pgls->g.bitmap_fonts_allowed = mode;
+ /*
+ * A different set of fonts is now available for consideration.
+ * Decache any affected font(s): those selected by parameter,
+ * and bitmap fonts selected by ID if bitmap fonts are now
+ * disallowed.
+ */
+ for ( i = 0; i < countof(pgls->g.font_selection); ++i ) {
pcl_font_selection_t *pfs = &pgls->g.font_selection[i];
- if ( ((int)pfs->selected_id < 0) ||
- (!mode && pfs->font != 0 &&
- pfs->font->scaling_technology == plfst_bitmap)
- )
- { pfs->font = 0;
- }
- }
+ if ( ((int)pfs->selected_id < 0) ||
+ (!mode && pfs->font != 0 &&
+ pfs->font->scaling_technology == plfst_bitmap)
+ )
+ { pfs->font = 0;
+ }
+ }
pgls->g.font = 0;
pgls->g.map = 0;
- }
- return 0;
+ }
+ return 0;
}
/* SD [kind,value...]; */
int
hpgl_SD(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_font_definition(pargs, pgls, 0);
+{
+ return hpgl_font_definition(pargs, pgls, 0);
}
/* SI [width,height]; */
@@ -448,39 +448,39 @@ hpgl_SD(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_SI(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t width_cm, height_cm;
- if ( hpgl_arg_c_real(pgls->memory, pargs, &width_cm) )
- { if ( !hpgl_arg_c_real(pgls->memory, pargs, &height_cm) )
- return e_Range;
+ if ( hpgl_arg_c_real(pgls->memory, pargs, &width_cm) )
+ { if ( !hpgl_arg_c_real(pgls->memory, pargs, &height_cm) )
+ return e_Range;
/* this isn't documented but HP seems to ignore the
command (retains previous value) if either parameter is
zero. NB probably should use epsilon have not tested. */
if (width_cm == 0.0 || height_cm == 0.0)
return e_Range;
- pgls->g.character.size.x = mm_2_plu(width_cm * 10);
- pgls->g.character.size.y = mm_2_plu(height_cm * 10);
- pgls->g.character.size_mode = hpgl_size_absolute;
- }
- else
- pgls->g.character.size_mode = hpgl_size_not_set;
- return 0;
+ pgls->g.character.size.x = mm_2_plu(width_cm * 10);
+ pgls->g.character.size.y = mm_2_plu(height_cm * 10);
+ pgls->g.character.size_mode = hpgl_size_absolute;
+ }
+ else
+ pgls->g.character.size_mode = hpgl_size_not_set;
+ return 0;
}
-#define MAX_SL_TANGENT 114.5887
+#define MAX_SL_TANGENT 114.5887
/* SL [slant]; */
int
hpgl_SL(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t slant = 0;
- hpgl_arg_c_real(pgls->memory, pargs, &slant);
- /* clamp to 89.5 degrees of char slant, avoids math issues around
- * tan 90degrees == infinity. Visually close to HP,
- * performance decrease as slant approaches tan(90).
- */
-
- pgls->g.character.slant = slant > MAX_SL_TANGENT ?
- MAX_SL_TANGENT : slant < -MAX_SL_TANGENT ?
- -MAX_SL_TANGENT : slant;
- return 0;
+ hpgl_arg_c_real(pgls->memory, pargs, &slant);
+ /* clamp to 89.5 degrees of char slant, avoids math issues around
+ * tan 90degrees == infinity. Visually close to HP,
+ * performance decrease as slant approaches tan(90).
+ */
+
+ pgls->g.character.slant = slant > MAX_SL_TANGENT ?
+ MAX_SL_TANGENT : slant < -MAX_SL_TANGENT ?
+ -MAX_SL_TANGENT : slant;
+ return 0;
}
#undef MAX_SL_TANGENT
@@ -489,7 +489,7 @@ hpgl_SL(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_SR(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t width_pct, height_pct;
- if ( hpgl_arg_c_real(pgls->memory, pargs, &width_pct) ) {
+ if ( hpgl_arg_c_real(pgls->memory, pargs, &width_pct) ) {
if ( !hpgl_arg_c_real(pgls->memory, pargs, &height_pct) )
return e_Range;
/* this isn't documented but HP seems to ignore the
@@ -497,22 +497,22 @@ hpgl_SR(hpgl_args_t *pargs, hpgl_state_t *pgls)
zero. NB probably should use epsilon have not tested. */
if (width_pct == 0.0 || height_pct == 0.0)
return e_Range;
- pgls->g.character.size.x = width_pct / 100;
- pgls->g.character.size.y = height_pct / 100;
- }
- else
- { pgls->g.character.size.x = 0.0075;
- pgls->g.character.size.y = 0.015;
- }
- pgls->g.character.size_mode = hpgl_size_relative;
- return 0;
+ pgls->g.character.size.x = width_pct / 100;
+ pgls->g.character.size.y = height_pct / 100;
+ }
+ else
+ { pgls->g.character.size.x = 0.0075;
+ pgls->g.character.size.y = 0.015;
+ }
+ pgls->g.character.size_mode = hpgl_size_relative;
+ return 0;
}
/* SS; */
int
hpgl_SS(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return hpgl_select_font(pgls, 0);
+{
+ return hpgl_select_font(pgls, 0);
}
/* TD [mode]; */
@@ -520,10 +520,10 @@ hpgl_SS(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_TD(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int mode = 0;
- if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
- return e_Range;
- pgls->g.transparent_data = mode;
- return 0;
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) && (mode & ~1) )
+ return e_Range;
+ pgls->g.transparent_data = mode;
+ return 0;
}
/* Initialization */
@@ -533,29 +533,29 @@ pgchar_do_registration(
gs_memory_t *mem)
{ /* Register commands */
DEFINE_HPGL_COMMANDS(mem)
- HPGL_COMMAND('A', 'D', hpgl_AD, hpgl_cdf_pcl_rtl_both), /* kind/value pairs */
- HPGL_COMMAND('C', 'F', hpgl_CF, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('D', 'I', hpgl_DI, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('D', 'R', hpgl_DR, hpgl_cdf_pcl_rtl_both),
- /* DT has special argument parsing, so it must handle skipping */
- /* in polygon mode itself. */
- HPGL_COMMAND('D', 'T', hpgl_DT, hpgl_cdf_polygon|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('D', 'V', hpgl_DV, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('E', 'S', hpgl_ES, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('F', 'I', hpgl_FI, hpgl_cdf_pcl),
- HPGL_COMMAND('F', 'N', hpgl_FN, hpgl_cdf_pcl),
- HPGL_COMMAND('L', 'M', hpgl_LM, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('L', 'O', hpgl_LO, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'A', hpgl_SA, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'B', hpgl_SB, hpgl_cdf_pcl),
- HPGL_COMMAND('S', 'D', hpgl_SD, hpgl_cdf_pcl_rtl_both), /* kind/value pairs */
- HPGL_COMMAND('S', 'I', hpgl_SI, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'L', hpgl_SL, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'R', hpgl_SR, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'S', hpgl_SS, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('T', 'D', hpgl_TD, hpgl_cdf_pcl_rtl_both),
- END_HPGL_COMMANDS
- return 0;
+ HPGL_COMMAND('A', 'D', hpgl_AD, hpgl_cdf_pcl_rtl_both), /* kind/value pairs */
+ HPGL_COMMAND('C', 'F', hpgl_CF, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('D', 'I', hpgl_DI, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('D', 'R', hpgl_DR, hpgl_cdf_pcl_rtl_both),
+ /* DT has special argument parsing, so it must handle skipping */
+ /* in polygon mode itself. */
+ HPGL_COMMAND('D', 'T', hpgl_DT, hpgl_cdf_polygon|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('D', 'V', hpgl_DV, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('E', 'S', hpgl_ES, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('F', 'I', hpgl_FI, hpgl_cdf_pcl),
+ HPGL_COMMAND('F', 'N', hpgl_FN, hpgl_cdf_pcl),
+ HPGL_COMMAND('L', 'M', hpgl_LM, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('L', 'O', hpgl_LO, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'A', hpgl_SA, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'B', hpgl_SB, hpgl_cdf_pcl),
+ HPGL_COMMAND('S', 'D', hpgl_SD, hpgl_cdf_pcl_rtl_both), /* kind/value pairs */
+ HPGL_COMMAND('S', 'I', hpgl_SI, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'L', hpgl_SL, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'R', hpgl_SR, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'S', hpgl_SS, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('T', 'D', hpgl_TD, hpgl_cdf_pcl_rtl_both),
+ END_HPGL_COMMANDS
+ return 0;
}
const pcl_init_t pgchar_init = {
pgchar_do_registration, 0
diff --git a/pcl/pgcolor.c b/pcl/pgcolor.c
index 1637b34f6..7dbd58744 100644
--- a/pcl/pgcolor.c
+++ b/pcl/pgcolor.c
@@ -37,7 +37,7 @@ hpgl_PC(
int32 npen = pcl_palette_get_num_entries(pgls->ppalet);
if ( pgls->personality == pcl5e )
- return 0;
+ return 0;
/* output any current path */
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
@@ -46,25 +46,25 @@ hpgl_PC(
hpgl_real_t primary[3];
if ((pen < 0) || (pen >= npen))
- return e_Range;
+ return e_Range;
- if (hpgl_arg_c_real(pgls->memory, pargs, &primary[0])) {
+ if (hpgl_arg_c_real(pgls->memory, pargs, &primary[0])) {
float comps[3];
- if ( !hpgl_arg_c_real(pgls->memory, pargs, &primary[1]) ||
- !hpgl_arg_c_real(pgls->memory, pargs, &primary[2]) )
- return e_Range;
+ if ( !hpgl_arg_c_real(pgls->memory, pargs, &primary[1]) ||
+ !hpgl_arg_c_real(pgls->memory, pargs, &primary[2]) )
+ return e_Range;
comps[0] = primary[0];
comps[1] = primary[1];
comps[2] = primary[2];
return pcl_palette_set_color(pgls, pen, comps);
} else
- return pcl_palette_set_default_color(pgls, pen);
+ return pcl_palette_set_default_color(pgls, pen);
} else {
int i;
int code;
- for (i = 0; i < npen; ++i) {
+ for (i = 0; i < npen; ++i) {
if ((code = pcl_palette_set_default_color(pgls, i)) < 0)
return code;
}
@@ -85,13 +85,13 @@ hpgl_NP(
int32 n = 8;
if ( pgls->personality == pcl5e )
- return 0;
+ return 0;
/* output any current path */
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
if ( hpgl_arg_int(pgls->memory, pargs, &n) && ((n < 2) || (n > 32768)) )
- return e_Range;
+ return e_Range;
return pcl_palette_NP(pgls, n);
}
@@ -124,8 +124,6 @@ hpgl_CR(
else /* no args - default references */
return pcl_palette_CR(pgls, 255, 255, 255, 0, 0, 0);
}
-
-
/*
* Initialization. There is no reset or copy command, as those operations are
diff --git a/pcl/pgconfig.c b/pcl/pgconfig.c
index 585df5b2e..6b0103a8d 100644
--- a/pcl/pgconfig.c
+++ b/pcl/pgconfig.c
@@ -34,52 +34,52 @@
int
hpgl_CO(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ const byte *p = pargs->source.ptr;
- const byte *rlimit = pargs->source.limit;
-
- while ( p < rlimit ) {
- if ( !pargs->phase ) {
- switch ( *++p ) {
- case ' ':
- /* Ignore spaces between command and opening ". */
- continue;
- case '"':
- pargs->phase = 1;
- break;
- default:
- /* Search for semicolon */
- pargs->phase = 2;
- break;
-
- }
- } else {
- /* Scanning for closing " or closing ';' */
- switch ( pargs->phase ) {
- case 1:
- if ( *++p == '"' ) {
- pargs->source.ptr = p;
- return 0;
- }
- /* syntax error on some hp devices */
- if ( *p == '\\' ) {
- pargs->source.ptr = p;
- return 0;
- }
- break;
- case 2:
- if ( *++p == ';' ) {
- pargs->source.ptr = p;
- return 0;
- }
- break;
- default:
- dprintf("HPGL CO automata is in an unknown state\n" );
- pargs->source.ptr = p;
- return 0;
- }
- }
- }
- pargs->source.ptr = p;
- return e_NeedData;
+ const byte *rlimit = pargs->source.limit;
+
+ while ( p < rlimit ) {
+ if ( !pargs->phase ) {
+ switch ( *++p ) {
+ case ' ':
+ /* Ignore spaces between command and opening ". */
+ continue;
+ case '"':
+ pargs->phase = 1;
+ break;
+ default:
+ /* Search for semicolon */
+ pargs->phase = 2;
+ break;
+
+ }
+ } else {
+ /* Scanning for closing " or closing ';' */
+ switch ( pargs->phase ) {
+ case 1:
+ if ( *++p == '"' ) {
+ pargs->source.ptr = p;
+ return 0;
+ }
+ /* syntax error on some hp devices */
+ if ( *p == '\\' ) {
+ pargs->source.ptr = p;
+ return 0;
+ }
+ break;
+ case 2:
+ if ( *++p == ';' ) {
+ pargs->source.ptr = p;
+ return 0;
+ }
+ break;
+ default:
+ dprintf("HPGL CO automata is in an unknown state\n" );
+ pargs->source.ptr = p;
+ return 0;
+ }
+ }
+ }
+ pargs->source.ptr = p;
+ return e_NeedData;
}
#ifdef DEBUG
@@ -97,15 +97,15 @@ hpgl_ZZ(hpgl_args_t *pargs, hpgl_state_t *pgls)
const byte *p = pargs->source.ptr;
const byte *rlimit = pargs->source.limit;
while ( p < rlimit ) {
- byte ch = *++p;
- /* ; terminates the command */
- if ( ch == ';' ) {
- pargs->source.ptr = p;
- return 0;
- }
- else {
- gs_debug[(int)ch] = 1;
- }
+ byte ch = *++p;
+ /* ; terminates the command */
+ if ( ch == ';' ) {
+ pargs->source.ptr = p;
+ return 0;
+ }
+ else {
+ gs_debug[(int)ch] = 1;
+ }
}
pargs->source.ptr = p;
return e_NeedData;
@@ -115,33 +115,33 @@ hpgl_ZZ(hpgl_args_t *pargs, hpgl_state_t *pgls)
int
hpgl_reset_overlay(hpgl_state_t *pgls)
{ hpgl_args_t args;
- hpgl_args_setup(&args);
- hpgl_AC(&args, pgls);
- hpgl_args_setup(&args);
- pgls->g.font_selected = 0;
- hpgl_AD(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_SD(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_CF(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_args_add_int(&args, 1);
- hpgl_args_add_int(&args, 0);
- hpgl_DI(&args, pgls);
- /* HAS -- Figure out some way to do this so that it is consistant */
- pgls->g.label.terminator = 3;
- pgls->g.label.print_terminator = false;
- hpgl_args_setup(&args);
- hpgl_DV(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_ES(&args, pgls);
- pgls->g.label.write_vertical = false;
- pgls->g.label.double_byte = false;
- hpgl_args_setup(&args);
- hpgl_LM(&args, pgls);
- hpgl_args_set_int(&args, 1);
- hpgl_LO(&args, pgls);
- /* we do this instead of calling SC directly */
+ hpgl_args_setup(&args);
+ hpgl_AC(&args, pgls);
+ hpgl_args_setup(&args);
+ pgls->g.font_selected = 0;
+ hpgl_AD(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_SD(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_CF(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_args_add_int(&args, 1);
+ hpgl_args_add_int(&args, 0);
+ hpgl_DI(&args, pgls);
+ /* HAS -- Figure out some way to do this so that it is consistant */
+ pgls->g.label.terminator = 3;
+ pgls->g.label.print_terminator = false;
+ hpgl_args_setup(&args);
+ hpgl_DV(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_ES(&args, pgls);
+ pgls->g.label.write_vertical = false;
+ pgls->g.label.double_byte = false;
+ hpgl_args_setup(&args);
+ hpgl_LM(&args, pgls);
+ hpgl_args_set_int(&args, 1);
+ hpgl_LO(&args, pgls);
+ /* we do this instead of calling SC directly */
if ( pgls->g.scaling_type != hpgl_scaling_none ) {
gs_point dpt, pt; /* device point and user point */
hpgl_call(hpgl_get_current_position(pgls, &pt));
@@ -151,33 +151,33 @@ hpgl_reset_overlay(hpgl_state_t *pgls)
hpgl_call(gs_itransform(pgls->pgs, dpt.x, dpt.y, &pt));
hpgl_call(hpgl_set_current_position(pgls, &pt));
}
- pgls->g.fill_type = hpgl_even_odd_rule;
- hpgl_args_set_int(&args,0);
- hpgl_PM(&args, pgls);
- hpgl_args_set_int(&args,2);
- hpgl_PM(&args, pgls);
- pgls->g.bitmap_fonts_allowed = 0;
- hpgl_args_setup(&args);
- hpgl_SI(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_SL(&args, pgls);
- /* We initialize symbol mode directly because hpgl_SM parses
+ pgls->g.fill_type = hpgl_even_odd_rule;
+ hpgl_args_set_int(&args,0);
+ hpgl_PM(&args, pgls);
+ hpgl_args_set_int(&args,2);
+ hpgl_PM(&args, pgls);
+ pgls->g.bitmap_fonts_allowed = 0;
+ hpgl_args_setup(&args);
+ hpgl_SI(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_SL(&args, pgls);
+ /* We initialize symbol mode directly because hpgl_SM parses
its argument differently than most other commands */
- pgls->g.symbol_mode = 0;
- hpgl_args_setup(&args);
- hpgl_SS(&args, pgls);
- hpgl_args_set_int(&args,1);
- hpgl_TR(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_TD(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_MC(&args, pgls);
+ pgls->g.symbol_mode = 0;
+ hpgl_args_setup(&args);
+ hpgl_SS(&args, pgls);
+ hpgl_args_set_int(&args,1);
+ hpgl_TR(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_TD(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_MC(&args, pgls);
#ifdef LJ6_COMPAT
- /* LJ6 seems to reset PP with an IN command the Color Laserjet
+ /* LJ6 seems to reset PP with an IN command the Color Laserjet
does not. NB this needs to be handled with dynamic
configuration */
- hpgl_args_setup(&args);
- hpgl_PP(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_PP(&args, pgls);
#endif
return 0;
}
@@ -185,7 +185,7 @@ hpgl_reset_overlay(hpgl_state_t *pgls)
/* DF; sets programmable features except P1 and P2 */
int
hpgl_DF(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
hpgl_args_t args;
hpgl_call(hpgl_reset_overlay(pgls));
@@ -240,7 +240,7 @@ hpgl_IN_implicit(
hpgl_args_setup(&args);
hpgl_PS(&args, pgls);
}
-
+
/* defaults P1 and P2 */
hpgl_args_setup(&args);
hpgl_IP(&args, pgls);
@@ -249,7 +249,6 @@ hpgl_IN_implicit(
hpgl_args_setup(&args);
hpgl_WU(&args, pgls);
-
/*
* pen up-absolute position and set gl/2 current positon to
* 0,0 or the lower left of the picture frame. Simply sets
@@ -273,7 +272,7 @@ hpgl_IN(
hpgl_args_t * pargs,
hpgl_state_t * pgls
)
-{
+{
int code = 0;
hpgl_args_t args;
@@ -304,36 +303,36 @@ hpgl_IN(
static int
hpgl_picture_frame_coords(hpgl_state_t *pgls, gs_int_rect *gl2_win)
{
- gs_rect dev_win; /* device window */
- hpgl_real_t x1 = pgls->g.picture_frame.anchor_point.x;
- hpgl_real_t y1 = pgls->g.picture_frame.anchor_point.y;
- hpgl_real_t x2 = x1 + pgls->g.picture_frame_width;
- hpgl_real_t y2 = y1 + pgls->g.picture_frame_height;
-
- pcl_set_ctm(pgls, false);
- hpgl_call(gs_transform(pgls->pgs, x1, y1, &dev_win.p));
- hpgl_call(gs_transform(pgls->pgs, x2, y2, &dev_win.q));
- hpgl_call(hpgl_set_plu_ctm(pgls));
- /*
- * gs_bbox_transform_inverse puts the resulting points in the
- * correct order, with p < q.
- */
- { gs_matrix mat;
- gs_rect pcl_win; /* pcl window */
-
- gs_currentmatrix(pgls->pgs, &mat);
- hpgl_call(gs_bbox_transform_inverse(&dev_win, &mat, &pcl_win));
+ gs_rect dev_win; /* device window */
+ hpgl_real_t x1 = pgls->g.picture_frame.anchor_point.x;
+ hpgl_real_t y1 = pgls->g.picture_frame.anchor_point.y;
+ hpgl_real_t x2 = x1 + pgls->g.picture_frame_width;
+ hpgl_real_t y2 = y1 + pgls->g.picture_frame_height;
+
+ pcl_set_ctm(pgls, false);
+ hpgl_call(gs_transform(pgls->pgs, x1, y1, &dev_win.p));
+ hpgl_call(gs_transform(pgls->pgs, x2, y2, &dev_win.q));
+ hpgl_call(hpgl_set_plu_ctm(pgls));
+ /*
+ * gs_bbox_transform_inverse puts the resulting points in the
+ * correct order, with p < q.
+ */
+ { gs_matrix mat;
+ gs_rect pcl_win; /* pcl window */
+
+ gs_currentmatrix(pgls->pgs, &mat);
+ hpgl_call(gs_bbox_transform_inverse(&dev_win, &mat, &pcl_win));
/* Round all coordinates to the nearest integer. */
#define set_round(e) gl2_win->e = (int)floor(pcl_win.e + 0.5)
- set_round(p.x);
- set_round(p.y);
- set_round(q.x);
- set_round(q.y);
+ set_round(p.x);
+ set_round(p.y);
+ set_round(q.x);
+ set_round(q.y);
#undef set_round
- }
- /* restore the ctm */
- hpgl_call(hpgl_set_ctm(pgls));
- return 0;
+ }
+ /* restore the ctm */
+ hpgl_call(hpgl_set_ctm(pgls));
+ return 0;
}
/* IP p1x,p1y[,p2x,p2y]; */
@@ -341,44 +340,44 @@ hpgl_picture_frame_coords(hpgl_state_t *pgls, gs_int_rect *gl2_win)
int
hpgl_IP(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int32 ptxy[4];
- int i;
- gs_int_rect win;
-
- /* draw the current path */
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- /* get the default picture frame coordinates */
- hpgl_call(hpgl_picture_frame_coords(pgls, &win));
-
- /* round the picture frame coordinates */
- ptxy[0] = win.p.x; ptxy[1] = win.p.y;
- ptxy[2] = win.q.x; ptxy[3] = win.q.y;
- for ( i = 0; i < 4 && hpgl_arg_int(pgls->memory, pargs, &ptxy[i]); ++i )
- ;
- if ( i & 1 )
- return e_Range;
-
- if ( i == 2 )
- {
- pgls->g.P2.x = (ptxy[0] - pgls->g.P1.x) +
- pgls->g.P2.x;
- pgls->g.P2.y = (ptxy[1] - pgls->g.P1.y) +
- pgls->g.P2.y;
- pgls->g.P1.x = ptxy[0];
- pgls->g.P1.y = ptxy[1];
- }
- else
- {
- pgls->g.P1.x = ptxy[0];
- pgls->g.P1.y = ptxy[1];
- pgls->g.P2.x = ptxy[2];
- pgls->g.P2.y = ptxy[3];
- }
-
- /* if either coordinate is equal it is incremented by 1 */
- if ( pgls->g.P1.x == pgls->g.P2.x ) pgls->g.P2.x++;
- if ( pgls->g.P1.y == pgls->g.P2.y ) pgls->g.P2.y++;
-
- return 0;
+ int i;
+ gs_int_rect win;
+
+ /* draw the current path */
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ /* get the default picture frame coordinates */
+ hpgl_call(hpgl_picture_frame_coords(pgls, &win));
+
+ /* round the picture frame coordinates */
+ ptxy[0] = win.p.x; ptxy[1] = win.p.y;
+ ptxy[2] = win.q.x; ptxy[3] = win.q.y;
+ for ( i = 0; i < 4 && hpgl_arg_int(pgls->memory, pargs, &ptxy[i]); ++i )
+ ;
+ if ( i & 1 )
+ return e_Range;
+
+ if ( i == 2 )
+ {
+ pgls->g.P2.x = (ptxy[0] - pgls->g.P1.x) +
+ pgls->g.P2.x;
+ pgls->g.P2.y = (ptxy[1] - pgls->g.P1.y) +
+ pgls->g.P2.y;
+ pgls->g.P1.x = ptxy[0];
+ pgls->g.P1.y = ptxy[1];
+ }
+ else
+ {
+ pgls->g.P1.x = ptxy[0];
+ pgls->g.P1.y = ptxy[1];
+ pgls->g.P2.x = ptxy[2];
+ pgls->g.P2.y = ptxy[3];
+ }
+
+ /* if either coordinate is equal it is incremented by 1 */
+ if ( pgls->g.P1.x == pgls->g.P2.x ) pgls->g.P2.x++;
+ if ( pgls->g.P1.y == pgls->g.P2.y ) pgls->g.P2.y++;
+
+ return 0;
}
/* IR r1x,r1y[,r2x,r2y]; */
@@ -386,18 +385,18 @@ hpgl_IP(hpgl_args_t *pargs, hpgl_state_t *pgls)
int
hpgl_IR(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t rptxy[4];
- int i;
- hpgl_args_t args;
- gs_int_rect win;
-
- for ( i = 0; i < 4 && hpgl_arg_c_real(pgls->memory, pargs, &rptxy[i]); ++i )
- ;
- if ( i & 1 )
- return e_Range;
-
- /* get the PCL picture frame coordinates */
- hpgl_call(hpgl_picture_frame_coords(pgls, &win));
- hpgl_args_setup(&args);
+ int i;
+ hpgl_args_t args;
+ gs_int_rect win;
+
+ for ( i = 0; i < 4 && hpgl_arg_c_real(pgls->memory, pargs, &rptxy[i]); ++i )
+ ;
+ if ( i & 1 )
+ return e_Range;
+
+ /* get the PCL picture frame coordinates */
+ hpgl_call(hpgl_picture_frame_coords(pgls, &win));
+ hpgl_args_setup(&args);
if ( i != 0 )
{
hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) *
@@ -405,16 +404,16 @@ hpgl_IR(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_args_add_int(&args, win.p.y + (win.q.y - win.p.y) *
rptxy[1] / 100.0);
}
- if ( i == 4 )
- {
- hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) *
- rptxy[2] / 100.0);
-
- hpgl_args_add_int(&args, win.p.y + (win.q.y - win.p.y) *
- rptxy[3] / 100.0);
- }
- hpgl_IP( &args, pgls );
- return 0;
+ if ( i == 4 )
+ {
+ hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) *
+ rptxy[2] / 100.0);
+
+ hpgl_args_add_int(&args, win.p.y + (win.q.y - win.p.y) *
+ rptxy[3] / 100.0);
+ }
+ hpgl_IP( &args, pgls );
+ return 0;
}
/* IW llx,lly,urx,ury; */
@@ -422,46 +421,46 @@ hpgl_IR(hpgl_args_t *pargs, hpgl_state_t *pgls)
int
hpgl_IW(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t wxy[4];
- int i;
- gs_int_rect win;
-
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- /* get the default picture frame coordinates. */
- hpgl_call(hpgl_picture_frame_coords(pgls, &win));
- wxy[0] = win.p.x;
- wxy[1] = win.p.y;
- wxy[2] = win.q.x;
- wxy[3] = win.q.y;
- for ( i = 0; i < 4 && hpgl_arg_units(pgls->memory, pargs, &wxy[i]); ++i )
- ;
- if ( i & 3 )
- return e_Range;
-
- /* no args case disables the soft clip window */
- if ( i == 0 ) {
- pgls->g.soft_clip_window.active = false;
+ int i;
+ gs_int_rect win;
+
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ /* get the default picture frame coordinates. */
+ hpgl_call(hpgl_picture_frame_coords(pgls, &win));
+ wxy[0] = win.p.x;
+ wxy[1] = win.p.y;
+ wxy[2] = win.q.x;
+ wxy[3] = win.q.y;
+ for ( i = 0; i < 4 && hpgl_arg_units(pgls->memory, pargs, &wxy[i]); ++i )
+ ;
+ if ( i & 3 )
+ return e_Range;
+
+ /* no args case disables the soft clip window */
+ if ( i == 0 ) {
+ pgls->g.soft_clip_window.active = false;
pgls->g.soft_clip_window.isbound = false;
- return 0;
- }
- /* HAS needs error checking */
- pgls->g.soft_clip_window.rect.p.x = wxy[0];
- pgls->g.soft_clip_window.rect.p.y = wxy[1];
- pgls->g.soft_clip_window.rect.q.x = wxy[2];
- pgls->g.soft_clip_window.rect.q.y = wxy[3];
- pgls->g.soft_clip_window.active = true;
- return 0;
+ return 0;
+ }
+ /* HAS needs error checking */
+ pgls->g.soft_clip_window.rect.p.x = wxy[0];
+ pgls->g.soft_clip_window.rect.p.y = wxy[1];
+ pgls->g.soft_clip_window.rect.q.x = wxy[2];
+ pgls->g.soft_clip_window.rect.q.y = wxy[3];
+ pgls->g.soft_clip_window.active = true;
+ return 0;
}
/* PG; */
int
hpgl_PG(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
if ( pgls->personality == rtl ) {
- int dummy;
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- /* with parameter always feed, without parameter feed if marked */
- if ( pcl_page_marked(pgls) || hpgl_arg_c_int(pgls->memory, pargs, &dummy) )
- hpgl_call(pcl_do_FF(pgls));
+ int dummy;
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ /* with parameter always feed, without parameter feed if marked */
+ if ( pcl_page_marked(pgls) || hpgl_arg_c_int(pgls->memory, pargs, &dummy) )
+ hpgl_call(pcl_do_FF(pgls));
}
return 0;
}
@@ -483,12 +482,12 @@ hpgl_PS(hpgl_args_t *pargs, hpgl_state_t *pgls)
int i;
if ( pgls->personality != rtl )
- return 0;
+ return 0;
/* PS return an error if the page is dirty */
if ( pcl_page_marked(pgls) )
return e_Range;
-
+
/* check for pjl override of the arguments - this is custom code
for a customer and is not the normal interaction between PCL &
PJL */
@@ -505,7 +504,7 @@ hpgl_PS(hpgl_args_t *pargs, hpgl_state_t *pgls)
}
paper.height = plu_2_coord(page_dims[0]);
paper.width = plu_2_coord(page_dims[1]);
- paper.offset_portrait = 0;
+ paper.offset_portrait = 0;
paper.offset_landscape = 0;
new_logical_page(pgls, 0, &paper, false, false);
return 0;
@@ -515,42 +514,42 @@ hpgl_PS(hpgl_args_t *pargs, hpgl_state_t *pgls)
/* RO; */
int
hpgl_RO(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- int angle=0;
- gs_point point, dev_pt;
+{
+ int angle=0;
+ gs_point point, dev_pt;
- /* this business is used by both SC and RO -- perhaps it needs
+ /* this business is used by both SC and RO -- perhaps it needs
a new home */
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(hpgl_get_current_position(pgls, &point));
- hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));
-
- if ( hpgl_arg_c_int(pgls->memory, pargs, &angle) )
- switch ( angle )
- {
- case 0: case 90: case 180: case 270:
- break;
- default:
- return e_Range;
- }
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(hpgl_get_current_position(pgls, &point));
+ hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));
+
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &angle) )
+ switch ( angle )
+ {
+ case 0: case 90: case 180: case 270:
+ break;
+ default:
+ return e_Range;
+ }
if ( angle != pgls->g.rotation )
- {
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- pgls->g.rotation = angle;
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
- hpgl_call(hpgl_set_current_position(pgls, &point));
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- }
- return 0;
+ {
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ pgls->g.rotation = angle;
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
+ hpgl_call(hpgl_set_current_position(pgls, &point));
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ }
+ return 0;
}
/* RP; */
int
hpgl_RP(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- return e_Unimplemented;
+{
+ return e_Unimplemented;
}
/* SC xmin,xmax,ymin,ymax[,type=0]; */
@@ -560,21 +559,21 @@ hpgl_RP(hpgl_args_t *pargs, hpgl_state_t *pgls)
int
hpgl_SC(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t xy[4];
- int i;
- int type;
- hpgl_scaling_params_t scale_params;
- gs_point point, dev_pt, dev_anchor;
-
- scale_params = pgls->g.scaling_params;
- hpgl_call(hpgl_get_current_position(pgls, &point));
- hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));
- hpgl_call(gs_transform(pgls->pgs, pgls->g.anchor_corner.x,
- pgls->g.anchor_corner.y, &dev_anchor));
- for ( i = 0; i < 4 && hpgl_arg_real(pgls->memory, pargs, &xy[i]); ++i )
- ;
- switch ( i )
- {
- case 0: /* set defaults */
+ int i;
+ int type;
+ hpgl_scaling_params_t scale_params;
+ gs_point point, dev_pt, dev_anchor;
+
+ scale_params = pgls->g.scaling_params;
+ hpgl_call(hpgl_get_current_position(pgls, &point));
+ hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));
+ hpgl_call(gs_transform(pgls->pgs, pgls->g.anchor_corner.x,
+ pgls->g.anchor_corner.y, &dev_anchor));
+ for ( i = 0; i < 4 && hpgl_arg_real(pgls->memory, pargs, &xy[i]); ++i )
+ ;
+ switch ( i )
+ {
+ case 0: /* set defaults */
{
/* a naked SC implies the soft clip window is bound
to plotter units. */
@@ -588,108 +587,107 @@ hpgl_SC(hpgl_args_t *pargs, hpgl_state_t *pgls)
pgls->g.soft_clip_window.isbound = true;
break;
}
- default:
- return e_Range;
- case 4:
- type = hpgl_scaling_anisotropic;
- hpgl_arg_c_int(pgls->memory, pargs, &type);
- switch ( type )
- {
- case hpgl_scaling_anisotropic: /* 0 */
- if ( xy[0] == xy[1] || xy[2] == xy[3] )
- return e_Range;
+ default:
+ return e_Range;
+ case 4:
+ type = hpgl_scaling_anisotropic;
+ hpgl_arg_c_int(pgls->memory, pargs, &type);
+ switch ( type )
+ {
+ case hpgl_scaling_anisotropic: /* 0 */
+ if ( xy[0] == xy[1] || xy[2] == xy[3] )
+ return e_Range;
pxy: scale_params.pmin.x = xy[0];
- scale_params.pmax.x = xy[1];
- scale_params.pmin.y = xy[2];
- scale_params.pmax.y = xy[3];
- break;
- case hpgl_scaling_isotropic: /* 1 */
- if ( xy[0] == xy[1] || xy[2] == xy[3] )
- return e_Range;
- { hpgl_real_t left = 50, bottom = 50;
- if ( (hpgl_arg_c_real(pgls->memory, pargs, &left) &&
- (left < 0 || left > 100 ||
- !hpgl_arg_c_real(pgls->memory, pargs, &bottom) ||
- bottom < 0 || bottom > 100))
- )
- return e_Range;
- scale_params.left = left;
- scale_params.bottom = bottom;
- }
- goto pxy;
- case hpgl_scaling_point_factor: /* 2 */
- if ( xy[1] == 0 || xy[3] == 0 )
- return e_Range;
- scale_params.pmin.x = xy[0];
- scale_params.factor.x = xy[1];
- scale_params.pmin.y = xy[2];
- scale_params.factor.y = xy[3];
- break;
- default:
- return e_Range;
- }
- }
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- pgls->g.scaling_params = scale_params;
- pgls->g.scaling_type = type;
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
- hpgl_call(hpgl_set_current_position(pgls, &point));
- hpgl_call(gs_itransform(pgls->pgs, dev_anchor.x, dev_anchor.y,
- &pgls->g.anchor_corner));
-
- /* PCLTRM 23-7 (commands the update cr position) does not list
+ scale_params.pmax.x = xy[1];
+ scale_params.pmin.y = xy[2];
+ scale_params.pmax.y = xy[3];
+ break;
+ case hpgl_scaling_isotropic: /* 1 */
+ if ( xy[0] == xy[1] || xy[2] == xy[3] )
+ return e_Range;
+ { hpgl_real_t left = 50, bottom = 50;
+ if ( (hpgl_arg_c_real(pgls->memory, pargs, &left) &&
+ (left < 0 || left > 100 ||
+ !hpgl_arg_c_real(pgls->memory, pargs, &bottom) ||
+ bottom < 0 || bottom > 100))
+ )
+ return e_Range;
+ scale_params.left = left;
+ scale_params.bottom = bottom;
+ }
+ goto pxy;
+ case hpgl_scaling_point_factor: /* 2 */
+ if ( xy[1] == 0 || xy[3] == 0 )
+ return e_Range;
+ scale_params.pmin.x = xy[0];
+ scale_params.factor.x = xy[1];
+ scale_params.pmin.y = xy[2];
+ scale_params.factor.y = xy[3];
+ break;
+ default:
+ return e_Range;
+ }
+ }
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ pgls->g.scaling_params = scale_params;
+ pgls->g.scaling_type = type;
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
+ hpgl_call(hpgl_set_current_position(pgls, &point));
+ hpgl_call(gs_itransform(pgls->pgs, dev_anchor.x, dev_anchor.y,
+ &pgls->g.anchor_corner));
+
+ /* PCLTRM 23-7 (commands the update cr position) does not list
SC but PCL updates the position */
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- return 0;
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ return 0;
}
-/* BP - Begin Plot
+/* BP - Begin Plot
*/
static int
hpgl_BP(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
hpgl_args_t args;
int32 command = 0;
int32 value = 0;
bool more = true;
-
while (more) {
more = hpgl_arg_int(pgls->memory, pargs, &command);
- if (!more)
- break;
- if (command == 1) {
- /* parse string */
- const byte *p = pargs->source.ptr;
- const byte *rlimit = pargs->source.limit;
- while ( p < rlimit ) {
- switch ( *++p ) {
- case ' ':
- /* Ignore spaces between command and opening ". */
- continue;
- case '"':
- if ( !pargs->phase ) {
- /* begin string */
- pargs->phase = 1;
- continue;
- }
- else /* end string */
- break;
- default:
- if ( !pargs->phase )
- break; /* ill formed command exit */
- else
- continue; /* character inside of string */
- }
- break; /* error or trailing " exits */
- }
- pargs->source.ptr = p;
- }
- else {
- more = hpgl_arg_int(pgls->memory, pargs, &value);
- /* BP command value pair is currently ignored */
- }
+ if (!more)
+ break;
+ if (command == 1) {
+ /* parse string */
+ const byte *p = pargs->source.ptr;
+ const byte *rlimit = pargs->source.limit;
+ while ( p < rlimit ) {
+ switch ( *++p ) {
+ case ' ':
+ /* Ignore spaces between command and opening ". */
+ continue;
+ case '"':
+ if ( !pargs->phase ) {
+ /* begin string */
+ pargs->phase = 1;
+ continue;
+ }
+ else /* end string */
+ break;
+ default:
+ if ( !pargs->phase )
+ break; /* ill formed command exit */
+ else
+ continue; /* character inside of string */
+ }
+ break; /* error or trailing " exits */
+ }
+ pargs->source.ptr = p;
+ }
+ else {
+ more = hpgl_arg_int(pgls->memory, pargs, &value);
+ /* BP command value pair is currently ignored */
+ }
}
hpgl_args_setup(&args);
@@ -705,26 +703,26 @@ pgconfig_do_registration(
)
{ /* Register commands */
DEFINE_HPGL_COMMANDS(mem)
- /* CO has special argument parsing, so it must handle skipping */
- /* in polygon mode itself. */
- HPGL_COMMAND('C', 'O', hpgl_CO, hpgl_cdf_polygon | hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('D', 'F', hpgl_DF, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('I', 'N', hpgl_IN, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('I', 'P', hpgl_IP, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('I', 'R', hpgl_IR, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('I', 'W', hpgl_IW, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('P', 'G', hpgl_PG, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('P', 'S', hpgl_PS, hpgl_cdf_rtl),
- HPGL_COMMAND('E','C', hpgl_EC, hpgl_cdf_rtl),
- HPGL_COMMAND('R', 'O', hpgl_RO, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('R', 'P', hpgl_RP, hpgl_cdf_rtl),
- HPGL_COMMAND('S', 'C', hpgl_SC, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('B', 'P', hpgl_BP, hpgl_cdf_pcl_rtl_both),
+ /* CO has special argument parsing, so it must handle skipping */
+ /* in polygon mode itself. */
+ HPGL_COMMAND('C', 'O', hpgl_CO, hpgl_cdf_polygon | hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('D', 'F', hpgl_DF, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('I', 'N', hpgl_IN, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('I', 'P', hpgl_IP, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('I', 'R', hpgl_IR, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('I', 'W', hpgl_IW, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('P', 'G', hpgl_PG, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('P', 'S', hpgl_PS, hpgl_cdf_rtl),
+ HPGL_COMMAND('E','C', hpgl_EC, hpgl_cdf_rtl),
+ HPGL_COMMAND('R', 'O', hpgl_RO, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('R', 'P', hpgl_RP, hpgl_cdf_rtl),
+ HPGL_COMMAND('S', 'C', hpgl_SC, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('B', 'P', hpgl_BP, hpgl_cdf_pcl_rtl_both),
#ifdef DEBUG
- HPGL_COMMAND('Z', 'Z', hpgl_ZZ, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('Z', 'Z', hpgl_ZZ, hpgl_cdf_pcl_rtl_both),
#endif
- END_HPGL_COMMANDS
- return 0;
+ END_HPGL_COMMANDS
+ return 0;
}
const pcl_init_t pgconfig_init = {
pgconfig_do_registration, 0
diff --git a/pcl/pgdraw.c b/pcl/pgdraw.c
index fd0ea134f..a45f74d8f 100644
--- a/pcl/pgdraw.c
+++ b/pcl/pgdraw.c
@@ -13,7 +13,7 @@
/* pgdraw.c - HP-GL/2 line drawing/path building routines. */
-#include "stdio_.h"
+#include "stdio_.h"
#include "math_.h"
#include "gdebug.h"
#include "gstypes.h" /* for gsstate.h */
@@ -35,8 +35,6 @@
#include "pcpatrn.h"
#include "pcpage.h"
-
-
/* hack to quiet compiler warnings */
#ifndef abs
extern int abs( int );
@@ -44,7 +42,6 @@ extern int abs( int );
#define round(x) (((x) < 0.0) ? (ceil ((x) - 0.5)) : (floor ((x) + 0.5)))
-
static inline gs_point
hpgl_picture_frame_scale(hpgl_state_t *pgls)
{
@@ -53,29 +50,29 @@ hpgl_picture_frame_scale(hpgl_state_t *pgls)
/* this should not happen in a real system */
if ( (pgls->g.picture_frame_height == 0) ||
- (pgls->g.picture_frame_width == 0) ||
- (pgls->g.plot_width == 0) ||
- (pgls->g.plot_height == 0) ) {
- dprintf("bad picture frame coordinates\n");
+ (pgls->g.picture_frame_width == 0) ||
+ (pgls->g.plot_width == 0) ||
+ (pgls->g.plot_height == 0) ) {
+ dprintf("bad picture frame coordinates\n");
} else {
scale.x = (pgls->g.plot_size_horizontal_specified) ?
- ((hpgl_real_t)pgls->g.picture_frame_width /
- (hpgl_real_t)pgls->g.plot_width) :
- 1.0;
+ ((hpgl_real_t)pgls->g.picture_frame_width /
+ (hpgl_real_t)pgls->g.plot_width) :
+ 1.0;
scale.y = (pgls->g.plot_size_vertical_specified) ?
- ((hpgl_real_t)pgls->g.picture_frame_height /
- (hpgl_real_t)pgls->g.plot_height) :
- 1.0;
+ ((hpgl_real_t)pgls->g.picture_frame_height /
+ (hpgl_real_t)pgls->g.plot_height) :
+ 1.0;
}
return scale;
}
-
+
static int
hpgl_set_picture_frame_scaling(hpgl_state_t *pgls)
{
if ( pgls->g.scaling_type != hpgl_scaling_point_factor ) {
gs_point scale = hpgl_picture_frame_scale(pgls);
- hpgl_call(gs_scale(pgls->pgs, scale.x, scale.y));
+ hpgl_call(gs_scale(pgls->pgs, scale.x, scale.y));
}
return 0;
}
@@ -91,72 +88,72 @@ hpgl_width_scale(hpgl_state_t *pgls)
int
hpgl_set_pcl_to_plu_ctm(hpgl_state_t *pgls)
{
- hpgl_real_t swap_temp;
- hpgl_real_t fw_plu = (coord_2_plu(pgls->g.picture_frame_width));
- hpgl_real_t fh_plu = (coord_2_plu(pgls->g.picture_frame_height));
+ hpgl_real_t swap_temp;
+ hpgl_real_t fw_plu = (coord_2_plu(pgls->g.picture_frame_width));
+ hpgl_real_t fh_plu = (coord_2_plu(pgls->g.picture_frame_height));
- hpgl_call(pcl_set_ctm(pgls, false));
- if ( pgls->personality == rtl ) {
- /* If plot length >= width, y increases across the short
+ hpgl_call(pcl_set_ctm(pgls, false));
+ if ( pgls->personality == rtl ) {
+ /* If plot length >= width, y increases across the short
edge and x increases down the plot. Rotate the pcl
coordinate system -90, scale and flip the x axis. Else
for plot width > length the origin is in the upper
right and x increases going to the left and y increases
going down, translate the pcl coordinate system by the
- picture frame width, scale and flip x.
- PLOTSIZEROTATE==OFF forces -90 rotation, top/left 0,0
- not legal pcl default is ON */
- if ( pgls->g.picture_frame_height >= pgls->g.picture_frame_width ||
- !pjl_proc_compare(pgls->pjls,
- pjl_proc_get_envvar(pgls->pjls, "plotsizerotate"), "on")) {
- hpgl_call(gs_rotate(pgls->pgs, -90));
- /* swap picture frame height and width
- * for the translation portion of the next RO cmd rotation.
- */
- swap_temp = fw_plu;
- fw_plu = fh_plu;
- fh_plu = swap_temp;
- }
- else
- hpgl_call(gs_translate(pgls->pgs, pgls->g.picture_frame_width, 0));
- hpgl_call(gs_scale(pgls->pgs, -(7200.0/1016.0), (7200.0/1016.0)));
- } else {
- hpgl_call(gs_translate(pgls->pgs,
- pgls->g.picture_frame.anchor_point.x,
- pgls->g.picture_frame.anchor_point.y));
- /* move the origin */
- hpgl_call(gs_translate(pgls->pgs, 0, pgls->g.picture_frame_height));
- /* scale to plotter units and a flip for y */
- hpgl_call(gs_scale(pgls->pgs, (7200.0/1016.0), -(7200.0/1016.0)));
- /* account for rotated coordinate system */
- }
- hpgl_call(gs_rotate(pgls->pgs, pgls->g.rotation));
- {
- switch (pgls->g.rotation)
- {
- case 0 :
- hpgl_call(gs_translate(pgls->pgs, 0, 0));
- break;
- case 90 :
- hpgl_call(gs_translate(pgls->pgs, 0, -fw_plu));
- break;
- case 180 :
- hpgl_call(gs_translate(pgls->pgs, -fw_plu, -fh_plu));
- break;
- case 270 :
- hpgl_call(gs_translate(pgls->pgs, -fh_plu, 0));
- break;
- }
- }
- hpgl_call(hpgl_set_picture_frame_scaling(pgls));
- {
- gs_matrix mat;
- gs_currentmatrix(pgls->pgs, &mat);
- mat.ty = floor(mat.ty); mat.tx = floor(mat.tx);
- gs_setmatrix(pgls->pgs, &mat);
- }
- hpgl_call(gs_setdotorientation(pgls->pgs));
- return 0;
+ picture frame width, scale and flip x.
+ PLOTSIZEROTATE==OFF forces -90 rotation, top/left 0,0
+ not legal pcl default is ON */
+ if ( pgls->g.picture_frame_height >= pgls->g.picture_frame_width ||
+ !pjl_proc_compare(pgls->pjls,
+ pjl_proc_get_envvar(pgls->pjls, "plotsizerotate"), "on")) {
+ hpgl_call(gs_rotate(pgls->pgs, -90));
+ /* swap picture frame height and width
+ * for the translation portion of the next RO cmd rotation.
+ */
+ swap_temp = fw_plu;
+ fw_plu = fh_plu;
+ fh_plu = swap_temp;
+ }
+ else
+ hpgl_call(gs_translate(pgls->pgs, pgls->g.picture_frame_width, 0));
+ hpgl_call(gs_scale(pgls->pgs, -(7200.0/1016.0), (7200.0/1016.0)));
+ } else {
+ hpgl_call(gs_translate(pgls->pgs,
+ pgls->g.picture_frame.anchor_point.x,
+ pgls->g.picture_frame.anchor_point.y));
+ /* move the origin */
+ hpgl_call(gs_translate(pgls->pgs, 0, pgls->g.picture_frame_height));
+ /* scale to plotter units and a flip for y */
+ hpgl_call(gs_scale(pgls->pgs, (7200.0/1016.0), -(7200.0/1016.0)));
+ /* account for rotated coordinate system */
+ }
+ hpgl_call(gs_rotate(pgls->pgs, pgls->g.rotation));
+ {
+ switch (pgls->g.rotation)
+ {
+ case 0 :
+ hpgl_call(gs_translate(pgls->pgs, 0, 0));
+ break;
+ case 90 :
+ hpgl_call(gs_translate(pgls->pgs, 0, -fw_plu));
+ break;
+ case 180 :
+ hpgl_call(gs_translate(pgls->pgs, -fw_plu, -fh_plu));
+ break;
+ case 270 :
+ hpgl_call(gs_translate(pgls->pgs, -fh_plu, 0));
+ break;
+ }
+ }
+ hpgl_call(hpgl_set_picture_frame_scaling(pgls));
+ {
+ gs_matrix mat;
+ gs_currentmatrix(pgls->pgs, &mat);
+ mat.ty = floor(mat.ty); mat.tx = floor(mat.tx);
+ gs_setmatrix(pgls->pgs, &mat);
+ }
+ hpgl_call(gs_setdotorientation(pgls->pgs));
+ return 0;
}
/* Set the CTM to map PLU to device units, regardless of scaling. */
@@ -164,62 +161,62 @@ hpgl_set_pcl_to_plu_ctm(hpgl_state_t *pgls)
int
hpgl_set_plu_ctm(hpgl_state_t *pgls)
{
- hpgl_call(hpgl_set_pcl_to_plu_ctm(pgls));
- return 0;
+ hpgl_call(hpgl_set_pcl_to_plu_ctm(pgls));
+ return 0;
}
int
hpgl_compute_user_units_to_plu_ctm(const hpgl_state_t *pgls, gs_matrix *pmat)
{ floatp origin_x = pgls->g.P1.x, origin_y = pgls->g.P1.y;
- switch ( pgls->g.scaling_type )
- {
- case hpgl_scaling_none:
- gs_make_identity(pmat);
- break;
- case hpgl_scaling_point_factor:
- hpgl_call(gs_make_translation(origin_x, origin_y, pmat));
- hpgl_call(gs_matrix_scale(pmat, pgls->g.scaling_params.factor.x,
- pgls->g.scaling_params.factor.y, pmat));
- hpgl_call(gs_matrix_translate(pmat,
- -pgls->g.scaling_params.pmin.x,
- -pgls->g.scaling_params.pmin.y, pmat));
- break;
- default:
- /*case hpgl_scaling_anisotropic:*/
- /*case hpgl_scaling_isotropic:*/
- {
- floatp window_x = pgls->g.P2.x - origin_x,
- range_x = pgls->g.scaling_params.pmax.x -
- pgls->g.scaling_params.pmin.x,
- scale_x = window_x / range_x;
- floatp window_y = pgls->g.P2.y - origin_y,
- range_y = pgls->g.scaling_params.pmax.y -
- pgls->g.scaling_params.pmin.y,
- scale_y = window_y / range_y;
+ switch ( pgls->g.scaling_type )
+ {
+ case hpgl_scaling_none:
+ gs_make_identity(pmat);
+ break;
+ case hpgl_scaling_point_factor:
+ hpgl_call(gs_make_translation(origin_x, origin_y, pmat));
+ hpgl_call(gs_matrix_scale(pmat, pgls->g.scaling_params.factor.x,
+ pgls->g.scaling_params.factor.y, pmat));
+ hpgl_call(gs_matrix_translate(pmat,
+ -pgls->g.scaling_params.pmin.x,
+ -pgls->g.scaling_params.pmin.y, pmat));
+ break;
+ default:
+ /*case hpgl_scaling_anisotropic:*/
+ /*case hpgl_scaling_isotropic:*/
+ {
+ floatp window_x = pgls->g.P2.x - origin_x,
+ range_x = pgls->g.scaling_params.pmax.x -
+ pgls->g.scaling_params.pmin.x,
+ scale_x = window_x / range_x;
+ floatp window_y = pgls->g.P2.y - origin_y,
+ range_y = pgls->g.scaling_params.pmax.y -
+ pgls->g.scaling_params.pmin.y,
+ scale_y = window_y / range_y;
#define SIGN(x) ((x) < 0 ? -1.0 : 1.0)
-
- if ( pgls->g.scaling_type == hpgl_scaling_isotropic ) {
- if ( fabs(scale_x) > fabs(scale_y) ) { /* Reduce the X scaling. */
- origin_x += SIGN(scale_x) * (range_x * (fabs(scale_x) - fabs(scale_y)) *
+
+ if ( pgls->g.scaling_type == hpgl_scaling_isotropic ) {
+ if ( fabs(scale_x) > fabs(scale_y) ) { /* Reduce the X scaling. */
+ origin_x += SIGN(scale_x) * (range_x * (fabs(scale_x) - fabs(scale_y)) *
(pgls->g.scaling_params.left / 100.0));
scale_x = SIGN(scale_x) * fabs(scale_y);
} else { /* Reduce the Y scaling. */
- origin_y += SIGN(scale_y) * (range_y * (fabs(scale_y) - fabs(scale_x)) *
+ origin_y += SIGN(scale_y) * (range_y * (fabs(scale_y) - fabs(scale_x)) *
(pgls->g.scaling_params.bottom / 100.0));
scale_y = SIGN(scale_y) * fabs(scale_x);
}
}
- hpgl_call(gs_make_translation(origin_x, origin_y, pmat));
- hpgl_call(gs_matrix_scale(pmat, scale_x, scale_y, pmat));
- hpgl_call(gs_matrix_translate(pmat,
- -pgls->g.scaling_params.pmin.x,
- -pgls->g.scaling_params.pmin.y, pmat));
- break;
- }
- }
- return 0;
+ hpgl_call(gs_make_translation(origin_x, origin_y, pmat));
+ hpgl_call(gs_matrix_scale(pmat, scale_x, scale_y, pmat));
+ hpgl_call(gs_matrix_translate(pmat,
+ -pgls->g.scaling_params.pmin.x,
+ -pgls->g.scaling_params.pmin.y, pmat));
+ break;
+ }
+ }
+ return 0;
}
@@ -230,13 +227,13 @@ hpgl_set_ctm(hpgl_state_t *pgls)
{
hpgl_call(hpgl_set_plu_ctm(pgls));
if ( pgls->g.scaling_type != hpgl_scaling_none ) {
- gs_matrix mat;
- hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &mat));
- hpgl_call(gs_concat(pgls->pgs, &mat));
- hpgl_call(gs_currentmatrix(pgls->pgs, &mat));
- mat.tx = round(mat.tx);
- mat.ty = round(mat.ty);
- hpgl_call(gs_setmatrix(pgls->pgs, &mat));
+ gs_matrix mat;
+ hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &mat));
+ hpgl_call(gs_concat(pgls->pgs, &mat));
+ hpgl_call(gs_currentmatrix(pgls->pgs, &mat));
+ mat.tx = round(mat.tx);
+ mat.ty = round(mat.ty);
+ hpgl_call(gs_setmatrix(pgls->pgs, &mat));
}
return 0;
}
@@ -252,108 +249,108 @@ hpgl_get_line_pattern_length(hpgl_state_t *pgls)
/* dispense with the unusual "isotropic relative" case first. The
normal calculation afterward is straightforward */
if ( (pgls->g.line.current.pattern_length_relative == 0) &&
- (pgls->g.scaling_type == hpgl_scaling_isotropic) ) {
- /* the box in user space */
- gs_rect isotropic_user_box;
- /* box in plotter units we compute 4% of the diagonal of this box */
- gs_rect isotropic_plu_box;
- gs_matrix user_to_plu_mat;
-
- hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &user_to_plu_mat));
-
- isotropic_user_box.p = pgls->g.scaling_params.pmin;
- isotropic_user_box.q = pgls->g.scaling_params.pmax;
-
- hpgl_call(gs_bbox_transform(&isotropic_user_box,
- &user_to_plu_mat,
- &isotropic_plu_box));
-
- return (pgls->g.line.current.pattern_length / 100.0) *
- hpgl_compute_distance(isotropic_plu_box.p.x,
- isotropic_plu_box.p.y,
- isotropic_plu_box.q.x,
- isotropic_plu_box.q.y);
+ (pgls->g.scaling_type == hpgl_scaling_isotropic) ) {
+ /* the box in user space */
+ gs_rect isotropic_user_box;
+ /* box in plotter units we compute 4% of the diagonal of this box */
+ gs_rect isotropic_plu_box;
+ gs_matrix user_to_plu_mat;
+
+ hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &user_to_plu_mat));
+
+ isotropic_user_box.p = pgls->g.scaling_params.pmin;
+ isotropic_user_box.q = pgls->g.scaling_params.pmax;
+
+ hpgl_call(gs_bbox_transform(&isotropic_user_box,
+ &user_to_plu_mat,
+ &isotropic_plu_box));
+
+ return (pgls->g.line.current.pattern_length / 100.0) *
+ hpgl_compute_distance(isotropic_plu_box.p.x,
+ isotropic_plu_box.p.y,
+ isotropic_plu_box.q.x,
+ isotropic_plu_box.q.y);
}
/* simple case 4% of the diagonal of P1 and P2 or absolute in millimeters */
return ((pgls->g.line.current.pattern_length_relative == 0) ?
- ((pgls->g.line.current.pattern_length / 100.0) *
- hpgl_compute_distance(pgls->g.P1.x,
- pgls->g.P1.y,
- pgls->g.P2.x,
- pgls->g.P2.y) *
+ ((pgls->g.line.current.pattern_length / 100.0) *
+ hpgl_compute_distance(pgls->g.P1.x,
+ pgls->g.P1.y,
+ pgls->g.P2.x,
+ pgls->g.P2.y) *
hpgl_width_scale(pgls)) :
- (mm_2_plu(pgls->g.line.current.pattern_length)));
+ (mm_2_plu(pgls->g.line.current.pattern_length)));
}
static int
hpgl_set_graphics_dash_state(hpgl_state_t *pgls)
{
- int entry = abs(pgls->g.line.current.type);
- bool adaptive;
- const hpgl_line_type_t *pat;
- float length;
- float pattern[20];
- float offset;
- int count;
- int i;
-
- /* handle the simple case (no dash) and return */
- if ( pgls->g.line.current.is_solid )
- {
- /* use a 0 count pattern to turn off dashing in case it is
+ int entry = abs(pgls->g.line.current.type);
+ bool adaptive;
+ const hpgl_line_type_t *pat;
+ float length;
+ float pattern[20];
+ float offset;
+ int count;
+ int i;
+
+ /* handle the simple case (no dash) and return */
+ if ( pgls->g.line.current.is_solid )
+ {
+ /* use a 0 count pattern to turn off dashing in case it is
set, and allow drawing dots */
- hpgl_call(gs_setdash(pgls->pgs, pattern, 0, 0));
- hpgl_call(gs_setdotlength(pgls->pgs, 0.00098, true));
- return 0;
- }
-
- hpgl_call(gs_setdotlength(pgls->pgs, 0.0, false));
- if ( entry == 0 )
- {
- /* dot length NOTE this is in absolute 1/72" units not
+ hpgl_call(gs_setdash(pgls->pgs, pattern, 0, 0));
+ hpgl_call(gs_setdotlength(pgls->pgs, 0.00098, true));
+ return 0;
+ }
+
+ hpgl_call(gs_setdotlength(pgls->pgs, 0.0, false));
+ if ( entry == 0 )
+ {
+ /* dot length NOTE this is in absolute 1/72" units not
user space */
- /* Use an adaptive pattern with an infinitely long segment length
- to get the dots drawn just at the ends of lines. */
- pattern[0] = 0;
- pattern[1] = 1.0e6; /* "infinity" */
- hpgl_call(gs_setdash(pgls->pgs, pattern, 2, 0));
- gs_setdashadapt(pgls->pgs, true);
- return 0;
- }
-
- adaptive = ( pgls->g.line.current.type < 0 );
- pat = ((adaptive) ?
- (&pgls->g.adaptive_line_type[entry - 1]) :
- (&pgls->g.fixed_line_type[entry - 1]));
-
- length = hpgl_get_line_pattern_length(pgls);
- gs_setdashadapt(pgls->pgs, adaptive);
- /*
- * The graphics library interprets odd pattern counts differently
- * from GL: if the pattern count is odd, we need to do something
- * a little special.
- */
- count = pat->count;
- for ( i = 0; i < count; i++ )
- pattern[i] = length * pat->gap[i];
- offset = pgls->g.line.current.pattern_offset * hpgl_get_line_pattern_length(pgls);
- if ( count & 1 )
- {
- /*
- * Combine the last gap with the first one, and change the
- * offset to compensate. NOTE: this doesn't work right with
- * adaptive line type: we may need to change the library to
- * make this work properly.
- */
- --count;
- pattern[0] += pattern[count];
- offset += pattern[count];
- }
-
- hpgl_call(gs_setdash(pgls->pgs, pattern, count, offset));
-
- return 0;
+ /* Use an adaptive pattern with an infinitely long segment length
+ to get the dots drawn just at the ends of lines. */
+ pattern[0] = 0;
+ pattern[1] = 1.0e6; /* "infinity" */
+ hpgl_call(gs_setdash(pgls->pgs, pattern, 2, 0));
+ gs_setdashadapt(pgls->pgs, true);
+ return 0;
+ }
+
+ adaptive = ( pgls->g.line.current.type < 0 );
+ pat = ((adaptive) ?
+ (&pgls->g.adaptive_line_type[entry - 1]) :
+ (&pgls->g.fixed_line_type[entry - 1]));
+
+ length = hpgl_get_line_pattern_length(pgls);
+ gs_setdashadapt(pgls->pgs, adaptive);
+ /*
+ * The graphics library interprets odd pattern counts differently
+ * from GL: if the pattern count is odd, we need to do something
+ * a little special.
+ */
+ count = pat->count;
+ for ( i = 0; i < count; i++ )
+ pattern[i] = length * pat->gap[i];
+ offset = pgls->g.line.current.pattern_offset * hpgl_get_line_pattern_length(pgls);
+ if ( count & 1 )
+ {
+ /*
+ * Combine the last gap with the first one, and change the
+ * offset to compensate. NOTE: this doesn't work right with
+ * adaptive line type: we may need to change the library to
+ * make this work properly.
+ */
+ --count;
+ pattern[0] += pattern[count];
+ offset += pattern[count];
+ }
+
+ hpgl_call(gs_setdash(pgls->pgs, pattern, count, offset));
+
+ return 0;
}
/* catch pen not being in the palette */
@@ -383,29 +380,29 @@ hpgl_set_graphics_line_attribute_state(
)
{
const gs_line_cap cap_map[] = { gs_cap_butt, /* 0 not supported */
- gs_cap_butt, /* 1 butt end */
- gs_cap_square, /* 2 square end */
- gs_cap_triangle, /* 3 triag. end */
- gs_cap_round /* 4 round cap */
+ gs_cap_butt, /* 1 butt end */
+ gs_cap_square, /* 2 square end */
+ gs_cap_triangle, /* 3 triag. end */
+ gs_cap_round /* 4 round cap */
};
const gs_line_join join_map[] = { gs_join_none, /* 0 not supported */
- gs_join_miter, /* 1 mitered */
- gs_join_miter, /* 2 mitrd/bevld */
- gs_join_triangle, /* 3 triag. join */
- gs_join_round, /* 4 round join */
- gs_join_bevel, /* 5 bevel join */
- gs_join_none /* 6 no join */
+ gs_join_miter, /* 1 mitered */
+ gs_join_miter, /* 2 mitrd/bevld */
+ gs_join_triangle, /* 3 triag. join */
+ gs_join_round, /* 4 round join */
+ gs_join_bevel, /* 5 bevel join */
+ gs_join_none /* 6 no join */
};
const float * widths = pcl_palette_get_pen_widths(pgls->ppalet);
floatp pen_wid = widths[hpgl_get_selected_pen(pgls)];
gs_setfilladjust(pgls->pgs, 0.0, 0.0);
-
+
/* character mode has already set up all of this information in
the build character routine for the font */
if ( render_mode == hpgl_rm_character )
- return 0;
+ return 0;
/*
* HP appears to use default line attributes if the the pen
* width is less than or equal to .35mm or 14.0 plu. This
@@ -413,11 +410,11 @@ hpgl_set_graphics_line_attribute_state(
* plotter units
*/
if ( render_mode != hpgl_rm_character && pen_wid <= 14.0 ) {
- hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_miter));
- hpgl_call(gs_setlinecap(pgls->pgs, gs_cap_butt));
- hpgl_call(gs_setlinewidth(pgls->pgs, pen_wid));
- hpgl_call(gs_setmiterlimit(pgls->pgs, 5.0));
- return 0;
+ hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_miter));
+ hpgl_call(gs_setlinecap(pgls->pgs, gs_cap_butt));
+ hpgl_call(gs_setlinewidth(pgls->pgs, pen_wid));
+ hpgl_call(gs_setmiterlimit(pgls->pgs, 5.0));
+ return 0;
}
switch (render_mode) {
@@ -425,30 +422,30 @@ hpgl_set_graphics_line_attribute_state(
case hpgl_rm_character:
case hpgl_rm_polygon:
case hpgl_rm_clip_and_fill_polygon:
- hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_round));
- hpgl_call(gs_setlinecap(pgls->pgs, gs_cap_round));
- break;
+ hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_round));
+ hpgl_call(gs_setlinecap(pgls->pgs, gs_cap_round));
+ break;
case hpgl_rm_vector_fill:
case hpgl_rm_vector:
vector:
- hpgl_call(gs_setlinejoin(pgls->pgs, join_map[pgls->g.line.join]));
- hpgl_call(gs_setlinecap(pgls->pgs, cap_map[pgls->g.line.cap]));
- hpgl_call(gs_setlinewidth(pgls->pgs, pen_wid));
- break;
+ hpgl_call(gs_setlinejoin(pgls->pgs, join_map[pgls->g.line.join]));
+ hpgl_call(gs_setlinecap(pgls->pgs, cap_map[pgls->g.line.cap]));
+ hpgl_call(gs_setlinewidth(pgls->pgs, pen_wid));
+ break;
default:
- /* shouldn't happen; we must have a mode to properly parse hpgl file. */
- dprintf("warning no hpgl rendering mode set using vector mode\n");
- goto vector;
+ /* shouldn't happen; we must have a mode to properly parse hpgl file. */
+ dprintf("warning no hpgl rendering mode set using vector mode\n");
+ goto vector;
}
#ifdef COMMENT
/* I do not remember the rational for the large miter */
hpgl_call(gs_setmiterlimit( pgls->pgs,
- (pgls->g.line.join == 1)
- ? 5000.0
- : pgls->g.miter_limit
+ (pgls->g.line.join == 1)
+ ? 5000.0
+ : pgls->g.miter_limit
) );
#endif
hpgl_call(gs_setmiterlimit(pgls->pgs, pgls->g.miter_limit));
@@ -481,41 +478,41 @@ hpgl_set_clipping_region(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
return 0;
else
{
- gs_fixed_rect fixed_box;
- gs_rect pcl_clip_box;
- gs_rect dev_clip_box;
- gs_matrix save_ctm;
- gs_matrix pcl_ctm;
-
- /* get pcl to device ctm and restore the current ctm */
- hpgl_call(gs_currentmatrix(pgls->pgs, &save_ctm));
- hpgl_call(pcl_set_ctm(pgls, false));
- hpgl_call(gs_currentmatrix(pgls->pgs, &pcl_ctm));
- hpgl_call(gs_setmatrix(pgls->pgs, &save_ctm));
- /* find the clipping region defined by the picture frame
+ gs_fixed_rect fixed_box;
+ gs_rect pcl_clip_box;
+ gs_rect dev_clip_box;
+ gs_matrix save_ctm;
+ gs_matrix pcl_ctm;
+
+ /* get pcl to device ctm and restore the current ctm */
+ hpgl_call(gs_currentmatrix(pgls->pgs, &save_ctm));
+ hpgl_call(pcl_set_ctm(pgls, false));
+ hpgl_call(gs_currentmatrix(pgls->pgs, &pcl_ctm));
+ hpgl_call(gs_setmatrix(pgls->pgs, &save_ctm));
+ /* find the clipping region defined by the picture frame
which is defined in pcl coordinates */
- pcl_clip_box.p.x = pgls->g.picture_frame.anchor_point.x;
- pcl_clip_box.p.y = pgls->g.picture_frame.anchor_point.y;
- pcl_clip_box.q.x = pcl_clip_box.p.x + pgls->g.picture_frame_width;
- pcl_clip_box.q.y = pcl_clip_box.p.y + pgls->g.picture_frame_height;
-
- hpgl_call(gs_bbox_transform(&pcl_clip_box,
- &pcl_ctm,
- &dev_clip_box));
- /* HP cheats and expands the clip box's extant by at least
+ pcl_clip_box.p.x = pgls->g.picture_frame.anchor_point.x;
+ pcl_clip_box.p.y = pgls->g.picture_frame.anchor_point.y;
+ pcl_clip_box.q.x = pcl_clip_box.p.x + pgls->g.picture_frame_width;
+ pcl_clip_box.q.y = pcl_clip_box.p.y + pgls->g.picture_frame_height;
+
+ hpgl_call(gs_bbox_transform(&pcl_clip_box,
+ &pcl_ctm,
+ &dev_clip_box));
+ /* HP cheats and expands the clip box's extant by at least
one device pixel in all directions */
- dev_clip_box.q.x += 1.0;
- dev_clip_box.q.y += 1.0;
+ dev_clip_box.q.x += 1.0;
+ dev_clip_box.q.y += 1.0;
dev_clip_box.p.x -= 1.0;
dev_clip_box.p.y -= 1.0;
- /* if the clipping window is active calculate the new clip
+ /* if the clipping window is active calculate the new clip
box derived from IW and the intersection of the device
space boxes replace the current box. Note that IW
coordinates are in current units and and the picture
frame in pcl coordinates. */
- if ( pgls->g.soft_clip_window.active ) {
- gs_rect dev_soft_window_box;
- gs_matrix ctm;
+ if ( pgls->g.soft_clip_window.active ) {
+ gs_rect dev_soft_window_box;
+ gs_matrix ctm;
if (pgls->g.soft_clip_window.isbound) {
/* we need the plotter unit matrix */
hpgl_call(gs_currentmatrix(pgls->pgs, &save_ctm));
@@ -525,28 +522,28 @@ hpgl_set_clipping_region(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
} else {
hpgl_call(gs_currentmatrix(pgls->pgs, &ctm));
}
- hpgl_call(gs_bbox_transform(&pgls->g.soft_clip_window.rect,
- &ctm,
- &dev_soft_window_box));
- /* Enlarge IW by 1 device dot to compensate for it's
- 'on the line' is not clipped behavior. */
- dev_clip_box.p.x = max(dev_clip_box.p.x, dev_soft_window_box.p.x - 1.0);
- dev_clip_box.p.y = max(dev_clip_box.p.y, dev_soft_window_box.p.y - 1.0);
- dev_clip_box.q.x = min(dev_clip_box.q.x, dev_soft_window_box.q.x + 1.0);
- dev_clip_box.q.y = min(dev_clip_box.q.y, dev_soft_window_box.q.y + 1.0);
-
- }
- /* convert intersection box to fixed point and clip */
- fixed_box.p.x = float2fixed(floor(dev_clip_box.p.x));
- fixed_box.p.y = float2fixed(floor(dev_clip_box.p.y));
- fixed_box.q.x = float2fixed(ceil(dev_clip_box.q.x));
- fixed_box.q.y = float2fixed(ceil(dev_clip_box.q.y));
- /* intersect with pcl clipping region */
- fixed_box.p.x = max(fixed_box.p.x, pgls->xfm_state.dev_print_rect.p.x);
- fixed_box.p.y = max(fixed_box.p.y, pgls->xfm_state.dev_print_rect.p.y);
- fixed_box.q.x = min(fixed_box.q.x, pgls->xfm_state.dev_print_rect.q.x);
- fixed_box.q.y = min(fixed_box.q.y, pgls->xfm_state.dev_print_rect.q.y);
- hpgl_call(gx_clip_to_rectangle(pgls->pgs, &fixed_box));
+ hpgl_call(gs_bbox_transform(&pgls->g.soft_clip_window.rect,
+ &ctm,
+ &dev_soft_window_box));
+ /* Enlarge IW by 1 device dot to compensate for it's
+ 'on the line' is not clipped behavior. */
+ dev_clip_box.p.x = max(dev_clip_box.p.x, dev_soft_window_box.p.x - 1.0);
+ dev_clip_box.p.y = max(dev_clip_box.p.y, dev_soft_window_box.p.y - 1.0);
+ dev_clip_box.q.x = min(dev_clip_box.q.x, dev_soft_window_box.q.x + 1.0);
+ dev_clip_box.q.y = min(dev_clip_box.q.y, dev_soft_window_box.q.y + 1.0);
+
+ }
+ /* convert intersection box to fixed point and clip */
+ fixed_box.p.x = float2fixed(floor(dev_clip_box.p.x));
+ fixed_box.p.y = float2fixed(floor(dev_clip_box.p.y));
+ fixed_box.q.x = float2fixed(ceil(dev_clip_box.q.x));
+ fixed_box.q.y = float2fixed(ceil(dev_clip_box.q.y));
+ /* intersect with pcl clipping region */
+ fixed_box.p.x = max(fixed_box.p.x, pgls->xfm_state.dev_print_rect.p.x);
+ fixed_box.p.y = max(fixed_box.p.y, pgls->xfm_state.dev_print_rect.p.y);
+ fixed_box.q.x = min(fixed_box.q.x, pgls->xfm_state.dev_print_rect.q.x);
+ fixed_box.q.y = min(fixed_box.q.y, pgls->xfm_state.dev_print_rect.q.y);
+ hpgl_call(gx_clip_to_rectangle(pgls->pgs, &fixed_box));
}
return 0;
}
@@ -567,13 +564,13 @@ hpgl_draw_vector_absolute(
hpgl_call(hpgl_add_point_to_path( pgls,
x0,
y0,
- hpgl_plot_move_absolute,
+ hpgl_plot_move_absolute,
set_ctm
) );
hpgl_call(hpgl_add_point_to_path( pgls,
x1,
y1,
- hpgl_plot_draw_absolute,
+ hpgl_plot_draw_absolute,
set_ctm
) );
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector_fill));
@@ -593,15 +590,15 @@ hpgl_get_adjusted_corner(
adjusted_anchor_corner->y = current_anchor_corner->y;
/* account for anchor corner greater than origin */
if (x_fill_increment != 0) {
- while (adjusted_anchor_corner->x > bbox->p.x)
- adjusted_anchor_corner->x -= x_fill_increment;
+ while (adjusted_anchor_corner->x > bbox->p.x)
+ adjusted_anchor_corner->x -= x_fill_increment;
} else if (adjusted_anchor_corner->x > bbox->p.x)
- adjusted_anchor_corner->x = bbox->p.x;
+ adjusted_anchor_corner->x = bbox->p.x;
if (y_fill_increment != 0) {
- while (adjusted_anchor_corner->y > bbox->p.y)
- adjusted_anchor_corner->y -= y_fill_increment;
+ while (adjusted_anchor_corner->y > bbox->p.y)
+ adjusted_anchor_corner->y -= y_fill_increment;
} else if (adjusted_anchor_corner->y > bbox->p.y)
- adjusted_anchor_corner->y = bbox->p.y;
+ adjusted_anchor_corner->y = bbox->p.y;
return 0;
}
@@ -609,9 +606,9 @@ static void
hpgl_alternate_line_pattern_offset(hpgl_state_t *pgls, uint lines_filled)
{
if ( lines_filled & 1 )
- pgls->g.line.current.pattern_offset = 0.5;
+ pgls->g.line.current.pattern_offset = 0.5;
else
- pgls->g.line.current.pattern_offset = 0.0;
+ pgls->g.line.current.pattern_offset = 0.0;
}
/* this definition is used to factor out the effect of the orientation
@@ -649,12 +646,12 @@ hpgl_polyfill(
: &pgls->g.fill.param.hatch);
gs_point spacing;
#ifdef FILL_IGNORES_PCL_ORIENTATION
- hpgl_real_t direction =
+ hpgl_real_t direction =
params->angle + pgls->xfm_state.lp_orient * 90;
#else
hpgl_real_t direction = params->angle;
#endif
-
+
hpgl_real_t unscaled_direction;
float saved_line_pattern_offset = pgls->g.line.current.pattern_offset;
int lines_filled;
@@ -668,20 +665,20 @@ hpgl_polyfill(
hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &user_to_plu_mat));
if (params->spacing == 0) {
/* Per TRM 22-12, use 1% of the P1/P2 distance. */
-
- spacing.x = 0.01 * hpgl_compute_distance( pgls->g.P1.x,
- pgls->g.P1.y,
- pgls->g.P2.x,
- pgls->g.P2.y
- );
-
- /* 1% is in plu, convert back to user units */
- spacing.y = spacing.x / fabs(user_to_plu_mat.yy);
- spacing.x /= fabs(user_to_plu_mat.xx);
+
+ spacing.x = 0.01 * hpgl_compute_distance( pgls->g.P1.x,
+ pgls->g.P1.y,
+ pgls->g.P2.x,
+ pgls->g.P2.y
+ );
+
+ /* 1% is in plu, convert back to user units */
+ spacing.y = spacing.x / fabs(user_to_plu_mat.yy);
+ spacing.x /= fabs(user_to_plu_mat.xx);
}
else {
- /* set spacing.y based on ratio of x/y scaling, still in user units */
- spacing.y = spacing.x * fabs(user_to_plu_mat.xx) / fabs(user_to_plu_mat.yy);
+ /* set spacing.y based on ratio of x/y scaling, still in user units */
+ spacing.y = spacing.x * fabs(user_to_plu_mat.xx) / fabs(user_to_plu_mat.yy);
}
/* get the bounding box */
hpgl_call(hpgl_polyfill_bbox(pgls, &bbox));
@@ -696,21 +693,20 @@ hpgl_polyfill(
hpgl_real_t line_width = widths[hpgl_get_selected_pen(pgls)];
line_width /= min(fabs(user_to_plu_mat.xx), fabs(user_to_plu_mat.yy));
- if (line_width >= spacing.x || line_width >= spacing.y) {
+ if (line_width >= spacing.x || line_width >= spacing.y) {
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_polygon));
- return 0;
- }
+ return 0;
+ }
}
/* get rid of the current path */
hpgl_call(hpgl_clear_current_path(pgls));
-
start: /* Change direction, come back and draw crosshatch lines. */
/* hatch angles are isotropic; ie 45degrees is not affected by y scale != x scale.
- unscaled_direction ::= user requested angle
+ unscaled_direction ::= user requested angle
direction ::= the angle that when scaled will generate user requested angle */
/* save unscaled angle */
@@ -718,41 +714,41 @@ hpgl_polyfill(
/* not necessery if direction is orthogonal */
if ( !equal(fmod( direction, 90 ), 0 ) ) {
- hpgl_real_t slope, scaled_slope;
- gs_sincos_degrees(direction, &sincos);
- /* take the tangent by dividing sin by cos. Since we know
- the angle is non-orthogonal the cosine is non-zero */
- slope = sin_dir / cos_dir;
- /* scale the slope by the ratio of the scaling factors */
- scaled_slope = (user_to_plu_mat.xx / user_to_plu_mat.yy) * slope;
- /* preserved angle in user space */
- direction = radians_to_degrees * atan(scaled_slope);
+ hpgl_real_t slope, scaled_slope;
+ gs_sincos_degrees(direction, &sincos);
+ /* take the tangent by dividing sin by cos. Since we know
+ the angle is non-orthogonal the cosine is non-zero */
+ slope = sin_dir / cos_dir;
+ /* scale the slope by the ratio of the scaling factors */
+ scaled_slope = (user_to_plu_mat.xx / user_to_plu_mat.yy) * slope;
+ /* preserved angle in user space */
+ direction = radians_to_degrees * atan(scaled_slope);
}
lines_filled = 0;
- /* spacing is done with the unscaled angle
- spacing.x .y is already scaled hence the unscaled angle is used.
+ /* spacing is done with the unscaled angle
+ spacing.x .y is already scaled hence the unscaled angle is used.
scale * spacing * sin(unscaled_angle) */
gs_sincos_degrees(unscaled_direction, &sincos);
if (sin_dir < 0)
- sin_dir = -sin_dir, cos_dir = -cos_dir; /* ensure y_inc >= 0 */
+ sin_dir = -sin_dir, cos_dir = -cos_dir; /* ensure y_inc >= 0 */
x_fill_increment = (sin_dir != 0) ? fabs(spacing.x / sin_dir) : 0;
y_fill_increment = (cos_dir != 0) ? fabs(spacing.y / cos_dir) : 0;
-
- /* scaled angle is used for end point calculation
- distance * sin( scaled_angle )
+
+ /* scaled angle is used for end point calculation
+ distance * sin( scaled_angle )
scale is applyed once and only once per calculation */
gs_sincos_degrees(direction, &sincos);
if (sin_dir < 0)
- sin_dir = -sin_dir, cos_dir = -cos_dir; /* ensure y_inc >= 0 */
+ sin_dir = -sin_dir, cos_dir = -cos_dir; /* ensure y_inc >= 0 */
hpgl_call(hpgl_get_adjusted_corner( x_fill_increment,
- y_fill_increment,
- &bbox,
- &pgls->g.anchor_corner,
- &start
- ) );
+ y_fill_increment,
+ &bbox,
+ &pgls->g.anchor_corner,
+ &start
+ ) );
/*
* calculate the diagonals magnitude. Note we clip this
@@ -765,67 +761,67 @@ hpgl_polyfill(
endy = (diag_mag * sin_dir) + start.y;
hpgl_alternate_line_pattern_offset(pgls, lines_filled++);
hpgl_call(hpgl_draw_vector_absolute( pgls,
- start.x,
- start.y,
- endx,
- endy,
- render_mode
- ) );
+ start.x,
+ start.y,
+ endx,
+ endy,
+ render_mode
+ ) );
/* Travel along +x using current spacing. */
if (x_fill_increment != 0) {
- while ( endx += x_fill_increment,
- (start.x += x_fill_increment) <= bbox.q.x ) {
-
- hpgl_alternate_line_pattern_offset(pgls, lines_filled++);
- hpgl_call(hpgl_draw_vector_absolute( pgls,
- start.x,
- start.y,
- endx,
- endy,
- render_mode
- ) );
- }
+ while ( endx += x_fill_increment,
+ (start.x += x_fill_increment) <= bbox.q.x ) {
+
+ hpgl_alternate_line_pattern_offset(pgls, lines_filled++);
+ hpgl_call(hpgl_draw_vector_absolute( pgls,
+ start.x,
+ start.y,
+ endx,
+ endy,
+ render_mode
+ ) );
+ }
}
/* Travel along +Y similarly. */
if (y_fill_increment != 0) {
- /*
- * If the slope is negative, we have to travel along the right
- * edge of the box rather than the left edge. Fortuitously,
- * the X loop left everything set up exactly right for this case.
- */
- if (cos_dir >= 0) {
- hpgl_call(hpgl_get_adjusted_corner( x_fill_increment,
- y_fill_increment,
- &bbox,
- &pgls->g.anchor_corner,
- &start
- ) );
- endx = (diag_mag * cos_dir) + start.x;
- endy = (diag_mag * sin_dir) + start.y;
- } else
- start.y -= y_fill_increment, endy -= y_fill_increment;
-
- while ( endy += y_fill_increment,
- (start.y += y_fill_increment) <= bbox.q.y ) {
- hpgl_alternate_line_pattern_offset(pgls, lines_filled++);
- hpgl_call(hpgl_draw_vector_absolute( pgls,
- start.x,
- start.y,
- endx,
- endy,
- render_mode
- ) );
- }
-
+ /*
+ * If the slope is negative, we have to travel along the right
+ * edge of the box rather than the left edge. Fortuitously,
+ * the X loop left everything set up exactly right for this case.
+ */
+ if (cos_dir >= 0) {
+ hpgl_call(hpgl_get_adjusted_corner( x_fill_increment,
+ y_fill_increment,
+ &bbox,
+ &pgls->g.anchor_corner,
+ &start
+ ) );
+ endx = (diag_mag * cos_dir) + start.x;
+ endy = (diag_mag * sin_dir) + start.y;
+ } else
+ start.y -= y_fill_increment, endy -= y_fill_increment;
+
+ while ( endy += y_fill_increment,
+ (start.y += y_fill_increment) <= bbox.q.y ) {
+ hpgl_alternate_line_pattern_offset(pgls, lines_filled++);
+ hpgl_call(hpgl_draw_vector_absolute( pgls,
+ start.x,
+ start.y,
+ endx,
+ endy,
+ render_mode
+ ) );
+ }
+
}
- if (cross) {
- /* go back and draw the perpendicular lines, +90degress */
- cross = false;
- direction = unscaled_direction + 90;
- if ( direction >= 180 )
- direction -= 180;
- goto start;
+ if (cross) {
+ /* go back and draw the perpendicular lines, +90degress */
+ cross = false;
+ direction = unscaled_direction + 90;
+ if ( direction >= 180 )
+ direction -= 180;
+ goto start;
}
hpgl_restore_pen_state(pgls, &saved_pen_state, hpgl_pen_pos);
pgls->g.line.current.pattern_offset = saved_line_pattern_offset;
@@ -847,7 +843,7 @@ hpgl_fill_polyfill_background(hpgl_state_t *pgls)
pcl_mark_page_for_path(pgls);
/* if we are drawing on a transparent background */
if ( pgls->g.source_transparent )
- return 0;
+ return 0;
/* preserve the current foreground color */
hpgl_call(hpgl_gsave(pgls));
/* fill a white region. */
@@ -857,7 +853,7 @@ hpgl_fill_polyfill_background(hpgl_state_t *pgls)
hpgl_call(hpgl_grestore(pgls));
return 0;
}
-
+
static int
hpgl_polyfill_using_current_line_type(
hpgl_state_t * pgls,
@@ -872,9 +868,9 @@ hpgl_polyfill_using_current_line_type(
* beginning at the anchor corner replicate lines
*/
if (pgls->g.fill_type == hpgl_even_odd_rule)
- hpgl_call(gs_eoclip(pgls->pgs));
+ hpgl_call(gs_eoclip(pgls->pgs));
else
- hpgl_call(gs_clip(pgls->pgs));
+ hpgl_call(gs_clip(pgls->pgs));
hpgl_call(hpgl_fill_polyfill_background(pgls));
hpgl_call(hpgl_polyfill(pgls, render_mode));
hpgl_call(hpgl_grestore(pgls));
@@ -895,7 +891,6 @@ hpgl_rop(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
return rop;
}
-
int
hpgl_set_drawing_color(
hpgl_state_t * pgls,
@@ -908,124 +903,124 @@ hpgl_set_drawing_color(
switch (render_mode) {
case hpgl_rm_clip_and_fill_polygon:
- hpgl_call(hpgl_polyfill_using_current_line_type(pgls, render_mode));
- return 0;
+ hpgl_call(hpgl_polyfill_using_current_line_type(pgls, render_mode));
+ return 0;
case hpgl_rm_character:
- switch (pgls->g.character.fill_mode) {
+ switch (pgls->g.character.fill_mode) {
- case hpgl_char_solid_edge: /* fall through */
- case hpgl_char_edge:
+ case hpgl_char_solid_edge: /* fall through */
+ case hpgl_char_edge:
set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
- break;
-
- case hpgl_char_fill:
- case hpgl_char_fill_edge:
- if ( (pgls->g.fill.type == hpgl_FT_pattern_one_line) ||
- (pgls->g.fill.type == hpgl_FT_pattern_two_lines) ) {
- hpgl_call(hpgl_polyfill_using_current_line_type( pgls,
- render_mode
- ) );
- return 0;
- } else
- goto fill;
-
- default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
- return 0;
- }
- break;
-
- /* fill like a polygon */
+ break;
+
+ case hpgl_char_fill:
+ case hpgl_char_fill_edge:
+ if ( (pgls->g.fill.type == hpgl_FT_pattern_one_line) ||
+ (pgls->g.fill.type == hpgl_FT_pattern_two_lines) ) {
+ hpgl_call(hpgl_polyfill_using_current_line_type( pgls,
+ render_mode
+ ) );
+ return 0;
+ } else
+ goto fill;
+
+ default:
+ dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ return 0;
+ }
+ break;
+
+ /* fill like a polygon */
case hpgl_rm_polygon:
fill:
- /* pixel placement mode is only relevant to polygon fills */
+ /* pixel placement mode is only relevant to polygon fills */
pixel_placement_mode = pgls->pp_mode;
set_proc = pcl_pattern_get_proc_FT(pgls->g.fill.type);
- switch (pgls->g.fill.type) {
+ switch (pgls->g.fill.type) {
- case hpgl_FT_pattern_solid_pen1:
- case hpgl_FT_pattern_solid_pen2:
- /*
+ case hpgl_FT_pattern_solid_pen1:
+ case hpgl_FT_pattern_solid_pen2:
+ /*
* this is documented incorrectly PCLTRM 22-12 says
* these should be solid black but they are actually
* set to the value of the current pen - (i.e pen 0 is
* solid white
*/
- code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
- break;
+ code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
+ break;
case hpgl_FT_pattern_one_line:
- case hpgl_FT_pattern_two_lines:
- set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
+ case hpgl_FT_pattern_two_lines:
+ set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
- break;
+ break;
- case hpgl_FT_pattern_cross_hatch:
+ case hpgl_FT_pattern_cross_hatch:
code = set_proc( pgls,
pgls->g.fill.param.pattern_type,
hpgl_get_selected_pen(pgls)
);
- break;
+ break;
- case hpgl_FT_pattern_shading:
+ case hpgl_FT_pattern_shading:
code = set_proc( pgls,
pgls->g.fill.param.shading,
hpgl_get_selected_pen(pgls)
);
- break;
+ break;
- case hpgl_FT_pattern_user_defined:
+ case hpgl_FT_pattern_user_defined:
code = set_proc( pgls,
pgls->g.fill.param.pattern_id,
hpgl_get_selected_pen(pgls)
);
break;
- case hpgl_FT_pattern_RF:
- /* pcl5e does not care about the current pen it always uses black (1). */
- if ( pgls->personality == pcl5e )
- code = set_proc( pgls,
- -pgls->g.fill.param.user_defined.pattern_index,
- 1 );
- else
- code = set_proc( pgls,
+ case hpgl_FT_pattern_RF:
+ /* pcl5e does not care about the current pen it always uses black (1). */
+ if ( pgls->personality == pcl5e )
+ code = set_proc( pgls,
+ -pgls->g.fill.param.user_defined.pattern_index,
+ 1 );
+ else
+ code = set_proc( pgls,
(pgls->g.fill.param.user_defined.use_current_pen
? -pgls->g.fill.param.user_defined.pattern_index
: pgls->g.fill.param.user_defined.pattern_index),
hpgl_get_selected_pen(pgls)
- );
+ );
break;
- default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
- break;
- }
- break;
+ default:
+ dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ break;
+ }
+ break;
case hpgl_rm_vector:
case hpgl_rm_vector_fill:
set_proc = pcl_pattern_get_proc_SV(pgls->g.screen.type);
- switch(pgls->g.screen.type) {
+ switch(pgls->g.screen.type) {
- case hpgl_SV_pattern_solid_pen:
- code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
- break;
+ case hpgl_SV_pattern_solid_pen:
+ code = set_proc(pgls, hpgl_get_selected_pen(pgls), false);
+ break;
- case hpgl_SV_pattern_shade:
+ case hpgl_SV_pattern_shade:
code = set_proc( pgls,
pgls->g.screen.param.shading,
hpgl_get_selected_pen(pgls)
);
- break;
+ break;
case hpgl_SV_pattern_cross_hatch:
code = set_proc( pgls,
pgls->g.screen.param.pattern_type,
hpgl_get_selected_pen(pgls)
);
- break;
+ break;
case hpgl_SV_pattern_RF:
code = set_proc( pgls,
@@ -1036,22 +1031,22 @@ fill:
);
break;
- case hpgl_SV_pattern_user_defined:
+ case hpgl_SV_pattern_user_defined:
code = set_proc( pgls,
pgls->g.screen.param.pattern_id,
hpgl_get_selected_pen(pgls)
);
break;
- default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
- break;
- }
- break;
+ default:
+ dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ break;
+ }
+ break;
default:
- dprintf("hpgl_set_drawing_color: internal error illegal mode\n");
- break;
+ dprintf("hpgl_set_drawing_color: internal error illegal mode\n");
+ break;
}
if (code >= 0) {
@@ -1117,7 +1112,7 @@ hpgl_add_point_to_path(
hpgl_plot_function_t func,
bool set_ctm
)
-{
+{
static int (*const gs_procs[])(gs_state *, floatp, floatp)
= { hpgl_plot_function_procedures };
@@ -1127,41 +1122,41 @@ hpgl_add_point_to_path(
is moot - so we set it to false. */
pgls->g.subpolygon_started = false;
if (gx_path_is_null(gx_current_path(pgls->pgs))) {
- /* Start a new GL/2 path. */
- gs_point current_pt;
-
- if (set_ctm)
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(gs_newpath(pgls->pgs));
-
- /* moveto the current position */
- hpgl_call(hpgl_get_current_position(pgls, &current_pt));
- hpgl_call_check_lost( gs_moveto( pgls->pgs,
- current_pt.x,
- current_pt.y
- ) );
+ /* Start a new GL/2 path. */
+ gs_point current_pt;
+
+ if (set_ctm)
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(gs_newpath(pgls->pgs));
+
+ /* moveto the current position */
+ hpgl_call(hpgl_get_current_position(pgls, &current_pt));
+ hpgl_call_check_lost( gs_moveto( pgls->pgs,
+ current_pt.x,
+ current_pt.y
+ ) );
}
{
int code = (*gs_procs[func])(pgls->pgs, x, y);
- if (code < 0) {
- if (code == gs_error_limitcheck)
- hpgl_set_lost_mode(pgls, hpgl_lost_mode_entered);
- } else {
+ if (code < 0) {
+ if (code == gs_error_limitcheck)
+ hpgl_set_lost_mode(pgls, hpgl_lost_mode_entered);
+ } else {
gs_point point;
- if (hpgl_plot_is_absolute(func))
- hpgl_set_lost_mode(pgls, hpgl_lost_mode_cleared);
-
- /* update hpgl's state position */
- if (hpgl_plot_is_absolute(func)) {
- point.x = x;
- point.y = y;
- } else {
- hpgl_call(hpgl_get_current_position(pgls, &point));
- point.x += x; point.y += y;
- }
- hpgl_call(hpgl_set_current_position(pgls, &point));
- }
+ if (hpgl_plot_is_absolute(func))
+ hpgl_set_lost_mode(pgls, hpgl_lost_mode_cleared);
+
+ /* update hpgl's state position */
+ if (hpgl_plot_is_absolute(func)) {
+ point.x = x;
+ point.y = y;
+ } else {
+ hpgl_call(hpgl_get_current_position(pgls, &point));
+ point.x += x; point.y += y;
+ }
+ hpgl_call(hpgl_set_current_position(pgls, &point));
+ }
}
return 0;
}
@@ -1170,35 +1165,35 @@ hpgl_add_point_to_path(
int
hpgl_clear_current_path(hpgl_state_t *pgls)
{
- hpgl_call(gs_newpath(pgls->pgs));
- return 0;
+ hpgl_call(gs_newpath(pgls->pgs));
+ return 0;
}
/* closes the current path, making the first point and last point coincident */
int
hpgl_close_current_path(hpgl_state_t *pgls)
{
- hpgl_call(gs_closepath(pgls->pgs));
- return 0;
+ hpgl_call(gs_closepath(pgls->pgs));
+ return 0;
}
/* converts pcl coordinate to device space and back to hpgl space */
int
hpgl_add_pcl_point_to_path(hpgl_state_t *pgls, const gs_point *pcl_pt)
{
- gs_point dev_pt, hpgl_pt;
-
- hpgl_call(hpgl_clear_current_path(pgls));
- pcl_set_ctm(pgls, true);
- hpgl_call(gs_transform(pgls->pgs, pcl_pt->x, pcl_pt->y, &dev_pt));
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &hpgl_pt));
- hpgl_call(hpgl_add_point_to_path(pgls, hpgl_pt.x, hpgl_pt.y,
- hpgl_plot_move_absolute, true));
- return 0;
+ gs_point dev_pt, hpgl_pt;
+
+ hpgl_call(hpgl_clear_current_path(pgls));
+ pcl_set_ctm(pgls, true);
+ hpgl_call(gs_transform(pgls->pgs, pcl_pt->x, pcl_pt->y, &dev_pt));
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &hpgl_pt));
+ hpgl_call(hpgl_add_point_to_path(pgls, hpgl_pt.x, hpgl_pt.y,
+ hpgl_plot_move_absolute, true));
+ return 0;
}
-static floatp
+static floatp
compute_chord_angle(floatp chord_angle)
{
floatp ca = fmod(chord_angle, 360);
@@ -1213,22 +1208,22 @@ compute_chord_angle(floatp chord_angle)
}
return ca;
}
-
+
int
hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
- floatp radius, floatp start_angle, floatp sweep_angle,
- floatp chord_angle, bool start_moveto, hpgl_plot_function_t draw,
- bool set_ctm)
+ floatp radius, floatp start_angle, floatp sweep_angle,
+ floatp chord_angle, bool start_moveto, hpgl_plot_function_t draw,
+ bool set_ctm)
{
floatp num_chordsf = sweep_angle / compute_chord_angle(chord_angle);
int num_chords = (int)(num_chordsf >= 0.0 ? ceil(num_chordsf) : floor(num_chordsf));
floatp integral_chord_angle = fabs(sweep_angle / num_chords);
int i;
floatp arccoord_x, arccoord_y;
-
+
if ( hpgl_plot_is_draw(draw) )
pgls->g.have_drawn_in_path = true;
-
+
(void)hpgl_compute_arc_coords(radius, center_x, center_y,
start_angle,
&arccoord_x, &arccoord_y);
@@ -1239,7 +1234,7 @@ hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
for ( i = 0; i < abs(num_chords); i++ ) {
if (sweep_angle > 0)
- start_angle += integral_chord_angle;
+ start_angle += integral_chord_angle;
else
start_angle -= integral_chord_angle;
hpgl_compute_arc_coords(radius, center_x, center_y,
@@ -1250,7 +1245,7 @@ hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
}
/* NB this is suspicious - why not any +- multiple of 360 if this
is correct at all. */
- if (sweep_angle - 360.0 > -0.0001)
+ if (sweep_angle - 360.0 > -0.0001)
hpgl_call(hpgl_close_current_path(pgls));
return 0;
}
@@ -1258,108 +1253,108 @@ hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
/* add a 3 point arc to the path */
int
hpgl_add_arc_3point_to_path(hpgl_state_t *pgls, floatp start_x, floatp
- start_y, floatp inter_x, floatp inter_y,
- floatp end_x, floatp end_y, floatp chord_angle,
- hpgl_plot_function_t draw)
+ start_y, floatp inter_x, floatp inter_y,
+ floatp end_x, floatp end_y, floatp chord_angle,
+ hpgl_plot_function_t draw)
{
- /* handle unusual cases as per pcltrm */
- if ( hpgl_3_same_points(start_x, start_y,
- inter_x, inter_y,
- end_x, end_y) )
- {
- hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
- return 0;
- }
- if ( hpgl_3_no_intermediate(start_x, start_y,
- inter_x, inter_y,
- end_x, end_y) )
- {
- hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
- hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_y, draw, true));
- return 0;
- }
- if ( hpgl_3_same_endpoints(start_x, start_y,
- inter_x, y_inter,
- end_x, end_y) )
- {
- hpgl_call(hpgl_add_arc_to_path(pgls, (start_x + inter_x) / 2.0,
- (start_y + inter_y) / 2.0,
- (hypot((inter_x - start_x),
- (inter_y - start_y)) / 2.0),
- 0.0, 360.0, chord_angle, false,
- draw, true));
- return 0;
- }
-
- if ( hpgl_3_colinear_points(start_x, start_y, inter_x, inter_y, end_x, end_y) )
- {
- if ( hpgl_3_intermediate_between(start_x, start_y,
- inter_x, inter_y,
- end_x, end_y) )
- {
- hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
- hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_x, draw, true));
- }
- else
- {
- hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
- hpgl_call(hpgl_add_point_to_path(pgls, inter_x, inter_y, draw, true));
- hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_y, draw, true));
- }
- return 0;
- }
-
- /* normal 3 point arc case */
- {
- hpgl_real_t center_x, center_y, radius;
- hpgl_real_t start_angle, inter_angle, end_angle;
- hpgl_real_t sweep_angle;
-
- hpgl_call(hpgl_compute_arc_center(start_x, start_y,
- inter_x, inter_y,
- end_x, end_y,
- &center_x, &center_y));
-
- radius = hypot(start_x - center_x, start_y - center_y);
- start_angle = radians_to_degrees *
- hpgl_compute_angle(start_x - center_x, start_y - center_y);
-
- inter_angle = radians_to_degrees *
- hpgl_compute_angle(inter_x - center_x, inter_y - center_y);
-
- end_angle = radians_to_degrees *
- hpgl_compute_angle(end_x - center_x, end_y - center_y);
- sweep_angle = end_angle - start_angle;
-
- /*
- * Figure out which direction to draw the arc, depending on the
- * relative position of start, inter, and end. Case analysis
- * shows that we should draw the arc counter-clockwise from S to
- * E iff exactly 2 of S<I, I<E, and E<S are true, and clockwise
- * if exactly 1 of these relations is true. (These are the only
- * possible cases if no 2 of the points coincide.)
- */
-
- if ( (start_angle < inter_angle) + (inter_angle < end_angle) +
- (end_angle < start_angle) == 1
- )
- {
- if ( sweep_angle > 0 )
- sweep_angle -= 360;
- }
- else
- {
- if ( sweep_angle < 0 )
- sweep_angle += 360;
- }
-
- hpgl_call(hpgl_add_arc_to_path(pgls, center_x, center_y,
- radius, start_angle, sweep_angle,
- (sweep_angle < 0.0 ) ?
- -chord_angle : chord_angle, false,
- draw, true));
- return 0;
- }
+ /* handle unusual cases as per pcltrm */
+ if ( hpgl_3_same_points(start_x, start_y,
+ inter_x, inter_y,
+ end_x, end_y) )
+ {
+ hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
+ return 0;
+ }
+ if ( hpgl_3_no_intermediate(start_x, start_y,
+ inter_x, inter_y,
+ end_x, end_y) )
+ {
+ hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_y, draw, true));
+ return 0;
+ }
+ if ( hpgl_3_same_endpoints(start_x, start_y,
+ inter_x, y_inter,
+ end_x, end_y) )
+ {
+ hpgl_call(hpgl_add_arc_to_path(pgls, (start_x + inter_x) / 2.0,
+ (start_y + inter_y) / 2.0,
+ (hypot((inter_x - start_x),
+ (inter_y - start_y)) / 2.0),
+ 0.0, 360.0, chord_angle, false,
+ draw, true));
+ return 0;
+ }
+
+ if ( hpgl_3_colinear_points(start_x, start_y, inter_x, inter_y, end_x, end_y) )
+ {
+ if ( hpgl_3_intermediate_between(start_x, start_y,
+ inter_x, inter_y,
+ end_x, end_y) )
+ {
+ hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_x, draw, true));
+ }
+ else
+ {
+ hpgl_call(hpgl_add_point_to_path(pgls, start_x, start_y, draw, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, inter_x, inter_y, draw, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, end_x, end_y, draw, true));
+ }
+ return 0;
+ }
+
+ /* normal 3 point arc case */
+ {
+ hpgl_real_t center_x, center_y, radius;
+ hpgl_real_t start_angle, inter_angle, end_angle;
+ hpgl_real_t sweep_angle;
+
+ hpgl_call(hpgl_compute_arc_center(start_x, start_y,
+ inter_x, inter_y,
+ end_x, end_y,
+ &center_x, &center_y));
+
+ radius = hypot(start_x - center_x, start_y - center_y);
+ start_angle = radians_to_degrees *
+ hpgl_compute_angle(start_x - center_x, start_y - center_y);
+
+ inter_angle = radians_to_degrees *
+ hpgl_compute_angle(inter_x - center_x, inter_y - center_y);
+
+ end_angle = radians_to_degrees *
+ hpgl_compute_angle(end_x - center_x, end_y - center_y);
+ sweep_angle = end_angle - start_angle;
+
+ /*
+ * Figure out which direction to draw the arc, depending on the
+ * relative position of start, inter, and end. Case analysis
+ * shows that we should draw the arc counter-clockwise from S to
+ * E iff exactly 2 of S<I, I<E, and E<S are true, and clockwise
+ * if exactly 1 of these relations is true. (These are the only
+ * possible cases if no 2 of the points coincide.)
+ */
+
+ if ( (start_angle < inter_angle) + (inter_angle < end_angle) +
+ (end_angle < start_angle) == 1
+ )
+ {
+ if ( sweep_angle > 0 )
+ sweep_angle -= 360;
+ }
+ else
+ {
+ if ( sweep_angle < 0 )
+ sweep_angle += 360;
+ }
+
+ hpgl_call(hpgl_add_arc_to_path(pgls, center_x, center_y,
+ radius, start_angle, sweep_angle,
+ (sweep_angle < 0.0 ) ?
+ -chord_angle : chord_angle, false,
+ draw, true));
+ return 0;
+ }
}
/* Bezier's are handled a bit differently than arcs as we use the
@@ -1368,24 +1363,24 @@ hpgl_add_arc_3point_to_path(hpgl_state_t *pgls, floatp start_x, floatp
int
hpgl_add_bezier_to_path(hpgl_state_t *pgls, floatp x1, floatp y1,
- floatp x2, floatp y2, floatp x3, floatp y3,
- floatp x4, floatp y4, hpgl_plot_function_t draw)
+ floatp x2, floatp y2, floatp x3, floatp y3,
+ floatp x4, floatp y4, hpgl_plot_function_t draw)
{
gx_path * ppath = gx_current_path(pgls->pgs);
/* Don't add superflous points in polygon mode */
- if ( ( !pgls->g.polygon_mode ) ||
- ( !ppath->current_subpath ) )
- hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
- draw ?
- hpgl_plot_draw_absolute :
- hpgl_plot_move_absolute, true));
+ if ( ( !pgls->g.polygon_mode ) ||
+ ( !ppath->current_subpath ) )
+ hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
+ draw ?
+ hpgl_plot_draw_absolute :
+ hpgl_plot_move_absolute, true));
if ( draw )
- hpgl_call(gs_curveto(pgls->pgs, x2, y2, x3, y3, x4, y4));
+ hpgl_call(gs_curveto(pgls->pgs, x2, y2, x3, y3, x4, y4));
/* update hpgl's state position to last point of the curve. */
{
- gs_point point;
- point.x = x4; point.y = y4;
- hpgl_call(hpgl_set_current_position(pgls, &point));
+ gs_point point;
+ point.x = x4; point.y = y4;
+ hpgl_call(hpgl_set_current_position(pgls, &point));
}
return 0;
}
@@ -1403,12 +1398,12 @@ hpgl_close_path(
gs_fixed_point first_device;
gx_path *ppath = gx_current_path(pgls->pgs);
if (!ppath->current_subpath)
- return 0;
+ return 0;
/* if we do not have a subpath there is nothing to do, get the
first points of the path in device space and convert to floats */
if ( gx_path_subpath_start_point(gx_current_path(pgls->pgs),
- &first_device) < 0 )
- return 0;
+ &first_device) < 0 )
+ return 0;
first.x = fixed2float(first_device.x);
first.y = fixed2float(first_device.y);
/* get gl/2 current position -- always current units */
@@ -1420,39 +1415,38 @@ hpgl_close_path(
* force gs to apply join and miter)
*/
if (equal(first.x, last.x) && equal(first.y, last.y))
- hpgl_call(gs_closepath(pgls->pgs));
+ hpgl_call(gs_closepath(pgls->pgs));
return 0;
}
-
/* To implement centered we move the points in the path to a pixel boundary.
Note this routine is sensitive to the orientation of the device.
Since rounding 0.5 is used here and 0.5 fill adjust this can fail to reduce and
- object in size by 1 pixel left/bottom for some user scale factors. This is not a
+ object in size by 1 pixel left/bottom for some user scale factors. This is not a
grave concern as the objects will still seam together. */
int
hpgl_set_special_pixel_placement(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
{
if ( pgls->pp_mode == 1 ) {
- gs_matrix default_matrix;
- gs_point distance, adjust;
- gx_path *ppath = gx_current_path(pgls->pgs);
- /* arbitrary just need the signs after transformation to
- device space */
- gs_setfilladjust(pgls->pgs, 0, 0);
- adjust.x = -1;
- adjust.y = -1;
- /* determine the adjustment in device space */
- hpgl_call(gs_defaultmatrix(pgls->pgs, &default_matrix));
- hpgl_call(gs_distance_transform(adjust.x, adjust.y, &default_matrix, &distance));
+ gs_matrix default_matrix;
+ gs_point distance, adjust;
+ gx_path *ppath = gx_current_path(pgls->pgs);
+ /* arbitrary just need the signs after transformation to
+ device space */
+ gs_setfilladjust(pgls->pgs, 0, 0);
+ adjust.x = -1;
+ adjust.y = -1;
+ /* determine the adjustment in device space */
+ hpgl_call(gs_defaultmatrix(pgls->pgs, &default_matrix));
+ hpgl_call(gs_distance_transform(adjust.x, adjust.y, &default_matrix, &distance));
/* modify the path but first it should be "unshared" so the
translation (next statement) does not update the polygon
buffer */
hpgl_call(gx_path_unshare(ppath));
- /* translate all points in the path by the adjustment. */
- hpgl_call(gx_path_translate(ppath,
+ /* translate all points in the path by the adjustment. */
+ hpgl_call(gx_path_translate(ppath,
float2fixed(distance.x / fabs(distance.x)),
float2fixed(distance.y / fabs(distance.y))));
}
@@ -1476,82 +1470,82 @@ hpgl_draw_current_path(
/* check if we have a current path - we don't need the current
point */
if (!ppath->current_subpath) {
- hpgl_call(hpgl_clear_current_path(pgls));
- return 0;
+ hpgl_call(hpgl_clear_current_path(pgls));
+ return 0;
}
if ( render_mode == hpgl_rm_vector_no_close )
- render_mode = hpgl_rm_vector;
- else
- hpgl_call(hpgl_close_path(pgls));
+ render_mode = hpgl_rm_vector;
+ else
+ hpgl_call(hpgl_close_path(pgls));
hpgl_call(hpgl_set_drawing_state(pgls, render_mode));
switch (render_mode) {
case hpgl_rm_character:
- {
- /* HAS need to set attributes in set_drawing color (next 2) */
-
- /* Intellifonts require eofill, but TrueType require fill. */
- /****** HACK: look at the scaling technology of ******/
- /****** the current font to decide. ******/
- int (*fill)(gs_state *);
-
- if (pgls->g.font->scaling_technology == plfst_Intellifont)
- fill = gs_eofill;
- else
- fill = gs_fill;
-
- switch (pgls->g.character.fill_mode) {
-
- case hpgl_char_solid_edge:
+ {
+ /* HAS need to set attributes in set_drawing color (next 2) */
+
+ /* Intellifonts require eofill, but TrueType require fill. */
+ /****** HACK: look at the scaling technology of ******/
+ /****** the current font to decide. ******/
+ int (*fill)(gs_state *);
+
+ if (pgls->g.font->scaling_technology == plfst_Intellifont)
+ fill = gs_eofill;
+ else
+ fill = gs_fill;
+
+ switch (pgls->g.character.fill_mode) {
+
+ case hpgl_char_solid_edge:
set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
if ((code = set_proc(pgls, hpgl_get_selected_pen(pgls), false)) < 0)
return code;
- hpgl_call((*fill)(pgs));
- /* falls through */
+ hpgl_call((*fill)(pgs));
+ /* falls through */
- case hpgl_char_edge:
- if (pgls->g.bitmap_fonts_allowed)
- break; /* no edging */
+ case hpgl_char_edge:
+ if (pgls->g.bitmap_fonts_allowed)
+ break; /* no edging */
set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
if ((code = set_proc(pgls, hpgl_get_character_edge_pen(pgls), false)) < 0)
return code;
- hpgl_call(hpgl_set_plu_ctm(pgls));
+ hpgl_call(hpgl_set_plu_ctm(pgls));
{
gs_point scale = hpgl_current_char_scale(pgls);
/* NB fix and comment */
hpgl_call(gs_setlinewidth(pgls->pgs, min(scale.x, scale.y) * 0.0375 * 0.2835));
}
pcl_mark_page_for_path(pgls);
- hpgl_call(gs_stroke(pgls->pgs));
- break;
+ hpgl_call(gs_stroke(pgls->pgs));
+ break;
- case hpgl_char_fill:
- /* the fill has already been done if the fill type is
+ case hpgl_char_fill:
+ /* the fill has already been done if the fill type is
hpgl/2 vector fills. This was handled when we set
the drawing color */
- if ((pgls->g.fill.type != hpgl_FT_pattern_one_line) &&
- (pgls->g.fill.type != hpgl_FT_pattern_two_lines))
- hpgl_call((*fill)(pgs));
- else
- hpgl_call(hpgl_clear_current_path(pgls));
- break;
- case hpgl_char_fill_edge:
- /* the fill has already been done if the fill type is
+ if ((pgls->g.fill.type != hpgl_FT_pattern_one_line) &&
+ (pgls->g.fill.type != hpgl_FT_pattern_two_lines))
+ hpgl_call((*fill)(pgs));
+ else
+ hpgl_call(hpgl_clear_current_path(pgls));
+ break;
+ case hpgl_char_fill_edge:
+ /* the fill has already been done if the fill type is
hpgl/2 vector fills. This was handled when we set
the drawing color. gsave to preserve the path for
subsequent edging */
- if ((pgls->g.fill.type != hpgl_FT_pattern_one_line) &&
- (pgls->g.fill.type != hpgl_FT_pattern_two_lines)) {
- hpgl_call(hpgl_gsave(pgls));
- /* all character fills appear to have 0 fill adjustment */
- gs_setfilladjust(pgls->pgs, 0, 0);
- hpgl_call((*fill)(pgs));
- hpgl_call(hpgl_grestore(pgls));
- }
+ if ((pgls->g.fill.type != hpgl_FT_pattern_one_line) &&
+ (pgls->g.fill.type != hpgl_FT_pattern_two_lines)) {
+ hpgl_call(hpgl_gsave(pgls));
+ /* all character fills appear to have 0 fill adjustment */
+ gs_setfilladjust(pgls->pgs, 0, 0);
+ hpgl_call((*fill)(pgs));
+ hpgl_call(hpgl_grestore(pgls));
+ }
if (pgls->g.bitmap_fonts_allowed) /* no edging */
- hpgl_call(hpgl_clear_current_path(pgls));
+ hpgl_call(hpgl_clear_current_path(pgls));
else {
set_proc = pcl_pattern_get_proc_FT(hpgl_FT_pattern_solid_pen1);
if ((code = set_proc(pgls, hpgl_get_character_edge_pen(pgls), false)) < 0)
@@ -1564,61 +1558,61 @@ hpgl_draw_current_path(
pgls->g.font_selection[pgls->g.font_selected].params.height_4ths * 0.0375));
hpgl_call(gs_stroke(pgls->pgs));
}
- break;
-
- }
- break;
- }
- break;
+ break;
+
+ }
+ break;
+ }
+ break;
case hpgl_rm_polygon:
- hpgl_set_special_pixel_placement(pgls, hpgl_rm_polygon);
+ hpgl_set_special_pixel_placement(pgls, hpgl_rm_polygon);
pcl_mark_page_for_path(pgls);
- if (pgls->g.fill_type == hpgl_even_odd_rule)
- hpgl_call(gs_eofill(pgs));
- else /* hpgl_winding_number_rule */
- hpgl_call(gs_fill(pgs));
- break;
+ if (pgls->g.fill_type == hpgl_even_odd_rule)
+ hpgl_call(gs_eofill(pgs));
+ else /* hpgl_winding_number_rule */
+ hpgl_call(gs_fill(pgs));
+ break;
case hpgl_rm_clip_and_fill_polygon:
- /*
- * A bizarre HPISM - If the pen is white we do a solid
+ /*
+ * A bizarre HPISM - If the pen is white we do a solid
* white fill this is true for *all* fill types (arg!) as
* tested on the 6mp. If pen 1 (black)
* hpgl_set_drawing_color() handles this case by drawing
* the lines that comprise the vector fill
*/
- if (hpgl_get_selected_pen(pgls) == 0) {
+ if (hpgl_get_selected_pen(pgls) == 0) {
pcl_mark_page_for_path(pgls);
- hpgl_call(gs_fill(pgls->pgs));
+ hpgl_call(gs_fill(pgls->pgs));
}
- hpgl_call(hpgl_clear_current_path(pgls));
- break;
+ hpgl_call(hpgl_clear_current_path(pgls));
+ break;
case hpgl_rm_vector:
case hpgl_rm_vector_fill:
- /*
- * we reset the ctm before stroking to preserve the line width
+ /*
+ * we reset the ctm before stroking to preserve the line width
* information, then restore the ctm.
*/
- {
- gs_matrix save_ctm;
- int save_scaling_type = pgls->g.scaling_type;
-
- hpgl_call(gs_currentmatrix(pgs, &save_ctm));
-
- /* force no picture frame scaling */
- pgls->g.scaling_type = hpgl_scaling_point_factor;
- hpgl_call(hpgl_set_plu_ctm(pgls));
- pgls->g.scaling_type = save_scaling_type;
-
- /* NB: what does reversing the path do? Currently DEAD code see pglfill.c */
- if ( !pgls->g.line.current.is_solid && (pgls->g.line.current.type == 0) )
- hpgl_call(gs_reversepath(pgls->pgs));
+ {
+ gs_matrix save_ctm;
+ int save_scaling_type = pgls->g.scaling_type;
+
+ hpgl_call(gs_currentmatrix(pgs, &save_ctm));
+
+ /* force no picture frame scaling */
+ pgls->g.scaling_type = hpgl_scaling_point_factor;
+ hpgl_call(hpgl_set_plu_ctm(pgls));
+ pgls->g.scaling_type = save_scaling_type;
+
+ /* NB: what does reversing the path do? Currently DEAD code see pglfill.c */
+ if ( !pgls->g.line.current.is_solid && (pgls->g.line.current.type == 0) )
+ hpgl_call(gs_reversepath(pgls->pgs));
pcl_mark_page_for_path(pgls);
- hpgl_call(gs_stroke(pgls->pgs));
- gs_setmatrix(pgs, &save_ctm);
- break;
- }
+ hpgl_call(gs_stroke(pgls->pgs));
+ gs_setmatrix(pgs, &save_ctm);
+ break;
+ }
default :
dprintf("unknown render mode\n");
}
diff --git a/pcl/pgdraw.h b/pcl/pgdraw.h
index ff4e7112e..dc5e1a383 100644
--- a/pcl/pgdraw.h
+++ b/pcl/pgdraw.h
@@ -22,7 +22,7 @@ int hpgl_set_plu_ctm(hpgl_state_t *pgls);
/* compute the scaling transformation from plu to user units */
int hpgl_compute_user_units_to_plu_ctm(const hpgl_state_t *pgls,
- gs_matrix *pmat);
+ gs_matrix *pmat);
/* The following 2 functions can be used together to calculate a ctm
without picture frame scaling. */
@@ -57,7 +57,7 @@ int hpgl_set_current_position(hpgl_state_t *pgls, gs_point *pt);
/* puts a point into the path using the operation specified by func */
int hpgl_add_point_to_path(hpgl_state_t *pgls, floatp x, floatp y,
- hpgl_plot_function_t func, bool set_ctm);
+ hpgl_plot_function_t func, bool set_ctm);
/* puts an arc into the current path. start moveto indicates that we
use moveto to go from the arc center to arc circumference. */
@@ -71,9 +71,9 @@ int hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x,
decomposition is a bit different for 3 point arcs since the polygon
wedge routines use this function as well */
int hpgl_add_arc_3point_to_path(hpgl_state_t *pgls, floatp start_x, floatp
- start_y, floatp inter_x, floatp inter_y,
- floatp end_x, floatp end_y, floatp chord_angle,
- hpgl_plot_function_t draw);
+ start_y, floatp inter_x, floatp inter_y,
+ floatp end_x, floatp end_y, floatp chord_angle,
+ hpgl_plot_function_t draw);
int hpgl_close_path(hpgl_state_t *pgls);
@@ -85,7 +85,7 @@ int hpgl_add_bezier_to_path(hpgl_state_t *pgls, floatp x1,
/* clears the current path with stroke or fill */
int hpgl_draw_current_path(hpgl_state_t *pgls,
- hpgl_rendering_mode_t render_mode);
+ hpgl_rendering_mode_t render_mode);
/* save/restore gs graphics state + HPGL/2's first moveto state */
#define hpgl_gsave(pgls) pcl_gsave(pgls)
@@ -98,7 +98,7 @@ int hpgl_copy_current_path_to_polygon_buffer(hpgl_state_t *pgls);
/* draw the current path with stroke or fill, but do not clear */
int hpgl_draw_and_preserve_path(hpgl_state_t *pgls,
- hpgl_rendering_mode_t render_mode);
+ hpgl_rendering_mode_t render_mode);
/* destroy the current path */
int hpgl_clear_current_path(hpgl_state_t *pgls);
diff --git a/pcl/pgfdata.c b/pcl/pgfdata.c
index 69ba3c7f6..983e910d8 100644
--- a/pcl/pgfdata.c
+++ b/pcl/pgfdata.c
@@ -23,7 +23,6 @@
#include "gxarith.h" /* for any_abs */
#include "pgfdata.h"
-
/* Font data consists of instructions for each character.
Fonts are on a 1024x1024 grid. */
@@ -5055,29 +5054,29 @@ hpgl_stick_segments(const gs_memory_t *mem, void *data, uint char_index)
/* set up tables debending on stick or arc font */
int i;
- if ( (char_index < 0x20) ||
- (char_index > 0xff) ||
- ((char_index > 0x7f) && (char_index < 0xa0)) )
- return 0; /* no glyph */
+ if ( (char_index < 0x20) ||
+ (char_index > 0xff) ||
+ ((char_index > 0x7f) && (char_index < 0xa0)) )
+ return 0; /* no glyph */
/* all entries have 3 short entries */
i = offset;
while ( i < stop ) {
- if ( stick_font_data[i] == FNT_LINETO ) {
- gs_lineto(data, (floatp)(stick_font_data[i+1]), (floatp)(stick_font_data[i+2]));
- i += 3;
- }
- else if ( stick_font_data[i] == FNT_MOVETO ) {
- gs_moveto(data, (floatp)(stick_font_data[i+1]), (floatp)(stick_font_data[i+2]));
- i += 3;
- }
- else
- return_error(gs_error_invalidfont);
+ if ( stick_font_data[i] == FNT_LINETO ) {
+ gs_lineto(data, (floatp)(stick_font_data[i+1]), (floatp)(stick_font_data[i+2]));
+ i += 3;
+ }
+ else if ( stick_font_data[i] == FNT_MOVETO ) {
+ gs_moveto(data, (floatp)(stick_font_data[i+1]), (floatp)(stick_font_data[i+2]));
+ i += 3;
+ }
+ else
+ return_error(gs_error_invalidfont);
}
/* table must be corrupt if the loop didn't stop at stop */
if ( i != stop )
- return_error(gs_error_invalidfont);
+ return_error(gs_error_invalidfont);
return 0;
}
@@ -5098,37 +5097,37 @@ hpgl_arc_segments(const gs_memory_t *mem, void *data, uint char_index)
int i;
/* 3 entries for moveto and lineto and 5 for curveto */
- if ( (char_index < 0x20) ||
- (char_index > 0xff) ||
- ((char_index > 0x7f) && (char_index < 0xa0)) )
- return 0; /* no glyph */
+ if ( (char_index < 0x20) ||
+ (char_index > 0xff) ||
+ ((char_index > 0x7f) && (char_index < 0xa0)) )
+ return 0; /* no glyph */
i = offset;
while ( i < stop ) {
- if ( arc_font_data[i] == FNT_LINETO ) {
- gs_lineto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]));
- i += 3;
- }
- else if ( arc_font_data[i] == FNT_MOVETO ) {
- gs_moveto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]));
- i += 3;
- }
- else if ( arc_font_data[i] == FNT_CURVETO ) {
- gs_curveto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]),
- (floatp)(arc_font_data[i+3]), (floatp)(arc_font_data[i+4]),
- (floatp)(arc_font_data[i+5]), (floatp)(arc_font_data[i+6]));
- i += 7;
- }
- else
- return_error(gs_error_invalidfont);
+ if ( arc_font_data[i] == FNT_LINETO ) {
+ gs_lineto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]));
+ i += 3;
+ }
+ else if ( arc_font_data[i] == FNT_MOVETO ) {
+ gs_moveto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]));
+ i += 3;
+ }
+ else if ( arc_font_data[i] == FNT_CURVETO ) {
+ gs_curveto(data, (floatp)(arc_font_data[i+1]), (floatp)(arc_font_data[i+2]),
+ (floatp)(arc_font_data[i+3]), (floatp)(arc_font_data[i+4]),
+ (floatp)(arc_font_data[i+5]), (floatp)(arc_font_data[i+6]));
+ i += 7;
+ }
+ else
+ return_error(gs_error_invalidfont);
}
/* table must be corrupt if the loop didn't stop at stop */
if ( i != stop )
- return_error(gs_error_invalidfont);
+ return_error(gs_error_invalidfont);
return 0;
}
-
+
static int
hpgl_stick_width(uint char_index)
{
@@ -5139,28 +5138,28 @@ hpgl_stick_width(uint char_index)
/* Get the unscaled width of a stick/arc character. */
static int
hpgl_arc_width(uint char_index)
-{
+{
if ( char_index < 0x20 || (char_index < 0xa0 && char_index > 0x7f))
- return arc_font_widths[0];
+ return arc_font_widths[0];
return arc_font_widths[char_index - 0x20];
}
/* interface procedure render the characters */
-int
+int
hpgl_stick_arc_segments(const gs_memory_t *mem,
- void *data, uint char_index, hpgl_font_type_t font_type)
+ void *data, uint char_index, hpgl_font_type_t font_type)
{
if ( font_type == HPGL_ARC_FONT )
- return hpgl_arc_segments(mem, data, char_index);
+ return hpgl_arc_segments(mem, data, char_index);
else
- return hpgl_stick_segments(mem, data, char_index);
+ return hpgl_stick_segments(mem, data, char_index);
}
/* interface procedure to get the width of the characters */
int hpgl_stick_arc_width(uint char_index, hpgl_font_type_t font_type)
{
if ( font_type == HPGL_ARC_FONT )
- return hpgl_arc_width(char_index);
+ return hpgl_arc_width(char_index);
else
- return hpgl_stick_width(char_index);
-}
+ return hpgl_stick_width(char_index);
+}
diff --git a/pcl/pgfdata.h b/pcl/pgfdata.h
index ba224858e..a849bc7b7 100644
--- a/pcl/pgfdata.h
+++ b/pcl/pgfdata.h
@@ -22,7 +22,7 @@ typedef enum {
/* Enumerate the segments of a stick/arc character. */
int hpgl_stick_arc_segments(const gs_memory_t *mem,
- void *data, uint char_index, hpgl_font_type_t font_type);
+ void *data, uint char_index, hpgl_font_type_t font_type);
/* Get the unscaled width of a stick/arc character. */
int hpgl_stick_arc_width(uint char_index, hpgl_font_type_t font_type);
diff --git a/pcl/pgfont.c b/pcl/pgfont.c
index 0f0ca0c6d..a8f71d4f1 100644
--- a/pcl/pgfont.c
+++ b/pcl/pgfont.c
@@ -30,15 +30,13 @@
#include "pgfdata.h"
#include "pgfont.h"
-
-
/* The client always asks for a Unicode indexed chr.
* The stick/arc fonts themselves use Roman-8 (8U) indexing.
*/
extern const pl_symbol_map_t map_8U_unicode;
static gs_glyph
hpgl_stick_arc_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t not_used)
-{
+{
int i;
/* reverse map unicode back to roman 8 */
for (i = 0; i < countof(map_8U_unicode.codes); i++) {
@@ -48,20 +46,20 @@ hpgl_stick_arc_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t not_use
return (gs_glyph)0xffff;
}
-/* The stick font is fixed-pitch.
+/* The stick font is fixed-pitch.
*/
static int
hpgl_stick_char_width(const pl_font_t *plfont, const void *pgs, uint uni_code, gs_point *pwidth)
-{
+{
/* first map uni_code to roman-8 */
uni_code = (uint) hpgl_stick_arc_encode_char(NULL, uni_code, 0);
/* NB need an interface function call to verify the character exists */
if ( (uni_code >= 0x20) && (uni_code <= 0xff) )
- pwidth->x = hpgl_stick_arc_width(uni_code, HPGL_STICK_FONT);
+ pwidth->x = hpgl_stick_arc_width(uni_code, HPGL_STICK_FONT);
else
- /* doesn't exist */
- return 1;
+ /* doesn't exist */
+ return 1;
return 0;
}
@@ -76,28 +74,28 @@ hpgl_stick_char_metrics(const pl_font_t *plfont, const void *pgs, uint uni_code,
metrics[0] = 0;
/* just get the width */
if ( (hpgl_stick_char_width(plfont, pgs, uni_code, &width)) == 1 )
- /* doesn't exist */
- return 1;
+ /* doesn't exist */
+ return 1;
metrics[2] = width.x;
return 0;
-}
+}
/* The arc font is proportionally spaced. */
static int
hpgl_arc_char_width(const pl_font_t *plfont, const void *pgs, uint uni_code, gs_point *pwidth)
-{
+{
/* first map uni_code to roman-8 */
uni_code = (uint) hpgl_stick_arc_encode_char(NULL, uni_code, 0);
/* NB need an interface function call to verify the character exists */
if ( (uni_code >= 0x20) && (uni_code <= 0xff) ) {
pwidth->x = hpgl_stick_arc_width(uni_code, HPGL_ARC_FONT)
- / 1024.0 /* convert to ratio of cell size to be multiplied by point size */
- * 0.667; /* TRM 23-18 cell is 2/3 of point size */
- }
+ / 1024.0 /* convert to ratio of cell size to be multiplied by point size */
+ * 0.667; /* TRM 23-18 cell is 2/3 of point size */
+ }
else
- /* doesn't exist */
- return 1;
+ /* doesn't exist */
+ return 1;
return 0;
}
@@ -111,17 +109,17 @@ hpgl_arc_char_metrics(const pl_font_t *plfont, const void *pgs, uint uni_code, f
metrics[0] = 0;
/* just get the width */
if ( (hpgl_arc_char_width(plfont, pgs, uni_code, &width)) == 1 )
- /* doesn't exist */
- return 1;
+ /* doesn't exist */
+ return 1;
metrics[2] = width.x;
return 0;
-}
+}
/* Add a symbol to the path. */
static int
hpgl_stick_arc_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
gs_glyph uni_code, hpgl_font_type_t font_type)
-{
+{
int width;
gs_matrix save_ctm;
int code;
@@ -140,14 +138,14 @@ hpgl_stick_arc_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
gs_moveto(pgs, 0.0, 0.0);
code = hpgl_stick_arc_segments(pfont->memory, (void *)pgs, uni_code, font_type);
if ( code < 0 )
- return code;
+ return code;
gs_setdefaultmatrix(pgs, NULL);
gs_initmatrix(pgs);
/* Set predictable join and cap styles. */
gs_setlinejoin(pgs, gs_join_round);
gs_setmiterlimit(pgs, 2.61); /* start beveling at 45 degrees */
gs_setlinecap(pgs, gs_cap_round);
- {
+ {
float pattern[1];
gs_setdash(pgs, pattern, 0, 0);
}
@@ -159,55 +157,55 @@ hpgl_stick_arc_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
static int
hpgl_stick_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
gs_char ignore_chr, gs_glyph uni_code)
-{
+{
return hpgl_stick_arc_build_char(penum, pgs, pfont, uni_code, HPGL_STICK_FONT);
}
static int
hpgl_arc_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
gs_char ignore_chr, gs_glyph uni_code)
{ return hpgl_stick_arc_build_char(penum, pgs, pfont, uni_code, HPGL_ARC_FONT);
-
+
}
/* Fill in stick/arc font boilerplate. */
static void
hpgl_fill_in_stick_arc_font(gs_font_base *pfont, long unique_id)
{ /* The way the code is written requires FontMatrix = identity. */
- gs_make_identity(&pfont->FontMatrix);
- pfont->FontType = ft_user_defined;
- pfont->PaintType = 1; /* stroked fonts */
- pfont->BitmapWidths = false;
- pfont->ExactSize = fbit_use_outlines;
- pfont->InBetweenSize = fbit_use_outlines;
- pfont->TransformedChar = fbit_use_outlines;
- pfont->procs.encode_char = hpgl_stick_arc_encode_char; /* FIX ME (void *) */
- /* p.y of the FontBBox is a guess, because of descenders. */
- /* Because of descenders, we have no real idea what the */
- /* FontBBox should be. */
- pfont->FontBBox.p.x = 0;
- pfont->FontBBox.p.y = -0.333;
- pfont->FontBBox.q.x = 0.667;
- pfont->FontBBox.q.y = 0.667;
- uid_set_UniqueID(&pfont->UID, unique_id);
- pfont->encoding_index = 1; /****** WRONG ******/
- pfont->nearest_encoding_index = 1; /****** WRONG ******/
+ gs_make_identity(&pfont->FontMatrix);
+ pfont->FontType = ft_user_defined;
+ pfont->PaintType = 1; /* stroked fonts */
+ pfont->BitmapWidths = false;
+ pfont->ExactSize = fbit_use_outlines;
+ pfont->InBetweenSize = fbit_use_outlines;
+ pfont->TransformedChar = fbit_use_outlines;
+ pfont->procs.encode_char = hpgl_stick_arc_encode_char; /* FIX ME (void *) */
+ /* p.y of the FontBBox is a guess, because of descenders. */
+ /* Because of descenders, we have no real idea what the */
+ /* FontBBox should be. */
+ pfont->FontBBox.p.x = 0;
+ pfont->FontBBox.p.y = -0.333;
+ pfont->FontBBox.q.x = 0.667;
+ pfont->FontBBox.q.y = 0.667;
+ uid_set_UniqueID(&pfont->UID, unique_id);
+ pfont->encoding_index = 1; /****** WRONG ******/
+ pfont->nearest_encoding_index = 1; /****** WRONG ******/
}
void
hpgl_fill_in_stick_font(gs_font_base *pfont, long unique_id)
{ hpgl_fill_in_stick_arc_font(pfont, unique_id);
#define plfont ((pl_font_t *)pfont->client_data)
- pfont->procs.build_char = hpgl_stick_build_char; /* FIX ME (void *) */
- plfont->char_width = hpgl_stick_char_width;
- plfont->char_metrics = hpgl_stick_char_metrics;
+ pfont->procs.build_char = hpgl_stick_build_char; /* FIX ME (void *) */
+ plfont->char_width = hpgl_stick_char_width;
+ plfont->char_metrics = hpgl_stick_char_metrics;
#undef plfont
}
void
hpgl_fill_in_arc_font(gs_font_base *pfont, long unique_id)
{ hpgl_fill_in_stick_arc_font(pfont, unique_id);
#define plfont ((pl_font_t *)pfont->client_data)
- pfont->procs.build_char = hpgl_arc_build_char; /* FIX ME (void *) */
- plfont->char_width = hpgl_arc_char_width;
- plfont->char_metrics = hpgl_arc_char_metrics;
+ pfont->procs.build_char = hpgl_arc_build_char; /* FIX ME (void *) */
+ plfont->char_width = hpgl_arc_char_width;
+ plfont->char_metrics = hpgl_arc_char_metrics;
#undef plfont
}
@@ -215,13 +213,13 @@ void
hpgl_initialize_stick_fonts( hpgl_state_t *pcs )
{
pcs->g.stick_font[0][0].pfont =
- pcs->g.stick_font[0][1].pfont =
- pcs->g.stick_font[1][0].pfont =
- pcs->g.stick_font[1][1].pfont = 0;
+ pcs->g.stick_font[0][1].pfont =
+ pcs->g.stick_font[1][0].pfont =
+ pcs->g.stick_font[1][1].pfont = 0;
/* NB most of the pl_font structure is uninitialized! */
pcs->g.stick_font[0][0].font_file =
- pcs->g.stick_font[0][1].font_file =
- pcs->g.stick_font[1][0].font_file =
- pcs->g.stick_font[1][1].font_file = 0;
+ pcs->g.stick_font[0][1].font_file =
+ pcs->g.stick_font[1][0].font_file =
+ pcs->g.stick_font[1][1].font_file = 0;
}
diff --git a/pcl/pgframe.c b/pcl/pgframe.c
index f39d88f05..87127e99c 100644
--- a/pcl/pgframe.c
+++ b/pcl/pgframe.c
@@ -20,7 +20,7 @@
#include "gstypes.h" /* for gsstate.h */
#include "gsmatrix.h" /* for gsstate.h */
#include "gsmemory.h" /* for gsstate.h */
-#include "gsstate.h"
+#include "gsstate.h"
#include "pcdraw.h"
#include "pcfont.h" /* for pcl_continue_underline */
#include "pcstate.h"
@@ -51,58 +51,57 @@ pcl_set_picture_frame_side_effects(pcl_state_t *pcs)
/* default P1 and P2 */
hpgl_args_setup(&args);
hpgl_IP(&args, pcs);
-
+
/* default the clipping window */
hpgl_args_setup(&args);
hpgl_IW(&args, pcs);
-
+
/* clear the polygon buffer */
hpgl_args_set_int(&args,0);
hpgl_PM(&args, pcs);
-
+
hpgl_args_set_int(&args,2);
hpgl_PM(&args, pcs);
/* NB according to spec should move pen to P1. */
return 0;
}
-
-int /* ESC * c <w_dp> X */
+int /* ESC * c <w_dp> X */
pcl_horiz_pic_frame_size_decipoints(pcl_args_t *pargs, pcl_state_t *pcs)
{
- coord size = (coord)(float_arg(pargs) * 10.0); /* --> centipoints */
-
- if ( size == 0 )
- size = pcs->xfm_state.lp_size.x;
- if ( size != pcs->g.picture_frame_width ) {
- pcs->g.picture_frame_width = size;
- pcl_set_picture_frame_side_effects(pcs);
- }
- return 0;
+ coord size = (coord)(float_arg(pargs) * 10.0); /* --> centipoints */
+
+ if ( size == 0 )
+ size = pcs->xfm_state.lp_size.x;
+ if ( size != pcs->g.picture_frame_width ) {
+ pcs->g.picture_frame_width = size;
+ pcl_set_picture_frame_side_effects(pcs);
+ }
+ return 0;
}
-int /* ESC * c <h_dp> Y */
+int /* ESC * c <h_dp> Y */
pcl_vert_pic_frame_size_decipoints(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
coord size = (coord)(float_arg(pargs) * 10.0); /* --> centipoints */
-
+
/* default to pcl logical page */
if ( size == 0 ) {
- size = pcs->xfm_state.lp_size.y;
- if ( pcs->personality != rtl )
- size -= inch2coord(1.0);
+ size = pcs->xfm_state.lp_size.y;
+ if ( pcs->personality != rtl )
+ size -= inch2coord(1.0);
}
if ( size != pcs->g.picture_frame_height ) {
- pcs->g.picture_frame_height = size;
- pcl_set_picture_frame_side_effects(pcs);
+ pcs->g.picture_frame_height = size;
+ pcl_set_picture_frame_side_effects(pcs);
}
return 0;
}
/*
* ESC * c 0 T
- */
+ */
int
pcl_set_pic_frame_anchor_point(
pcl_args_t * pargs,
@@ -120,43 +119,43 @@ pcl_set_pic_frame_anchor_point(
tmp_pt.y = pcs->cap.y;
pcl_xfm_to_logical_page_space(pcs, &tmp_pt);
if ( ( tmp_pt.x != pcs->g.picture_frame.anchor_point.x ) ||
- ( tmp_pt.y != pcs->g.picture_frame.anchor_point.y ) ) {
- pcs->g.picture_frame.anchor_point.x = tmp_pt.x;
- pcs->g.picture_frame.anchor_point.y = tmp_pt.y;
- pcl_set_picture_frame_side_effects(pcs);
+ ( tmp_pt.y != pcs->g.picture_frame.anchor_point.y ) ) {
+ pcs->g.picture_frame.anchor_point.x = tmp_pt.x;
+ pcs->g.picture_frame.anchor_point.y = tmp_pt.y;
+ pcl_set_picture_frame_side_effects(pcs);
}
return 0;
}
-int /* ESC * c <w_in> K */
+int /* ESC * c <w_in> K */
pcl_hpgl_plot_horiz_size(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
/* convert to centipoints as to match the picture frame */
float size = float_arg(pargs) * 7200.0;
-
+
if ( (coord)size == 0 ) {
- size = pcs->g.picture_frame_width;
- pcs->g.plot_size_horizontal_specified = false;
+ size = pcs->g.picture_frame_width;
+ pcs->g.plot_size_horizontal_specified = false;
}
else
- pcs->g.plot_size_horizontal_specified = true;
+ pcs->g.plot_size_horizontal_specified = true;
pcs->g.plot_width = (coord)size;
pcl_set_picture_frame_side_effects(pcs);
return 0;
}
-int /* ESC * c <h_in> L */
+int /* ESC * c <h_in> L */
pcl_hpgl_plot_vert_size(pcl_args_t *pargs, pcl_state_t *pcs)
-{
+{
/* convert to centipoints as to match the picture frame */
float size = float_arg(pargs) * 7200.0;
if ( (coord)size == 0 ) {
- size = pcs->g.picture_frame_height;
- pcs->g.plot_size_vertical_specified = false;
+ size = pcs->g.picture_frame_height;
+ pcs->g.plot_size_vertical_specified = false;
}
else
- pcs->g.plot_size_vertical_specified = true;
+ pcs->g.plot_size_vertical_specified = true;
pcs->g.plot_height = (coord)size;
pcl_set_picture_frame_side_effects(pcs);
return 0;
@@ -164,22 +163,22 @@ pcl_hpgl_plot_vert_size(pcl_args_t *pargs, pcl_state_t *pcs)
/* We redefine this command so we can draw the current GL path */
/* and, if appropriate, reset the underline bookkeeping. */
-static int /* ESC % <enum> A */
+static int /* ESC % <enum> A */
pcl_enter_pcl_mode(pcl_args_t *pargs, pcl_state_t *pcs)
{ int code;
- hpgl_call_mem(pcs->memory, hpgl_draw_current_path(pcs, hpgl_rm_vector));
- code = rtl_enter_pcl_mode(pargs, pcs);
- switch ( code )
- {
- default: /* error */
- return code;
- case 1: /* CAP changed */
- pcl_continue_underline(pcs);
- case 0: /* CAP not changed */
- break;
- }
- return 0;
+ hpgl_call_mem(pcs->memory, hpgl_draw_current_path(pcs, hpgl_rm_vector));
+ code = rtl_enter_pcl_mode(pargs, pcs);
+ switch ( code )
+ {
+ default: /* error */
+ return code;
+ case 1: /* CAP changed */
+ pcl_continue_underline(pcs);
+ case 0: /* CAP not changed */
+ break;
+ }
+ return 0;
}
/* Initialization */
@@ -189,35 +188,35 @@ pgframe_do_registration(
gs_memory_t *mem
)
{ /* Register commands */
- DEFINE_CLASS('*')
- {'c', 'X',
- PCL_COMMAND("Horizontal Picture Frame Size Decipoints",
- pcl_horiz_pic_frame_size_decipoints,
- pca_neg_error|pca_big_error)},
- {'c', 'Y',
- PCL_COMMAND("Vertical Picture Frame Size Decipoints",
- pcl_vert_pic_frame_size_decipoints,
- pca_neg_error|pca_big_error)},
- {'c', 'T',
- PCL_COMMAND("Set Picture Frame Anchor Point",
- pcl_set_pic_frame_anchor_point,
- pca_neg_error|pca_big_error)},
- {'c', 'K',
- PCL_COMMAND("HP-GL/2 Plot Horizontal Size",
- pcl_hpgl_plot_horiz_size,
- pca_neg_error|pca_big_error)},
- {'c', 'L',
- PCL_COMMAND("HP-GL/2 Plot Vertical Size",
- pcl_hpgl_plot_vert_size,
- pca_neg_error|pca_big_error)},
- END_CLASS
- DEFINE_CLASS('%')
- {0, 'A',
- PCL_COMMAND("Enter PCL Mode",
- pcl_enter_pcl_mode,
- pca_neg_ok|pca_big_ok|pca_in_rtl)},
- END_CLASS
- return 0;
+ DEFINE_CLASS('*')
+ {'c', 'X',
+ PCL_COMMAND("Horizontal Picture Frame Size Decipoints",
+ pcl_horiz_pic_frame_size_decipoints,
+ pca_neg_error|pca_big_error)},
+ {'c', 'Y',
+ PCL_COMMAND("Vertical Picture Frame Size Decipoints",
+ pcl_vert_pic_frame_size_decipoints,
+ pca_neg_error|pca_big_error)},
+ {'c', 'T',
+ PCL_COMMAND("Set Picture Frame Anchor Point",
+ pcl_set_pic_frame_anchor_point,
+ pca_neg_error|pca_big_error)},
+ {'c', 'K',
+ PCL_COMMAND("HP-GL/2 Plot Horizontal Size",
+ pcl_hpgl_plot_horiz_size,
+ pca_neg_error|pca_big_error)},
+ {'c', 'L',
+ PCL_COMMAND("HP-GL/2 Plot Vertical Size",
+ pcl_hpgl_plot_vert_size,
+ pca_neg_error|pca_big_error)},
+ END_CLASS
+ DEFINE_CLASS('%')
+ {0, 'A',
+ PCL_COMMAND("Enter PCL Mode",
+ pcl_enter_pcl_mode,
+ pca_neg_ok|pca_big_ok|pca_in_rtl)},
+ END_CLASS
+ return 0;
}
const pcl_init_t pgframe_init = {
pgframe_do_registration, 0
diff --git a/pcl/pggeom.c b/pcl/pggeom.c
index e804388bb..ead8daf16 100644
--- a/pcl/pggeom.c
+++ b/pcl/pggeom.c
@@ -26,85 +26,85 @@
floatp
hpgl_compute_angle(floatp dx, floatp dy)
{
- floatp alpha = atan2(dy, dx);
+ floatp alpha = atan2(dy, dx);
- return (alpha < 0 ? alpha + M_PI * 2.0 : alpha);
+ return (alpha < 0 ? alpha + M_PI * 2.0 : alpha);
}
/* compute the center of an arc given 3 points on the arc */
int
hpgl_compute_arc_center(floatp x1, floatp y1, floatp x2, floatp y2,
- floatp x3, floatp y3, floatp *pcx, floatp *pcy)
+ floatp x3, floatp y3, floatp *pcx, floatp *pcy)
{
- floatp px2, py2, dx2, dy2, px3, py3, dx3, dy3;
- double denom, t2;
-
- /*
- * The center is the intersection of the perpendicular bisectors
- * of the 3 chords. Any two will do for the computation.
- * (For greatest numerical stability, we should probably choose
- * the two outside chords, but this is a refinement that we will
- * leave for the future.)
- * We define each bisector by a line with the equations
- * xi = pxi + ti * dxi
- * yi = pyi + ti * dyi
- * where i is 2 or 3.
- */
+ floatp px2, py2, dx2, dy2, px3, py3, dx3, dy3;
+ double denom, t2;
+
+ /*
+ * The center is the intersection of the perpendicular bisectors
+ * of the 3 chords. Any two will do for the computation.
+ * (For greatest numerical stability, we should probably choose
+ * the two outside chords, but this is a refinement that we will
+ * leave for the future.)
+ * We define each bisector by a line with the equations
+ * xi = pxi + ti * dxi
+ * yi = pyi + ti * dyi
+ * where i is 2 or 3.
+ */
#define compute_bisector(px, py, dx, dy, xa, ya, xb, yb)\
(px = (xa + xb) / 2, py = (ya + yb) / 2,\
dx = (ya - yb), dy = (xb - xa) /* 90 degree rotation (either way is OK) */)
- compute_bisector(px2, py2, dx2, dy2, x1, y1, x2, y2);
- compute_bisector(px3, py3, dx3, dy3, x1, y1, x3, y3);
+ compute_bisector(px2, py2, dx2, dy2, x1, y1, x2, y2);
+ compute_bisector(px3, py3, dx3, dy3, x1, y1, x3, y3);
#undef compute_bisector
- /*
- * Now find the intersections by solving for t2 or t3:
- * px2 + t2 * dx2 = px3 + t3 * dx3
- * py2 + t2 * dy2 = py3 + t3 * dy3
- * i.e., in standard form,
- * t2 * dx2 - t3 * dx3 = px3 - px2
- * t2 * dy2 - t3 * dy3 = py3 - py2
- * The solution of
- * a*x + b*y = c
- * d*x + e*y = f
- * is
- * denom = a*e - b*d
- * x = (c*e - b*f) / denom
- * y = (a*f - c*d) / denom
- */
- denom = dx3 * dy2 - dx2 * dy3;
- if ( fabs(denom) < 1.0e-6 )
- return -1; /* degenerate */
-
- t2 = ((px3 - px2) * (-dy3) - (-dx3) * (py3 - py2)) / denom;
- *pcx = px2 + t2 * dx2;
- *pcy = py2 + t2 * dy2;
- return 0;
+ /*
+ * Now find the intersections by solving for t2 or t3:
+ * px2 + t2 * dx2 = px3 + t3 * dx3
+ * py2 + t2 * dy2 = py3 + t3 * dy3
+ * i.e., in standard form,
+ * t2 * dx2 - t3 * dx3 = px3 - px2
+ * t2 * dy2 - t3 * dy3 = py3 - py2
+ * The solution of
+ * a*x + b*y = c
+ * d*x + e*y = f
+ * is
+ * denom = a*e - b*d
+ * x = (c*e - b*f) / denom
+ * y = (a*f - c*d) / denom
+ */
+ denom = dx3 * dy2 - dx2 * dy3;
+ if ( fabs(denom) < 1.0e-6 )
+ return -1; /* degenerate */
+
+ t2 = ((px3 - px2) * (-dy3) - (-dx3) * (py3 - py2)) / denom;
+ *pcx = px2 + t2 * dx2;
+ *pcy = py2 + t2 * dy2;
+ return 0;
}
/* compute the coordinates of a point on an arc */
int
hpgl_compute_arc_coords(floatp radius, floatp center_x, floatp center_y,
- floatp angle, floatp *px, floatp *py)
+ floatp angle, floatp *px, floatp *py)
{
- gs_sincos_t sincos;
- gs_sincos_degrees(angle, &sincos);
- *px = radius * sincos.cos + center_x;
- *py = radius * sincos.sin + center_y;
- return 0;
+ gs_sincos_t sincos;
+ gs_sincos_degrees(angle, &sincos);
+ *px = radius * sincos.cos + center_x;
+ *py = radius * sincos.sin + center_y;
+ return 0;
}
/* given a start point, angle (degrees) and magnitude of a vector compute its
endpoints */
int
hpgl_compute_vector_endpoints(floatp magnitude, floatp x, floatp y,
- floatp angle_degrees, floatp *endx, floatp *endy)
+ floatp angle_degrees, floatp *endx, floatp *endy)
{
- return hpgl_compute_arc_coords(magnitude, x, y,
- angle_degrees, endx, endy);
+ return hpgl_compute_arc_coords(magnitude, x, y,
+ angle_degrees, endx, endy);
}
diff --git a/pcl/pggeom.h b/pcl/pggeom.h
index be8d4532e..9d8f79a81 100644
--- a/pcl/pggeom.h
+++ b/pcl/pggeom.h
@@ -43,19 +43,19 @@ floatp hpgl_compute_angle(floatp dx, floatp dy);
/* compute the center of an arc given 3 points on the arc */
int hpgl_compute_arc_center(floatp x1, floatp y1, floatp x2,
- floatp y2, floatp x3, floatp y3,
- floatp *pcx, floatp *pcy);
+ floatp y2, floatp x3, floatp y3,
+ floatp *pcx, floatp *pcy);
/* compute the coordinates of a point on an arc */
int hpgl_compute_arc_coords(floatp radius, floatp center_x,
- floatp center_y, floatp angle,
- floatp *px, floatp *py);
+ floatp center_y, floatp angle,
+ floatp *px, floatp *py);
/* given a start point, angle (degrees) and magnitude of a vector compute its
endpoints */
int hpgl_compute_vector_endpoints(floatp magnitude, floatp x, floatp y,
- floatp angle_degrees, floatp *endx,
- floatp *endy);
+ floatp angle_degrees, floatp *endx,
+ floatp *endy);
/* ------ 3-point arcs ------ */
@@ -68,15 +68,15 @@ int hpgl_compute_vector_endpoints(floatp magnitude, floatp x, floatp y,
/* points are equal. HAS -- TEST for epsilon */
#define hpgl_3_same_points(x1, y1, x2, y2, x3, y3) \
- ((equal2((x1), (x2), (x2), (x3))) && (equal2((y1), (y2), (y2), (y3))))
+ ((equal2((x1), (x2), (x2), (x3))) && (equal2((y1), (y2), (y2), (y3))))
/* points are on the same line */
#define hpgl_3_colinear_points(x1, y1, x2, y2, x3, y3) \
- (equal(((y1) - (y3)) * ((x1) - (x2)), ((y1) - (y2)) * ((x1) - (x3))))
+ (equal(((y1) - (y3)) * ((x1) - (x2)), ((y1) - (y2)) * ((x1) - (x3))))
/* intermediate is the same as first point or last */
#define hpgl_3_no_intermediate(x1, y1, x2, y2, x3, y3) \
- ((equal2((x1), (x2), (y1), (y2))) || (equal2((x2), (x3), (y2), (y3))))
+ ((equal2((x1), (x2), (y1), (y2))) || (equal2((x2), (x3), (y2), (y3))))
/* intermediate lies between endpoints */
#define hpgl_3_intermediate_between(x1, y1, x2, y2, x3, y3) \
@@ -85,5 +85,5 @@ int hpgl_compute_vector_endpoints(floatp magnitude, floatp x, floatp y,
/* equal endpoints */
#define hpgl_3_same_endpoints(x1, y1, x2, y2, x3, y3) \
- (equal2((x1), (x3), (y1), (y3)))
+ (equal2((x1), (x3), (y1), (y3)))
#endif /* pggeom_INCLUDED */
diff --git a/pcl/pglabel.c b/pcl/pglabel.c
index 3391e6cd0..25f059d78 100644
--- a/pcl/pglabel.c
+++ b/pcl/pglabel.c
@@ -70,12 +70,12 @@ hpgl_is_currentfont_stick(const hpgl_state_t *pgls)
/* convert points 2 plu - agfa uses 72.307 points per inch */
static floatp
hpgl_points_2_plu(const hpgl_state_t *pgls, floatp points)
-{
+{
const pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
+ &pgls->g.font_selection[pgls->g.font_selected];
floatp ppi = 72.0;
if ( pfs->font->scaling_technology == plfst_Intellifont )
- ppi = 72.307;
+ ppi = 72.307;
return points * (1016.0 / ppi);
}
@@ -90,11 +90,11 @@ hpgl_is_printable(
bool is_stick,
bool transparent
)
-{
+{
if (transparent)
return true;
if ( is_stick )
- return (chr >= ' ') && (chr <= 0xff);
+ return (chr >= ' ') && (chr <= 0xff);
if ((psm == 0) || (psm->type >= 2))
return true;
else if (psm->type == 1)
@@ -107,11 +107,11 @@ hpgl_is_printable(
*/
static gs_char
hpgl_map_symbol(uint chr, const hpgl_state_t *pgls)
-{
+{
const pcl_font_selection_t *pfs =
&pgls->g.font_selection[pgls->g.font_selected];
const pl_symbol_map_t *psm = pfs->map;
-
+
return pl_map_symbol(psm, chr,
pfs->font->storage == pcds_internal,
pfs->font->font_type == plgv_MSL,
@@ -126,8 +126,8 @@ hpgl_select_font_pri_alt(hpgl_state_t *pgls, int index)
{
if ( pgls->g.font_selected != index ) {
hpgl_free_stick_fonts(pgls);
- pgls->g.font_selected = index;
- pgls->g.font = 0;
+ pgls->g.font_selected = index;
+ pgls->g.font = 0;
}
return;
}
@@ -137,10 +137,10 @@ static int hpgl_recompute_font(hpgl_state_t *pgls);
/* Ensure a font is available. */
static int
-hpgl_ensure_font(hpgl_state_t *pgls)
+hpgl_ensure_font(hpgl_state_t *pgls)
{
if ( ( pgls->g.font == 0 ) || ( pgls->g.font->pfont == 0 ) )
- hpgl_call(hpgl_recompute_font(pgls));
+ hpgl_call(hpgl_recompute_font(pgls));
return 0;
}
@@ -159,16 +159,15 @@ static const byte stick_character_complement[8] = {
static int
hpgl_select_stick_font(hpgl_state_t *pgls)
{ pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
- pl_font_t *font = &pgls->g.stick_font[pgls->g.font_selected]
- [pfs->params.proportional_spacing];
+ &pgls->g.font_selection[pgls->g.font_selected];
+ pl_font_t *font = &pgls->g.stick_font[pgls->g.font_selected]
+ [pfs->params.proportional_spacing];
gs_font_base *pfont;
int code;
- /* Create a gs_font if none has been created yet. */
+ /* Create a gs_font if none has been created yet. */
hpgl_free_stick_fonts(pgls);
- pfont = gs_alloc_struct(pgls->memory, gs_font_base, &st_gs_font_base,
- "stick/arc font");
-
+ pfont = gs_alloc_struct(pgls->memory, gs_font_base, &st_gs_font_base,
+ "stick/arc font");
if ( pfont == 0 )
return_error(e_Memory);
@@ -184,37 +183,37 @@ hpgl_select_stick_font(hpgl_state_t *pgls)
font->scaling_technology = plfst_TrueType;/****** WRONG ******/
font->font_type = plft_Unicode;
memcpy(font->character_complement, stick_character_complement, 8);
- /*
- * The stick/arc font is protean: set its proportional spacing,
- * style, and stroke weight parameters to the requested ones.
- * We could fill in some of the other characteristics earlier,
- * but it's simpler to do it here.
- */
- font->params = pfs->params;
- font->params.typeface_family = STICK_FONT_TYPEFACE;
- /*
- * The stick font is defined in a cell that's only 2/3
- * the size of the actual character.
- */
- pl_fp_set_pitch_cp(&font->params, 1000.0*2/3);
- pfs->font = font;
- {
- byte id[2];
-
- id[0] = pfs->params.symbol_set >> 8;
- id[1] = pfs->params.symbol_set & 0xff;
- pfs->map = pcl_find_symbol_map(pgls,
- id, plgv_Unicode,
+ /*
+ * The stick/arc font is protean: set its proportional spacing,
+ * style, and stroke weight parameters to the requested ones.
+ * We could fill in some of the other characteristics earlier,
+ * but it's simpler to do it here.
+ */
+ font->params = pfs->params;
+ font->params.typeface_family = STICK_FONT_TYPEFACE;
+ /*
+ * The stick font is defined in a cell that's only 2/3
+ * the size of the actual character.
+ */
+ pl_fp_set_pitch_cp(&font->params, 1000.0*2/3);
+ pfs->font = font;
+ {
+ byte id[2];
+
+ id[0] = pfs->params.symbol_set >> 8;
+ id[1] = pfs->params.symbol_set & 0xff;
+ pfs->map = pcl_find_symbol_map(pgls,
+ id, plgv_Unicode,
font->font_type == plft_16bit);
- }
- return 0;
+ }
+ return 0;
}
/* Check whether the stick font supports a given symbol set. */
static bool
hpgl_stick_font_supports(const pcl_state_t *pcs, uint symbol_set)
-{
- pl_glyph_vocabulary_t gv =
+{
+ pl_glyph_vocabulary_t gv =
pl_complement_to_vocab(stick_character_complement);
byte id[2];
pl_symbol_map_t *map;
@@ -231,45 +230,45 @@ hpgl_stick_font_supports(const pcl_state_t *pcs, uint symbol_set)
static int
hpgl_recompute_font(hpgl_state_t *pgls)
{ pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
-
- if (( ((pfs->params.typeface_family & 0xfff) == STICK_FONT_TYPEFACE ||
- (pfs->params.typeface_family & 0xfff) == ARC_FONT_TYPEFACE )
- && pfs->params.style == 0 /* upright */
- && hpgl_stick_font_supports(pgls,
- pfs->params.symbol_set))
- /* rtl only has stick fonts */
- || ( pgls->personality == rtl )
- )
- hpgl_call(hpgl_select_stick_font(pgls));
- else
+ &pgls->g.font_selection[pgls->g.font_selected];
+
+ if (( ((pfs->params.typeface_family & 0xfff) == STICK_FONT_TYPEFACE ||
+ (pfs->params.typeface_family & 0xfff) == ARC_FONT_TYPEFACE )
+ && pfs->params.style == 0 /* upright */
+ && hpgl_stick_font_supports(pgls,
+ pfs->params.symbol_set))
+ /* rtl only has stick fonts */
+ || ( pgls->personality == rtl )
+ )
+ hpgl_call(hpgl_select_stick_font(pgls));
+ else
{ int code = pcl_reselect_font(pfs, pgls, false);
- if ( code < 0 )
- return code;
- }
- pgls->g.font = pfs->font;
- pgls->g.map = pfs->map;
- return pl_load_resident_font_data_from_file(pgls->memory, pfs->font);
+ if ( code < 0 )
+ return code;
+ }
+ pgls->g.font = pfs->font;
+ pgls->g.map = pfs->map;
+ return pl_load_resident_font_data_from_file(pgls->memory, pfs->font);
}
/* ------ Position management ------ */
/* accessor for character extra space takes line feed direction into account */
static inline hpgl_real_t
-hpgl_get_character_extra_space_x(const hpgl_state_t *pgls)
+hpgl_get_character_extra_space_x(const hpgl_state_t *pgls)
{
- return (pgls->g.character.line_feed_direction < 0) ?
- pgls->g.character.extra_space.y :
- pgls->g.character.extra_space.x;
+ return (pgls->g.character.line_feed_direction < 0) ?
+ pgls->g.character.extra_space.y :
+ pgls->g.character.extra_space.x;
}
static inline hpgl_real_t
-hpgl_get_character_extra_space_y(const hpgl_state_t *pgls)
+hpgl_get_character_extra_space_y(const hpgl_state_t *pgls)
{
- return (pgls->g.character.line_feed_direction < 0) ?
- pgls->g.character.extra_space.x :
- pgls->g.character.extra_space.y;
+ return (pgls->g.character.line_feed_direction < 0) ?
+ pgls->g.character.extra_space.x :
+ pgls->g.character.extra_space.y;
}
/* Get a character width in the current font, plus extra space if any. */
@@ -279,12 +278,12 @@ hpgl_get_char_width(const hpgl_state_t *pgls, gs_char ch, hpgl_real_t *width)
{
gs_glyph glyph = hpgl_map_symbol(ch, pgls);
const pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
+ &pgls->g.font_selection[pgls->g.font_selected];
int code = 0;
gs_point gs_width;
if ( pgls->g.character.size_mode == hpgl_size_not_set ) {
- if ( pfs->params.proportional_spacing ) {
- code = pl_font_char_width(pfs->font, (void *)(pgls->pgs), glyph, &gs_width);
+ if ( pfs->params.proportional_spacing ) {
+ code = pl_font_char_width(pfs->font, (void *)(pgls->pgs), glyph, &gs_width);
/* hack until this code gets written properly, the
following should amount to a percentage of the
em-square the space character would occupy... */
@@ -292,47 +291,47 @@ hpgl_get_char_width(const hpgl_state_t *pgls, gs_char ch, hpgl_real_t *width)
gs_width.y = 0;
gs_width.x = pl_fp_pitch_cp(&pfs->font->params) / 1000.0;
}
-
- if ( !pl_font_is_scalable(pfs->font) ) {
- if ( code == 0 )
- *width = gs_width.x * inches_2_plu(1.0 / pfs->font->resolution.x);
- else
- *width = coord_2_plu(pl_fp_pitch_cp(&pfs->font->params));
- goto add;
- }
- else if ( code >= 0 ) {
- *width = gs_width.x * hpgl_points_2_plu(pgls, pfs->params.height_4ths / 4.0);
- goto add;
- }
- code = 1;
- }
- *width = hpgl_points_2_plu(pgls, pl_fp_pitch_cp(&pfs->params) / 100.0);
+
+ if ( !pl_font_is_scalable(pfs->font) ) {
+ if ( code == 0 )
+ *width = gs_width.x * inches_2_plu(1.0 / pfs->font->resolution.x);
+ else
+ *width = coord_2_plu(pl_fp_pitch_cp(&pfs->font->params));
+ goto add;
+ }
+ else if ( code >= 0 ) {
+ *width = gs_width.x * hpgl_points_2_plu(pgls, pfs->params.height_4ths / 4.0);
+ goto add;
+ }
+ code = 1;
+ }
+ *width = hpgl_points_2_plu(pgls, pl_fp_pitch_cp(&pfs->params) / 100.0);
} else {
- *width = pgls->g.character.size.x;
- if (pgls->g.character.size_mode == hpgl_size_relative)
- *width *= pgls->g.P2.x - pgls->g.P1.x;
+ *width = pgls->g.character.size.x;
+ if (pgls->g.character.size_mode == hpgl_size_relative)
+ *width *= pgls->g.P2.x - pgls->g.P1.x;
}
- add:
+ add:
if ( hpgl_get_character_extra_space_x(pgls) != 0 ) {
- /* Add extra space. */
- if ( pfs->params.proportional_spacing && ch != ' ' ) {
- /* Get the width of the space character. */
- int scode =
- pl_font_char_width(pfs->font, (void *)(pgls->pgs), hpgl_map_symbol(' ', pgls), &gs_width);
- hpgl_real_t extra;
-
- if ( scode >= 0 )
- extra = gs_width.x * hpgl_points_2_plu(pgls, pfs->params.height_4ths / 4.0);
- else
- extra = hpgl_points_2_plu(pgls, (pl_fp_pitch_cp(&pfs->params)) / 10.0);
- *width += extra * hpgl_get_character_extra_space_x(pgls);
- } else {
- /* All characters have the same width, */
- /* or we're already getting the width of a space. */
- *width *= 1.0 + hpgl_get_character_extra_space_x(pgls);
- }
+ /* Add extra space. */
+ if ( pfs->params.proportional_spacing && ch != ' ' ) {
+ /* Get the width of the space character. */
+ int scode =
+ pl_font_char_width(pfs->font, (void *)(pgls->pgs), hpgl_map_symbol(' ', pgls), &gs_width);
+ hpgl_real_t extra;
+
+ if ( scode >= 0 )
+ extra = gs_width.x * hpgl_points_2_plu(pgls, pfs->params.height_4ths / 4.0);
+ else
+ extra = hpgl_points_2_plu(pgls, (pl_fp_pitch_cp(&pfs->params)) / 10.0);
+ *width += extra * hpgl_get_character_extra_space_x(pgls);
+ } else {
+ /* All characters have the same width, */
+ /* or we're already getting the width of a space. */
+ *width *= 1.0 + hpgl_get_character_extra_space_x(pgls);
+ }
}
return code;
}
@@ -341,13 +340,13 @@ hpgl_get_char_width(const hpgl_state_t *pgls, gs_char ch, hpgl_real_t *width)
static int
hpgl_get_current_cell_height(const hpgl_state_t *pgls, hpgl_real_t *height)
{
- const pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
+ const pcl_font_selection_t *pfs =
+ &pgls->g.font_selection[pgls->g.font_selected];
if ( pfs->font->scaling_technology != plfst_bitmap ) {
gs_point scale = hpgl_current_char_scale(pgls);
*height = fabs(scale.y);
- } else {
+ } else {
/* NB temporary not correct */
*height = hpgl_points_2_plu(pgls, pfs->params.height_4ths / 4.0);
}
@@ -369,10 +368,9 @@ hpgl_get_current_cell_height(const hpgl_state_t *pgls, hpgl_real_t *height)
else
*height *= .898;
}
-
- *height *= 1.0 + hpgl_get_character_extra_space_y(pgls);
- return 0;
+ *height *= 1.0 + hpgl_get_character_extra_space_y(pgls);
+ return 0;
}
/* distance tranformation for character slant */
@@ -380,11 +378,11 @@ static int
hpgl_slant_transform_distance(hpgl_state_t *pgls, gs_point *dxy, gs_point *s_dxy)
{
if ( pgls->g.character.slant && !pgls->g.bitmap_fonts_allowed ) {
- gs_matrix smat;
- gs_point tmp_dxy = *dxy;
- gs_make_identity(&smat);
- smat.yx = pgls->g.character.slant;
- hpgl_call(gs_distance_transform(tmp_dxy.x, tmp_dxy.y, &smat, s_dxy));
+ gs_matrix smat;
+ gs_point tmp_dxy = *dxy;
+ gs_make_identity(&smat);
+ smat.yx = pgls->g.character.slant;
+ hpgl_call(gs_distance_transform(tmp_dxy.x, tmp_dxy.y, &smat, s_dxy));
}
return 0;
}
@@ -396,15 +394,15 @@ hpgl_rotation_transform_distance(hpgl_state_t *pgls, gs_point *dxy, gs_point *r_
double run = pgls->g.character.direction.x;
double rise = pgls->g.character.direction.y;
if ( rise != 0 ) {
- double denom = hypot(run, rise);
- gs_point tmp_dxy = *dxy;
- gs_matrix rmat;
- gs_make_identity(&rmat);
- rmat.xx = run / denom;
- rmat.xy = rise / denom;
- rmat.yx = -rmat.xy;
- rmat.yy = rmat.xx;
- hpgl_call(gs_distance_transform(tmp_dxy.x, tmp_dxy.y, &rmat, r_dxy));
+ double denom = hypot(run, rise);
+ gs_point tmp_dxy = *dxy;
+ gs_matrix rmat;
+ gs_make_identity(&rmat);
+ rmat.xx = run / denom;
+ rmat.xy = rise / denom;
+ rmat.yx = -rmat.xy;
+ rmat.yy = rmat.xx;
+ hpgl_call(gs_distance_transform(tmp_dxy.x, tmp_dxy.y, &rmat, r_dxy));
}
return 0;
}
@@ -424,28 +422,28 @@ hpgl_move_cursor_by_characters(hpgl_state_t *pgls, hpgl_real_t spaces,
lines *= pgls->g.character.line_feed_direction;
/* For vertical text paths, we have to swap spaces and lines. */
switch ( pgls->g.character.text_path )
- {
- case hpgl_text_right:
- nx = spaces, ny = lines; break;
- case hpgl_text_down:
- nx = lines, ny = -spaces; break;
- case hpgl_text_left:
- nx = -spaces, ny = -lines; break;
- case hpgl_text_up:
- nx = -lines, ny = spaces; break;
- }
+ {
+ case hpgl_text_right:
+ nx = spaces, ny = lines; break;
+ case hpgl_text_down:
+ nx = lines, ny = -spaces; break;
+ case hpgl_text_left:
+ nx = -spaces, ny = -lines; break;
+ case hpgl_text_up:
+ nx = -lines, ny = spaces; break;
+ }
/* calculate the next label position in relative coordinates. */
if ( nx != 0 ) {
- hpgl_real_t width;
- if ( pwidth != 0 )
- width = *pwidth;
- else
- hpgl_get_char_width(pgls, ' ', &width);
- dx = width * nx;
+ hpgl_real_t width;
+ if ( pwidth != 0 )
+ width = *pwidth;
+ else
+ hpgl_get_char_width(pgls, ' ', &width);
+ dx = width * nx;
}
if ( ny != 0 ) {
- hpgl_real_t height;
- hpgl_call(hpgl_get_current_cell_height(pgls, &height));
+ hpgl_real_t height;
+ hpgl_call(hpgl_get_current_cell_height(pgls, &height));
dy = ny * height;
}
@@ -456,31 +454,31 @@ hpgl_move_cursor_by_characters(hpgl_state_t *pgls, hpgl_real_t spaces,
* sizing, we have to convert the deltas to user units.
*/
if ( pgls->g.scaling_type != hpgl_scaling_none )
- {
- gs_matrix mat;
- gs_point user_dxy;
- hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &mat));
- hpgl_call(gs_distance_transform_inverse(dx, dy, &mat, &user_dxy));
- dx = user_dxy.x;
- dy = user_dxy.y;
- }
+ {
+ gs_matrix mat;
+ gs_point user_dxy;
+ hpgl_call(hpgl_compute_user_units_to_plu_ctm(pgls, &mat));
+ hpgl_call(gs_distance_transform_inverse(dx, dy, &mat, &user_dxy));
+ dx = user_dxy.x;
+ dy = user_dxy.y;
+ }
{
- gs_point dxy;
- dxy.x = dx;
- dxy.y = dy;
- hpgl_rotation_transform_distance(pgls, &dxy, &dxy);
- dx = dxy.x;
- dy = dxy.y;
+ gs_point dxy;
+ dxy.x = dx;
+ dxy.y = dy;
+ hpgl_rotation_transform_distance(pgls, &dxy, &dxy);
+ dx = dxy.x;
+ dy = dxy.y;
}
/* a relative move to the new position */
hpgl_call(hpgl_add_point_to_path(pgls, dx, dy,
- hpgl_plot_move_relative, true));
+ hpgl_plot_move_relative, true));
- if ( lines != 0 ) {
- /* update the position of the carriage return point */
- pgls->g.carriage_return_pos.x += dx;
- pgls->g.carriage_return_pos.y += dy;
+ if ( lines != 0 ) {
+ /* update the position of the carriage return point */
+ pgls->g.carriage_return_pos.x += dx;
+ pgls->g.carriage_return_pos.y += dy;
}
/* free any selected stick fonts */
hpgl_free_stick_fonts(pgls);
@@ -490,34 +488,34 @@ hpgl_move_cursor_by_characters(hpgl_state_t *pgls, hpgl_real_t spaces,
/* Execute a CR for CP or LB. */
static int
hpgl_do_CR(hpgl_state_t *pgls)
-{
+{
return hpgl_add_point_to_path(pgls, pgls->g.carriage_return_pos.x,
- pgls->g.carriage_return_pos.y,
- hpgl_plot_move_absolute,
- true);
+ pgls->g.carriage_return_pos.y,
+ hpgl_plot_move_absolute,
+ true);
}
/* CP [spaces,lines]; */
/* CP [;] */
int
hpgl_CP(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- hpgl_real_t spaces, lines;
-
- if ( hpgl_arg_c_real(pgls->memory, pargs, &spaces) )
- {
- if ( !hpgl_arg_c_real(pgls->memory, pargs, &lines) )
- return e_Range;
- }
- else
- {
- /* if there are no arguments a carriage return and line feed
- is executed */
- hpgl_call(hpgl_do_CR(pgls));
- spaces = 0, lines = -1;
- }
- return hpgl_move_cursor_by_characters(pgls, spaces, lines,
- (const hpgl_real_t *)0);
+{
+ hpgl_real_t spaces, lines;
+
+ if ( hpgl_arg_c_real(pgls->memory, pargs, &spaces) )
+ {
+ if ( !hpgl_arg_c_real(pgls->memory, pargs, &lines) )
+ return e_Range;
+ }
+ else
+ {
+ /* if there are no arguments a carriage return and line feed
+ is executed */
+ hpgl_call(hpgl_do_CR(pgls));
+ spaces = 0, lines = -1;
+ }
+ return hpgl_move_cursor_by_characters(pgls, spaces, lines,
+ (const hpgl_real_t *)0);
}
/* ------ Label buffer management ------ */
@@ -528,48 +526,48 @@ hpgl_CP(hpgl_args_t *pargs, hpgl_state_t *pgls)
static int
hpgl_init_label_buffer(hpgl_state_t *pgls)
{
- pgls->g.label.char_count = 0;
- pgls->g.label.buffer_size = hpgl_char_count;
- return ((pgls->g.label.buffer =
- gs_alloc_bytes(pgls->memory, hpgl_char_count,
- "hpgl_init_label_buffer")) == 0 ?
- e_Memory :
- 0);
+ pgls->g.label.char_count = 0;
+ pgls->g.label.buffer_size = hpgl_char_count;
+ return ((pgls->g.label.buffer =
+ gs_alloc_bytes(pgls->memory, hpgl_char_count,
+ "hpgl_init_label_buffer")) == 0 ?
+ e_Memory :
+ 0);
}
/* release the character buffer */
static int
hpgl_destroy_label_buffer(hpgl_state_t *pgls)
{
- gs_free_object(pgls->memory, pgls->g.label.buffer,
- "hpgl_destroy_label_buffer");
- pgls->g.label.char_count = 0;
- pgls->g.label.buffer_size = 0;
- pgls->g.label.buffer = 0;
- return 0;
+ gs_free_object(pgls->memory, pgls->g.label.buffer,
+ "hpgl_destroy_label_buffer");
+ pgls->g.label.char_count = 0;
+ pgls->g.label.buffer_size = 0;
+ pgls->g.label.buffer = 0;
+ return 0;
}
/* add a single character to the line buffer */
static int
hpgl_buffer_char(hpgl_state_t *pgls, byte ch)
{
- /* check if there is room for the new character and resize if
+ /* check if there is room for the new character and resize if
necessary */
- if ( pgls->g.label.buffer_size == pgls->g.label.char_count )
- { /* Resize the label buffer, currently by doubling its size. */
- uint new_size = pgls->g.label.buffer_size << 1;
- byte *new_mem =
- gs_resize_object(pgls->memory, pgls->g.label.buffer, new_size,
- "hpgl_resize_label_buffer");
-
- if ( new_mem == 0 )
- return_error(e_Memory);
- pgls->g.label.buffer = new_mem;
- pgls->g.label.buffer_size = new_size;
- }
- /* store the character */
- pgls->g.label.buffer[pgls->g.label.char_count++] = ch;
- return 0;
+ if ( pgls->g.label.buffer_size == pgls->g.label.char_count )
+ { /* Resize the label buffer, currently by doubling its size. */
+ uint new_size = pgls->g.label.buffer_size << 1;
+ byte *new_mem =
+ gs_resize_object(pgls->memory, pgls->g.label.buffer, new_size,
+ "hpgl_resize_label_buffer");
+
+ if ( new_mem == 0 )
+ return_error(e_Memory);
+ pgls->g.label.buffer = new_mem;
+ pgls->g.label.buffer_size = new_size;
+ }
+ /* store the character */
+ pgls->g.label.buffer[pgls->g.label.char_count++] = ch;
+ return 0;
}
/*
@@ -589,16 +587,16 @@ hpgl_use_show(hpgl_state_t *pgls, pl_font_t *pfont)
world */
if (pgls->g.source_transparent == 0 && pfont->scaling_technology != plfst_bitmap)
return false;
-
+
/* Show cannot be used if CF is not default since the character
may require additional processing by the line drawing code. */
if ( (pgls->g.character.fill_mode == 0 && pgls->g.character.edge_pen == 0) ||
(pfont->scaling_technology == plfst_bitmap) )
- return true;
+ return true;
else
- return false;
+ return false;
}
-
+
/* get the scaling factors for a gl/2 character */
gs_point
hpgl_current_char_scale(const hpgl_state_t *pgls)
@@ -609,7 +607,7 @@ hpgl_current_char_scale(const hpgl_state_t *pgls)
bool bitmaps_allowed = pgls->g.bitmap_fonts_allowed;
gs_point scale;
-
+
if (pgls->g.character.size_mode == hpgl_size_not_set || font->scaling_technology == plfst_bitmap) {
if (font->scaling_technology == plfst_bitmap) {
scale.x = inches_2_plu(1.0 / font->resolution.x);
@@ -646,7 +644,7 @@ hpgl_current_char_scale(const hpgl_state_t *pgls)
scale.y = pgls->g.character.size.y * 1.5;
if (pgls->g.character.size_mode == hpgl_size_relative)
scale.x *= pgls->g.P2.x - pgls->g.P1.x,
- scale.y *= pgls->g.P2.y - pgls->g.P1.y;
+ scale.y *= pgls->g.P2.y - pgls->g.P1.y;
if (bitmaps_allowed) /* no mirroring */
scale.x = fabs(scale.x), scale.y = fabs(scale.y);
}
@@ -664,7 +662,7 @@ hpgl_print_char(
{
int text_path = pgls->g.character.text_path;
const pcl_font_selection_t * pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
+ &pgls->g.font_selection[pgls->g.font_selected];
pl_font_t * font = pfs->font;
gs_state * pgs = pgls->pgs;
gs_matrix save_ctm;
@@ -677,7 +675,7 @@ hpgl_print_char(
hpgl_call( hpgl_add_point_to_path( pgls,
pgls->g.pos.x,
pgls->g.pos.y,
- hpgl_plot_move_absolute,
+ hpgl_plot_move_absolute,
true
) );
hpgl_call(gs_currentmatrix(pgs, &save_ctm));
@@ -690,17 +688,17 @@ hpgl_print_char(
/* ?? WRONG and UGLY */
{
float metrics[4];
- if ( (pl_font_char_metrics(font, (void *)(pgls->pgs),
+ if ( (pl_font_char_metrics(font, (void *)(pgls->pgs),
hpgl_map_symbol(ch, pgls), metrics)) == 1)
ch = ' ';
}
- /*
- * If we're using a stroked font, patch the pen width to reflect
- * the stroke weight. Note that when the font's build_char
- * procedure calls stroke, the CTM is still scaled.
- ****** WHAT IF scale.x != scale.y? ****** this should be unnecessary.
- */
+ /*
+ * If we're using a stroked font, patch the pen width to reflect
+ * the stroke weight. Note that when the font's build_char
+ * procedure calls stroke, the CTM is still scaled.
+ ****** WHAT IF scale.x != scale.y? ****** this should be unnecessary.
+ */
if (pfont->PaintType != 0) {
const float * widths = pcl_palette_get_pen_widths(pgls->ppalet);
@@ -718,7 +716,6 @@ hpgl_print_char(
gs_setlinewidth(pgs, nwidth * (72.0/1016.0));
}
-
/*
* We know that the drawing machinery only sets the CTM
* once, at the beginning of the path. We now impose the scale
@@ -731,153 +728,153 @@ hpgl_print_char(
bool use_show = hpgl_use_show(pgls, font);
gs_matrix pre_rmat, rmat, advance_mat;
int angle = -1; /* a multiple of 90 if used */
- gs_text_enum_t *penum;
+ gs_text_enum_t *penum;
byte str[2];
int code;
gs_point start_pt, end_pt;
- hpgl_real_t space_width;
- int space_code;
- hpgl_real_t width;
+ hpgl_real_t space_width;
+ int space_code;
+ hpgl_real_t width;
- /* Handle size. */
+ /* Handle size. */
- gs_scale(pgs, scale.x, scale.y);
- /* Handle rotation. */
- {
+ gs_scale(pgs, scale.x, scale.y);
+ /* Handle rotation. */
+ {
double run = pgls->g.character.direction.x,
- rise = pgls->g.character.direction.y;
+ rise = pgls->g.character.direction.y;
/* gl/2 bitmap fonts are scaled in a left handed coordinate
system - so the "rise" direction is opposite. */
if (font->scaling_technology == plfst_bitmap)
rise *= -1;
-
- if (pgls->g.character.direction_relative)
- run *= pgls->g.P2.x - pgls->g.P1.x,
- rise *= pgls->g.P2.y - pgls->g.P1.y;
- gs_make_identity(&rmat);
- if ((run < 0) || (rise != 0)) {
+
+ if (pgls->g.character.direction_relative)
+ run *= pgls->g.P2.x - pgls->g.P1.x,
+ rise *= pgls->g.P2.y - pgls->g.P1.y;
+ gs_make_identity(&rmat);
+ if ((run < 0) || (rise != 0)) {
double denom = hypot(run, rise);
- rmat.xx = run / denom;
- rmat.xy = rise / denom;
- rmat.yx = -rmat.xy;
- rmat.yy = rmat.xx;
- if ( bitmaps_allowed &&
- (run != 0) &&
+ rmat.xx = run / denom;
+ rmat.xy = rise / denom;
+ rmat.yx = -rmat.xy;
+ rmat.yy = rmat.xx;
+ if ( bitmaps_allowed &&
+ (run != 0) &&
(rise != 0) ) { /* not a multple of 90 degrees */
- /*
- * If bitmap fonts are allowed, rotate to the nearest
- * multiple of 90 degrees. We have to do something
- * special at the end to create the correct escapement.
- */
- gs_currentmatrix(pgs, &pre_rmat);
- if (run >= 0) {
- if (rise >= 0)
- angle = (run >= rise ? 0 : 90);
- else
- angle = (-rise >= run ? 270 : 0);
- } else {
- if (rise >= 0)
- angle = (rise >= -run ? 90 : 180);
- else
- angle = (-run >= -rise ? 180 : 270);
- }
- }
- gs_concat(pgs, &rmat);
- }
+ /*
+ * If bitmap fonts are allowed, rotate to the nearest
+ * multiple of 90 degrees. We have to do something
+ * special at the end to create the correct escapement.
+ */
+ gs_currentmatrix(pgs, &pre_rmat);
+ if (run >= 0) {
+ if (rise >= 0)
+ angle = (run >= rise ? 0 : 90);
+ else
+ angle = (-rise >= run ? 270 : 0);
+ } else {
+ if (rise >= 0)
+ angle = (rise >= -run ? 90 : 180);
+ else
+ angle = (-run >= -rise ? 180 : 270);
+ }
+ }
+ gs_concat(pgs, &rmat);
+ }
}
- /* Handle slant. */
- if (pgls->g.character.slant && !bitmaps_allowed) {
+ /* Handle slant. */
+ if (pgls->g.character.slant && !bitmaps_allowed) {
gs_matrix smat;
- gs_make_identity(&smat);
- smat.yx = pgls->g.character.slant;
- gs_concat(pgs, &smat);
- }
+ gs_make_identity(&smat);
+ smat.yx = pgls->g.character.slant;
+ gs_concat(pgs, &smat);
+ }
- gs_setfont(pgs, pfont);
+ gs_setfont(pgs, pfont);
pfont->FontMatrix = pfont->orig_FontMatrix;
- /*
- * Adjust the initial position of the character according to
- * the text path. And the left side bearing. It appears
- * HPGL/2 renders all characters without a left side bearing.
- */
- hpgl_call(gs_currentpoint(pgs, &start_pt));
- if (text_path == hpgl_text_left) {
+ /*
+ * Adjust the initial position of the character according to
+ * the text path. And the left side bearing. It appears
+ * HPGL/2 renders all characters without a left side bearing.
+ */
+ hpgl_call(gs_currentpoint(pgs, &start_pt));
+ if (text_path == hpgl_text_left) {
hpgl_get_char_width(pgls, ch, &width);
- start_pt.x -= width / scale.x;
- hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x, start_pt.y,
- hpgl_plot_move_absolute, false));
+ start_pt.x -= width / scale.x;
+ hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x, start_pt.y,
+ hpgl_plot_move_absolute, false));
- }
+ }
- /*
- * Reset the rotation if we're using a bitmap font.
- */
- gs_currentmatrix(pgs, &advance_mat);
- if (angle >= 0) {
+ /*
+ * Reset the rotation if we're using a bitmap font.
+ */
+ gs_currentmatrix(pgs, &advance_mat);
+ if (angle >= 0) {
gs_setmatrix(pgs, &pre_rmat);
- gs_rotate(pgs, (floatp)angle);
- }
+ gs_rotate(pgs, (floatp)angle);
+ }
- str[0] = ch;
- str[1] = 0;
+ str[0] = ch;
+ str[1] = 0;
- /* If SP is a control code, get the width of the space character. */
- if (ch == ' ') {
+ /* If SP is a control code, get the width of the space character. */
+ if (ch == ' ') {
space_code = hpgl_get_char_width(pgls, ' ', &space_width);
-
- if ( 0 == space_code &&
- pl_font_is_scalable(font) &&
- pfs->params.proportional_spacing )
- space_code = 1; /* NB hpgl_get_width lies. */
- if (space_code == 1) {
+ if ( 0 == space_code &&
+ pl_font_is_scalable(font) &&
+ pfs->params.proportional_spacing )
+ space_code = 1; /* NB hpgl_get_width lies. */
+
+ if (space_code == 1) {
/* Space is a control code. */
- if ( pl_font_is_scalable(font) ) {
- if (pfs->params.proportional_spacing)
- space_width =
- (coord_2_plu((pl_fp_pitch_cp(&pfs->font->params) / 10)
- * pfs->params.height_4ths / 4) ) / scale.x;
- else
- space_width = 1.0;
- /* error! NB scalable fixed pitch space_code == 0 */
- } else
- space_width =
+ if ( pl_font_is_scalable(font) ) {
+ if (pfs->params.proportional_spacing)
+ space_width =
+ (coord_2_plu((pl_fp_pitch_cp(&pfs->font->params) / 10)
+ * pfs->params.height_4ths / 4) ) / scale.x;
+ else
+ space_width = 1.0;
+ /* error! NB scalable fixed pitch space_code == 0 */
+ } else
+ space_width =
coord_2_plu(pl_fp_pitch_cp(&pfs->font->params)) / scale.x;
- space_width *= (1.0 + hpgl_get_character_extra_space_x(pgls));
+ space_width *= (1.0 + hpgl_get_character_extra_space_x(pgls));
}
- }
+ }
- /* Check for SP control code. */
- if (ch == ' ' && space_code != 0) {
+ /* Check for SP control code. */
+ if (ch == ' ' && space_code != 0) {
/* Space is a control code. Just advance the position. */
- gs_setmatrix(pgs, &advance_mat);
- hpgl_call(hpgl_add_point_to_path(pgls, space_width, 0.0,
- hpgl_plot_move_relative, false));
- hpgl_call(gs_currentpoint(pgs, &end_pt));
+ gs_setmatrix(pgs, &advance_mat);
+ hpgl_call(hpgl_add_point_to_path(pgls, space_width, 0.0,
+ hpgl_plot_move_relative, false));
+ hpgl_call(gs_currentpoint(pgs, &end_pt));
/* at this point we will assume the page is marked */
pgls->page_marked = true;
- } else {
+ } else {
gs_text_params_t text;
gs_char mychar_buff[1];
mychar_buff[0] = hpgl_map_symbol(ch, pgls);
if (use_show) {
/* not a path that needs to be drawn by the hpgl/2
vector drawing code. */
- hpgl_call(hpgl_set_drawing_color(pgls, hpgl_rm_character));
+ hpgl_call(hpgl_set_drawing_color(pgls, hpgl_rm_character));
text.operation = TEXT_FROM_CHARS | TEXT_DO_DRAW | TEXT_RETURN_WIDTH;
- } else
+ } else
text.operation = TEXT_FROM_CHARS | TEXT_DO_TRUE_CHARPATH | TEXT_RETURN_WIDTH;
text.data.chars = mychar_buff;
/* always on char (gs_chars (ints)) at a time */
text.size = 1;
code = gs_text_begin(pgs, &text, pgls->memory, &penum);
- if ( code >= 0 )
- code = gs_text_process(penum);
+ if ( code >= 0 )
+ code = gs_text_process(penum);
if ( code >= 0 ) {
/* we just check the current position for
@@ -886,77 +883,77 @@ hpgl_print_char(
pcl_mark_page_for_current_pos(pgls);
gs_text_release(penum, "hpgl_print_char");
}
- if ( code < 0 )
- return code;
- gs_setmatrix(pgs, &advance_mat);
- if (angle >= 0) {
+ if ( code < 0 )
+ return code;
+ gs_setmatrix(pgs, &advance_mat);
+ if (angle >= 0) {
/* Compensate for bitmap font non-rotation. */
- if (text_path == hpgl_text_right) {
+ if (text_path == hpgl_text_right) {
hpgl_get_char_width(pgls, ch, &width);
- hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x + width / scale.x,
- start_pt.y, hpgl_plot_move_absolute, false));
- }
+ hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x + width / scale.x,
+ start_pt.y, hpgl_plot_move_absolute, false));
+ }
}
- hpgl_call(gs_currentpoint(pgs, &end_pt));
- if ( start_pt.x == end_pt.x && start_pt.y == end_pt.y ) {
- /* freetype doesn't move currentpoint in gs_show(),
- * since gs cache is not used. NB we don't support
- * freetype anymore is this necessary?
- */
- hpgl_get_char_width(pgls, ch, &width);
- hpgl_call(hpgl_add_point_to_path(pgls, width / scale.x, 0.0,
- hpgl_plot_move_relative, false));
- hpgl_call(gs_currentpoint(pgs, &end_pt));
- }
- if ( (text_path == hpgl_text_right) &&
- (hpgl_get_character_extra_space_x(pgls) != 0) ) {
- hpgl_get_char_width(pgls, ch, &width);
- end_pt.x = start_pt.x + width / scale.x;
- hpgl_call(hpgl_add_point_to_path(pgls, end_pt.x, end_pt.y, hpgl_plot_move_absolute, false));
- }
- }
- /*
- * Adjust the final position according to the text path.
- */
- switch (text_path) {
- case hpgl_text_right:
- break;
-
- case hpgl_text_down:
- {
+ hpgl_call(gs_currentpoint(pgs, &end_pt));
+ if ( start_pt.x == end_pt.x && start_pt.y == end_pt.y ) {
+ /* freetype doesn't move currentpoint in gs_show(),
+ * since gs cache is not used. NB we don't support
+ * freetype anymore is this necessary?
+ */
+ hpgl_get_char_width(pgls, ch, &width);
+ hpgl_call(hpgl_add_point_to_path(pgls, width / scale.x, 0.0,
+ hpgl_plot_move_relative, false));
+ hpgl_call(gs_currentpoint(pgs, &end_pt));
+ }
+ if ( (text_path == hpgl_text_right) &&
+ (hpgl_get_character_extra_space_x(pgls) != 0) ) {
+ hpgl_get_char_width(pgls, ch, &width);
+ end_pt.x = start_pt.x + width / scale.x;
+ hpgl_call(hpgl_add_point_to_path(pgls, end_pt.x, end_pt.y, hpgl_plot_move_absolute, false));
+ }
+ }
+ /*
+ * Adjust the final position according to the text path.
+ */
+ switch (text_path) {
+ case hpgl_text_right:
+ break;
+
+ case hpgl_text_down:
+ {
hpgl_real_t height;
- hpgl_call(hpgl_get_current_cell_height(pgls, &height));
+ hpgl_call(hpgl_get_current_cell_height(pgls, &height));
hpgl_call( hpgl_add_point_to_path(pgls, start_pt.x, end_pt.y - height / scale.y,
- hpgl_plot_move_absolute, false) );
+ hpgl_plot_move_absolute, false) );
- }
- break;
+ }
+ break;
- case hpgl_text_left:
- hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x, start_pt.y,
- hpgl_plot_move_absolute, false));
- break;
- case hpgl_text_up:
- {
+ case hpgl_text_left:
+ hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x, start_pt.y,
+ hpgl_plot_move_absolute, false));
+ break;
+ case hpgl_text_up:
+ {
hpgl_real_t height;
- hpgl_call(hpgl_get_current_cell_height(pgls, &height));
- hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x,
- end_pt.y + height / scale.y, hpgl_plot_move_absolute, false));
- }
- break;
- }
+ hpgl_call(hpgl_get_current_cell_height(pgls, &height));
+ hpgl_call(hpgl_add_point_to_path(pgls, start_pt.x,
+ end_pt.y + height / scale.y, hpgl_plot_move_absolute, false));
+ }
+ break;
+ }
- gs_setmatrix(pgs, &save_ctm);
- hpgl_call(gs_currentpoint(pgs, &end_pt));
- if (!use_show)
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_character));
+ gs_setmatrix(pgs, &save_ctm);
+ hpgl_call(gs_currentpoint(pgs, &end_pt));
+ if (!use_show)
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_character));
- hpgl_call( hpgl_add_point_to_path( pgls,
+ hpgl_call( hpgl_add_point_to_path( pgls,
end_pt.x,
end_pt.y,
- hpgl_plot_move_absolute,
+ hpgl_plot_move_absolute,
true
) );
}
@@ -969,22 +966,21 @@ hpgl_print_char(
static bool
hpgl_can_concat_labels(const hpgl_state_t *pgls)
{ /* The following is per TRM 23-78. */
- static const byte can_concat[22] = {
- 0, 9, 1, 3, 8, 0, 2, 12, 4, 6,
- 0, 9, 1, 3, 8, 0, 2, 12, 4, 6,
- 0, 9
- };
-
- return (can_concat[pgls->g.label.origin] &
- (1 << pgls->g.character.text_path)) != 0;
+ static const byte can_concat[22] = {
+ 0, 9, 1, 3, 8, 0, 2, 12, 4, 6,
+ 0, 9, 1, 3, 8, 0, 2, 12, 4, 6,
+ 0, 9
+ };
+
+ return (can_concat[pgls->g.label.origin] &
+ (1 << pgls->g.character.text_path)) != 0;
}
-
/* return relative coordinates to compensate for origin placement -- LO */
static int
hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
- hpgl_real_t width, hpgl_real_t height,
- gs_point *offset)
+ hpgl_real_t width, hpgl_real_t height,
+ gs_point *offset)
{
double pos_x = 0.0, pos_y = 0.0;
double off_x, off_y;
@@ -997,7 +993,7 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
adjusted_height /= 1.6;
if (hpgl_is_currentfont_stick(pgls))
adjusted_height /= 1.4;
-
+
/* offset values specified by the documentation */
if ( (origin >= 11 && origin <= 14) || (origin >= 16 && origin <= 19) ) {
if (hpgl_is_currentfont_stick(pgls)) {
@@ -1102,7 +1098,7 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
DO_NOTHING;
}
- {
+ {
gs_matrix mat;
hpgl_compute_user_units_to_plu_ctm(pgls, &mat);
offset->x /= mat.xx;
@@ -1117,7 +1113,7 @@ hpgl_next_char(hpgl_state_t *pgls, byte **ppb)
{
byte *pb = *ppb;
gs_char chr = *pb++;
-
+
if (pgls->g.label.double_byte)
chr = (chr << 8) + *pb++;
*ppb = pb;
@@ -1142,7 +1138,6 @@ hpgl_process_buffer(hpgl_state_t *pgls, gs_point *offset)
} else {
inc = 1;
}
-
/*
* NOTE: the two loops below must be consistent with each other!
@@ -1157,44 +1152,44 @@ hpgl_process_buffer(hpgl_state_t *pgls, gs_point *offset)
for ( i=0; i < pgls->g.label.char_count; i+=inc ) {
gs_char ch = hpgl_next_char(pgls, &b);
if ( ch < 0x20 && !pgls->g.transparent_data )
- switch (ch) {
- case BS :
+ switch (ch) {
+ case BS :
if ( width == 0.0 ) { /* BS as first char of string */
hpgl_call(hpgl_ensure_font(pgls));
hpgl_get_char_width(pgls, ' ', &width);
hpgl_call(hpgl_get_current_cell_height(pgls, &height));
- }
+ }
if ( vertical ) { /* Vertical text path, back up in Y. */
label_height -= height;
if ( label_height < 0.0 )
label_height = 0.0;
- } else { /* Horizontal text path, back up in X. */
+ } else { /* Horizontal text path, back up in X. */
label_length -= width;
if ( label_length < 0.0 )
label_length = 0.0;
}
continue;
- case LF :
- first_char_on_line = true;
- continue;
- case CR :
+ case LF :
+ first_char_on_line = true;
+ continue;
+ case CR :
continue;
- case FF :
+ case FF :
continue;
- case HT :
+ case HT :
hpgl_call(hpgl_ensure_font(pgls));
hpgl_get_char_width(pgls, ' ', &width);
width *= 5;
goto acc_ht;
- case SI :
+ case SI :
hpgl_select_font_pri_alt(pgls, 0);
continue;
- case SO :
+ case SO :
hpgl_select_font_pri_alt(pgls, 1);
continue;
- default :
+ default :
break;
- }
+ }
hpgl_call(hpgl_ensure_font(pgls));
hpgl_get_char_width(pgls, ch, &width);
acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
@@ -1208,7 +1203,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
} else { /* Horizontal text path: sum widths, take max of heights. */
label_length += width;
if ( height > label_height )
- label_height = height;
+ label_height = height;
}
}
hpgl_select_font_pri_alt(pgls, save_index);
@@ -1223,9 +1218,9 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
{
byte *b = pgls->g.label.buffer;
- for ( i = 0; i < pgls->g.label.char_count; i+=inc ) {
+ for ( i = 0; i < pgls->g.label.char_count; i+=inc ) {
gs_char ch = hpgl_next_char(pgls, &b);
- if ( ch < 0x20 && !pgls->g.transparent_data ) {
+ if ( ch < 0x20 && !pgls->g.transparent_data ) {
hpgl_real_t spaces, lines;
switch (ch) {
@@ -1238,7 +1233,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
* computed label (horizontal) width, not the width
* of a space.
*/
- if ( vertical ) {
+ if ( vertical ) {
const pcl_font_selection_t * pfs =
&pgls->g.font_selection[pgls->g.font_selected];
hpgl_real_t label_advance;
@@ -1257,7 +1252,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
/*** WRONG ****/
label_advance = hpgl_points_2_plu(pgls, pl_fp_pitch_cp(&pfs->params) /
((pl_fp_pitch_cp(&pfs->font->params)/10.0)));
- if ( hpgl_get_character_extra_space_x(pgls) != 0 )
+ if ( hpgl_get_character_extra_space_x(pgls) != 0 )
label_advance *= 1.0 + hpgl_get_character_extra_space_x(pgls);
} else {
/*
@@ -1266,7 +1261,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height));
*
*
* HACKS - I am not sure what this should be the
- * actual values ???
+ * actual values ???
*/
label_advance = pgls->g.character.size.x * 1.5 * 1.25;
if (pgls->g.character.size_mode == hpgl_size_relative)
@@ -1311,7 +1306,7 @@ print: {
it is printed as a space character */
const pcl_font_selection_t *pfs =
&pgls->g.font_selection[pgls->g.font_selected];
- if ( !hpgl_is_printable(pfs->map, ch,
+ if ( !hpgl_is_printable(pfs->map, ch,
(pfs->params.typeface_family & 0xfff) == STICK_FONT_TYPEFACE,
pgls->g.transparent_data) )
continue;
@@ -1324,22 +1319,21 @@ print: {
return 0;
}
-
/**
* used by hpgl_LB() to find the end of a label
- *
+ *
* 8bit and 16bit label terminator check
* (prev << 8) & curr -> 16 bit
* have_16bits allows per byte call with true on 16bit boundary.
- */
-static
+ */
+static
bool is_terminator( hpgl_state_t *pgls, byte prev, byte curr, bool have_16bits )
{
- return
- pgls->g.label.double_byte ?
- ( have_16bits && prev == 0 && curr == pgls->g.label.terminator ) :
- ( curr == pgls->g.label.terminator );
-}
+ return
+ pgls->g.label.double_byte ?
+ ( have_16bits && prev == 0 && curr == pgls->g.label.terminator ) :
+ ( curr == pgls->g.label.terminator );
+}
#define GL_LB_HAVE_16BITS (pgls->g.label.have_16bits)
#define GL_LB_CH (pgls->g.label.ch)
@@ -1349,50 +1343,50 @@ bool is_terminator( hpgl_state_t *pgls, byte prev, byte curr, bool have_16bits )
int
hpgl_LB(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ const byte *p = pargs->source.ptr;
- const byte *rlimit = pargs->source.limit;
- bool print_terminator = pgls->g.label.print_terminator;
-
- if ( pargs->phase == 0 )
- {
- /* initialize the character buffer and CTM first time only */
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- hpgl_call(hpgl_init_label_buffer(pgls));
- hpgl_call(hpgl_set_ctm(pgls));
- hpgl_call(hpgl_set_clipping_region(pgls, hpgl_rm_vector));
- pgls->g.label.initial_pos = pgls->g.pos;
+ const byte *rlimit = pargs->source.limit;
+ bool print_terminator = pgls->g.label.print_terminator;
+
+ if ( pargs->phase == 0 )
+ {
+ /* initialize the character buffer and CTM first time only */
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ hpgl_call(hpgl_init_label_buffer(pgls));
+ hpgl_call(hpgl_set_ctm(pgls));
+ hpgl_call(hpgl_set_clipping_region(pgls, hpgl_rm_vector));
+ pgls->g.label.initial_pos = pgls->g.pos;
GL_LB_HAVE_16BITS = true;
GL_LB_CH = 0xff;
- GL_LB_PREV_CH = 0xff; /* for two byte terminators */
- pargs->phase = 1;
- }
+ GL_LB_PREV_CH = 0xff; /* for two byte terminators */
+ pargs->phase = 1;
+ }
- while ( p < rlimit )
- {
+ while ( p < rlimit )
+ {
/* This is not ugly and unintuitive */
- GL_LB_HAVE_16BITS = !GL_LB_HAVE_16BITS;
- GL_LB_PREV_CH = GL_LB_CH;
- GL_LB_CH = *++p;
- if_debug1('I',
- (GL_LB_CH == '\\' ? " \\%c" : GL_LB_CH >= 33 && GL_LB_CH <= 126 ? " %c" :
- " \\%03o"),
- GL_LB_CH);
- if ( is_terminator(pgls, GL_LB_PREV_CH, GL_LB_CH, GL_LB_HAVE_16BITS) )
- {
- if ( !print_terminator )
- {
+ GL_LB_HAVE_16BITS = !GL_LB_HAVE_16BITS;
+ GL_LB_PREV_CH = GL_LB_CH;
+ GL_LB_CH = *++p;
+ if_debug1('I',
+ (GL_LB_CH == '\\' ? " \\%c" : GL_LB_CH >= 33 && GL_LB_CH <= 126 ? " %c" :
+ " \\%03o"),
+ GL_LB_CH);
+ if ( is_terminator(pgls, GL_LB_PREV_CH, GL_LB_CH, GL_LB_HAVE_16BITS) )
+ {
+ if ( !print_terminator )
+ {
gs_point lo_offsets;
- hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
- hpgl_call(hpgl_destroy_label_buffer(pgls));
- pargs->source.ptr = p;
- /*
- * Depending on the DV/LO combination, conditionally
- * restore the initial position, per TRM 23-78.
- */
- if ( !hpgl_can_concat_labels(pgls) ) {
- hpgl_call(hpgl_add_point_to_path(pgls,
- pgls->g.carriage_return_pos.x,
- pgls->g.carriage_return_pos.y,
- hpgl_plot_move_absolute, true));
+ hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
+ hpgl_call(hpgl_destroy_label_buffer(pgls));
+ pargs->source.ptr = p;
+ /*
+ * Depending on the DV/LO combination, conditionally
+ * restore the initial position, per TRM 23-78.
+ */
+ if ( !hpgl_can_concat_labels(pgls) ) {
+ hpgl_call(hpgl_add_point_to_path(pgls,
+ pgls->g.carriage_return_pos.x,
+ pgls->g.carriage_return_pos.y,
+ hpgl_plot_move_absolute, true));
} else {
/* undo the label origin offsets */
hpgl_call(hpgl_add_point_to_path(pgls, lo_offsets.x, lo_offsets.y,
@@ -1408,43 +1402,43 @@ hpgl_LB(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_free_stick_fonts(pgls);
return 0;
}
- /*
- * Process the character in the ordinary way, then come here
- * again. We do things this way to simplify the case where
- * the terminator is a control character.
- */
- --p;
- print_terminator = false;
- }
-
- /* process the buffer for a carriage return so that we can
+ /*
+ * Process the character in the ordinary way, then come here
+ * again. We do things this way to simplify the case where
+ * the terminator is a control character.
+ */
+ --p;
+ print_terminator = false;
+ }
+
+ /* process the buffer for a carriage return so that we can
treat the label origin correctly, and initialize a new
buffer */
- hpgl_call(hpgl_buffer_char(pgls, GL_LB_CH));
- if ( GL_LB_CH == CR && !pgls->g.transparent_data )
+ hpgl_call(hpgl_buffer_char(pgls, GL_LB_CH));
+ if ( GL_LB_CH == CR && !pgls->g.transparent_data )
{
gs_point lo_offsets;
- hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
- hpgl_call(hpgl_destroy_label_buffer(pgls));
- hpgl_call(hpgl_init_label_buffer(pgls));
- }
- }
- pargs->source.ptr = p;
- return e_NeedData;
+ hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
+ hpgl_call(hpgl_destroy_label_buffer(pgls));
+ hpgl_call(hpgl_init_label_buffer(pgls));
+ }
+ }
+ pargs->source.ptr = p;
+ return e_NeedData;
}
void
hpgl_free_stick_fonts(hpgl_state_t *pgls)
{
pcl_font_selection_t *pfs =
- &pgls->g.font_selection[pgls->g.font_selected];
+ &pgls->g.font_selection[pgls->g.font_selected];
pl_font_t *font = &pgls->g.stick_font[pgls->g.font_selected]
- [pfs->params.proportional_spacing];
+ [pfs->params.proportional_spacing];
/* no stick fonts - nothing to do */
if ( font->pfont == 0 )
- return;
+ return;
gs_free_object(pgls->memory, font->pfont, "stick/arc font");
font->pfont = 0;
@@ -1453,28 +1447,28 @@ hpgl_free_stick_fonts(hpgl_state_t *pgls)
int
hpgl_print_symbol_mode_char(hpgl_state_t *pgls)
-{
+{
/* save the original origin since symbol mode character are
always centered */
- int saved_origin = pgls->g.label.origin;
- gs_point save_pos = pgls->g.pos;
+ int saved_origin = pgls->g.label.origin;
+ gs_point save_pos = pgls->g.pos;
gs_point lo_offsets;
- hpgl_call(hpgl_gsave(pgls));
- /* HAS this need checking. I don't know how text direction
+ hpgl_call(hpgl_gsave(pgls));
+ /* HAS this need checking. I don't know how text direction
and label origin interact in symbol mode */
- pgls->g.label.origin = 5;
- /* HAS - alot of work for one character */
- hpgl_call(hpgl_clear_current_path(pgls));
- hpgl_call(hpgl_init_label_buffer(pgls));
- hpgl_call(hpgl_buffer_char(pgls, pgls->g.symbol_mode));
- hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
- hpgl_call(hpgl_destroy_label_buffer(pgls));
- hpgl_call(hpgl_grestore(pgls));
- /* restore the origin */
- pgls->g.label.origin = saved_origin;
- hpgl_call(hpgl_set_current_position(pgls, &save_pos));
+ pgls->g.label.origin = 5;
+ /* HAS - alot of work for one character */
+ hpgl_call(hpgl_clear_current_path(pgls));
+ hpgl_call(hpgl_init_label_buffer(pgls));
+ hpgl_call(hpgl_buffer_char(pgls, pgls->g.symbol_mode));
+ hpgl_call(hpgl_process_buffer(pgls, &lo_offsets));
+ hpgl_call(hpgl_destroy_label_buffer(pgls));
+ hpgl_call(hpgl_grestore(pgls));
+ /* restore the origin */
+ pgls->g.label.origin = saved_origin;
+ hpgl_call(hpgl_set_current_position(pgls, &save_pos));
hpgl_free_stick_fonts(pgls);
- return 0;
+ return 0;
}
/* Initialization */
@@ -1485,11 +1479,11 @@ pglabel_do_registration(
)
{ /* Register commands */
DEFINE_HPGL_COMMANDS(mem)
- HPGL_COMMAND('C', 'P', hpgl_CP, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- /* LB also has special argument parsing. */
- HPGL_COMMAND('L', 'B', hpgl_LB, hpgl_cdf_polygon|hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- END_HPGL_COMMANDS
- return 0;
+ HPGL_COMMAND('C', 'P', hpgl_CP, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ /* LB also has special argument parsing. */
+ HPGL_COMMAND('L', 'B', hpgl_LB, hpgl_cdf_polygon|hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ END_HPGL_COMMANDS
+ return 0;
}
const pcl_init_t pglabel_init = {
diff --git a/pcl/pglfill.c b/pcl/pglfill.c
index cab275e21..65b7a55ea 100644
--- a/pcl/pglfill.c
+++ b/pcl/pglfill.c
@@ -42,7 +42,7 @@ hpgl_AC(
if (hpgl_arg_units(pgls->memory, pargs, &x)) {
if (!hpgl_arg_units(pgls->memory, pargs, &y))
- return e_Range;
+ return e_Range;
} else {
x = 0.0;
y = 0.0;
@@ -80,102 +80,102 @@ hpgl_FT(
case hpgl_FT_pattern_solid_pen1: /* 1 */
case hpgl_FT_pattern_solid_pen2: /* 2 */
- /* Default all the parameters. */
- pgls->g.fill.param.hatch.spacing = 0;
- pgls->g.fill.param.hatch.angle = 0;
- pgls->g.fill.param.crosshatch.spacing = 0;
- pgls->g.fill.param.crosshatch.angle = 0;
- pgls->g.fill.param.shading = 100;
- pgls->g.fill.param.user_defined.pattern_index = 1;
+ /* Default all the parameters. */
+ pgls->g.fill.param.hatch.spacing = 0;
+ pgls->g.fill.param.hatch.angle = 0;
+ pgls->g.fill.param.crosshatch.spacing = 0;
+ pgls->g.fill.param.crosshatch.angle = 0;
+ pgls->g.fill.param.shading = 100;
+ pgls->g.fill.param.user_defined.pattern_index = 1;
pgls->g.fill.param.user_defined.use_current_pen = false;
- pgls->g.fill.param.pattern_type = 1; /****** NOT SURE ******/
- pgls->g.fill.param.pattern_id = 0; /****** NOT SURE ******/
- break;
+ pgls->g.fill.param.pattern_type = 1; /****** NOT SURE ******/
+ pgls->g.fill.param.pattern_id = 0; /****** NOT SURE ******/
+ break;
case hpgl_FT_pattern_one_line: /* 3 */
- params = &pgls->g.fill.param.hatch;
- goto hatch;
+ params = &pgls->g.fill.param.hatch;
+ goto hatch;
case hpgl_FT_pattern_two_lines: /* 4 */
- params = &pgls->g.fill.param.crosshatch;
+ params = &pgls->g.fill.param.crosshatch;
hatch:
- {
+ {
hpgl_real_t spacing = params->spacing;
- hpgl_real_t angle = params->angle;
+ hpgl_real_t angle = params->angle;
- if (hpgl_arg_real(pgls->memory, pargs, &spacing)) {
+ if (hpgl_arg_real(pgls->memory, pargs, &spacing)) {
if (spacing < 0)
- return e_Range;
- hpgl_arg_real(pgls->memory, pargs, &angle);
- }
-
- /*
- * If the specified spacing is 0, we use 1% of the P1/P2
- * diagonal distance. We handle this when performing the
- * fill, not here, because this distance may change
- * depending on the position of P1 and P2.
- */
- params->spacing = spacing;
- params->angle = angle;
- }
- break;
+ return e_Range;
+ hpgl_arg_real(pgls->memory, pargs, &angle);
+ }
+
+ /*
+ * If the specified spacing is 0, we use 1% of the P1/P2
+ * diagonal distance. We handle this when performing the
+ * fill, not here, because this distance may change
+ * depending on the position of P1 and P2.
+ */
+ params->spacing = spacing;
+ params->angle = angle;
+ }
+ break;
case hpgl_FT_pattern_shading: /* 10 */
- {
+ {
int level;
- if (hpgl_arg_c_int(pgls->memory, pargs, &level)) {
+ if (hpgl_arg_c_int(pgls->memory, pargs, &level)) {
if ((level < 0) || (level > 100))
- return e_Range;
- pgls->g.fill.param.shading = level;
- }
- }
- break;
+ return e_Range;
+ pgls->g.fill.param.shading = level;
+ }
+ }
+ break;
case hpgl_FT_pattern_RF: /* 11 */
- {
+ {
int index, mode;
/* contrary to the documentation, option 2 is used */
- if (!hpgl_arg_int(pgls->memory, pargs, &index))
+ if (!hpgl_arg_int(pgls->memory, pargs, &index))
index = pgls->g.fill.param.user_defined.pattern_index;
else if ((index < 1) || (index > 8))
return e_Range;
- if (!hpgl_arg_c_int(pgls->memory, pargs, &mode))
- mode = pgls->g.fill.param.user_defined.use_current_pen;
+ if (!hpgl_arg_c_int(pgls->memory, pargs, &mode))
+ mode = pgls->g.fill.param.user_defined.use_current_pen;
else if ((mode & ~1) != 0)
- return e_Range;
- pgls->g.fill.param.user_defined.pattern_index = index;
- pgls->g.fill.param.user_defined.use_current_pen = mode;
- }
- break;
+ return e_Range;
+ pgls->g.fill.param.user_defined.pattern_index = index;
+ pgls->g.fill.param.user_defined.use_current_pen = mode;
+ }
+ break;
case hpgl_FT_pattern_cross_hatch: /* 21 */
- {
+ {
int pattern;
- if (hpgl_arg_c_int(pgls->memory, pargs, &pattern)) {
+ if (hpgl_arg_c_int(pgls->memory, pargs, &pattern)) {
if ((pattern < 1) || (pattern > 6))
- return e_Range;
- pgls->g.fill.param.pattern_type = pattern;
- }
- }
- break;
+ return e_Range;
+ pgls->g.fill.param.pattern_type = pattern;
+ }
+ }
+ break;
case hpgl_FT_pattern_user_defined: /* 22 */
- {
+ {
int32 id;
- if (hpgl_arg_int(pgls->memory, pargs, &id)) {
- if ((id < 0) || (id > 0xffff))
- return e_Range;
- pgls->g.fill.param.pattern_id = id;
- }
- }
- break;
+ if (hpgl_arg_int(pgls->memory, pargs, &id)) {
+ if ((id < 0) || (id > 0xffff))
+ return e_Range;
+ pgls->g.fill.param.pattern_id = id;
+ }
+ }
+ break;
default:
- return e_Range;
+ return e_Range;
}
pgls->g.fill.type = (hpgl_FT_pattern_source_t)type;
return 0;
@@ -203,44 +203,44 @@ hpgl_LA(
int kind;
while (hpgl_arg_c_int(pgls->memory, pargs, &kind)) {
- no_args=false;
- switch (kind) {
-
- case 1: /* line ends */
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &cap) || (cap < 1) || (cap > 4) )
- return e_Range;
- break;
-
- case 2: /* line joins */
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &join) || (join < 1) || (join > 6) )
- return e_Range;
- break;
-
- case 3: /* miter limit */
- if ( !hpgl_arg_c_real(pgls->memory, pargs, &miter_limit) )
- return e_Range;
- if (miter_limit < 1)
- miter_limit = 1;
- break;
-
- default:
- return e_Range;
- }
+ no_args=false;
+ switch (kind) {
+
+ case 1: /* line ends */
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &cap) || (cap < 1) || (cap > 4) )
+ return e_Range;
+ break;
+
+ case 2: /* line joins */
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &join) || (join < 1) || (join > 6) )
+ return e_Range;
+ break;
+
+ case 3: /* miter limit */
+ if ( !hpgl_arg_c_real(pgls->memory, pargs, &miter_limit) )
+ return e_Range;
+ if (miter_limit < 1)
+ miter_limit = 1;
+ break;
+
+ default:
+ return e_Range;
+ }
}
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
/* LA1,1,2,1,3,5 is the same as LA */
if (no_args) {
- hpgl_args_setup(pargs);
- hpgl_args_add_int(pargs, 1);
- hpgl_args_add_int(pargs, 1);
- hpgl_args_add_int(pargs, 2);
- hpgl_args_add_int(pargs, 1);
- hpgl_args_add_int(pargs, 3);
- hpgl_args_add_real(pargs, 5.0);
- hpgl_LA(pargs, pgls);
- return 0;
+ hpgl_args_setup(pargs);
+ hpgl_args_add_int(pargs, 1);
+ hpgl_args_add_int(pargs, 1);
+ hpgl_args_add_int(pargs, 2);
+ hpgl_args_add_int(pargs, 1);
+ hpgl_args_add_int(pargs, 3);
+ hpgl_args_add_real(pargs, 5.0);
+ hpgl_LA(pargs, pgls);
+ return 0;
}
pgls->g.line.cap = cap;
@@ -281,13 +281,13 @@ hpgl_set_line_pattern_defaults(hpgl_state_t *pgls)
pgls->g.line.current.is_solid = true;
pgls->g.line.current.type = 0;
memcpy( &pgls->g.fixed_line_type,
- &hpgl_fixed_pats,
- sizeof(hpgl_fixed_pats)
- );
+ &hpgl_fixed_pats,
+ sizeof(hpgl_fixed_pats)
+ );
memcpy( &pgls->g.adaptive_line_type,
- &hpgl_adaptive_pats,
- sizeof(hpgl_adaptive_pats)
- );
+ &hpgl_adaptive_pats,
+ sizeof(hpgl_adaptive_pats)
+ );
/* initialize the current pattern offset - this is not part of the
command but is used internally to modulate the phase of the
@@ -299,14 +299,14 @@ hpgl_set_line_pattern_defaults(hpgl_state_t *pgls)
* LT type[,length[,mode]];
* LT99;
* LT;
- * NB - needs reorganizing
+ * NB - needs reorganizing
*/
int
hpgl_LT(
hpgl_args_t * pargs,
hpgl_state_t * pgls
)
-{
+{
int type;
/* Draw the current path for any LT command irrespective of
@@ -319,11 +319,11 @@ hpgl_LT(
since type 99 can only be invoked if the current line is solid
(i.e. the 99 pattern only needs to be saved here */
if ( !hpgl_arg_c_int(pgls->memory, pargs, &type) ) {
- pgls->g.line.saved = pgls->g.line.current;
+ pgls->g.line.saved = pgls->g.line.current;
pgls->g.line.saved.pos.x = pgls->g.pos.x;
pgls->g.line.saved.pos.y = pgls->g.pos.y;
- pgls->g.line.current.is_solid = true;
- return 0;
+ pgls->g.line.current.is_solid = true;
+ return 0;
}
/* 99 restores the previous line type if a solid line type is the
@@ -331,50 +331,50 @@ hpgl_LT(
type is in effect, of course the previous line may have been a
solid line resulting in nop. */
if ( type == 99 && pgls->g.line.current.is_solid == true &&
- pgls->g.line.saved.pos.x == pgls->g.pos.x &&
- pgls->g.line.saved.pos.y == pgls->g.pos.y ) {
- pgls->g.line.current = pgls->g.line.saved;
- return 0;
+ pgls->g.line.saved.pos.x == pgls->g.pos.x &&
+ pgls->g.line.saved.pos.y == pgls->g.pos.y ) {
+ pgls->g.line.current = pgls->g.line.saved;
+ return 0;
}
-
+
/* check line type range */
if ( type < -8 || type > 8 )
- return e_Range;
+ return e_Range;
/* Initialize, get and check pattern length and mode. If the mode
is relative (0) the units are a % of the distance from P1 to P2
for the absolute mode units are millimeters */
{
- /* initialize pattern lengths to current state values */
- hpgl_real_t length = pgls->g.line.current.pattern_length;
- int mode = pgls->g.line.current.pattern_length_relative;
-
- /* get/check the pattern length and mode */
- if ( hpgl_arg_c_real(pgls->memory, pargs, &length) ) {
- if ( length <= 0 )
- return e_Range;
- if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) )
- if ( (mode != 0) && (mode != 1) )
- return e_Range;
- }
-
- /* if we are here this is a non-solid line and we should be
+ /* initialize pattern lengths to current state values */
+ hpgl_real_t length = pgls->g.line.current.pattern_length;
+ int mode = pgls->g.line.current.pattern_length_relative;
+
+ /* get/check the pattern length and mode */
+ if ( hpgl_arg_c_real(pgls->memory, pargs, &length) ) {
+ if ( length <= 0 )
+ return e_Range;
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &mode) )
+ if ( (mode != 0) && (mode != 1) )
+ return e_Range;
+ }
+
+ /* if we are here this is a non-solid line and we should be
able to set the rest of the line parameter state values.
NB have not checked if some of these get set if there is a
range error for pattern length or mode. An experiment for
another day... */
- if ( type == 0 ) {
- /* Spec says this is for dots, on clj4550 its solid line type!
- * NB: need multiple device testing as its likely to be device specific.
- * fts 1435 1451 1830 1833. */
- pgls->g.line.current.is_solid = true;
- }
- else
- pgls->g.line.current.is_solid = false;
+ if ( type == 0 ) {
+ /* Spec says this is for dots, on clj4550 its solid line type!
+ * NB: need multiple device testing as its likely to be device specific.
+ * fts 1435 1451 1830 1833. */
+ pgls->g.line.current.is_solid = true;
+ }
+ else
+ pgls->g.line.current.is_solid = false;
+ pgls->g.line.current.type = type;
+ pgls->g.line.current.pattern_length = length;
+ pgls->g.line.current.pattern_length_relative = mode;
pgls->g.line.current.type = type;
- pgls->g.line.current.pattern_length = length;
- pgls->g.line.current.pattern_length_relative = mode;
- pgls->g.line.current.type = type;
}
return 0;
}
@@ -387,17 +387,17 @@ hpgl_MC(
hpgl_args_t * pargs,
hpgl_state_t * pgls
)
-{
+{
int mode = 0, opcode;
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
if (hpgl_arg_c_int(pgls->memory, pargs, &mode) && ((mode & ~1) != 0))
- return e_Range;
+ return e_Range;
opcode = mode ? 168 : 252;
if ((mode != 0) && hpgl_arg_c_int(pgls->memory, pargs, &opcode)) {
- if ((opcode < 0) || (opcode > 255)) {
- pgls->logical_op = 252;
- return e_Range;
- }
+ if ((opcode < 0) || (opcode > 255)) {
+ pgls->logical_op = 252;
+ return e_Range;
+ }
}
pgls->logical_op = opcode;
return 0;
@@ -415,8 +415,8 @@ hpgl_PP(
int mode = 0;
if (hpgl_arg_c_int(pgls->memory, pargs, &mode)) {
- if ((mode < 0) || (mode > 1))
- return e_Range;
+ if ((mode < 0) || (mode > 1))
+ return e_Range;
}
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
pgls->pp_mode = mode;
@@ -431,7 +431,7 @@ hpgl_PW(
hpgl_args_t * pargs,
hpgl_state_t * pgls
)
-{
+{
/*
* we initialize the parameter to be parsed to either .1 which
* is a % of the magnitude of P1 P2 or .35 MM WU sets up how
@@ -449,8 +449,8 @@ hpgl_PW(
*/
if (hpgl_arg_c_real(pgls->memory, pargs, &param)) {
if (hpgl_arg_c_int(pgls->memory, pargs, &pmin)) {
- if ((pmin < 0) || (pmin > pmax))
- return e_Range;
+ if ((pmin < 0) || (pmin > pmax))
+ return e_Range;
pmax = pmin;
}
}
@@ -476,12 +476,12 @@ hpgl_PW(
* the line width in PU not MM.
*/
if (pgls->g.pen.width_relative)
- width_plu *= pf_factor;
+ width_plu *= pf_factor;
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
{
- int i;
- for (i = pmin; i <= pmax; ++i)
+ int i;
+ for (i = pmin; i <= pmax; ++i)
pcl_palette_PW(pgls, i, width_plu);
}
return 0;
@@ -497,7 +497,7 @@ hpgl_PW(
* pattern.
*/
-/*
+/*
* RF helper procedure to construct a mask if the input is only 1's
* and 0's. Note we store the original pattern in a dictionary keyed
* on the index, the mask is stored simultaneously keyed on the
@@ -567,58 +567,58 @@ hpgl_RF(
if (pargs->phase == 0) {
- if (!hpgl_arg_c_int(pgls->memory, pargs, (int *)&index)) {
- hpgl_default_all_fill_patterns(pgls);
- return 0;
- }
- if ((index < 1) || (index > 8))
- return e_Range;
+ if (!hpgl_arg_c_int(pgls->memory, pargs, (int *)&index)) {
+ hpgl_default_all_fill_patterns(pgls);
+ return 0;
+ }
+ if ((index < 1) || (index > 8))
+ return e_Range;
- if (!hpgl_arg_c_int(pgls->memory, pargs, (int *)&width)) {
- pcl_pattern_RF(index, NULL, pgls);
+ if (!hpgl_arg_c_int(pgls->memory, pargs, (int *)&width)) {
+ pcl_pattern_RF(index, NULL, pgls);
return 0;
- }
- if ( (width < 1) ||
+ }
+ if ( (width < 1) ||
(width > 255) ||
- !hpgl_arg_c_int(pgls->memory, pargs, (int *)&height) ||
- (height < 1) ||
+ !hpgl_arg_c_int(pgls->memory, pargs, (int *)&height) ||
+ (height < 1) ||
(height > 255) )
- return e_Range;
+ return e_Range;
/* allocate enough memory for pattern header and data */
data = gs_alloc_bytes(pgls->memory, width * height, "hpgl raster fill");
if (data == 0)
- return e_Memory;
+ return e_Memory;
/*
* All variables must be saved in globals since the parser
* the parser reinvokes hpgl_RF() while processing data
* (hpgl_arg_c_int can execute a longjmp).
*/
- pgls->g.raster_fill.width = width;
- pgls->g.raster_fill.height = height;
+ pgls->g.raster_fill.width = width;
+ pgls->g.raster_fill.height = height;
pgls->g.raster_fill.data = data;
pgls->g.raster_fill.is_mask = is_mask;
- pgls->g.raster_fill.index = index;
+ pgls->g.raster_fill.index = index;
/* set bitmap to 0, as not all pens need be provided */
- memset(data, 0, width * height);
- /* prepare to read the pixel values */
- hpgl_next_phase(pargs);
+ memset(data, 0, width * height);
+ /* prepare to read the pixel values */
+ hpgl_next_phase(pargs);
} else {
width = pgls->g.raster_fill.width;
height = pgls->g.raster_fill.height;
data = pgls->g.raster_fill.data;
is_mask = pgls->g.raster_fill.is_mask;
- index = pgls->g.raster_fill.index;
+ index = pgls->g.raster_fill.index;
}
while ((pargs->phase - 1) < width * height) {
- int pixel;
+ int pixel;
- if (!hpgl_arg_c_int(pgls->memory, pargs, &pixel))
- break;
- if (pixel != 0) {
+ if (!hpgl_arg_c_int(pgls->memory, pargs, &pixel))
+ break;
+ if (pixel != 0) {
data[pargs->phase - 1] = pixel;
if (pixel != 1)
is_mask = false;
@@ -627,7 +627,7 @@ hpgl_RF(
}
if ( pgls->personality == pcl5e )
- is_mask = true; /* always for a monochrome configuration */
+ is_mask = true; /* always for a monochrome configuration */
/* if the pattern is uncolored, collapse it to 1-bit per pixel */
if (is_mask) {
@@ -673,31 +673,31 @@ hpgl_SM(
for (;;) {
if (p >= rlimit) {
pargs->source.ptr = p;
- return e_NeedData;
- }
- ++p;
- if (*p == ' ')
- continue; /* ignore initial spaces */
- else if (*p == ';') {
+ return e_NeedData;
+ }
+ ++p;
+ if (*p == ' ')
+ continue; /* ignore initial spaces */
+ else if (*p == ';') {
pgls->g.symbol_mode = 0;
- break;
- }
-
- /*
- * p. 22-44 of the PCL5 manual says that the allowable codes
- * are 33-58, 60-126, 161 and 254. This is surely an error:
- * it must be 161-254.
- */
- else if ( ((*p >= 33) && (*p <= 126)) || ((*p >= 161) && (*p <= 254)) ) {
- pgls->g.symbol_mode = *p;
- return 0;
+ break;
+ }
+
+ /*
+ * p. 22-44 of the PCL5 manual says that the allowable codes
+ * are 33-58, 60-126, 161 and 254. This is surely an error:
+ * it must be 161-254.
+ */
+ else if ( ((*p >= 33) && (*p <= 126)) || ((*p >= 161) && (*p <= 254)) ) {
+ pgls->g.symbol_mode = *p;
+ return 0;
} else
- return e_Range;
+ return e_Range;
}
return 0;
}
-/*
+/*
* SP [pen];
*/
int
@@ -714,15 +714,15 @@ hpgl_SP(
if (hpgl_arg_c_int(pgls->memory, pargs, &pen)) {
if (pen < 0)
return e_Range;
- while ( pen > max_pen )
- pen = pen - max_pen;
+ while ( pen > max_pen )
+ pen = pen - max_pen;
}
if (pen == pgls->g.pen.selected)
return 0;
if ( !pgls->g.polygon_mode )
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
pgls->g.pen.selected = pen;
return 0;
}
@@ -747,70 +747,70 @@ hpgl_SV(
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
if (hpgl_arg_c_int(pgls->memory, pargs, &type)) {
- switch (type) {
+ switch (type) {
- case hpgl_SV_pattern_solid_pen: /* 0 */
+ case hpgl_SV_pattern_solid_pen: /* 0 */
pgls->g.screen.param.shading = 100;
pgls->g.screen.param.user_defined.pattern_index = 1;
pgls->g.screen.param.user_defined.use_current_pen = false;
pgls->g.screen.param.pattern_type = 1;
pgls->g.screen.param.pattern_id = 0;
- break;
+ break;
- case hpgl_SV_pattern_shade: /* 1 */
- {
+ case hpgl_SV_pattern_shade: /* 1 */
+ {
int level;
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &level) ||
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &level) ||
(level < 0) ||
(level > 100) )
- return e_Range;
- pgls->g.screen.param.shading = level;
- }
- break;
+ return e_Range;
+ pgls->g.screen.param.shading = level;
+ }
+ break;
- case hpgl_SV_pattern_RF: /* 2 */
- {
+ case hpgl_SV_pattern_RF: /* 2 */
+ {
int index, mode;
- if (!hpgl_arg_int(pgls->memory, pargs, &index))
+ if (!hpgl_arg_int(pgls->memory, pargs, &index))
index = pgls->g.screen.param.user_defined.pattern_index;
else if ((index < 1) || (index > 8))
return e_Range;
- if (!hpgl_arg_c_int(pgls->memory, pargs, &mode))
- mode = pgls->g.screen.param.user_defined.use_current_pen;
+ if (!hpgl_arg_c_int(pgls->memory, pargs, &mode))
+ mode = pgls->g.screen.param.user_defined.use_current_pen;
else if ((mode & ~1) != 0)
- return e_Range;
- pgls->g.screen.param.user_defined.pattern_index = index;
- pgls->g.screen.param.user_defined.use_current_pen = mode;
- }
- break;
-
- case hpgl_SV_pattern_cross_hatch: /* 21 */
- {
+ return e_Range;
+ pgls->g.screen.param.user_defined.pattern_index = index;
+ pgls->g.screen.param.user_defined.use_current_pen = mode;
+ }
+ break;
+
+ case hpgl_SV_pattern_cross_hatch: /* 21 */
+ {
int pattern;
- if ( !hpgl_arg_c_int(pgls->memory, pargs, &pattern) ||
- (pattern < 1) ||
+ if ( !hpgl_arg_c_int(pgls->memory, pargs, &pattern) ||
+ (pattern < 1) ||
(pattern > 6) )
- return e_Range;
- pgls->g.screen.param.pattern_type = pattern;
- }
- break;
+ return e_Range;
+ pgls->g.screen.param.pattern_type = pattern;
+ }
+ break;
- case hpgl_SV_pattern_user_defined: /* 22 */
- {
+ case hpgl_SV_pattern_user_defined: /* 22 */
+ {
int32 id;
- if (!hpgl_arg_int(pgls->memory, pargs, &id) || (id < 0) || (id > 0xffff))
- return e_Range;
- pgls->g.screen.param.pattern_id = id;
- }
- break;
+ if (!hpgl_arg_int(pgls->memory, pargs, &id) || (id < 0) || (id > 0xffff))
+ return e_Range;
+ pgls->g.screen.param.pattern_id = id;
+ }
+ break;
- default:
- return e_Range;
- }
+ default:
+ return e_Range;
+ }
}
pgls->g.screen.type = (hpgl_SV_pattern_source_t)type;
@@ -838,7 +838,7 @@ hpgl_TR(
int mode = 1;
if (hpgl_arg_c_int(pgls->memory, pargs, &mode) && ((mode & ~1) != 0))
- return e_Range;
+ return e_Range;
pgls->g.source_transparent = (mode != 0);
return 0;
@@ -856,36 +856,36 @@ hpgl_UL(
int index;
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
if (hpgl_arg_c_int(pgls->memory, pargs, &index)) {
- hpgl_real_t gap[20];
+ hpgl_real_t gap[20];
double total = 0;
int i, k;
if ((index < -8) || (index > 8) || (index == 0))
- return e_Range;
- for (i = 0; (i < 20) && hpgl_arg_c_real(pgls->memory, pargs, &gap[i]); ++i ) {
+ return e_Range;
+ for (i = 0; (i < 20) && hpgl_arg_c_real(pgls->memory, pargs, &gap[i]); ++i ) {
if (gap[i] < 0)
- return e_Range;
- total += gap[i];
- }
- if (total == 0)
- return e_Range;
+ return e_Range;
+ total += gap[i];
+ }
+ if (total == 0)
+ return e_Range;
- for (k = 0; k < i; k++)
- gap[k] /= total;
+ for (k = 0; k < i; k++)
+ gap[k] /= total;
- {
- hpgl_line_type_t * fixed_plt =
+ {
+ hpgl_line_type_t * fixed_plt =
&pgls->g.fixed_line_type[(index < 0 ? -index : index) - 1];
hpgl_line_type_t * adaptive_plt =
- &pgls->g.adaptive_line_type[(index < 0 ? -index : index) - 1];
+ &pgls->g.adaptive_line_type[(index < 0 ? -index : index) - 1];
- fixed_plt->count = adaptive_plt->count = i;
- memcpy(fixed_plt->gap, gap, i * sizeof(hpgl_real_t));
- memcpy(adaptive_plt->gap, gap, i * sizeof(hpgl_real_t));
- }
+ fixed_plt->count = adaptive_plt->count = i;
+ memcpy(fixed_plt->gap, gap, i * sizeof(hpgl_real_t));
+ memcpy(adaptive_plt->gap, gap, i * sizeof(hpgl_real_t));
+ }
} else {
- hpgl_set_line_pattern_defaults(pgls);
+ hpgl_set_line_pattern_defaults(pgls);
}
return 0;
}
@@ -902,8 +902,8 @@ hpgl_WU(
int mode = 0;
if (hpgl_arg_c_int(pgls->memory, pargs, &mode)) {
- if ((mode != 0) && (mode != 1))
- return e_Range;
+ if ((mode != 0) && (mode != 1))
+ return e_Range;
}
pgls->g.pen.width_relative = mode;
hpgl_args_setup(pargs);
@@ -936,7 +936,7 @@ pglfill_do_registration(
* in polygon mode itself.`
*/
HPGL_COMMAND('S', 'M', hpgl_SM, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('S', 'P', hpgl_SP, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('S', 'P', hpgl_SP, hpgl_cdf_pcl_rtl_both),
HPGL_COMMAND('S', 'V', hpgl_SV, hpgl_cdf_pcl_rtl_both),
HPGL_COMMAND('T', 'R', hpgl_TR, hpgl_cdf_pcl_rtl_both),
HPGL_COMMAND('U', 'L', hpgl_UL, hpgl_cdf_pcl_rtl_both),
diff --git a/pcl/pgmisc.c b/pcl/pgmisc.c
index 58911aeb1..5f0388e98 100644
--- a/pcl/pgmisc.c
+++ b/pcl/pgmisc.c
@@ -32,23 +32,23 @@ current_units_out_of_range(hpgl_real_t x)
void
hpgl_set_lost_mode(hpgl_state_t *pgls, hpgl_lost_mode_t lost_mode)
{
- if ( lost_mode == hpgl_lost_mode_entered )
- {
+ if ( lost_mode == hpgl_lost_mode_entered )
+ {
#ifdef INFINITE_LOOP
- hpgl_args_t args;
- /* raise the pen. Note this should handle the pcl oddity
+ hpgl_args_t args;
+ /* raise the pen. Note this should handle the pcl oddity
that when lost mode is cleared with an absolute PD we
draw a line from the last valid position to the first
args of pen down. The following appends a moveto the
current point in the gs path */
- hpgl_args_setup(&args);
- hpgl_PU(&args, pgls);
+ hpgl_args_setup(&args);
+ hpgl_PU(&args, pgls);
#endif
#ifdef DEBUG
- dprintf("entering lost mode\n");
+ dprintf("entering lost mode\n");
#endif
- }
- pgls->g.lost_mode = lost_mode;
+ }
+ pgls->g.lost_mode = lost_mode;
}
@@ -57,19 +57,19 @@ hpgl_set_lost_mode(hpgl_state_t *pgls, hpgl_lost_mode_t lost_mode)
/* Print an error message. Note that function may be NULL. */
/* This procedure must return its 'code' argument: see pgmisc.h. */
int
-hpgl_print_error(const gs_memory_t *mem,
- const char *function, const char *file, int line, int code)
+hpgl_print_error(const gs_memory_t *mem,
+ const char *function, const char *file, int line, int code)
{
- dprintf4("hpgl call failed\n\tcalled from: %s\n\tfile: %s\n\tline: %d\n\terror code: %d\n",
- (function == 0 ? "" : function), file, line, code);
- hpgl_error();
- return code;
+ dprintf4("hpgl call failed\n\tcalled from: %s\n\tfile: %s\n\tline: %d\n\terror code: %d\n",
+ (function == 0 ? "" : function), file, line, code);
+ hpgl_error();
+ return code;
}
/* called when there is a graphics error. Keep a breakpoint on this function */
void
hpgl_error()
{
- return;
+ return;
}
#endif
diff --git a/pcl/pgmisc.h b/pcl/pgmisc.h
index f86c08f2b..320d4bca3 100644
--- a/pcl/pgmisc.h
+++ b/pcl/pgmisc.h
@@ -33,8 +33,8 @@ int32 hpgl_get_character_edge_pen(hpgl_state_t *pgls);
#ifdef DEBUG
void hpgl_error(void);
-int hpgl_print_error(const gs_memory_t *mem,
- const char *function, const char *file, int line, int code);
+int hpgl_print_error(const gs_memory_t *mem,
+ const char *function, const char *file, int line, int code);
# ifdef __GNUC__
# define hpgl_call_note_error(mem, code)\
diff --git a/pcl/pgparse.c b/pcl/pgparse.c
index e140757f7..f3745a05e 100644
--- a/pcl/pgparse.c
+++ b/pcl/pgparse.c
@@ -25,19 +25,19 @@
/* Register a command. Return true if this is a redefinition. */
static bool
hpgl_register_command(hpgl_parser_state_t *pgl_parser_state,
- byte *pindex,
- const hpgl_command_definition_t *pcmd)
+ byte *pindex,
+ const hpgl_command_definition_t *pcmd)
{
int index = pgl_parser_state->hpgl_command_next_index;
byte prev = *pindex;
- if ( prev != 0 && prev <= index &&
- pgl_parser_state->hpgl_command_list[prev] == pcmd )
- index = prev;
+ if ( prev != 0 && prev <= index &&
+ pgl_parser_state->hpgl_command_list[prev] == pcmd )
+ index = prev;
else if ( index != 0 && pgl_parser_state->hpgl_command_list[index] == pcmd )
- ;
+ ;
else
- pgl_parser_state->hpgl_command_list[pgl_parser_state->hpgl_command_next_index = ++index] = (hpgl_command_definition_t *)pcmd;
+ pgl_parser_state->hpgl_command_list[pgl_parser_state->hpgl_command_next_index = ++index] = (hpgl_command_definition_t *)pcmd;
*pindex = index;
return (prev != 0 && prev != index);
}
@@ -45,23 +45,23 @@ hpgl_register_command(hpgl_parser_state_t *pgl_parser_state,
/* Define a list of commands. */
void
hpgl_define_commands(const gs_memory_t *mem, const hpgl_named_command_t *pcmds,
- hpgl_parser_state_t *pgl_parser_state
+ hpgl_parser_state_t *pgl_parser_state
)
{ const hpgl_named_command_t *pcmd = pcmds;
- for ( ; pcmd->char1; ++pcmd )
+ for ( ; pcmd->char1; ++pcmd )
#ifdef DEBUG
- if (
+ if (
#endif
- hpgl_register_command(pgl_parser_state,
- &pgl_parser_state->hpgl_command_indices
- [pcmd->char1 - 'A'][pcmd->char2 - 'A'],
- &pcmd->defn)
+ hpgl_register_command(pgl_parser_state,
+ &pgl_parser_state->hpgl_command_indices
+ [pcmd->char1 - 'A'][pcmd->char2 - 'A'],
+ &pcmd->defn)
#ifdef DEBUG
- )
- dprintf2("Redefining command %c%c\n", pcmd->char1, pcmd->char2);
+ )
+ dprintf2("Redefining command %c%c\n", pcmd->char1, pcmd->char2);
#endif
- ;
+ ;
}
/* ---------------- Parsing ---------------- */
@@ -70,7 +70,7 @@ hpgl_define_commands(const gs_memory_t *mem, const hpgl_named_command_t *pcmds,
void
hpgl_process_init(hpgl_parser_state_t *pst)
{ pst->first_letter = -1;
- pst->command = 0;
+ pst->command = 0;
}
/* Process a buffer of HP-GL/2 commands. */
@@ -79,117 +79,117 @@ int
hpgl_process(hpgl_parser_state_t *pst, hpgl_state_t *pgls,
stream_cursor_read *pr)
{ const byte *p = pr->ptr;
- const byte *rlimit = pr->limit;
- int code = 0;
+ const byte *rlimit = pr->limit;
+ int code = 0;
- pst->source.limit = rlimit;
- /* Prepare to catch a longjmp indicating the argument scanner */
- /* needs more data, or encountered an error. */
- code = setjmp(pst->exit_to_parser);
- if ( code )
- { /* The command detected an error, or we need to ask */
- /* the caller for more data. pst->command != 0. */
- pr->ptr = pst->source.ptr;
- if ( code < 0 && code != e_NeedData )
- { pst->command = 0; /* cancel command */
- if_debug0('i', "\n");
- return code;
- }
- return 0;
- }
- /* Check whether we're still feeding data to a command. */
+ pst->source.limit = rlimit;
+ /* Prepare to catch a longjmp indicating the argument scanner */
+ /* needs more data, or encountered an error. */
+ code = setjmp(pst->exit_to_parser);
+ if ( code )
+ { /* The command detected an error, or we need to ask */
+ /* the caller for more data. pst->command != 0. */
+ pr->ptr = pst->source.ptr;
+ if ( code < 0 && code != e_NeedData )
+ { pst->command = 0; /* cancel command */
+ if_debug0('i', "\n");
+ return code;
+ }
+ return 0;
+ }
+ /* Check whether we're still feeding data to a command. */
call: if ( pst->command )
- { pst->source.ptr = p;
- pst->arg.next = 0;
- code = (*pst->command->proc)(pst, pgls);
- p = pst->source.ptr;
- if ( code < 0 )
- goto x;
- pst->command = 0;
- if_debug0('i', "\n");
- }
- while ( p < rlimit )
- { byte next = *++p;
+ { pst->source.ptr = p;
+ pst->arg.next = 0;
+ code = (*pst->command->proc)(pst, pgls);
+ p = pst->source.ptr;
+ if ( code < 0 )
+ goto x;
+ pst->command = 0;
+ if_debug0('i', "\n");
+ }
+ while ( p < rlimit )
+ { byte next = *++p;
- if ( next >= 'A' && next <= 'Z' )
- next -= 'A';
- else if ( next >= 'a' && next <= 'z' )
- next -= 'a';
- else if ( next == ESC )
- { --p;
- pst->first_letter = -1;
- code = 1;
- break;
- }
- else /* ignore everything else */
- { /* Apparently this is what H-P plotters do.... */
- if ( next > ' ' && next != ',' )
- pst->first_letter = -1;
- continue;
- }
- if ( pst->first_letter < 0 )
- { pst->first_letter = next;
- continue;
- }
- { int index = pst->hpgl_command_indices[pst->first_letter][next];
+ if ( next >= 'A' && next <= 'Z' )
+ next -= 'A';
+ else if ( next >= 'a' && next <= 'z' )
+ next -= 'a';
+ else if ( next == ESC )
+ { --p;
+ pst->first_letter = -1;
+ code = 1;
+ break;
+ }
+ else /* ignore everything else */
+ { /* Apparently this is what H-P plotters do.... */
+ if ( next > ' ' && next != ',' )
+ pst->first_letter = -1;
+ continue;
+ }
+ if ( pst->first_letter < 0 )
+ { pst->first_letter = next;
+ continue;
+ }
+ { int index = pst->hpgl_command_indices[pst->first_letter][next];
#ifdef DEBUG
- if ( gs_debug_c('i') )
- { char c = (index ? '-' : '?');
- dprintf4("--%c%c%c%c", pst->first_letter + 'A',
- next + 'A', c, c);
- }
+ if ( gs_debug_c('i') )
+ { char c = (index ? '-' : '?');
+ dprintf4("--%c%c%c%c", pst->first_letter + 'A',
+ next + 'A', c, c);
+ }
#endif
- if ( index == 0 ) /* anomalous, drop 1st letter */
- { pst->first_letter = next;
- continue;
- }
- pst->first_letter = -1;
- pst->command = pst->hpgl_command_list[index];
- pst->phase = 0;
- pst->done = false;
- hpgl_args_init(pst);
- /*
- * Only a few commands should be executed while we're in
- * polygon mode: check for this here. Note that we rely
- * on the garbage-skipping property of the parser to skip
- * over any following arguments. This doesn't work for
- * the few commands with special syntax that should be
- * ignored in polygon mode (CO, DT, LB, SM); they must be
- * flagged as executable even in polygon mode, and check
- * the render_mode themselves.
- */
- {
- bool ignore_command = false;
- if (( pgls->g.polygon_mode ) &&
- !(pst->command->flags & hpgl_cdf_polygon)
- )
- ignore_command = true;
- else
- { /* similarly if we are in lost mode we do not
- execute the commands that are only defined to
- be used when lost mode is cleared. */
- if (( pgls->g.lost_mode == hpgl_lost_mode_entered ) &&
- (pst->command->flags & hpgl_cdf_lost_mode_cleared)
- )
- ignore_command = true;
- }
- /* Also, check that we have a command that can be executed
- with the current personality. NB reorganize me. */
- if ( pgls->personality == rtl )
- if ( !(pst->command->flags & hpgl_cdf_rtl) ) /* not rtl pcl only */
- ignore_command = true;
- if ( (pgls->personality == pcl5c) || (pgls->personality == pcl5e) )
- if ( !(pst->command->flags & hpgl_cdf_pcl) ) /* not pcl rtl only */
- ignore_command = true;
- if ( ignore_command )
- pst->command = 0;
- }
- goto call;
- }
- }
+ if ( index == 0 ) /* anomalous, drop 1st letter */
+ { pst->first_letter = next;
+ continue;
+ }
+ pst->first_letter = -1;
+ pst->command = pst->hpgl_command_list[index];
+ pst->phase = 0;
+ pst->done = false;
+ hpgl_args_init(pst);
+ /*
+ * Only a few commands should be executed while we're in
+ * polygon mode: check for this here. Note that we rely
+ * on the garbage-skipping property of the parser to skip
+ * over any following arguments. This doesn't work for
+ * the few commands with special syntax that should be
+ * ignored in polygon mode (CO, DT, LB, SM); they must be
+ * flagged as executable even in polygon mode, and check
+ * the render_mode themselves.
+ */
+ {
+ bool ignore_command = false;
+ if (( pgls->g.polygon_mode ) &&
+ !(pst->command->flags & hpgl_cdf_polygon)
+ )
+ ignore_command = true;
+ else
+ { /* similarly if we are in lost mode we do not
+ execute the commands that are only defined to
+ be used when lost mode is cleared. */
+ if (( pgls->g.lost_mode == hpgl_lost_mode_entered ) &&
+ (pst->command->flags & hpgl_cdf_lost_mode_cleared)
+ )
+ ignore_command = true;
+ }
+ /* Also, check that we have a command that can be executed
+ with the current personality. NB reorganize me. */
+ if ( pgls->personality == rtl )
+ if ( !(pst->command->flags & hpgl_cdf_rtl) ) /* not rtl pcl only */
+ ignore_command = true;
+ if ( (pgls->personality == pcl5c) || (pgls->personality == pcl5e) )
+ if ( !(pst->command->flags & hpgl_cdf_pcl) ) /* not pcl rtl only */
+ ignore_command = true;
+ if ( ignore_command )
+ pst->command = 0;
+ }
+ goto call;
+ }
+ }
x: pr->ptr = p;
- return (code == e_NeedData ? 0 : code);
+ return (code == e_NeedData ? 0 : code);
}
/*
@@ -198,201 +198,201 @@ x: pr->ptr = p;
* need more data. Note that no errors are possible.
*/
static const hpgl_value_t *
-hpgl_arg(const gs_memory_t *mem,
- hpgl_parser_state_t *pst)
+hpgl_arg(const gs_memory_t *mem,
+ hpgl_parser_state_t *pst)
{ const byte *p;
const byte *rlimit;
- hpgl_value_t *pvalue;
+ hpgl_value_t *pvalue;
#define parg (&pst->arg)
- if ( parg->next < parg->count )
- { /* We're still replaying already-scanned arguments. */
- return &parg->scanned[parg->next++];
- }
- if ( pst->done )
- return 0;
+ if ( parg->next < parg->count )
+ { /* We're still replaying already-scanned arguments. */
+ return &parg->scanned[parg->next++];
+ }
+ if ( pst->done )
+ return 0;
p = pst->source.ptr;
rlimit = pst->source.limit;
- pvalue = &parg->scanned[parg->count];
+ pvalue = &parg->scanned[parg->count];
#define check_value()\
if ( parg->have_value ) goto done
- for ( ; p < rlimit; ++p )
- { byte ch = p[1];
- switch ( ch )
- {
- case '+':
- check_value();
- parg->have_value = 1;
- parg->sign = 1;
- pvalue->v_n.i = 0;
- break;
- case '-':
- check_value();
- parg->have_value = 1;
- parg->sign = -1;
- pvalue->v_n.i = 0;
- break;
- case '.':
- switch ( parg->have_value )
- {
- default: /* > 1 */
- goto out;
- case 0:
- pvalue->v_n.r = 0;
- break;
- case 1:
- pvalue->v_n.r = pvalue->v_n.i;
- }
- parg->have_value = 2;
- parg->frac_scale = 1.0;
- break;
- case ';':
- pst->done = true;
- check_value();
- goto out;
- case HT: case LF: case FF: case CR:
- /* control charachers are ignored during parsing hpgl
- */
- continue;
- case SP: case ',':
- /*
- * The specification doesn't say what to do with extra
- * separators; we just ignore them.
- */
- if ( !parg->have_value )
- break;
- ++p;
+ for ( ; p < rlimit; ++p )
+ { byte ch = p[1];
+ switch ( ch )
+ {
+ case '+':
+ check_value();
+ parg->have_value = 1;
+ parg->sign = 1;
+ pvalue->v_n.i = 0;
+ break;
+ case '-':
+ check_value();
+ parg->have_value = 1;
+ parg->sign = -1;
+ pvalue->v_n.i = 0;
+ break;
+ case '.':
+ switch ( parg->have_value )
+ {
+ default: /* > 1 */
+ goto out;
+ case 0:
+ pvalue->v_n.r = 0;
+ break;
+ case 1:
+ pvalue->v_n.r = pvalue->v_n.i;
+ }
+ parg->have_value = 2;
+ parg->frac_scale = 1.0;
+ break;
+ case ';':
+ pst->done = true;
+ check_value();
+ goto out;
+ case HT: case LF: case FF: case CR:
+ /* control charachers are ignored during parsing hpgl
+ */
+ continue;
+ case SP: case ',':
+ /*
+ * The specification doesn't say what to do with extra
+ * separators; we just ignore them.
+ */
+ if ( !parg->have_value )
+ break;
+ ++p;
done: if ( parg->sign < 0 )
- { if ( parg->have_value > 1 )
- pvalue->v_n.r = -pvalue->v_n.r;
- else
- pvalue->v_n.i = -pvalue->v_n.i;
- }
- goto out;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- ch -= '0';
+ { if ( parg->have_value > 1 )
+ pvalue->v_n.r = -pvalue->v_n.r;
+ else
+ pvalue->v_n.i = -pvalue->v_n.i;
+ }
+ goto out;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ch -= '0';
#define max_i 0x7fffffff
- switch ( parg->have_value )
- {
- default: /* case 2 */
- pvalue->v_n.r += ch / (parg->frac_scale *= 10);
- break;
- case 0:
- parg->have_value = 1;
- pvalue->v_n.i = ch;
- break;
- case 1:
- if ( pvalue->v_n.i >= max_i/10 &&
- (pvalue->v_n.i > max_i/10 || ch > max_i%10)
- )
+ switch ( parg->have_value )
+ {
+ default: /* case 2 */
+ pvalue->v_n.r += ch / (parg->frac_scale *= 10);
+ break;
+ case 0:
+ parg->have_value = 1;
+ pvalue->v_n.i = ch;
+ break;
+ case 1:
+ if ( pvalue->v_n.i >= max_i/10 &&
+ (pvalue->v_n.i > max_i/10 || ch > max_i%10)
+ )
return NULL;
- else
- pvalue->v_n.i = pvalue->v_n.i * 10 + ch;
- }
- break;
- default:
- pst->done = true;
- check_value();
- goto out;
- }
- }
- /* We ran out of data before reaching a terminator. */
- pst->source.ptr = p;
- longjmp(pst->exit_to_parser, e_NeedData);
- /* NOTREACHED */
+ else
+ pvalue->v_n.i = pvalue->v_n.i * 10 + ch;
+ }
+ break;
+ default:
+ pst->done = true;
+ check_value();
+ goto out;
+ }
+ }
+ /* We ran out of data before reaching a terminator. */
+ pst->source.ptr = p;
+ longjmp(pst->exit_to_parser, e_NeedData);
+ /* NOTREACHED */
out: pst->source.ptr = p;
- switch ( parg->have_value )
- {
- case 0: /* no argument */
- return NULL;
- case 1: /* integer */
- if_debug1('I', " %ld", (long)pvalue->v_n.i);
- pvalue->is_real = false;
- break;
- default /* case 2 */: /* real */
- if_debug1('I', " %g", pvalue->v_n.r);
- pvalue->is_real = true;
- }
- hpgl_arg_init(pst);
- parg->next = ++(parg->count);
- return pvalue;
+ switch ( parg->have_value )
+ {
+ case 0: /* no argument */
+ return NULL;
+ case 1: /* integer */
+ if_debug1('I', " %ld", (long)pvalue->v_n.i);
+ pvalue->is_real = false;
+ break;
+ default /* case 2 */: /* real */
+ if_debug1('I', " %g", pvalue->v_n.r);
+ pvalue->is_real = true;
+ }
+ hpgl_arg_init(pst);
+ parg->next = ++(parg->count);
+ return pvalue;
#undef parg
}
/* Get a real argument. */
bool
hpgl_arg_real(const gs_memory_t *mem,
- hpgl_args_t *pargs, hpgl_real_t *pr)
+ hpgl_args_t *pargs, hpgl_real_t *pr)
{ const hpgl_value_t *pvalue = hpgl_arg(mem, pargs);
- if ( !pvalue )
- return false;
- *pr = (pvalue->is_real ? pvalue->v_n.r : pvalue->v_n.i);
- return true;
+ if ( !pvalue )
+ return false;
+ *pr = (pvalue->is_real ? pvalue->v_n.r : pvalue->v_n.i);
+ return true;
}
/* Get a clamped real argument. */
bool
hpgl_arg_c_real(const gs_memory_t *mem,
- hpgl_args_t *pargs, hpgl_real_t *pr)
+ hpgl_args_t *pargs, hpgl_real_t *pr)
{ const hpgl_value_t *pvalue = hpgl_arg(mem, pargs);
- hpgl_real_t r;
+ hpgl_real_t r;
- if ( !pvalue )
- return false;
- r = (pvalue->is_real ? pvalue->v_n.r : pvalue->v_n.i);
- *pr = (r < -32768 ? -32768 : r > 32767 ? 32767 : r);
- return true;
+ if ( !pvalue )
+ return false;
+ r = (pvalue->is_real ? pvalue->v_n.r : pvalue->v_n.i);
+ *pr = (r < -32768 ? -32768 : r > 32767 ? 32767 : r);
+ return true;
}
/* Get an integer argument. */
bool
hpgl_arg_int(const gs_memory_t *mem,
- hpgl_args_t *pargs, int32 *pi)
+ hpgl_args_t *pargs, int32 *pi)
{ const hpgl_value_t *pvalue = hpgl_arg(mem, pargs);
- if ( !pvalue )
- return false;
- *pi = (pvalue->is_real ? (int32)pvalue->v_n.r : pvalue->v_n.i);
- return true;
+ if ( !pvalue )
+ return false;
+ *pi = (pvalue->is_real ? (int32)pvalue->v_n.r : pvalue->v_n.i);
+ return true;
}
/* Get a clamped integer argument. */
bool
-hpgl_arg_c_int(const gs_memory_t *mem,
- hpgl_args_t *pargs, int *pi)
+hpgl_arg_c_int(const gs_memory_t *mem,
+ hpgl_args_t *pargs, int *pi)
{ const hpgl_value_t *pvalue = hpgl_arg(mem, pargs);
- int32 i;
+ int32 i;
- if ( !pvalue )
- return false;
- i = (pvalue->is_real ? (int32)pvalue->v_n.r : pvalue->v_n.i);
- *pi = (i < -32768 ? -32768 : i > 32767 ? 32767 : i);
- return true;
+ if ( !pvalue )
+ return false;
+ i = (pvalue->is_real ? (int32)pvalue->v_n.r : pvalue->v_n.i);
+ *pi = (i < -32768 ? -32768 : i > 32767 ? 32767 : i);
+ return true;
}
/* Get a "current units" argument. */
bool
-hpgl_arg_units(const gs_memory_t *mem,
- hpgl_args_t *pargs, hpgl_real_t *pu)
+hpgl_arg_units(const gs_memory_t *mem,
+ hpgl_args_t *pargs, hpgl_real_t *pu)
{ /****** PROBABLY WRONG ******/
- return hpgl_arg_real(mem, pargs, pu);
+ return hpgl_arg_real(mem, pargs, pu);
}
/* initialize the HPGL command counter */
int
hpgl_init_command_index(hpgl_parser_state_t **pgl_parser_state, gs_memory_t *mem)
{
- hpgl_parser_state_t *pgst =
- (hpgl_parser_state_t *)gs_alloc_bytes(mem, sizeof(hpgl_parser_state_t),
- "hpgl_init_command_index");
+ hpgl_parser_state_t *pgst =
+ (hpgl_parser_state_t *)gs_alloc_bytes(mem, sizeof(hpgl_parser_state_t),
+ "hpgl_init_command_index");
/* fatal */
if ( pgst == 0 )
- return -1;
-
+ return -1;
+
pgst->hpgl_command_next_index = 0;
/* NB fix me the parser should not depend on this behavior the
previous design had these in bss which was automatically
diff --git a/pcl/pgpoly.c b/pcl/pgpoly.c
index d4f504d61..cc75b2374 100644
--- a/pcl/pgpoly.c
+++ b/pcl/pgpoly.c
@@ -39,49 +39,49 @@ hpgl_clear_polygon_buffer(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_call(hpgl_PM(pargs, pgls));
return 0;
}
-
+
/* Build a rectangle in polygon mode used by (EA, ER, RA, RR). */
static int
hpgl_rectangle(hpgl_args_t *pargs, hpgl_state_t *pgls, int flags, bool do_poly)
{ hpgl_real_t x2, y2;
- if ( !hpgl_arg_units(pgls->memory, pargs, &x2) ||
- !hpgl_arg_units(pgls->memory, pargs, &y2) ||
+ if ( !hpgl_arg_units(pgls->memory, pargs, &x2) ||
+ !hpgl_arg_units(pgls->memory, pargs, &y2) ||
current_units_out_of_range(x2) ||
current_units_out_of_range(y2) ) {
hpgl_call(hpgl_clear_polygon_buffer(pargs, pgls));
return e_Range;
}
- if ( flags & DO_RELATIVE )
- {
- x2 += pgls->g.pos.x;
- y2 += pgls->g.pos.y;
- }
-
+ if ( flags & DO_RELATIVE )
+ {
+ x2 += pgls->g.pos.x;
+ y2 += pgls->g.pos.y;
+ }
+
if ( do_poly ) {
hpgl_args_setup(pargs);
/* enter polygon mode. */
hpgl_call(hpgl_PM(pargs, pgls));
}
- /* do the rectangle */
- {
- hpgl_real_t x1 = pgls->g.pos.x;
- hpgl_real_t y1 = pgls->g.pos.y;
+ /* do the rectangle */
+ {
+ hpgl_real_t x1 = pgls->g.pos.x;
+ hpgl_real_t y1 = pgls->g.pos.y;
- hpgl_call(hpgl_add_point_to_path(pgls, x1, y1, hpgl_plot_move_absolute, true));
- hpgl_call(hpgl_add_point_to_path(pgls, x2, y1, hpgl_plot_draw_absolute, true));
- hpgl_call(hpgl_add_point_to_path(pgls, x2, y2, hpgl_plot_draw_absolute, true));
- hpgl_call(hpgl_add_point_to_path(pgls, x1, y2, hpgl_plot_draw_absolute, true));
- hpgl_call(hpgl_close_current_path(pgls));
- }
+ hpgl_call(hpgl_add_point_to_path(pgls, x1, y1, hpgl_plot_move_absolute, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, x2, y1, hpgl_plot_draw_absolute, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, x2, y2, hpgl_plot_draw_absolute, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, x1, y2, hpgl_plot_draw_absolute, true));
+ hpgl_call(hpgl_close_current_path(pgls));
+ }
- /* exit polygon mode PM2 */
+ /* exit polygon mode PM2 */
if ( do_poly ) {
hpgl_args_set_int(pargs,2);
hpgl_call(hpgl_PM(pargs, pgls));
}
- return 0;
+ return 0;
}
/* Fill or edge a wedge (EW, WG). */
@@ -89,9 +89,9 @@ static int
hpgl_wedge(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ hpgl_real_t radius, start, sweep, chord = 5.0;
- if ( !hpgl_arg_units(pgls->memory, pargs, &radius) ||
- !hpgl_arg_c_real(pgls->memory, pargs, &start) ||
- !hpgl_arg_c_real(pgls->memory, pargs, &sweep) || sweep < -360 || sweep > 360
+ if ( !hpgl_arg_units(pgls->memory, pargs, &radius) ||
+ !hpgl_arg_c_real(pgls->memory, pargs, &start) ||
+ !hpgl_arg_c_real(pgls->memory, pargs, &sweep) || sweep < -360 || sweep > 360
) {
hpgl_call(hpgl_clear_polygon_buffer(pargs, pgls));
return e_Range;
@@ -99,49 +99,49 @@ hpgl_wedge(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_arg_c_real(pgls->memory, pargs, &chord);
- /* enter polygon mode */
- hpgl_args_setup(pargs);
- hpgl_call(hpgl_PM(pargs, pgls));
-
- if ( sweep > 359.9 || sweep < -359.9) {
- floatp num_chordsf = 360 / chord;
- /* match hp 4600 rounding, precompute since regular arc rounding is different. */
- floatp intpart;
- int num_chords = (modf(num_chordsf, &intpart) < 0.06) ? intpart : intpart+1;
- floatp integral_chord_angle = fabs(sweep / num_chords);
-
- hpgl_call(hpgl_add_arc_to_path(pgls, pgls->g.pos.x, pgls->g.pos.y,
- radius, start, 360.0, integral_chord_angle, true,
- hpgl_plot_draw_absolute, true));
- }
- else
- /* draw the 2 lines and the arc using 3 point this does seem
+ /* enter polygon mode */
+ hpgl_args_setup(pargs);
+ hpgl_call(hpgl_PM(pargs, pgls));
+
+ if ( sweep > 359.9 || sweep < -359.9) {
+ floatp num_chordsf = 360 / chord;
+ /* match hp 4600 rounding, precompute since regular arc rounding is different. */
+ floatp intpart;
+ int num_chords = (modf(num_chordsf, &intpart) < 0.06) ? intpart : intpart+1;
+ floatp integral_chord_angle = fabs(sweep / num_chords);
+
+ hpgl_call(hpgl_add_arc_to_path(pgls, pgls->g.pos.x, pgls->g.pos.y,
+ radius, start, 360.0, integral_chord_angle, true,
+ hpgl_plot_draw_absolute, true));
+ }
+ else
+ /* draw the 2 lines and the arc using 3 point this does seem
convoluted but it does guarantee that the endpoint lines
for the vectors and the arc endpoints are coincident. */
- {
- hpgl_real_t x1, y1, x2, y2, x3, y3;
- hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
- start, &x1, &y1);
- hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
- (start + (sweep / 2.0)), &x2, &y2);
- hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
- (start + sweep), &x3, &y3);
- hpgl_call(hpgl_add_point_to_path(pgls, pgls->g.pos.x, pgls->g.pos.y,
- hpgl_plot_move_absolute, true));
- hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
- hpgl_plot_draw_absolute, true));
- hpgl_call(hpgl_add_arc_3point_to_path(pgls,
- x1, y1,
- x2, y2,
- x3, y3, chord,
- hpgl_plot_draw_absolute));
- }
-
- hpgl_call(hpgl_close_current_path(pgls));
- hpgl_args_set_int(pargs,2);
- hpgl_call(hpgl_PM(pargs, pgls));
-
- return 0;
+ {
+ hpgl_real_t x1, y1, x2, y2, x3, y3;
+ hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
+ start, &x1, &y1);
+ hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
+ (start + (sweep / 2.0)), &x2, &y2);
+ hpgl_compute_vector_endpoints(radius, pgls->g.pos.x, pgls->g.pos.y,
+ (start + sweep), &x3, &y3);
+ hpgl_call(hpgl_add_point_to_path(pgls, pgls->g.pos.x, pgls->g.pos.y,
+ hpgl_plot_move_absolute, true));
+ hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
+ hpgl_plot_draw_absolute, true));
+ hpgl_call(hpgl_add_arc_3point_to_path(pgls,
+ x1, y1,
+ x2, y2,
+ x3, y3, chord,
+ hpgl_plot_draw_absolute));
+ }
+
+ hpgl_call(hpgl_close_current_path(pgls));
+ hpgl_args_set_int(pargs,2);
+ hpgl_call(hpgl_PM(pargs, pgls));
+
+ return 0;
}
/* ------ Commands ------ */
@@ -149,45 +149,45 @@ hpgl_wedge(hpgl_args_t *pargs, hpgl_state_t *pgls)
/* EA x,y; */
int
hpgl_EA(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
-
+{
+
hpgl_call(hpgl_rectangle(pargs, pgls, DO_EDGE, true));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- return 0;
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ return 0;
}
/* EP; */
int
hpgl_EP(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- /* preserve the current path and copy the polygon buffer to
+{
+ /* preserve the current path and copy the polygon buffer to
the current path */
- hpgl_call(hpgl_gsave(pgls));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector_no_close));
- hpgl_call(hpgl_grestore(pgls));
- return 0;
+ hpgl_call(hpgl_gsave(pgls));
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector_no_close));
+ hpgl_call(hpgl_grestore(pgls));
+ return 0;
}
/* ER dx,dy; */
int
hpgl_ER(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
hpgl_call(hpgl_rectangle(pargs, pgls, DO_RELATIVE, true));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- return 0;
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ return 0;
}
/* EW radius,astart,asweep[,achord]; */
int
hpgl_EW(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- hpgl_call(hpgl_wedge(pargs, pgls));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- return 0;
+{
+ hpgl_call(hpgl_wedge(pargs, pgls));
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ return 0;
}
static hpgl_rendering_mode_t
@@ -198,7 +198,7 @@ hpgl_get_poly_render_mode(
hpgl_FT_pattern_source_t type = pgls->g.fill.type;
return ( ((type == hpgl_FT_pattern_one_line) ||
- (type == hpgl_FT_pattern_two_lines) )
+ (type == hpgl_FT_pattern_two_lines) )
? hpgl_rm_clip_and_fill_polygon
: hpgl_rm_polygon );
}
@@ -222,49 +222,49 @@ hpgl_FP(hpgl_args_t *pargs, hpgl_state_t *pgls)
}
/* close a subpolygon; PM1 or CI inside of a polygon */
-int
+int
hpgl_close_subpolygon(hpgl_state_t *pgls)
{
gs_point first, last;
gs_point point;
gs_fixed_point first_device;
-
+
if ( pgls->g.polygon_mode ) {
- if ( gx_path_subpath_start_point(gx_current_path(pgls->pgs),
- &first_device) >= 0 ) {
- first.x = fixed2float(first_device.x);
- first.y = fixed2float(first_device.y);
-
- /* get gl/2 current position -- always current units */
- hpgl_call(hpgl_get_current_position(pgls, &last));
- /* convert to device space using the current ctm */
- hpgl_call(gs_transform(pgls->pgs, last.x, last.y, &last));
- /*
- * if the first and last are the same close the path (i.e
- * force gs to apply join and miter)
- */
- if (equal(first.x, last.x) && equal(first.y, last.y)) {
- hpgl_call(gs_closepath(pgls->pgs));
- }
- else {
- /* explicitly close the path if the pen has been down */
- if ( pgls->g.have_drawn_in_path ) {
- hpgl_call(hpgl_close_current_path(pgls));
-
- /* update current position to the first point in sub-path,
- * should be the same as last point after close path
- * needed for relative moves after close of unclosed polygon
- */
- hpgl_call(gs_itransform(pgls->pgs, first.x, first.y, &point));
- hpgl_call(hpgl_set_current_position(pgls, &point));
- hpgl_call(hpgl_update_carriage_return_pos(pgls));
- }
- }
- /* remain in poly mode, this shouldn't be necessary */
- pgls->g.polygon_mode = true;
- }
- pgls->g.subpolygon_started = true;
+ if ( gx_path_subpath_start_point(gx_current_path(pgls->pgs),
+ &first_device) >= 0 ) {
+ first.x = fixed2float(first_device.x);
+ first.y = fixed2float(first_device.y);
+
+ /* get gl/2 current position -- always current units */
+ hpgl_call(hpgl_get_current_position(pgls, &last));
+ /* convert to device space using the current ctm */
+ hpgl_call(gs_transform(pgls->pgs, last.x, last.y, &last));
+ /*
+ * if the first and last are the same close the path (i.e
+ * force gs to apply join and miter)
+ */
+ if (equal(first.x, last.x) && equal(first.y, last.y)) {
+ hpgl_call(gs_closepath(pgls->pgs));
+ }
+ else {
+ /* explicitly close the path if the pen has been down */
+ if ( pgls->g.have_drawn_in_path ) {
+ hpgl_call(hpgl_close_current_path(pgls));
+
+ /* update current position to the first point in sub-path,
+ * should be the same as last point after close path
+ * needed for relative moves after close of unclosed polygon
+ */
+ hpgl_call(gs_itransform(pgls->pgs, first.x, first.y, &point));
+ hpgl_call(hpgl_set_current_position(pgls, &point));
+ hpgl_call(hpgl_update_carriage_return_pos(pgls));
+ }
+ }
+ /* remain in poly mode, this shouldn't be necessary */
+ pgls->g.polygon_mode = true;
+ }
+ pgls->g.subpolygon_started = true;
}
return 0;
}
@@ -274,75 +274,75 @@ int
hpgl_PM(hpgl_args_t *pargs, hpgl_state_t *pgls)
{ int op;
- if ( hpgl_arg_c_int(pgls->memory, pargs, &op) == 0 )
- op = 0;
+ if ( hpgl_arg_c_int(pgls->memory, pargs, &op) == 0 )
+ op = 0;
- switch( op )
- {
- case 0 :
- /* draw the current path if there is one */
- hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
- /* clear the polygon buffer as well */
+ switch( op )
+ {
+ case 0 :
+ /* draw the current path if there is one */
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ /* clear the polygon buffer as well */
gx_path_new(&pgls->g.polygon.buffer.path);
- /* global flag to indicate that we are in polygon mode */
- pgls->g.polygon_mode = true;
- /* save the pen state, to be restored by PM2 */
- hpgl_save_pen_state(pgls,
- &pgls->g.polygon.pen_state,
- hpgl_pen_down | hpgl_pen_pos);
- break;
- case 1 :
- hpgl_call(hpgl_close_subpolygon(pgls));
- break;
- case 2 :
- if ( pgls->g.polygon_mode ) {
- /* explicitly close the path if the pen is down */
- if ( pgls->g.move_or_draw == hpgl_pen_down
- && pgls->g.have_drawn_in_path )
- hpgl_call(hpgl_close_current_path(pgls));
- /* make a copy of the path and clear the current path */
- hpgl_call(hpgl_copy_current_path_to_polygon_buffer(pgls));
- hpgl_call(hpgl_clear_current_path(pgls));
- /* return to vector mode */
- pgls->g.polygon_mode = false;
- /* restore the pen state */
- hpgl_restore_pen_state(pgls,
- &pgls->g.polygon.pen_state,
- hpgl_pen_down | hpgl_pen_pos);
- }
- break;
- default:
- return e_Range;
- }
- return 0;
+ /* global flag to indicate that we are in polygon mode */
+ pgls->g.polygon_mode = true;
+ /* save the pen state, to be restored by PM2 */
+ hpgl_save_pen_state(pgls,
+ &pgls->g.polygon.pen_state,
+ hpgl_pen_down | hpgl_pen_pos);
+ break;
+ case 1 :
+ hpgl_call(hpgl_close_subpolygon(pgls));
+ break;
+ case 2 :
+ if ( pgls->g.polygon_mode ) {
+ /* explicitly close the path if the pen is down */
+ if ( pgls->g.move_or_draw == hpgl_pen_down
+ && pgls->g.have_drawn_in_path )
+ hpgl_call(hpgl_close_current_path(pgls));
+ /* make a copy of the path and clear the current path */
+ hpgl_call(hpgl_copy_current_path_to_polygon_buffer(pgls));
+ hpgl_call(hpgl_clear_current_path(pgls));
+ /* return to vector mode */
+ pgls->g.polygon_mode = false;
+ /* restore the pen state */
+ hpgl_restore_pen_state(pgls,
+ &pgls->g.polygon.pen_state,
+ hpgl_pen_down | hpgl_pen_pos);
+ }
+ break;
+ default:
+ return e_Range;
+ }
+ return 0;
}
/* RA x,y; */
int
hpgl_RA(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
hpgl_call(hpgl_rectangle(pargs, pgls, 0, true));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls,
- hpgl_get_poly_render_mode(pgls)));
- return 0;
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls,
+ hpgl_get_poly_render_mode(pgls)));
+ return 0;
}
/* RR dx,dy;*/
int
hpgl_RR(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
hpgl_call(hpgl_rectangle(pargs, pgls, DO_RELATIVE, true));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls,
- hpgl_get_poly_render_mode(pgls)));
- return 0;
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls,
+ hpgl_get_poly_render_mode(pgls)));
+ return 0;
}
/* RQ dx,dy;*/
int
hpgl_RQ(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
+{
/* contary to the specification HP uses default pixel placement
with RQ */
byte save_pp = pgls->pp_mode;
@@ -355,16 +355,15 @@ hpgl_RQ(hpgl_args_t *pargs, hpgl_state_t *pgls)
return 0;
}
-
/* WG radius,astart,asweep[,achord]; */
int
hpgl_WG(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{
- hpgl_call(hpgl_wedge(pargs, pgls));
- hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
- hpgl_call(hpgl_draw_current_path(pgls,
- hpgl_get_poly_render_mode(pgls)));
- return 0;
+{
+ hpgl_call(hpgl_wedge(pargs, pgls));
+ hpgl_call(hpgl_copy_polygon_buffer_to_current_path(pgls));
+ hpgl_call(hpgl_draw_current_path(pgls,
+ hpgl_get_poly_render_mode(pgls)));
+ return 0;
}
/* Initialization */
@@ -374,18 +373,18 @@ pgpoly_do_registration(
gs_memory_t *mem)
{ /* Register commands */
DEFINE_HPGL_COMMANDS(mem)
- HPGL_COMMAND('E', 'A', hpgl_EA, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('E', 'P', hpgl_EP, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('E', 'R', hpgl_ER, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('E', 'W', hpgl_EW, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('F', 'P', hpgl_FP, hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('P', 'M', hpgl_PM, hpgl_cdf_polygon|hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('R', 'A', hpgl_RA, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('R', 'R', hpgl_RR, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('R', 'Q', hpgl_RQ, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- HPGL_COMMAND('W', 'G', hpgl_WG, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
- END_HPGL_COMMANDS
- return 0;
+ HPGL_COMMAND('E', 'A', hpgl_EA, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('E', 'P', hpgl_EP, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('E', 'R', hpgl_ER, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('E', 'W', hpgl_EW, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('F', 'P', hpgl_FP, hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('P', 'M', hpgl_PM, hpgl_cdf_polygon|hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('R', 'A', hpgl_RA, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('R', 'R', hpgl_RR, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('R', 'Q', hpgl_RQ, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ HPGL_COMMAND('W', 'G', hpgl_WG, hpgl_cdf_lost_mode_cleared|hpgl_cdf_pcl_rtl_both),
+ END_HPGL_COMMANDS
+ return 0;
}
const pcl_init_t pgpoly_init = {
pgpoly_do_registration, 0
diff --git a/pcl/pgstate.h b/pcl/pgstate.h
index 4dbce5f7c..419cca0a9 100644
--- a/pcl/pgstate.h
+++ b/pcl/pgstate.h
@@ -21,7 +21,7 @@
#ifndef pgstate_INCLUDED
#define pgstate_INCLUDED
-/*
+/*
* HPGL/2 coordinates are internally represented in plotter units
* 1/1024" when scaling is off and user units when scaling is in
* effect. The data structure g.pos maintains the coordinates in the
@@ -63,7 +63,7 @@ typedef struct hpgl_line_type_s {
} hpgl_line_type_t;
typedef struct hpgl_path_state_s {
- gx_path path;
+ gx_path path;
} hpgl_path_state_t;
/* Define rendering modes - character, polygon, or vector.
@@ -71,33 +71,33 @@ typedef struct hpgl_path_state_s {
hpgl_set_graphics_line_attribute_state) and whether we use
stroke or fill on the path. */
typedef enum {
- hpgl_rm_vector,
- hpgl_rm_vector_no_close,
- hpgl_rm_character,
- hpgl_rm_polygon,
- hpgl_rm_vector_fill,
- hpgl_rm_clip_and_fill_polygon, /* for hpgl/2 line type filling */
- hpgl_rm_nop /* don't do anything with the path. future use */
+ hpgl_rm_vector,
+ hpgl_rm_vector_no_close,
+ hpgl_rm_character,
+ hpgl_rm_polygon,
+ hpgl_rm_vector_fill,
+ hpgl_rm_clip_and_fill_polygon, /* for hpgl/2 line type filling */
+ hpgl_rm_nop /* don't do anything with the path. future use */
} hpgl_rendering_mode_t;
/* state of lost mode */
typedef enum {
- hpgl_lost_mode_entered,
- hpgl_lost_mode_cleared
+ hpgl_lost_mode_entered,
+ hpgl_lost_mode_cleared
} hpgl_lost_mode_t;
typedef enum {
- hpgl_even_odd_rule,
- hpgl_winding_number_rule
+ hpgl_even_odd_rule,
+ hpgl_winding_number_rule
} hpgl_render_fill_type_t;
/* Define the structure for saving the pen state temporarily. */
/* HAS: note don't mix and match save a restores. perhaps there
should be a type check field in the structure. */
typedef struct hpgl_pen_state_s {
- int relative_coords;
- int move_or_draw;
- gs_point pos;
+ int relative_coords;
+ int move_or_draw;
+ gs_point pos;
} hpgl_pen_state_t;
/* Define the parameters for GL hatch/cross-hatch fill types. */
@@ -129,190 +129,190 @@ typedef enum {
gs_moveto, gs_rmoveto, gs_lineto, gs_rlineto
typedef struct pcl_hpgl_state_s {
- /* Chapter 17 lost mode (pgmisc.c) */
-
- /* According to PCLTRM IN, PG, RP and PA with args in range clears
- lost mode. Note that all these commands have PA with valid args
- as a side effect so only PA needs to clear lost mode. */
+ /* Chapter 17 lost mode (pgmisc.c) */
+
+ /* According to PCLTRM IN, PG, RP and PA with args in range clears
+ lost mode. Note that all these commands have PA with valid args
+ as a side effect so only PA needs to clear lost mode. */
- hpgl_lost_mode_t lost_mode;
+ hpgl_lost_mode_t lost_mode;
- /* Chapter 18 (pgframe.c) */
+ /* Chapter 18 (pgframe.c) */
- struct pf_ {
- coord_point_t size;
- coord_point_t anchor_point;
- } picture_frame;
+ struct pf_ {
+ coord_point_t size;
+ coord_point_t anchor_point;
+ } picture_frame;
#define picture_frame_width picture_frame.size.x
#define picture_frame_height picture_frame.size.y
- coord_point_t plot_size;
+ coord_point_t plot_size;
#define plot_width plot_size.x
#define plot_height plot_size.y
bool plot_size_vertical_specified;
bool plot_size_horizontal_specified;
- /* Chapter 19 (pgconfig.c) */
-
- enum {
- hpgl_scaling_none = -1,
- hpgl_scaling_anisotropic = 0,
- hpgl_scaling_isotropic = 1,
- hpgl_scaling_point_factor = 2
- } scaling_type;
- hpgl_scaling_params_t scaling_params;
- struct soft_clip_window_ {
+ /* Chapter 19 (pgconfig.c) */
+
+ enum {
+ hpgl_scaling_none = -1,
+ hpgl_scaling_anisotropic = 0,
+ hpgl_scaling_isotropic = 1,
+ hpgl_scaling_point_factor = 2
+ } scaling_type;
+ hpgl_scaling_params_t scaling_params;
+ struct soft_clip_window_ {
bool active; /* current unit window has be given,
if not use picture frame */
bool isbound; /* bound to plotter units */
- gs_rect rect; /* clipping window (IW) */
- } soft_clip_window;
- int rotation;
- gs_point P1, P2; /* in plotter units */
-
- /* Chapter 20 (pgvector.c) */
-
- int move_or_draw; /* hpgl_plot_move/draw */
- int relative_coords; /* hpgl_plot_absolute/relative */
+ gs_rect rect; /* clipping window (IW) */
+ } soft_clip_window;
+ int rotation;
+ gs_point P1, P2; /* in plotter units */
+
+ /* Chapter 20 (pgvector.c) */
+
+ int move_or_draw; /* hpgl_plot_move/draw */
+ int relative_coords; /* hpgl_plot_absolute/relative */
gs_point pos;
/* used to track the line drawing state in hpgl */
gs_point first_point;
- /* Chapter 21 (pgpoly.c) */
- struct polygon_ {
- hpgl_path_state_t buffer; /* path for polygon buffer */
- hpgl_pen_state_t pen_state; /* save pen state during polygon mode */
- } polygon;
- bool polygon_mode;
-
- /* Chapter 22 (pglfill.c) */
-
- struct lp_ {
- struct ltl_ {
- int type;
- /* the offset value is not required by the gl/2
+ /* Chapter 21 (pgpoly.c) */
+ struct polygon_ {
+ hpgl_path_state_t buffer; /* path for polygon buffer */
+ hpgl_pen_state_t pen_state; /* save pen state during polygon mode */
+ } polygon;
+ bool polygon_mode;
+
+ /* Chapter 22 (pglfill.c) */
+
+ struct lp_ {
+ struct ltl_ {
+ int type;
+ /* the offset value is not required by the gl/2
language, however we use it to implement offsetting
line patterns for hpgl/2 vector fills */
float pattern_offset;
- float pattern_length;
- bool pattern_length_relative;
- bool is_solid;
- gs_point pos;
- } current, saved; /* enable saving for LT99 */
- int cap;
- int join;
- } line;
- float miter_limit;
- struct pen_ {
- bool width_relative;
- int selected; /* currently selected pen # */
- } pen;
- byte symbol_mode; /* 0 if not in symbol mode */
- struct ft_ {
+ float pattern_length;
+ bool pattern_length_relative;
+ bool is_solid;
+ gs_point pos;
+ } current, saved; /* enable saving for LT99 */
+ int cap;
+ int join;
+ } line;
+ float miter_limit;
+ struct pen_ {
+ bool width_relative;
+ int selected; /* currently selected pen # */
+ } pen;
+ byte symbol_mode; /* 0 if not in symbol mode */
+ struct ft_ {
hpgl_FT_pattern_source_t type;
- /*
- * Because each fill type remembers its previous parameter values,
- * we must use a structure rather than a union here.
- */
- struct fp_ {
- hpgl_hatch_params_t hatch;
- hpgl_hatch_params_t crosshatch;
- int shading; /* 0..100 */
- struct { int pattern_index; bool use_current_pen; } user_defined;
- int pattern_type;
- uint pattern_id;
- } param;
- } fill;
+ /*
+ * Because each fill type remembers its previous parameter values,
+ * we must use a structure rather than a union here.
+ */
+ struct fp_ {
+ hpgl_hatch_params_t hatch;
+ hpgl_hatch_params_t crosshatch;
+ int shading; /* 0..100 */
+ struct { int pattern_index; bool use_current_pen; } user_defined;
+ int pattern_type;
+ uint pattern_id;
+ } param;
+ } fill;
/* current bits of fraction for polyline encoded numbers */
int32 fraction_bits;
- hpgl_render_fill_type_t fill_type;
- hpgl_line_type_t fixed_line_type[8];
- hpgl_line_type_t adaptive_line_type[8];
- gs_point anchor_corner;
- bool source_transparent;
- struct scr_ {
+ hpgl_render_fill_type_t fill_type;
+ hpgl_line_type_t fixed_line_type[8];
+ hpgl_line_type_t adaptive_line_type[8];
+ gs_point anchor_corner;
+ bool source_transparent;
+ struct scr_ {
hpgl_SV_pattern_source_t type;
- struct sp_ {
- int shading; /* 0..100 */
- struct { int pattern_index; bool use_current_pen; } user_defined;
- int pattern_type;
- uint pattern_id;
- } param;
- } screen;
- /* Temporary while downloading raster fill pattern */
- struct rf_ {
- int index, width, height;
- uint raster;
- byte *data;
+ struct sp_ {
+ int shading; /* 0..100 */
+ struct { int pattern_index; bool use_current_pen; } user_defined;
+ int pattern_type;
+ uint pattern_id;
+ } param;
+ } screen;
+ /* Temporary while downloading raster fill pattern */
+ struct rf_ {
+ int index, width, height;
+ uint raster;
+ byte *data;
bool is_mask;
- } raster_fill;
-
- /* Chapter 23 (pgchar.c, pglabel.c) */
-
- pcl_font_selection_t font_selection[2];
- int font_selected; /* 0 or 1 */
- pl_font_t *font; /* 0 means recompute from params */
- pl_symbol_map_t *map; /* map for current font */
- pl_font_t stick_font[2][2]; /* stick/arc fonts */
- struct ch_ {
- gs_point direction;
- bool direction_relative;
- enum {
- hpgl_text_right = 0,
- hpgl_text_down = 1,
- hpgl_text_left = 2,
- hpgl_text_up = 3
- } text_path;
+ } raster_fill;
+
+ /* Chapter 23 (pgchar.c, pglabel.c) */
+
+ pcl_font_selection_t font_selection[2];
+ int font_selected; /* 0 or 1 */
+ pl_font_t *font; /* 0 means recompute from params */
+ pl_symbol_map_t *map; /* map for current font */
+ pl_font_t stick_font[2][2]; /* stick/arc fonts */
+ struct ch_ {
+ gs_point direction;
+ bool direction_relative;
+ enum {
+ hpgl_text_right = 0,
+ hpgl_text_down = 1,
+ hpgl_text_left = 2,
+ hpgl_text_up = 3
+ } text_path;
#define hpgl_text_is_vertical(path) (((path) & 1) != 0)
- int line_feed_direction; /* +1 = normal, -1 = reversed */
- gs_point extra_space;
- gs_point size;
- enum {
- hpgl_size_not_set,
- hpgl_size_absolute,
- hpgl_size_relative
- } size_mode;
- hpgl_real_t slant;
- enum {
- hpgl_char_solid_edge = 0,
- hpgl_char_edge = 1,
- hpgl_char_fill = 2,
- hpgl_char_fill_edge = 3
- } fill_mode;
- int edge_pen; /* 0 = no edge */
- } character;
- struct lb_ {
- int origin;
- uint terminator;
- bool print_terminator;
- /* Double-byte support */
- uint row_offset; /* implicit high byte */
- bool double_byte;
- bool write_vertical;
- /*
- * The following are only used during the execution of a
- * single LB command, but since hpgl_LB may need to exit
- * back to the parser for more data, we can't make them
- * local variables of hpgl_LB.
- */
- gs_point initial_pos;
+ int line_feed_direction; /* +1 = normal, -1 = reversed */
+ gs_point extra_space;
+ gs_point size;
+ enum {
+ hpgl_size_not_set,
+ hpgl_size_absolute,
+ hpgl_size_relative
+ } size_mode;
+ hpgl_real_t slant;
+ enum {
+ hpgl_char_solid_edge = 0,
+ hpgl_char_edge = 1,
+ hpgl_char_fill = 2,
+ hpgl_char_fill_edge = 3
+ } fill_mode;
+ int edge_pen; /* 0 = no edge */
+ } character;
+ struct lb_ {
+ int origin;
+ uint terminator;
+ bool print_terminator;
+ /* Double-byte support */
+ uint row_offset; /* implicit high byte */
+ bool double_byte;
+ bool write_vertical;
+ /*
+ * The following are only used during the execution of a
+ * single LB command, but since hpgl_LB may need to exit
+ * back to the parser for more data, we can't make them
+ * local variables of hpgl_LB.
+ */
+ gs_point initial_pos;
#define hpgl_char_count 128 /* initial buffer size */
- byte *buffer; /* start of line buffer pointer */
+ byte *buffer; /* start of line buffer pointer */
uint buffer_size; /* size of the current buffer */
- uint char_count; /* count of chars in the buffer */
+ uint char_count; /* count of chars in the buffer */
byte ch;
byte prev_ch;
bool have_16bits; /* two byte terminators need 16 bits */
- } label;
- bool transparent_data;
- uint font_id[2];
- bool bitmap_fonts_allowed;
- gs_point carriage_return_pos;
+ } label;
+ bool transparent_data;
+ uint font_id[2];
+ bool bitmap_fonts_allowed;
+ gs_point carriage_return_pos;
/* extra pen state for routines that cannot use local variables
- because of longjmp parser braindamage. */
+ because of longjmp parser braindamage. */
hpgl_pen_state_t pen_state;
- bool subpolygon_started; /* true if we are just starting a subpolygon */
- bool have_drawn_in_path; /* true if the pen has been down during this path */
+ bool subpolygon_started; /* true if we are just starting a subpolygon */
+ bool have_drawn_in_path; /* true if the pen has been down during this path */
} pcl_hpgl_state_t;
#define hpgl_pen_relative (1)
diff --git a/pcl/rtgmode.c b/pcl/rtgmode.c
index ec68c5e49..45adc0ee4 100644
--- a/pcl/rtgmode.c
+++ b/pcl/rtgmode.c
@@ -69,11 +69,11 @@ adjust_pres_mode(pcl_state_t *pcs)
* Get the effective printing region in raster space
*/
static void
-get_raster_print_rect( const gs_memory_t *mem,
- const gs_rect * plp_print_rect,
- gs_rect * prst_print_rect,
- const gs_matrix * prst2lp
- )
+get_raster_print_rect( const gs_memory_t *mem,
+ const gs_rect * plp_print_rect,
+ gs_rect * prst_print_rect,
+ const gs_matrix * prst2lp
+ )
{
gs_matrix lp2rst;
@@ -164,14 +164,14 @@ get_raster_print_rect( const gs_memory_t *mem,
*
* If only one destination dimension is specified, the ratio of this
* dimension to the corresponding source dimension determins the
- * raster scale for both dimensions; With strange interactions with
+ * raster scale for both dimensions; With strange interactions with
* the 1200centipoint margin and rotated pages (Bug emulation).
*
* If neither dimension is specified, the page printable region is
* transformed to raster space, the intersection of this with the
* positive quadrant is taken. The dimensions of the resulting region
* are compared with the dimensions of the source raster. The smaller
- * of the two dest_dim / src_dim ratios is used as the ratio for
+ * of the two dest_dim / src_dim ratios is used as the ratio for
* the raster scale in both dimensions (i.e.: select the largest
* isotropic scaling that does not cause clipping).
*
@@ -179,7 +179,7 @@ get_raster_print_rect( const gs_memory_t *mem,
* converting the page printable region to raster space and intersecting
* the result with the positive quadrant. This region is used to determine
* the useable source raster width and height.
- *
+ *
*/
int
pcl_enter_graphics_mode(
@@ -248,32 +248,32 @@ pcl_enter_graphics_mode(
scale_y = scale_x;
} else if (prstate->dest_width_set) {
- scale_x = (floatp)prstate->dest_width_cp / (floatp)prstate->src_width;
-
- if ( clip_x < 0 && pxfmst->lp_orient == 3 ) {
- scale_y = (floatp)(prstate->dest_width_cp - clip_y ) / (floatp)prstate->src_width;
- if ( rot == 2 && scale_y <= 2* prstate->src_width) /* empirical test 1 */
- scale_y = scale_x;
- }
- else if ( clip_x < 0 && pxfmst->lp_orient == 1 && rot == 3 ) {
- scale_y = (floatp)(prstate->dest_width_cp - clip_y) / (floatp)prstate->src_width;
-
- if ( prstate->dest_width_cp <= 7200 ) /* empirical test 2 */
- scale_y = (floatp)(prstate->dest_width_cp + clip_y) / (floatp)prstate->src_width;
- }
- else
- scale_y = scale_x;
-
- if (prstate->dest_height_set)
- scale_y = (floatp)prstate->dest_height_cp / (floatp)prstate->src_height;
-
- } else if (prstate->dest_height_set) {
- scale_x = scale_y = (floatp)prstate->dest_height_cp / (floatp)prstate->src_height;
+ scale_x = (floatp)prstate->dest_width_cp / (floatp)prstate->src_width;
+
+ if ( clip_x < 0 && pxfmst->lp_orient == 3 ) {
+ scale_y = (floatp)(prstate->dest_width_cp - clip_y ) / (floatp)prstate->src_width;
+ if ( rot == 2 && scale_y <= 2* prstate->src_width) /* empirical test 1 */
+ scale_y = scale_x;
+ }
+ else if ( clip_x < 0 && pxfmst->lp_orient == 1 && rot == 3 ) {
+ scale_y = (floatp)(prstate->dest_width_cp - clip_y) / (floatp)prstate->src_width;
+
+ if ( prstate->dest_width_cp <= 7200 ) /* empirical test 2 */
+ scale_y = (floatp)(prstate->dest_width_cp + clip_y) / (floatp)prstate->src_width;
+ }
+ else
+ scale_y = scale_x;
+
+ if (prstate->dest_height_set)
+ scale_y = (floatp)prstate->dest_height_cp / (floatp)prstate->src_height;
+
+ } else if (prstate->dest_height_set) {
+ scale_x = scale_y = (floatp)prstate->dest_height_cp / (floatp)prstate->src_height;
} else {
/* select isotropic scaling with no clipping */
- scale_x = (floatp)dwid / (floatp)prstate->src_width;
- scale_y = (floatp)dhgt / (floatp)prstate->src_height;
+ scale_x = (floatp)dwid / (floatp)prstate->src_width;
+ scale_y = (floatp)dhgt / (floatp)prstate->src_height;
if (scale_x > scale_y)
scale_x = scale_y;
else
@@ -382,12 +382,11 @@ pcl_end_graphics_mode(
);
}
-
/*
* ESC * t # R
*
- * Set raster graphics resolution.
- * The value provided will be rounded up to the nearest legal value or down to 600dpi.
+ * Set raster graphics resolution.
+ * The value provided will be rounded up to the nearest legal value or down to 600dpi.
* 75 100 150 200 300 600 are legal; 120 and 85.7143 are multiples of 75 but not legal.
*/
static int
@@ -399,7 +398,6 @@ set_graphics_resolution(
uint res = arg_is_present(pargs) ? uint_arg(pargs) : 75;
uint qi = 600 / res;
-
/* HP does not allow 120 dpi or 85.7 dpi as a resolution */
qi = (qi == 0 ? 1 : (qi > 8 ? 8 : (qi == 7 ? 6 : (qi == 5 ? 4 : qi))));
@@ -529,14 +527,14 @@ set_dest_raster_width(
)
{
if (!pcs->raster_state.graphics_mode) {
- if ( arg_is_present(pargs) ) {
- uint dw = 10 * fabs(float_arg(pargs));
-
- pcs->raster_state.dest_width_cp = dw;
- pcs->raster_state.dest_width_set = (dw != 0);
- }
- else
- pcs->raster_state.dest_width_set = false;
+ if ( arg_is_present(pargs) ) {
+ uint dw = 10 * fabs(float_arg(pargs));
+
+ pcs->raster_state.dest_width_cp = dw;
+ pcs->raster_state.dest_width_set = (dw != 0);
+ }
+ else
+ pcs->raster_state.dest_width_set = false;
}
return 0;
}
@@ -558,15 +556,15 @@ set_dest_raster_height(
pcl_state_t * pcs
)
{
- if (!pcs->raster_state.graphics_mode) {
- if ( arg_is_present(pargs) ) {
- uint dh = 10 * fabs(float_arg(pargs));
-
- pcs->raster_state.dest_height_cp = dh;
- pcs->raster_state.dest_height_set = (dh != 0);
- }
- else
- pcs->raster_state.dest_height_set = false;
+ if (!pcs->raster_state.graphics_mode) {
+ if ( arg_is_present(pargs) ) {
+ uint dh = 10 * fabs(float_arg(pargs));
+
+ pcs->raster_state.dest_height_cp = dh;
+ pcs->raster_state.dest_height_set = (dh != 0);
+ }
+ else
+ pcs->raster_state.dest_height_set = false;
}
return 0;
}
@@ -638,7 +636,6 @@ end_graphics_mode_C(
return 0;
}
-
/*
* Initialization
*/
@@ -736,7 +733,7 @@ gmode_do_reset(
if ((type & mask) != 0) {
pcl_raster_state_t * prstate = &(pcs->raster_state);
- prstate->gmargin_cp = 0L;
+ prstate->gmargin_cp = 0L;
prstate->resolution = 75;
prstate->pres_mode_3 = true;
prstate->scale_raster = false;
diff --git a/pcl/rtgmode.h b/pcl/rtgmode.h
index eb2b21013..39dc7a748 100644
--- a/pcl/rtgmode.h
+++ b/pcl/rtgmode.h
@@ -32,7 +32,6 @@ typedef enum {
IMPLICIT = 100
} pcl_gmode_entry_t;
-
/* enter raster graphics mode */
int pcl_enter_graphics_mode(
pcl_state_t * pcs,
diff --git a/pcl/rtmisc.c b/pcl/rtmisc.c
index acf21d6ca..0b0f64559 100644
--- a/pcl/rtmisc.c
+++ b/pcl/rtmisc.c
@@ -18,7 +18,7 @@
#include "pgdraw.h" /* for hpgl_add_pcl_point_to_path() */
#include "pgmisc.h" /* for hpgl_call */
#include "gsmemory.h"
-#include "gsrop.h"
+#include "gsrop.h"
#include "gscoord.h"
#include "pcpatxfm.h"
#include "pcpage.h"
@@ -33,7 +33,7 @@ extern const pcl_init_t * pcl_init_table[];
/*
* ESC % <enum> B
- */
+ */
static int
rtl_enter_hpgl_mode(
pcl_args_t * pargs,
@@ -44,9 +44,9 @@ rtl_enter_hpgl_mode(
/* Note: -1..3 for PCL5c, 0..1 for PCL5 */
if (i < 0)
- i = -1;
+ i = -1;
else if (i > 3)
- return 0;
+ return 0;
hpgl_call_mem(pcs->memory, hpgl_clear_current_path(pcs));
pcs->parse_other = ( int (*)( void *,
pcl_state_t *,
@@ -55,12 +55,12 @@ rtl_enter_hpgl_mode(
/* add the pcl cap to hpgl/2's path */
if (i == 1) {
- gs_point pcl_pt;
+ gs_point pcl_pt;
- pcl_pt.x = (hpgl_real_t)pcs->cap.x;
- pcl_pt.y = (hpgl_real_t)pcs->cap.y;
+ pcl_pt.x = (hpgl_real_t)pcs->cap.x;
+ pcl_pt.y = (hpgl_real_t)pcs->cap.y;
hpgl_add_pcl_point_to_path(pcs, &pcl_pt);
- hpgl_update_carriage_return_pos(pcs);
+ hpgl_update_carriage_return_pos(pcs);
}
hpgl_call_mem(pcs->memory, hpgl_set_ctm(pcs));
return 0;
@@ -71,7 +71,7 @@ rtl_enter_hpgl_mode(
* Note that it returns 1 iff it changed the PCL CAP.
*
* ESC % <enum> A
- */
+ */
int
rtl_enter_pcl_mode(
pcl_args_t * pargs,
@@ -80,30 +80,30 @@ rtl_enter_pcl_mode(
{
int b = int_arg(pargs) & 1;
- if ( pcs->parse_other ==
- (int(*)(void *, pcl_state_t *, stream_cursor_read *))hpgl_process ) {
- /*
+ if ( pcs->parse_other ==
+ (int(*)(void *, pcl_state_t *, stream_cursor_read *))hpgl_process ) {
+ /*
* We were in HP-GL/2 mode. Destroy the gl/2 polygon path
- * and conditionally copy back the cursor position.
+ * and conditionally copy back the cursor position.
*/
- if (b != 0) {
+ if (b != 0) {
/* the usual user -> device -> user dance. */
- gs_point pt, dev_pt;
+ gs_point pt, dev_pt;
- hpgl_call_mem(pcs->memory, hpgl_set_ctm(pcs));
- hpgl_call_mem(pcs->memory, hpgl_get_current_position(pcs, &pt));
- hpgl_call_mem(pcs->memory, gs_transform(pcs->pgs, pt.x, pt.y, &dev_pt));
- hpgl_call_mem(pcs->memory, pcl_set_ctm(pcs, true));
- hpgl_call_mem(pcs->memory, gs_itransform(pcs->pgs, dev_pt.x, dev_pt.y, &pt));
+ hpgl_call_mem(pcs->memory, hpgl_set_ctm(pcs));
+ hpgl_call_mem(pcs->memory, hpgl_get_current_position(pcs, &pt));
+ hpgl_call_mem(pcs->memory, gs_transform(pcs->pgs, pt.x, pt.y, &dev_pt));
+ hpgl_call_mem(pcs->memory, pcl_set_ctm(pcs, true));
+ hpgl_call_mem(pcs->memory, gs_itransform(pcs->pgs, dev_pt.x, dev_pt.y, &pt));
- /* HPGL/2 uses floats for coordinates */
+ /* HPGL/2 uses floats for coordinates */
#define round(x) (((x) < 0.0) ? (ceil ((x) - 0.5)) : (floor ((x) + 0.5)))
- pcs->cap.x = round(pt.x);
- pcs->cap.y = round(pt.y);
+ pcs->cap.x = round(pt.x);
+ pcs->cap.y = round(pt.y);
#undef round
- }
+ }
} else
- b = 0;
+ b = 0;
pcs->parse_other = 0;
return b; /* not 0, see comment above */
@@ -127,15 +127,15 @@ pcl_appletalk_configuration(
uint i;
if ((count < 2) || (data[0] == ' '))
- return e_Range;
+ return e_Range;
/* split the string at the first space */
for (i = 1; data[i] != ' '; ++i) {
- if (i == count - 1)
- return e_Range;
+ if (i == count - 1)
+ return e_Range;
}
if (pcs->configure_appletalk == 0)
- return 0;
+ return 0;
return (*pcs->configure_appletalk)(data, i, data + i + 1, count - (i + 1));
}
@@ -153,7 +153,7 @@ pcl_negative_motion(
int motion = int_arg(pargs);
if (motion > 1)
- return e_Range;
+ return e_Range;
/* Currently we can't take any advantage of this.... */
return 0;
@@ -174,14 +174,14 @@ rtmisc_do_registration(
0, 'B',
PCL_COMMAND( "Enter HP-GL/2 Mode",
rtl_enter_hpgl_mode,
- pca_neg_ok | pca_big_ok | pca_in_rtl
+ pca_neg_ok | pca_big_ok | pca_in_rtl
)
},
{
0, 'A',
- PCL_COMMAND( "Enter PCL Mode",
+ PCL_COMMAND( "Enter PCL Mode",
rtl_enter_pcl_mode,
- pca_neg_ok | pca_big_ok | pca_in_rtl
+ pca_neg_ok | pca_big_ok | pca_in_rtl
)
},
END_CLASS
@@ -190,16 +190,16 @@ rtmisc_do_registration(
DEFINE_CLASS('&')
{
'b', 'W',
- PCL_COMMAND( "Appletalk Configuration",
- pcl_appletalk_configuration,
- pca_bytes
+ PCL_COMMAND( "Appletalk Configuration",
+ pcl_appletalk_configuration,
+ pca_bytes
)
},
{
'a', 'N',
- PCL_COMMAND( "Negative Motion",
+ PCL_COMMAND( "Negative Motion",
pcl_negative_motion,
- pca_neg_error | pca_big_error
+ pca_neg_error | pca_big_error
)
},
END_CLASS
diff --git a/pcl/rtraster.c b/pcl/rtraster.c
index a40249262..24c3109f8 100644
--- a/pcl/rtraster.c
+++ b/pcl/rtraster.c
@@ -47,14 +47,14 @@
* Structure to describe a PCL raster
*/
typedef struct pcl_raster_s {
-
+
/* memory used to allocate this structure */
gs_memory_t * pmem;
-
+
byte nplanes; /* # of planes (seed rows) */
byte bits_per_plane; /* bits per plane */
byte nsrcs; /* # of data sources, 1 or 3 */
-
+
uint transparent:1; /* 1 ==> source transparency */
uint src_height_set:1; /* source height was set */
uint indexed:1; /* != 0 ==> indexed color space */
@@ -64,27 +64,27 @@ typedef struct pcl_raster_s {
int wht_indx; /* white index, for indexed color
space only */
const void * remap_ary; /* remap array, if needed */
-
+
pcl_state_t * pcs; /* to avoid n extra operand */
pcl_cs_indexed_t * pindexed; /* color space */
-
+
gs_image_enum * pen; /* image enumerator */
uint16 plane_index; /* next plane to be received */
uint16 rows_rendered; /* # of source rows rendered */
uint16 src_width; /* usable raster width */
uint16 src_height; /* remaining usable raster height */
-
+
/* objects required for opaque source/transparent pattern case */
gs_image_enum * mask_pen; /* enumerator for mask */
pcl_cs_indexed_t * mask_pindexed; /* special color space for mask */
ulong white_val; /* value interpreted as white */
void (*gen_mask_row)( struct pcl_raster_s * prast );
-
+
/* buffers */
pcl_seed_row_t * pseed_rows; /* seed rows, one per plane */
byte * cons_buff; /* consolidation buffer */
byte * mask_buff; /* buffer for mask row, if needed */
-
+
} pcl_raster_t;
/* GC routines */
@@ -103,7 +103,6 @@ gs_private_st_ptrs2( st_raster_t,
/* forward declaration */
static int process_zero_rows( gs_state * pgs, pcl_raster_t * prast, int nrows );
-
/*
* Clear the consolidation buffer, allocating it if it does not already
* exist.
@@ -316,39 +315,39 @@ consolidate_row(
byte * op = pcons;
int cnt = npixels;
- for (; cnt >= 8; ip++, op += 8, cnt -= 8) {
- uint val = *ip;
+ for (; cnt >= 8; ip++, op += 8, cnt -= 8) {
+ uint val = *ip;
- /*
- * cons_buff was allocated with gs_alloc_bytes, so we know
- * it is aligned for (at least) bits32 access.
- */
+ /*
+ * cons_buff was allocated with gs_alloc_bytes, so we know
+ * it is aligned for (at least) bits32 access.
+ */
#if ARCH_IS_BIG_ENDIAN
- static const bits32 spread[16] = {
- 0x00000000, 0x00000001, 0x00000100, 0x00000101,
- 0x00010000, 0x00010001, 0x00010100, 0x00010101,
- 0x01000000, 0x01000001, 0x01000100, 0x01000101,
- 0x01010000, 0x01010001, 0x01010100, 0x01010101
- };
+ static const bits32 spread[16] = {
+ 0x00000000, 0x00000001, 0x00000100, 0x00000101,
+ 0x00010000, 0x00010001, 0x00010100, 0x00010101,
+ 0x01000000, 0x01000001, 0x01000100, 0x01000101,
+ 0x01010000, 0x01010001, 0x01010100, 0x01010101
+ };
#else
- static const bits32 spread[16] = {
- 0x00000000, 0x01000000, 0x00010000, 0x01010000,
- 0x00000100, 0x01000100, 0x00010100, 0x01010100,
- 0x00000001, 0x01000001, 0x00010001, 0x01010001,
- 0x00000101, 0x01000101, 0x00010101, 0x01010101
- };
+ static const bits32 spread[16] = {
+ 0x00000000, 0x01000000, 0x00010000, 0x01010000,
+ 0x00000100, 0x01000100, 0x00010100, 0x01010100,
+ 0x00000001, 0x01000001, 0x00010001, 0x01010001,
+ 0x00000101, 0x01000101, 0x00010101, 0x01010101
+ };
#endif
- ((bits32 *)op)[0] |= spread[val >> 4] << i;
- ((bits32 *)op)[1] |= spread[val & 0xf] << i;
- }
- if (cnt) {
- uint ishift = 7;
- uint val = *ip;
-
- do {
- *op++ |= ((val >> ishift--) & 0x1) << i;
- } while (--cnt > 0);
- }
+ ((bits32 *)op)[0] |= spread[val >> 4] << i;
+ ((bits32 *)op)[1] |= spread[val & 0xf] << i;
+ }
+ if (cnt) {
+ uint ishift = 7;
+ uint val = *ip;
+
+ do {
+ *op++ |= ((val >> ishift--) & 0x1) << i;
+ } while (--cnt > 0);
+ }
}
}
@@ -372,10 +371,10 @@ create_mask_enumerator(
*/
union {
gs_image1_t i1;
- gs_image4_t i4;
+ gs_image4_t i4;
} image;
gs_image_enum * pen = gs_image_enum_alloc( prast->pmem,
- "Create image for PCL raster" );
+ "Create image for PCL raster" );
int code = 0;
const byte * pcolor = 0;
gx_image_enum_common_t * pie = 0;
@@ -408,22 +407,22 @@ create_mask_enumerator(
image.i1.Width = prast->src_width;
image.i1.Height = prast->src_height;
- if ( pcs->personality == pcl5e )
- image.i1.CombineWithColor = false;
- else
- image.i1.CombineWithColor = true;
- image.i1.format = gs_image_format_chunky;
- image.i1.BitsPerComponent = 1;
- image.i1.Decode[0] = 0.0;
- image.i1.Decode[1] = 1.0;
+ if ( pcs->personality == pcl5e )
+ image.i1.CombineWithColor = false;
+ else
+ image.i1.CombineWithColor = true;
+ image.i1.format = gs_image_format_chunky;
+ image.i1.BitsPerComponent = 1;
+ image.i1.Decode[0] = 0.0;
+ image.i1.Decode[1] = 1.0;
if (transparent)
- image.i4.MaskColor[0] = 0.0;
-
- code = gs_image_begin_typed( (const gs_image_common_t *)&image,
- pcs->pgs,
- true,
- &pie
- );
+ image.i4.MaskColor[0] = 0.0;
+
+ code = gs_image_begin_typed( (const gs_image_common_t *)&image,
+ pcs->pgs,
+ true,
+ &pie
+ );
if (code >= 0)
code = gs_image_common_init( pen,
@@ -468,7 +467,7 @@ create_image_enumerator(
int use_image4 = prast->transparent;
union {
gs_image1_t i1;
- gs_image4_t i4;
+ gs_image4_t i4;
} image;
gs_image_enum * pen = gs_image_enum_alloc( prast->pmem,
"Create image for PCL raster" );
@@ -514,7 +513,7 @@ create_image_enumerator(
image.i1.Interpolate = prast->interpolate;
if (prast->indexed) {
- if (use_image4)
+ if (use_image4)
image.i4.MaskColor[0] = prast->wht_indx;
image.i1.Decode[0] = 0.0;
image.i1.Decode[1] = (1 << image.i1.BitsPerComponent) - 1;
@@ -525,7 +524,7 @@ create_image_enumerator(
image.i1.Decode[2 * i] = prast->pindexed->Decode[2 * i];
image.i1.Decode[2 * i + 1] = prast->pindexed->Decode[2 * i + 1];
- if (use_image4) {
+ if (use_image4) {
image.i4.MaskColor[i] = (1 << image.i1.BitsPerComponent);
if (image.i1.Decode[2 * i] == 1.0)
image.i4.MaskColor[i] = 0;
@@ -540,7 +539,7 @@ create_image_enumerator(
true,
&pie
);
- if (code >= 0)
+ if (code >= 0)
code = gs_image_common_init( pen,
pie,
(gs_data_image_t *)&image,
@@ -575,7 +574,7 @@ close_raster(
)
{
/* see if we need to fill in any missing rows */
- if ( complete &&
+ if ( complete &&
(prast->src_height > prast->rows_rendered) &&
prast->src_height_set )
(void)process_zero_rows(pgs, prast, prast->src_height - prast->rows_rendered);
@@ -594,7 +593,6 @@ close_raster(
prast->rows_rendered = 0;
}
-
/*
* Generate the white-mask corresponding to an image scanline. This is
* necessary to implement the opaque source/transparent texture case.
@@ -743,7 +741,7 @@ process_zero_rows(
}
/* render as raster or rectangle */
- if ( ((nrows * nbytes > 1024) || (prast->pen == 0)) &&
+ if ( ((nrows * nbytes > 1024) || (prast->pen == 0)) &&
(prast->zero_is_white || prast->zero_is_black) ) {
gs_state * pgs = prast->pcs->pgs;
@@ -760,21 +758,21 @@ process_zero_rows(
gs_setrasterop( pgs,
(gs_rop3_t)rop3_invert_S(gs_currentrasterop(pgs))
);
- gs_rectfill(pgs, &tmp_rect, 1 );
+ gs_rectfill(pgs, &tmp_rect, 1 );
gs_setrasterop( pgs,
(gs_rop3_t)rop3_invert_S(gs_currentrasterop(pgs))
);
- }
- else
- gs_rectfill(pgs, &tmp_rect, 1);
-
+ }
+ else
+ gs_rectfill(pgs, &tmp_rect, 1);
+
}
prast->src_height -= nrows;
- /* NB HP bug CET21.04 pg 7 */
- /* NB text cap move to moveto_nrows, but raster cap moveto nrows */
- gs_translate(pgs, 0.0, (floatp)moveto_nrows);
+ /* NB HP bug CET21.04 pg 7 */
+ /* NB text cap move to moveto_nrows, but raster cap moveto nrows */
+ gs_translate(pgs, 0.0, (floatp)moveto_nrows);
return 0;
@@ -817,7 +815,7 @@ process_zero_rows(
return code;
}
}
-
+
/*
* Process the next raster row.
*
@@ -920,7 +918,7 @@ process_row(
*/
static int
process_adaptive_compress(
- gs_state * pgs,
+ gs_state * pgs,
pcl_raster_t * prast,
const byte * pin,
uint insize
@@ -1093,7 +1091,7 @@ pcl_start_raster(
prast->pmem = pcs->memory;
- if ( pcs->source_transparent || pcs->pattern_transparent)
+ if ( pcs->source_transparent || pcs->pattern_transparent)
prast->transparent = true;
else
prast->transparent = false;
@@ -1183,7 +1181,7 @@ pcl_start_raster(
/* memory exhaustion; release the already allocated seed rows */
for (j = 0; j < i; j++)
- gs_free_object( prast->pmem,
+ gs_free_object( prast->pmem,
pseed_rows[j].pdata,
"start PCL raster"
);
@@ -1204,7 +1202,7 @@ pcl_start_raster(
/* see if a mask is required */
if ( !pcs->source_transparent &&
pcs->pattern_transparent &&
- (!prast->indexed ||
+ (!prast->indexed ||
(prast->wht_indx
< (1 << prast->nplanes * prast->bits_per_plane)) ) ) {
@@ -1293,7 +1291,6 @@ pcl_complete_raster(pcl_state_t *pcs)
gs_free_object(prast->pmem, prast->cons_buff, "Complete PCL raster");
if (prast->mask_buff != 0)
gs_free_object(prast->pmem, prast->mask_buff, "Complete PCL raster");
-
/* free the PCL raster robject itself */
gs_free_object(prast->pmem, prast, "Complete PCL raster");
@@ -1377,7 +1374,7 @@ set_line_path(
uint i = uint_arg(pargs);
if (i <= 1)
- pcs->raster_state.y_advance = (i == 1 ? -1 : 1);
+ pcs->raster_state.y_advance = (i == 1 ? -1 : 1);
return 0;
}
@@ -1416,12 +1413,12 @@ raster_do_registration(
)
},
{
- /* NB this command should *only* be exectuted in rtl but we
+ /* NB this command should *only* be exectuted in rtl but we
use it in both rtl and pcl5 */
'b', 'L',
PCL_COMMAND( "Line Path",
set_line_path,
- pca_neg_ok | pca_big_ignore | pca_in_rtl
+ pca_neg_ok | pca_big_ignore | pca_in_rtl
)
},
END_CLASS
diff --git a/pcl/rtrstcmp.c b/pcl/rtrstcmp.c
index 159f28f4f..fcddedd5c 100644
--- a/pcl/rtrstcmp.c
+++ b/pcl/rtrstcmp.c
@@ -136,7 +136,7 @@ uncompress_3(
if ((offset == 0x1f) && (i-- > 0)) {
uint add_offset;
- do
+ do
offset += (add_offset = *pin++);
while ((add_offset == 0xff) && (i-- > 0));
}
@@ -163,7 +163,7 @@ uncompress_3(
/*
* Compression mode 9.
*
- * HP's documentation of this command is not completely clear regarding the
+ * HP's documentation of this command is not completely clear regarding the
* interpretation of the replacement byte count for the run-length compression
* case. The interpretation used here, based on the documentation in the
* "PCL 5 Comparison Guide", October 1996 edition, pp. 2.94-2.96, is that the
@@ -182,7 +182,6 @@ uncompress_9(
byte * pb = pout->pdata;
byte * plim = pb + pout->size;
-
while (i-- > 0) {
uint val = *pin++;
uint cnt = 0;
@@ -231,7 +230,7 @@ uncompress_9(
*pb++ = rep_val;
}
i -= 2 * j;
-
+
} else {
if (cnt > i)
cnt = i;
@@ -248,10 +247,9 @@ uncompress_9(
}
-
void (*const pcl_decomp_proc[9 + 1])( pcl_seed_row_t * pout,
const byte * pin,
- int in_size
+ int in_size
) = {
uncompress_0,
uncompress_1,
diff --git a/pcl/rtrstcmp.h b/pcl/rtrstcmp.h
index b996cbaa8..e9b34c378 100644
--- a/pcl/rtrstcmp.h
+++ b/pcl/rtrstcmp.h
@@ -82,8 +82,8 @@ typedef struct pcl_seed_row_s {
* The array of decompression functions.
*/
extern void (*const pcl_decomp_proc[9 + 1])(pcl_seed_row_t *pout,
- const byte *pin,
- int in_size
+ const byte *pin,
+ int in_size
);
#endif /* rtrstcmp_INCLUDED */
diff --git a/pcl/rtrstst.h b/pcl/rtrstst.h
index c71e4283e..5afd64c3b 100644
--- a/pcl/rtrstst.h
+++ b/pcl/rtrstst.h
@@ -137,11 +137,11 @@ typedef struct pcl_raster_state_s {
* origin was at the logical page edge, hence
* the raster needs to be clipped */
pcl_raster_type *pcur_raster; /* There is at most one image
- * actively under construction in PCL
- * at one time. This pointer points
- * to that image, if it exists. The
- * pointer will be non-null while in
- * graphic mode. */
+ * actively under construction in PCL
+ * at one time. This pointer points
+ * to that image, if it exists. The
+ * pointer will be non-null while in
+ * graphic mode. */
} pcl_raster_state_t;
#endif /* rtrstst_INCLUDED */