summaryrefslogtreecommitdiff
path: root/pcl
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>1998-07-23 03:58:09 +0000
committerHenry Stiles <henry.stiles@artifex.com>1998-07-23 03:58:09 +0000
commitafbd308c838d0e32814f0d0a6187f88b7fc9eb5d (patch)
treeee9a46076a7b9d77b0c285366a6287322c52d847 /pcl
parent88c12f9e04760ca4d5f13418458a7e9aaff5d312 (diff)
This commit was generated by cvs2svn to compensate for changes in r196,
which included commits to RCS files with non-trunk default branches. git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@197 06663e23-700e-0410-b217-a244a6096597
Diffstat (limited to 'pcl')
-rw-r--r--pcl/news-pcl77
-rw-r--r--pcl/pccprint.c13
-rw-r--r--pcl/pcdraw.c32
-rw-r--r--pcl/pcdraw.h2
-rw-r--r--pcl/pcfsel.c3
-rw-r--r--pcl/pcl.mak5
-rw-r--r--pcl/pcl_ugcc.mak2
-rw-r--r--pcl/pclfont.c3
-rw-r--r--pcl/pcprint.c61
-rw-r--r--pcl/pcsfont.c4
-rw-r--r--pcl/pcstate.h3
-rw-r--r--pcl/pcstatus.c5
-rw-r--r--pcl/pgcolor.c15
-rw-r--r--pcl/pgconfig.c133
-rw-r--r--pcl/pgdraw.c103
-rw-r--r--pcl/pgdraw.h5
-rw-r--r--pcl/pgframe.c2
-rw-r--r--pcl/pggeom.c12
-rw-r--r--pcl/pginit.c17
-rw-r--r--pcl/pglabel.c64
-rw-r--r--pcl/pglfill.c29
-rw-r--r--pcl/pgpoly.c41
-rw-r--r--pcl/pgstate.h2
-rw-r--r--pcl/pgvector.c8
-rw-r--r--pcl/rtmisc.c8
25 files changed, 359 insertions, 290 deletions
diff --git a/pcl/news-pcl b/pcl/news-pcl
index d38264a12..96fa438fb 100644
--- a/pcl/news-pcl
+++ b/pcl/news-pcl
@@ -6,6 +6,83 @@
This file, NEWS-PCL, describes the changes in the most recent releases of
Aladdin's PCL5 code, in reverse chronological order.
+Version 0.40 (11/30/97)
+=======================
+
+(HAS)
+-rtmisc.c - changed comments, pcl_source_transparent() changed to only
+update state source transparency; moved gs call to
+pcl_set_drawing_color().
+-pgvector.c - hpgl_plot() update for symbol mode (see below). Also,
+changed/removed obsolete comments.
+-pgstate.h - edited obsolete comments.
+-pgpoly.c - sweep angles of 360 degrees no longer uses arc 3 point, now
+uses arc code directly.
+-pglfill.c - comment to check if updating transparency mode in gl/2
+needs also updates source/texture transparency in pcl, like MC updates
+pcl's logical op.
+-pglfill.c hpgl_SM() - parsing command incorrectly continued parse
+after getting the symbol, then reaching the ';' the code set the
+symbol code back to '\0'. We now return upon getting a symbol and let
+the parser discard the semicolon.
+-pglfill.c hpgl_MC() - default opcode for mode 1 was 255 instead of 252.
+-pglfill.c hpgl_PP() - moved this function from pgcolor.c.
+-pglfill.c hpgl_PP() - default fill mode should be adjust, not centered.
+-pglabel.c hpgl_print_symbol_mode_character() - interface for printing
+characters in symbol mode - (first attempt at symbol mode)
+-pglabel.c - reworked comments.
+-pginit.c - reworked comments.
+-pggeom.c: hpgl_compute_arc_coords() redone to use gs library's sin
+and cos functions.
+-pgframe.c - cleanup.
+-pgdraw.h - added hpgl_set_drawing_color() to the interface, needed by
+character code.
+-pgdraw.c hpgl_draw_current_path(): fixed to preserve the current path
+between drawing the edge and the fill of characters.
+-pgdraw.c hpgl_set_drawing_color(): gs calls to set fill adjustment,
+source and texture transparency.
+-pgdraw.c hpgl_set_pcl_to_plu_ctm(): left and bottom parameters were
+being treated as fractions instead of percentages.
+-pgdraw.c cleanup.
+-pgcolor.c hpgl_PP() - removed and moved in pglfill.c (see above).
+-pcstate.h changed bool grid_centered to float grid_adjust.
+-pcsfont.c - proper round of quarter dots -> quarter points. Yes this
+did cause a bug in the fts. A tenth of a point difference caused the
+wrong font to be selected. The rounding fixes the problem.
+-pcprint.c - pcl_purge_pattern_cache() now clears pcl pattern
+references.
+-pcprint.c - obsolete lvalue pcls->pattern_set removed.
+-pcprint.c pcl_store_user_defined_patterns() - now purges the pattern
+cache if the user downloads a pattern with the same id as the
+currently cached pattern.
+-pclfont.c - removed "Loaded" printf to cut down on stdout messages,
+the font loading code now reports any font *not* found in the internal
+table of resident fonts so this message should be unnecessary.
+-pcfsel.c - fixed debug message to divide "height_4ths" by 4 to print
+the point size.
+-pcdraw.c - added new function to clear pattern references.
+-pcdraw.c - gs calls to set source, texture, and fill adjust.
+-pccprint.c - pccprint_do_copy() doesn't need to evaluate boolean
+adjust since this is now maintained directly as floats.
+-pccprint.c - pcl_pixel_placement() grid adjust (not grid centered)
+now float.
+-pcl.mak - new include file dependencies added.
+
+(LPD) Adds some #includes to make the code compile with library version
+5.20, in which gs_memory_default is not declared by gsmemory.h.
+(pcstatus.c)
+
+See Version 0.38 notes for missing functionality.
+
+Version 0.39 (11/25/97)
+=======================
+
+This release simply changes the default pcl5 device to x11mono. Currently
+the pcl code does not completely support devices with more than 1 bit per
+pixel, previously the default device was X11 which is an 8 bit per pixel
+color device. The only necessary change was reordering the device files in
+the pcl5 makefile. (pcl.mak)
+
Version 0.38 (11/20/97)
=======================
diff --git a/pcl/pccprint.c b/pcl/pccprint.c
index 06c4c873c..e686fc5e3 100644
--- a/pcl/pccprint.c
+++ b/pcl/pccprint.c
@@ -18,20 +18,16 @@ pcl_logical_operation(pcl_args_t *pargs, pcl_state_t *pcls)
if ( rop > 255 )
return e_Range;
pcls->logical_op = rop;
- gs_setrasterop(pcls->pgs, rop);
return 0;
}
private int /* ESC * l <bool> R */
pcl_pixel_placement(pcl_args_t *pargs, pcl_state_t *pcls)
{ uint i = uint_arg(pargs);
- float adjust;
if ( i > 1 )
return 0;
- pcls->grid_centered = i != 0;
- adjust = (pcls->grid_centered ? 0.0 : 0.5);
- gs_setfilladjust(pcls->pgs, adjust, adjust);
+ pcls->grid_adjust = (i == 0) ? 0.5 : 0.0;
return 0;
}
@@ -64,10 +60,9 @@ private int
pccprint_do_copy(pcl_state_t *psaved, const pcl_state_t *pcls,
pcl_copy_operation_t operation)
{ if ( operation & pcl_copy_after )
- { float adjust;
- gs_setrasterop(pcls->pgs, psaved->logical_op);
- adjust = (psaved->grid_centered ? 0.0 : 0.5);
- gs_setfilladjust(pcls->pgs, adjust, adjust);
+ { gs_setrasterop(pcls->pgs, psaved->logical_op);
+ gs_setfilladjust(pcls->pgs,
+ psaved->grid_adjust, psaved->grid_adjust);
}
return 0;
}
diff --git a/pcl/pcdraw.c b/pcl/pcdraw.c
index 5462ba812..a9d0b8b92 100644
--- a/pcl/pcdraw.c
+++ b/pcl/pcdraw.c
@@ -10,6 +10,7 @@
#include "gsmatrix.h" /* for gsstate.h */
#include "gsmemory.h" /* for gsstate.h */
#include "gsstate.h"
+#include "gsrop.h"
#include "gscspace.h" /* for gscolor2.h */
#include "gscoord.h"
#include "gsdcolor.h"
@@ -555,12 +556,7 @@ pcl_set_drawing_color_rotation(pcl_state_t *pcls, pcl_pattern_type_t type,
*/
if ( id_value(*pid) != id_value(pcls->cached_pattern_id) )
{ /* Release patterns being decached. */
- int i;
- for ( i = 0; i < 3; ++i )
- { rc_decrement_only(pcls->cached_pattern[i],
- "old cached_pattern");
- pcls->cached_pattern[i] = 0;
- }
+ pcl_clear_cached_pattern_refs(pcls);
pcls->cached_pattern_id = *pid;
}
ppi = pcls->cached_pattern;
@@ -639,9 +635,28 @@ pcl_set_drawing_color(pcl_state_t *pcls, pcl_pattern_type_t type, const pcl_id_t
rotation = pcls->rotate_patterns ? pcls->print_direction : 0;
pcl_set_drawing_color_rotation(pcls, type, pid,
&pcls->patterns, rotation, &pattern_origin_device);
+ gs_setsourcetransparent(pcls->pgs, pcls->source_transparent);
+ gs_settexturetransparent(pcls->pgs, pcls->pattern_transparent);
+ gs_setrasterop(pcls->pgs, pcls->logical_op);
+ gs_setfilladjust(pcls->pgs, pcls->grid_adjust, pcls->grid_adjust);
return 0;
}
+/* get rid of cached pattern references maintained in the pcl state.
+ This code is duplicated in pattern initilization. */
+private void
+cached_pattern_release(gs_pattern_instance **pcpat)
+{ rc_decrement_only(*pcpat, "cached_pattern_release");
+ *pcpat = 0;
+}
+int
+pcl_clear_cached_pattern_refs(pcl_state_t *pcls)
+{ int i;
+ for ( i=0; i < countof(pcls->cached_pattern); i++ )
+ cached_pattern_release(&pcls->cached_pattern[i]);
+ return 0;
+}
+
/* Initialization */
private int
pcdraw_do_init(gs_memory_t *mem)
@@ -652,11 +667,6 @@ cached_pattern_init(gs_pattern_instance **pcpat)
{ *pcpat = 0;
}
private void
-cached_pattern_release(gs_pattern_instance **pcpat)
-{ rc_decrement_only(*pcpat, "cached_pattern_release");
- *pcpat = 0;
-}
-private void
pcdraw_do_reset(pcl_state_t *pcls, pcl_reset_type_t type)
{ void (*proc)(P1(gs_pattern_instance **));
diff --git a/pcl/pcdraw.h b/pcl/pcdraw.h
index 40d6ca18e..9cc1fda6f 100644
--- a/pcl/pcdraw.h
+++ b/pcl/pcdraw.h
@@ -97,4 +97,6 @@ int pcl_set_drawing_color_rotation(P6(pcl_state_t *pcls,
int pcl_set_drawing_color(P3(pcl_state_t *pcls, pcl_pattern_type_t type,
const pcl_id_t *pid));
+/* get rid of cached pattern references maintained in the pcl state. */
+int pcl_clear_cached_pattern_refs(P1(pcl_state_t *pcls));
#endif /* pcdraw_INCLUDED */
diff --git a/pcl/pcfsel.c b/pcl/pcfsel.c
index c65113dae..20b7f3f56 100644
--- a/pcl/pcfsel.c
+++ b/pcl/pcfsel.c
@@ -43,7 +43,7 @@ dprint_font_params_t(const pl_font_params_t *pfp)
{ dprintf7("symset=%u %s pitch=%g ht=%u style=%u wt=%d face=%u\n",
pfp->symbol_set,
(pfp->proportional_spacing ? "prop." : "fixed"),
- pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths * 4, pfp->style,
+ pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths / 4, pfp->style,
pfp->stroke_weight, pfp->typeface_family);
}
private void
@@ -259,7 +259,6 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcls)
{ pl_font_t *fp = (pl_font_t *)value;
match_score_t match;
score_index_t i;
-
score_match(pcls, pfs, fp, &mapp, match);
for (i=0; i<score_limit; i++)
if ( match[i] != best_match[i] )
diff --git a/pcl/pcl.mak b/pcl/pcl.mak
index ac7ef7aea..8e5640935 100644
--- a/pcl/pcl.mak
+++ b/pcl/pcl.mak
@@ -93,7 +93,7 @@ $(PCLOBJ)pcommand.$(OBJ): $(PCLSRC)pcommand.c $(std_h)\
$(PCLOBJ)pcdraw.$(OBJ): $(PCLSRC)pcdraw.c $(std_h) $(math__h)\
$(gscolor2_h) $(gscoord_h) $(gscspace_h) $(gsdcolor_h) $(gsimage_h)\
- $(gsmatrix_h) $(gsmemory_h) $(gsstate_h) $(gstypes_h) $(gsutil_h)\
+ $(gsmatrix_h) $(gsmemory_h) $(gsrop_h) $(gsstate_h) $(gstypes_h) $(gsutil_h)\
$(gxfixed_h) $(gxstate_h) $(gzstate_h)\
$(plvalue_h)\
$(pcdraw_h) $(pcommand_h) $(pcfont_h) $(pcstate_h)
@@ -306,6 +306,7 @@ $(PCLOBJ)pcrect.$(OBJ): $(PCLSRC)pcrect.c $(math__h)\
# Chapter 16
$(PCLOBJ)pcstatus.$(OBJ): $(PCLSRC)pcstatus.c $(memory__h) $(stdio__h) $(string__h)\
+ $(gsmemory_h) $(gstypes_h) $(gxdevice_h)\
$(stream_h)\
$(pcfont_h) $(pcommand_h) $(pcstate_h) $(pcsymbol_h)
$(PCLCCC) $(PCLSRC)pcstatus.c $(PCLO_)pcstatus.$(OBJ)
@@ -396,7 +397,7 @@ $(PCLOBJ)pgdraw.$(OBJ): $(PCLSRC)pgdraw.c $(math__h) $(stdio__h)\
$(PCLCCC) $(PCLSRC)pgdraw.c $(PCLO_)pgdraw.$(OBJ)
$(PCLOBJ)pggeom.$(OBJ): $(PCLSRC)pggeom.c $(math__h) $(stdio__h)\
- $(pggeom_h)
+ $(gxfarith_h) $(pggeom_h)
$(PCLCCC) $(PCLSRC)pggeom.c $(PCLO_)pggeom.$(OBJ)
$(PCLOBJ)pgmisc.$(OBJ): $(PCLSRC)pgmisc.c $(pgmand_h) $(pgmisc_h)
diff --git a/pcl/pcl_ugcc.mak b/pcl/pcl_ugcc.mak
index 286ec6c74..fe8a2d8cb 100644
--- a/pcl/pcl_ugcc.mak
+++ b/pcl/pcl_ugcc.mak
@@ -39,7 +39,7 @@ XLIBS=Xt SM ICE Xext X11
CCLD=gcc
-DEVICE_DEVS=x11.dev x11mono.dev x11alpha.dev x11cmyk.dev\
+DEVICE_DEVS=x11mono.dev x11.dev x11alpha.dev x11cmyk.dev\
djet500.dev ljet4.dev\
pcxmono.dev pcxgray.dev\
pbmraw.dev pgmraw.dev ppmraw.dev\
diff --git a/pcl/pclfont.c b/pcl/pclfont.c
index 40603b399..cc3071f6d 100644
--- a/pcl/pclfont.c
+++ b/pcl/pclfont.c
@@ -203,9 +203,6 @@ pcl_load_built_in_fonts(pcl_state_t *pcls, const char *prefixes[])
#endif
continue;
}
-#ifdef DEBUG
- dprintf1("Loaded %s\n", fname);
-#endif
plfont->storage = pcds_internal;
if ( residentp->params.symbol_set != 0 )
plfont->font_type = plft_8bit;
diff --git a/pcl/pcprint.c b/pcl/pcprint.c
index 3e817b6a1..b7fa9747b 100644
--- a/pcl/pcprint.c
+++ b/pcl/pcprint.c
@@ -14,6 +14,7 @@
#include "gscoord.h"
#include "gsrop.h"
#include "gsstate.h"
+#include "gsrefct.h"
#include "gxbitmap.h"
#include "gxdevice.h" /* for gxpcolor.h */
#include "gxpcolor.h" /* for pattern cache winnowing */
@@ -26,7 +27,6 @@ pcl_pattern_transparency_mode(pcl_args_t *pargs, pcl_state_t *pcls)
if ( i > 1 )
return 0;
pcls->pattern_transparent = !i;
- gs_settexturetransparent(pcls->pgs, pcls->pattern_transparent);
return 0;
}
@@ -35,9 +35,7 @@ pcl_pattern_id(pcl_args_t *pargs, pcl_state_t *pcls)
{ uint id = int_arg(pargs);
if ( id_value(pcls->pattern_id) != id )
- { id_set_value(pcls->pattern_id, id);
- pcls->pattern_set = false;
- }
+ id_set_value(pcls->pattern_id, id);
return 0;
}
@@ -53,11 +51,34 @@ pcl_select_pattern(pcl_args_t *pargs, pcl_state_t *pcls)
)
{ pcls->pattern_type = i;
pcls->current_pattern_id = pcls->pattern_id;
- pcls->pattern_set = false;
}
return 0;
}
+/* Purge deleted entries from the graphics library's Pattern cache. */
+private bool
+choose_deleted_patterns(gx_color_tile *ctile, void *pcls_data)
+{ pcl_state_t *pcls = (pcl_state_t *)pcls_data;
+ long id = ctile->uid.id;
+ pcl_id_t key;
+ void *ignore_value;
+
+ if ( id & ~0xffffL )
+ return false; /* not a user-defined pattern */
+ id_set_value(key, (uint)id);
+ return !pl_dict_find(&pcls->patterns, id_key(key), 2, &ignore_value);
+}
+private void
+pcl_purge_pattern_cache(pcl_state_t *pcls)
+{ gx_pattern_cache *pcache = gstate_pattern_cache(pcls->pgs);
+
+ if ( pcache != 0 )
+ gx_pattern_cache_winnow(pcache, choose_deleted_patterns,
+ (void *)pcls);
+ /* remove stale references from pcl pattern cache */
+ pcl_clear_cached_pattern_refs(pcls);
+}
+
/* build a pattern and create a dictionary entry for it. Also used by
hpgl/2 for raster fills. */
int
@@ -106,6 +127,8 @@ pcl_store_user_defined_pattern(pcl_state_t *pcls, pl_dict_t *pattern_dict,
start = size - bytes; /* start of downloaded bitmap data */
stored_raster = bitmap_raster(width);
pl_dict_undef(pattern_dict, id_key(pattern_id), 2);
+ if ( id_value(pattern_id) == id_value(pcls->cached_pattern_id) )
+ pcl_purge_pattern_cache(pcls);
header = gs_alloc_bytes(pcls->memory,
pattern_data_offset +
((height + 7) & -8) * stored_raster,
@@ -148,10 +171,6 @@ pcl_user_defined_pattern(pcl_args_t *pargs, pcl_state_t *pcls)
return code;
}
}
- if ( pcls->pattern_type == pcpt_user_defined &&
- id_value(pcls->current_pattern_id) == id_value(pcls->pattern_id)
- )
- pcls->pattern_set = false;
return 0;
}
@@ -166,28 +185,6 @@ pcl_set_pattern_reference_point(pcl_args_t *pargs, pcl_state_t *pcls)
return 0;
}
-/* Purge deleted entries from the graphics library's Pattern cache. */
-private bool
-choose_deleted_patterns(gx_color_tile *ctile, void *pcls_data)
-{ pcl_state_t *pcls = (pcl_state_t *)pcls_data;
- long id = ctile->uid.id;
- pcl_id_t key;
- void *ignore_value;
-
- if ( id & ~0xffffL )
- return false; /* not a user-defined pattern */
- id_set_value(key, (uint)id);
- return !pl_dict_find(&pcls->patterns, id_key(key), 2, &ignore_value);
-}
-private void
-pcl_purge_pattern_cache(pcl_state_t *pcls)
-{ gx_pattern_cache *pcache = gstate_pattern_cache(pcls->pgs);
-
- if ( pcache != 0 )
- gx_pattern_cache_winnow(pcache, choose_deleted_patterns,
- (void *)pcls);
-}
-
private int /* ESC * c <pc_enum> Q */
pcl_pattern_control(pcl_args_t *pargs, pcl_state_t *pcls)
{ gs_const_string key;
@@ -273,10 +270,8 @@ pcprint_do_reset(pcl_state_t *pcls, pcl_reset_type_t type)
{ id_set_value(pcls->pattern_id, 0);
pcls->pattern_type = pcpt_solid_black;
pcls->pattern_transparent = true;
- gs_settexturetransparent(pcls->pgs, true);
pcls->shift_patterns = false;
pcls->rotate_patterns = true;
- pcls->pattern_set = false;
if ( type & pcl_reset_initial )
pl_dict_init(&pcls->patterns, pcls->memory, NULL);
else
diff --git a/pcl/pcsfont.c b/pcl/pcsfont.c
index 29cc8533a..0c505a768 100644
--- a/pcl/pcsfont.c
+++ b/pcl/pcsfont.c
@@ -110,6 +110,7 @@ pcl_font_control(pcl_args_t *pargs, pcl_state_t *pcls)
return 0;
case 6:
{ /* Assign <font_id> to copy of current font. */
+ /* recompute the current font */
}
return e_Unimplemented;
default:
@@ -204,7 +205,8 @@ pcl_font_header(pcl_args_t *pargs, pcl_state_t *pcls)
pl_fp_set_pitch_cp(&plfont->params, pitch_cp);
}
plfont->params.height_4ths =
- pl_get_uint16(pfh->Height) * 72 / plfont->resolution.x;
+ (uint)(pl_get_uint16(pfh->Height) * 72.0 / plfont->resolution.x +
+ 0.5);
break;
}
case plfst_TrueType:
diff --git a/pcl/pcstate.h b/pcl/pcstate.h
index 8875ebd0b..6fae02ed3 100644
--- a/pcl/pcstate.h
+++ b/pcl/pcstate.h
@@ -370,7 +370,6 @@ struct pcl_state_s {
pl_dict_t patterns;
/* Internal variables */
pcl_id_t current_pattern_id; /* at last select_pattern */
- bool pattern_set; /* true if pattern set in graphics state */
gx_ht_tile pattern_tile; /* set by pcl_set_drawing_color */
gs_pattern_instance *cached_shading[7*4]; /* create as needed, */
/* 1 per rotation */
@@ -467,7 +466,7 @@ struct pcl_state_s {
/* Chapter C5 (pccprint.c) */
byte logical_op; /* (also in graphics state) */
- bool grid_centered; /* (also fill adjust in graphics state) */
+ float grid_adjust; /* (also fill adjust in graphics state) */
/* Chapter C6 (pccrastr.c) */
diff --git a/pcl/pcstatus.c b/pcl/pcstatus.c
index 1d79a6747..af00d05a9 100644
--- a/pcl/pcstatus.c
+++ b/pcl/pcstatus.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Aladdin Enterprises. All rights reserved.
+/* Copyright (C) 1996, 1997 Aladdin Enterprises. All rights reserved.
Unauthorized use, copying, and/or distribution prohibited.
*/
@@ -8,6 +8,9 @@
#include "stdio_.h"
#include <stdarg.h> /* how to make this portable? */
#include "string_.h"
+#include "gsmemory.h" /* for gxdevice.h */
+#include "gstypes.h" /* ditto */
+#include "gxdevice.h" /* for gs_memory_default, if needed */
#include "pcommand.h"
#include "pcstate.h"
#include "pcfont.h"
diff --git a/pcl/pgcolor.c b/pcl/pgcolor.c
index 9bbca270b..59e3de798 100644
--- a/pcl/pgcolor.c
+++ b/pcl/pgcolor.c
@@ -83,20 +83,6 @@ hpgl_CR(hpgl_args_t *pargs, hpgl_state_t *pgls)
return 0;
}
-/* PP [mode]; */
-int
-hpgl_PP(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{ int mode = 0;
- float adjust;
-
- if ( !hpgl_arg_c_int(pargs, &mode) || (mode & ~1) )
- return e_Range;
- pgls->grid_centered = mode;
- adjust = (pgls->grid_centered ? 0.0 : 0.5);
- gs_setfilladjust(pgls->pgs, adjust, adjust);
- return 0;
-}
-
/* Initialization */
private int
pgcolor_do_init(gs_memory_t *mem)
@@ -105,7 +91,6 @@ pgcolor_do_init(gs_memory_t *mem)
HPGL_COMMAND('C', 'R', hpgl_CR, 0),
HPGL_COMMAND('N', 'P', hpgl_NP, 0),
HPGL_COMMAND('P', 'C', hpgl_PC, 0),
- HPGL_COMMAND('P', 'P', hpgl_PP, 0),
END_HPGL_COMMANDS
return 0;
}
diff --git a/pcl/pgconfig.c b/pcl/pgconfig.c
index 07f15ad13..3f63d2af8 100644
--- a/pcl/pgconfig.c
+++ b/pcl/pgconfig.c
@@ -51,92 +51,63 @@ hpgl_CO(hpgl_args_t *pargs, 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_args_setup(&args);
- hpgl_AC(&args, pgls);
- hpgl_args_setup(&args);
- hpgl_AD(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_CF(&args, pgls);
-
+{
+ hpgl_args_t args;
+
+#define hpgl_do_command(hpgl_xx)\
+ hpgl_args_setup(&args);\
+ hpgl_xx(&args, pgls)
+#define hpgl_do_int_command(hpgl_xx, intv)\
+ hpgl_args_set_int(&args, intv);\
+ hpgl_xx(&args, pgls)
+
+ hpgl_do_command(hpgl_AC);
+ hpgl_do_command(hpgl_AD);
+ hpgl_do_command(hpgl_CF);
+
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);
-
- hpgl_args_setup(&args);
- hpgl_FT(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_IW(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_LA(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_LM(&args, pgls);
-
- hpgl_args_set_int(&args, 1);
- hpgl_LO(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_LT(&args, pgls);
+ hpgl_do_command(hpgl_DV);
+ hpgl_do_command(hpgl_ES);
+ hpgl_do_command(hpgl_FT);
+ hpgl_do_command(hpgl_IW);
+ hpgl_do_command(hpgl_LA);
+ hpgl_do_command(hpgl_LM);
+ hpgl_do_int_command(hpgl_LO, 1);
+ hpgl_do_command(hpgl_LT);
/* we do this instead of calling SC directly */
pgls->g.scaling_type = hpgl_scaling_none;
- hpgl_args_set_int(&args,0);
- hpgl_PM(&args, pgls);
-
- hpgl_args_set_int(&args,2);
- hpgl_PM(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_RF(&args, pgls);
-
- hpgl_args_set_int(&args,0);
- hpgl_SB(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_SV(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_SD(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_SI(&args, pgls);
-
- hpgl_args_setup(&args);
- hpgl_SL(&args, pgls);
+ hpgl_do_int_command(hpgl_PM, 0);
+ hpgl_do_int_command(hpgl_PM, 2);
+ hpgl_do_command(hpgl_RF);
+ hpgl_do_int_command(hpgl_SB, 0);
+ hpgl_do_command(hpgl_SV);
+ hpgl_do_command(hpgl_SD);
+ hpgl_do_command(hpgl_SI);
+ hpgl_do_command(hpgl_SL);
/* HAS needs to be consistant */
pgls->g.symbol_mode = 0;
/* hpgl_args_setup(&args);
hpgl_SM(&args, pgls); */
- 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_UL(&args, pgls);
-
+ hpgl_do_command(hpgl_SS);
+ hpgl_do_int_command(hpgl_TR, 1);
+ hpgl_do_command(hpgl_TD);
+ hpgl_do_command(hpgl_UL);
+ hpgl_do_command(hpgl_MC);
+ hpgl_do_command(hpgl_PP);
+#undef hpgl_do_command
+#undef hpgl_do_int_command
return 0;
}
@@ -145,35 +116,25 @@ int
hpgl_IN(hpgl_args_t *pargs, hpgl_state_t *pgls)
{
hpgl_args_t args;
-
/* restore defaults */
hpgl_DF(&args, pgls);
-
/* cancel rotation */
hpgl_args_setup(&args);
hpgl_RO(&args, pgls);
-
/* defaults P1 and P2 */
hpgl_args_setup(&args);
hpgl_IP(&args, pgls);
-
/* HAS temporarily hardwired. Should use NP but that is broken
at the moment. */
pgls->g.number_of_pens = 2;
-
- /* HAS: difficult to tell in SP has a default value. We shall
- use 1 for now. */
hpgl_args_set_int(&args,1);
hpgl_SP(&args, pgls);
-
/* pen width units - metric */
hpgl_args_setup(&args);
hpgl_WU(&args, pgls);
-
/* pw .35 */
hpgl_args_set_real(&args,0.35);
hpgl_PW(&args, pgls);
-
/* HAS Unclear what to do here. state hardwired to 2 above */
#ifdef LATER
hpgl_args_set_int(&args,2);
@@ -183,7 +144,6 @@ hpgl_IN(hpgl_args_t *pargs, hpgl_state_t *pgls)
0,0 or the lower left of the picture frame. Simply sets
the gl/2 state, we subsequently clear the path because we
do not want to create a live gs path. */
-
hpgl_args_setup(&args);
hpgl_PU(&args, pgls);
hpgl_args_set_real2(&args, 0.0, 0.0);
@@ -216,7 +176,6 @@ hpgl_picture_frame_coords(hpgl_state_t *pgls, gs_int_rect *gl2_win)
gs_currentmatrix(pgls->pgs, &mat);
hpgl_call(gs_bbox_transform_inverse(&dev_win, &mat, &pcl_win));
-/* HAS have not checked if this is properly rounded or truncated */
/* 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);
@@ -266,8 +225,6 @@ hpgl_IP(hpgl_args_t *pargs, hpgl_state_t *pgls)
}
/* if either coordinate is equal it is incremented by 1 */
- /* HAS more error checking ??? */
-
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++;
@@ -317,8 +274,7 @@ hpgl_IW(hpgl_args_t *pargs, hpgl_state_t *pgls)
int i;
gs_int_rect win;
- /* get the default picture frame coordinates. HAS this need
- to be redone. I don't think it is necessary. */
+ /* get the default picture frame coordinates. */
hpgl_call(hpgl_picture_frame_coords(pgls, &win));
wxy[0] = win.p.x;
wxy[1] = win.p.y;
@@ -374,11 +330,9 @@ hpgl_RO(hpgl_args_t *pargs, hpgl_state_t *pgls)
return e_Range;
}
- /* HAS need documentation */
if ( angle != pgls->g.rotation )
{
hpgl_args_t args;
-
hpgl_pen_state_t saved_pen_state;
hpgl_save_pen_state(pgls, &saved_pen_state, hpgl_pen_down | hpgl_pen_relative);
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
@@ -392,9 +346,9 @@ hpgl_RO(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_args_set_real(&args, point.x);
hpgl_args_add_real(&args, point.y);
hpgl_call(hpgl_PA(&args, pgls));
- /* HAS this is added to clear first moveto yuck */
hpgl_call(hpgl_clear_current_path(pgls));
- hpgl_restore_pen_state(pgls, &saved_pen_state, hpgl_pen_down | hpgl_pen_relative);
+ hpgl_restore_pen_state(pgls, &saved_pen_state,
+ hpgl_pen_down | hpgl_pen_relative);
}
return 0;
}
@@ -480,9 +434,6 @@ pxy: scale_params.pmin.x = xy[0];
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
pgls->g.scaling_params = scale_params;
pgls->g.scaling_type = type;
-
- /* HAS probably only needs to be done if the scaling state
- has changed */
hpgl_call(hpgl_set_ctm(pgls));
hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
/* we must clear the current path because we set up the CTM
diff --git a/pcl/pgdraw.c b/pcl/pgdraw.c
index 1c793d192..859af68fa 100644
--- a/pcl/pgdraw.c
+++ b/pcl/pgdraw.c
@@ -49,13 +49,6 @@ hpgl_set_picture_frame_scaling(hpgl_state_t *pgls)
return 0;
}
-/* HAS: update ghostscript's gs and the current ctm to reflect hpgl's.
- embodied in hpgl_set_graphics_dash_state(),
- hpgl_set_graphics_line_attributes(), and hpgl_set_drawing_state() below.
- Note: For now the gs gstate is updated each time graphics are
- rendered and the ctm is updated each time a new path is started.
- Potential performance issue. The design choice is based solely on
- ease of implementation. */
/* ctm to translate from pcl space to plu space */
int
hpgl_set_pcl_to_plu_ctm(hpgl_state_t *pgls)
@@ -136,13 +129,13 @@ hpgl_compute_user_units_to_plu_ctm(const hpgl_state_t *pgls, gs_matrix *pmat)
{ if ( scale_x > scale_y )
{ /* Reduce the X scaling. */
origin_x += range_x * (scale_x - scale_y) *
- pgls->g.scaling_params.left;
+ (pgls->g.scaling_params.left / 100.0);
scale_x = scale_y;
}
else if ( scale_y > scale_x )
{ /* Reduce the Y scaling. */
origin_y += range_y * (scale_y - scale_x) *
- pgls->g.scaling_params.bottom;
+ (pgls->g.scaling_params.bottom / 100.0);
scale_y = scale_x;
}
}
@@ -228,15 +221,11 @@ hpgl_set_graphics_dash_state(hpgl_state_t *pgls)
(mm_2_plu(pgls->g.line.current.pattern_length)));
gs_setdashadapt(pgls->pgs, adaptive);
- /* HAS not correct as user space may not be PU */
-
/*
* The graphics library interprets odd pattern counts differently
* from GL: if the pattern count is odd, we need to do something
* a little special.
*/
- /* HAS does not handle residual / offset yet. It is
- not clear where the calculation should take place. */
count = pat->count;
for ( i = 0; i < count; i++ )
pattern[i] = length * pat->gap[i];
@@ -265,8 +254,6 @@ hpgl_set_graphics_line_attribute_state(hpgl_state_t *pgls,
hpgl_rendering_mode_t render_mode)
{
- /* HAS *** We use a miter join instead of miter/beveled as I
- am not sure if the gs library supports it */
const gs_line_cap cap_map[] = {gs_cap_butt, /* 0 not supported */
gs_cap_butt, /* 1 butt end */
gs_cap_square, /* 2 square end */
@@ -321,10 +308,6 @@ vector: hpgl_call(gs_setlinejoin(pgls->pgs,
goto vector;
}
- /* HAS -- yuck need symbolic names for GL join types. Set
- miter limit !very large! if there is not bevel. Miter is
- also sensitive to render mode but I have not figured it
- out completely. */
#ifdef COMMENT
/* I do not remember the rational for the large miter */
hpgl_call(gs_setmiterlimit(pgls->pgs,
@@ -429,7 +412,7 @@ hpgl_draw_vector_absolute(hpgl_state_t *pgls, hpgl_real_t x0, hpgl_real_t y0,
bool set_ctm = (render_mode != hpgl_rm_character);
hpgl_call(hpgl_add_point_to_path(pgls, x0, y0,
hpgl_plot_move_absolute, set_ctm));
- hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
+ hpgl_call(hpgl_add_point_to_path(pgls, x1, y1,
hpgl_plot_draw_absolute, set_ctm));
return 0;
@@ -554,7 +537,6 @@ start: gs_sincos_degrees(direction, &sincos);
#undef cos_dir
}
-/* HAS - probably not necessary and clip intersection with IW */
private int
hpgl_polyfill_using_current_line_type(hpgl_state_t *pgls,
hpgl_rendering_mode_t render_mode)
@@ -579,7 +561,8 @@ hpgl_set_pcl_pattern_origin(hpgl_state_t *pgls, gs_point *point)
hpgl_call(gs_sethalftonephase(pgls->pgs, pattern_origin.x, pattern_origin.y));
return 0;
}
- private int
+
+ int
hpgl_set_drawing_color(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
{
pcl_id_t pcl_id;
@@ -588,19 +571,11 @@ hpgl_set_drawing_color(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
use a private hpgl/2 dictionary. */
pl_dict_t *pattern_dictp = &pgls->patterns;
pcl_pattern_type_t pat;
- /* HAS - this is tooooo complicated. */
- if ( (render_mode == hpgl_rm_clip_and_fill_polygon) ||
- ((pgls->g.fill.type == hpgl_fill_hatch || pgls->g.fill.type == hpgl_fill_crosshatch) &&
- ((render_mode == hpgl_rm_character) &&
- ((pgls->g.character.fill_mode == hpgl_char_fill) ||
- (pgls->g.character.fill_mode == hpgl_char_fill_edge)))) )
- {
- hpgl_call(hpgl_polyfill_using_current_line_type(pgls,
- render_mode));
- return 0;
- }
switch ( render_mode )
{
+ case hpgl_rm_clip_and_fill_polygon:
+ hpgl_call(hpgl_polyfill_using_current_line_type(pgls, render_mode));
+ return 0;
case hpgl_rm_character:
switch ( pgls->g.character.fill_mode )
{
@@ -610,7 +585,14 @@ hpgl_set_drawing_color(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
break;
case hpgl_char_fill:
case hpgl_char_fill_edge:
- goto fill;
+ if ( pgls->g.fill.type == hpgl_fill_hatch ||
+ pgls->g.fill.type == hpgl_fill_crosshatch )
+ {
+ 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;
@@ -622,9 +604,13 @@ fill: switch ( pgls->g.fill.type )
{
case hpgl_fill_solid:
case hpgl_fill_solid2: /* fall through */
- /* this is handled by hpgl/2 line drawing machinary
- and should not be handled here. (see hpgl_polyfill()
- below). For now we use black and no id */
+ /* 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 */
+ /* HAS should use set foreground color */
+ pat = (pgls->g.pen.selected == 0 ? pcpt_solid_white : pcpt_solid_black);
+ break;
case hpgl_fill_hatch:
case hpgl_fill_crosshatch:
pat = pcpt_solid_black;
@@ -705,14 +691,15 @@ fill: switch ( pgls->g.fill.type )
dprintf("hpgl_set_drawing_color: internal error illegal mode\n");
break;
}
-
gs_setrasterop(pgls->pgs, pgls->logical_op);
gs_setsourcetransparent(pgls->pgs, pgls->g.source_transparent);
+ gs_settexturetransparent(pgls->pgs, pgls->g.source_transparent);
/* set up the halftone phase origin in device space */
hpgl_call(gs_transform(pgls->pgs, pgls->g.anchor_corner.x,
pgls->g.anchor_corner.y, &pattern_origin));
+ gs_setfilladjust(pgls->pgs, pgls->grid_adjust, pgls->grid_adjust);
hpgl_call(pcl_set_drawing_color_rotation(pgls,
- pat, &pcl_id, pattern_dictp, -((pgls->g.rotation / 90) & 3),
+ pat, &pcl_id, pattern_dictp, ((pgls->g.rotation / 90) & 3),
&pattern_origin));
return 0;
}
@@ -833,19 +820,17 @@ hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
floatp chord_angle, bool start_moveto, hpgl_plot_function_t draw,
bool set_ctm)
{
- floatp start_angle_radians = start_angle * degrees_to_radians;
/*
* Ensure that the sweep angle is an integral multiple of the
* chord angle, by decreasing the chord angle if necessary.
*/
int num_chords = (int)ceil(sweep_angle / chord_angle);
- floatp chord_angle_radians =
- sweep_angle / num_chords * degrees_to_radians;
+ floatp integral_chord_angle = sweep_angle / num_chords;
int i;
floatp arccoord_x, arccoord_y;
(void)hpgl_compute_arc_coords(radius, center_x, center_y,
- start_angle_radians,
+ start_angle,
&arccoord_x, &arccoord_y);
hpgl_call(hpgl_add_point_to_path(pgls, arccoord_x, arccoord_y,
(draw && !start_moveto ?
@@ -855,10 +840,9 @@ hpgl_add_arc_to_path(hpgl_state_t *pgls, floatp center_x, floatp center_y,
/* HAS - pen up/down is invariant in the loop */
for ( i = 0; i < num_chords; i++ )
{
- start_angle_radians += chord_angle_radians;
+ start_angle += integral_chord_angle;
hpgl_compute_arc_coords(radius, center_x, center_y,
- start_angle_radians,
- &arccoord_x, &arccoord_y);
+ start_angle, &arccoord_x, &arccoord_y);
hpgl_call(hpgl_add_point_to_path(pgls, arccoord_x, arccoord_y,
(draw ? hpgl_plot_draw_absolute :
hpgl_plot_move_absolute), set_ctm));
@@ -988,11 +972,12 @@ hpgl_add_bezier_to_path(hpgl_state_t *pgls, floatp x1, floatp y1,
hpgl_plot_move_absolute, true));
if ( draw )
hpgl_call(gs_curveto(pgls->pgs, x2, y2, x3, y3, x4, y4));
-
- /* this is done simply to set gl/2's current position */
- hpgl_call(hpgl_add_point_to_path(pgls, x4, y4,
- draw ? hpgl_plot_draw_absolute :
- hpgl_plot_move_absolute, true));
+ /* 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));
+ }
return 0;
}
@@ -1024,7 +1009,7 @@ hpgl_close_path(hpgl_state_t *pgls)
hpgl_call(gs_closepath(pgls->pgs));
return 0;
}
-
+
/* HAS -- There will need to be compression phase here note that
extraneous PU's do not result in separate subpaths. */
@@ -1062,7 +1047,7 @@ hpgl_draw_current_path(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode)
hpgl_call((*fill)(pgs));
/* falls through */
case hpgl_char_edge:
-char_edge: if ( pgls->g.bitmap_fonts_allowed )
+ if ( pgls->g.bitmap_fonts_allowed )
break; /* no edging */
if ( pgls->g.character.edge_pen != 0 )
{ gs_setgray(pgs, 0.0); /* solid edge */
@@ -1076,8 +1061,17 @@ char_edge: if ( pgls->g.bitmap_fonts_allowed )
break;
case hpgl_char_fill_edge:
/****** SHOULD USE VECTOR FILL ******/
+ if ( pgls->g.bitmap_fonts_allowed )
+ break; /* no edging */
+ if ( pgls->g.character.edge_pen != 0 )
+ {
+ hpgl_call(hpgl_gsave(pgls));
+ gs_setgray(pgs, 0.0); /* solid edge */
+ gs_setlinewidth(pgs, 0.1);
+ hpgl_call(gs_stroke(pgs));
+ hpgl_call(hpgl_grestore(pgls));
+ }
hpgl_call((*fill)(pgs));
- goto char_edge;
}
}
break;
@@ -1106,7 +1100,6 @@ char_edge: if ( pgls->g.bitmap_fonts_allowed )
return 0;
}
-/* HAS needs error checking for empty paths and such */
int
hpgl_copy_current_path_to_polygon_buffer(hpgl_state_t *pgls)
{
diff --git a/pcl/pgdraw.h b/pcl/pgdraw.h
index 568860be3..cc5b9ca5a 100644
--- a/pcl/pgdraw.h
+++ b/pcl/pgdraw.h
@@ -24,6 +24,11 @@ int hpgl_set_user_units_to_plu_ctm(P1(const hpgl_state_t *pgls));
/* set (user units) ctm */
int hpgl_set_ctm(P1(hpgl_state_t *pgls));
+/* function set up the current drawing attributes this is only used by
+ the character code since it does most of it's own graphic's state
+ bookkeeping */
+int hpgl_set_drawing_color(P2(hpgl_state_t *pgls, hpgl_rendering_mode_t render_mode));
+
/* function to get the current hpgl/2 state position */
int hpgl_get_current_position(P2(hpgl_state_t *pgls, gs_point *pt));
diff --git a/pcl/pgframe.c b/pcl/pgframe.c
index 39b26fc70..3c9c52535 100644
--- a/pcl/pgframe.c
+++ b/pcl/pgframe.c
@@ -77,7 +77,6 @@ pcl_vert_pic_frame_size_decipoints(pcl_args_t *pargs, pcl_state_t *pcls)
hpgl_args_set_int(&args,2);
hpgl_PM(&args, pcls);
- /* HAS update the pen's position */
}
return 0;
}
@@ -109,7 +108,6 @@ pcl_set_pic_frame_anchor_point(pcl_args_t *pargs, pcl_state_t *pcls)
hpgl_args_set_int(&args,2);
hpgl_PM(&args, pcls);
- /* HAS update the pen's position */
}
return 0;
}
diff --git a/pcl/pggeom.c b/pcl/pggeom.c
index ad596bf2c..4940c2e6d 100644
--- a/pcl/pggeom.c
+++ b/pcl/pggeom.c
@@ -8,6 +8,7 @@
#include "stdio_.h"
#include "math_.h"
#include "pggeom.h"
+#include "gxfarith.h" /* for gs_sincos */
/* HAS most of these computations require more error checking */
@@ -82,8 +83,10 @@ int
hpgl_compute_arc_coords(floatp radius, floatp center_x, floatp center_y,
floatp angle, floatp *px, floatp *py)
{
- *px = radius * cos(angle) + center_x;
- *py = radius * sin(angle) + center_y;
+ gs_sincos_t sincos;
+ gs_sincos_degrees(angle, &sincos);
+ *px = radius * sincos.cos + center_x;
+ *py = radius * sincos.sin + center_y;
return 0;
}
@@ -94,7 +97,6 @@ hpgl_compute_vector_endpoints(floatp magnitude, floatp x, floatp y,
floatp angle_degrees, floatp *endx, floatp *endy)
{
- return hpgl_compute_arc_coords(magnitude, x, y,
- angle_degrees * (M_PI/180.0),
- endx, endy);
+ return hpgl_compute_arc_coords(magnitude, x, y,
+ angle_degrees, endx, endy);
}
diff --git a/pcl/pginit.c b/pcl/pginit.c
index 955d826a8..3204169bc 100644
--- a/pcl/pginit.c
+++ b/pcl/pginit.c
@@ -105,9 +105,6 @@ hpgl_clear_state(pcl_state_t *pcls)
void
hpgl_do_reset(pcl_state_t *pcls, pcl_reset_type_t type)
{ /* pgframe.c (Chapter 18) */
- /* HAS we expect the pcl logical page size to be calculated in
- advance of an hpgl reset. Alot of repetition here that can
- be done away with */
hpgl_args_t hpgl_args;
if ( type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_cold) )
@@ -127,9 +124,7 @@ hpgl_do_reset(pcl_state_t *pcls, pcl_reset_type_t type)
/* provide default anchor point, plot size and picture
frame size */
hpgl_default_coordinate_system(pcls);
- /* HAS clear the current gs path if there is one. This
- needs investigation since we should not have a path at
- the end of gl/2 invocation. */
+ /* we should not have a path at this point but we make sure */
hpgl_clear_current_path(pcls);
/* Initialize stick/arc font instances */
pcls->g.stick_font[0][0].pfont =
@@ -143,34 +138,24 @@ hpgl_do_reset(pcl_state_t *pcls, pcl_reset_type_t type)
if ( type & (pcl_reset_page_params) )
{
hpgl_default_coordinate_system(pcls);
-
hpgl_args_setup(&hpgl_args);
hpgl_IW(&hpgl_args, pcls);
-
hpgl_args_set_int(&hpgl_args,0);
hpgl_PM(&hpgl_args, pcls);
-
hpgl_args_set_int(&hpgl_args,2);
hpgl_PM(&hpgl_args, pcls);
-
- /* update the cursor position ?? */
}
if ( type & (pcl_reset_picture_frame) )
{
hpgl_args_setup(&hpgl_args);
hpgl_IP(&hpgl_args, pcls);
-
hpgl_args_setup(&hpgl_args);
hpgl_IW(&hpgl_args, pcls);
-
hpgl_args_set_int(&hpgl_args,0);
hpgl_PM(&hpgl_args, pcls);
-
hpgl_args_set_int(&hpgl_args,2);
hpgl_PM(&hpgl_args, pcls);
-
- /* HAS pen to P1 */
}
if (type & (pcl_reset_plot_size))
diff --git a/pcl/pglabel.c b/pcl/pglabel.c
index 17cbf3074..5dec3add5 100644
--- a/pcl/pglabel.c
+++ b/pcl/pglabel.c
@@ -680,7 +680,10 @@ hpgl_print_char(hpgl_state_t *pgls, uint ch)
}
else
{ if ( use_show )
+ {
code = gs_show_n_init(penum, pgs, str, 1);
+ hpgl_call(hpgl_set_drawing_color(pgls, hpgl_rm_character));
+ }
else
code = gs_charpath_n_init(penum, pgs, str, 1, true);
if ( code < 0 || (code = gs_show_next(penum)) != 0 )
@@ -761,8 +764,8 @@ hpgl_can_concat_labels(const hpgl_state_t *pgls)
/* return relative coordinates to compensate for origin placement -- LO */
private int
-hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
- hpgl_real_t width, hpgl_real_t height,
+hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
+ hpgl_real_t width, hpgl_real_t height,
gs_point *offset)
{
double pos_x = 0.0, pos_y = 0.0;
@@ -771,8 +774,6 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
point size. HAS need to support other font types. */
if ( origin > 10 )
off_x = off_y = 0.33 * height;
-
- /* HAS does not yet handle 21. */
switch ( origin )
{
case 11:
@@ -846,7 +847,6 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
dprintf("unknown label parameter");
}
-
offset->x = pos_x;
offset->y = pos_y;
return 0;
@@ -864,6 +864,38 @@ hpgl_process_buffer(hpgl_state_t *pgls)
/*
* NOTE: the two loops below must be consistent with each other!
*/
+
+#if 0 /* **************** */
+ /****************
+
+The algorithm below for deciding whether to compute the label length is
+wrong: hpgl_can_concat_labels is *not* the correct way to determine what
+needs to be computed. To minimize the computation, what we need is a table
+that maps
+ <int label_origin, int text_path>
+to
+ <bool need_width, bool need_height>.
+If both need_width and need_height are false, we can skip the loop entirely;
+if only one is true, we can omit some of the computations in the loop (e.g.,
+if we are writing horizontally and only need the height, for example for LO
+3, we can omit the calls on hpgl_get_char_width and the special stuff for BS
+and HT). I would choose to do this with a table of bytes, similar to
+can_concat, in which the bits of each byte contained
+ h3 h2 h1 h0 w3 w2 w1 w0
+i.e., <height needed for text path 3>, <height needed for text path 2>, ...,
+<width needed for text path 0>:
+ { static const byte width_height_needed[22] = {
+ ...
+ };
+ byte mask = width_height_needed[pgls->g.label.origin] >>
+ pgls->g.character.text_path;
+
+ need_width = (mask & 1) != 0;
+ need_height = (mask & 0x10) != 0;
+ }
+We still need some special code to handle LFs.
+
+ ****************/
/*
* Compute the label length if the combination of text path and
@@ -875,6 +907,7 @@ hpgl_process_buffer(hpgl_state_t *pgls)
(vertical &&
memchr(pgls->g.label.buffer, LF, pgls->g.label.char_count) != 0)
)
+#endif /* **************** */
{
hpgl_real_t width = 0.0, height = 0.0;
int save_index = pgls->g.font_selected;
@@ -969,7 +1002,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height, vertical, ve
hpgl_call(hpgl_add_point_to_path(pgls, -offset.x, -offset.y,
hpgl_plot_move_relative, true));
}
-
+
{
int i;
for ( i = 0; i < pgls->g.label.char_count; ++i )
@@ -981,7 +1014,7 @@ acc_ht: hpgl_call(hpgl_get_current_cell_height(pgls, &height, vertical, ve
switch (ch)
{
case BS :
- spaces = -1;
+ spaces = -1, lines = 0;
break;
case LF :
/*
@@ -1099,6 +1132,23 @@ hpgl_LB(hpgl_args_t *pargs, hpgl_state_t *pgls)
return e_NeedData;
}
+ int
+hpgl_print_symbol_mode_char(hpgl_state_t *pgls)
+{
+ int saved_origin = pgls->g.label.origin;
+ hpgl_call(hpgl_gsave(pgls));
+ pgls->g.label.origin = 5;
+ 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));
+ hpgl_call(hpgl_destroy_label_buffer(pgls));
+ hpgl_call(hpgl_grestore(pgls));
+ pgls->g.label.origin = saved_origin;
+ return 0;
+}
+
+
/* Initialization */
private int
pglabel_do_init(gs_memory_t *mem)
diff --git a/pcl/pglfill.c b/pcl/pglfill.c
index 5c81c0dd4..e7e31faab 100644
--- a/pcl/pglfill.c
+++ b/pcl/pglfill.c
@@ -273,25 +273,41 @@ hpgl_LT(hpgl_args_t *pargs, hpgl_state_t *pgls)
/* MC mode[,opcode]; */
int
hpgl_MC(hpgl_args_t *pargs, hpgl_state_t *pgls)
-{ int mode = 0, opcode;
+{
+ int mode = 0, opcode;
if ( hpgl_arg_c_int(pargs, &mode) && (mode & ~1) )
return e_Range;
- opcode = (mode ? 168 : 255);
+ opcode = ( mode ) ? 168 : 252;
if ( mode != 0 && hpgl_arg_c_int(pargs, &opcode) )
if (opcode < 0 || opcode > 255 )
return e_Range;
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
pgls->logical_op = opcode;
return 0;
}
+/* PP [mode]; */
+int
+hpgl_PP(hpgl_args_t *pargs, hpgl_state_t *pgls)
+{ int mode = 0;
+
+ if ( hpgl_arg_c_int(pargs, &mode) )
+ if ( mode < 0 || mode > 1 )
+ return e_Range;
+ hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
+ pgls->grid_adjust = (mode == 0) ? 0.5 : 0.0;
+ return 0;
+}
+
+
/* PW [width[,pen]]; */
int
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
- it get interpreted. */
+ it gets interpreted. */
hpgl_real_t param = pgls->g.pen.width_relative ? .1 : .35;
hpgl_real_t width_plu;
int pmin = 0, pmax = pgls->g.number_of_pens - 1;
@@ -440,7 +456,10 @@ hpgl_SM(hpgl_args_t *pargs, hpgl_state_t *pgls)
else if ( (*p >= 33 && *p <= 126) ||
(*p >= 161 && *p <= 254)
)
- pgls->g.symbol_mode = *p;
+ {
+ pgls->g.symbol_mode = *p;
+ return 0;
+ }
else
return e_Range;
}
@@ -526,6 +545,7 @@ hpgl_TR(hpgl_args_t *pargs, hpgl_state_t *pgls)
if ( hpgl_arg_c_int(pargs, &mode) && (mode & ~1) )
return e_Range;
+ /* HAS not sure if pcl's state is updated as well */
pgls->g.source_transparent = mode;
return 0;
}
@@ -596,6 +616,7 @@ pglfill_do_init(gs_memory_t *mem)
HPGL_COMMAND('L', 'T', hpgl_LT, 0),
HPGL_COMMAND('M', 'C', hpgl_MC, 0),
HPGL_COMMAND('P', 'W', hpgl_PW, 0),
+ HPGL_COMMAND('P', 'P', hpgl_PP, 0),
HPGL_COMMAND('R', 'F', hpgl_RF, 0), /* + additional I parameters */
/* SM has special argument parsing, so it must handle skipping */
/* in polygon mode itself. */
diff --git a/pcl/pgpoly.c b/pcl/pgpoly.c
index ccaaed313..659666eda 100644
--- a/pcl/pgpoly.c
+++ b/pcl/pgpoly.c
@@ -66,27 +66,32 @@ hpgl_wedge(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_args_setup(pargs);
hpgl_call(hpgl_PM(pargs, pgls));
+ if ( sweep == 360.0 ) /* HAS needs epsilon */
+ hpgl_call(hpgl_add_arc_to_path(pgls, pgls->g.pos.x, pgls->g.pos.y,
+ radius, 0.0, 360.0, chord, 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_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));
+ }
/* exit polygon mode, this should close the path and the wedge
is complete */
diff --git a/pcl/pgstate.h b/pcl/pgstate.h
index 2fd274246..675dc17f9 100644
--- a/pcl/pgstate.h
+++ b/pcl/pgstate.h
@@ -252,7 +252,6 @@ typedef struct pcl_hpgl_state_s {
/* derived from the current raster fill index */
pcl_id_t raster_pattern_id;
uint raster_fill_index;
-
/* Chapter 23 (pgchar.c, pglabel.c) */
pcl_font_selection_t font_selection[2];
@@ -326,7 +325,6 @@ typedef struct pcl_hpgl_state_s {
#define hpgl_pen_pos (1<<2)
#define hpgl_pen_all (hpgl_pen_relative | hpgl_pen_down | hpgl_pen_pos)
-/* HAS we may wish to make these functions to save on code space */
#define hpgl_save_pen_state(pgls, save, save_flags)\
do {\
if ( (save_flags) & hpgl_pen_relative )\
diff --git a/pcl/pgvector.c b/pcl/pgvector.c
index 87a650883..1c1e98768 100644
--- a/pcl/pgvector.c
+++ b/pcl/pgvector.c
@@ -58,8 +58,6 @@ hpgl_arc(hpgl_args_t *pargs, hpgl_state_t *pgls, bool relative)
}
/* Draw a 3-point arc (AT, RT). */
-/* HAS check if these can be connected to other portions of the
- current subpath */
private int
hpgl_arc_3_point(hpgl_args_t *pargs, hpgl_state_t *pgls, bool relative)
{
@@ -165,13 +163,14 @@ hpgl_plot(hpgl_args_t *pargs, hpgl_state_t *pgls, hpgl_plot_function_t func)
pargs->phase = 1; /* we have arguments */
hpgl_call(hpgl_add_point_to_path(pgls, x, y, func, true));
/* Prepare for the next set of points. */
+ if ( pgls->g.symbol_mode != 0 )
+ hpgl_call(hpgl_print_symbol_mode_char(pgls, pgls->g.symbol_mode));
hpgl_args_init(pargs);
}
/* check for no argument case */
if ( !pargs->phase)
{
- /* HAS needs investigation -- NO ARGS case in relative mode */
if ( hpgl_plot_is_relative(func) )
{
hpgl_call(hpgl_add_point_to_path(pgls, 0.0, 0.0, func, true));
@@ -184,6 +183,8 @@ hpgl_plot(hpgl_args_t *pargs, hpgl_state_t *pgls, hpgl_plot_function_t func)
hpgl_call(hpgl_add_point_to_path(pgls, cur_point.x,
cur_point.y, func, true));
}
+ if ( pgls->g.symbol_mode != 0 )
+ hpgl_call(hpgl_print_symbol_mode_char(pgls, pgls->g.symbol_mode));
}
pgls->g.carriage_return_pos = pgls->g.pos;
@@ -258,7 +259,6 @@ hpgl_CI(hpgl_args_t *pargs, hpgl_state_t *pgls)
the pen up .. or something like that. */
if ( pgls->g.polygon_mode )
{
- /* HAS investigate commands added after CI in polygon mode */
hpgl_args_t args;
hpgl_restore_pen_state(pgls, &saved_pen_state, hpgl_pen_pos);
hpgl_args_setup(&args);
diff --git a/pcl/rtmisc.c b/pcl/rtmisc.c
index 7a23f1b50..d2028d2b8 100644
--- a/pcl/rtmisc.c
+++ b/pcl/rtmisc.c
@@ -4,7 +4,7 @@
/* rtmisc.c */
/* Miscellanous HP RTL commands */
-/* HAS the order of these are jumbled because of dependencies */
+/* the order of these includes are jumbled because of dependencies */
#include "math_.h"
#include "pgmand.h"
#include "pgdraw.h" /* for hpgl_add_pcl_point_to_path() */
@@ -47,7 +47,6 @@ pcl_source_transparency_mode(pcl_args_t *pargs, pcl_state_t *pcls)
if ( i > 1 )
return 0;
pcls->source_transparent = !i;
- gs_setsourcetransparent(pcls->pgs, pcls->source_transparent);
return 0;
}
@@ -94,9 +93,7 @@ rtl_enter_pcl_mode(pcl_args_t *pargs, pcl_state_t *pcls)
and conditionally copy back the cursor position. */
gx_path_release(&(pcls->g.polygon.buffer.path));
if ( b )
- { /* the usual user -> device -> user dance. HAS This is
- done frequently enough that it should be separated
- out into a separate function */
+ { /* the usual user -> device -> user dance. */
gs_point pt, dev_pt;
hpgl_call(hpgl_set_ctm(pcls));
hpgl_call(hpgl_get_current_position(pcls, &pt));
@@ -104,7 +101,6 @@ rtl_enter_pcl_mode(pcl_args_t *pargs, pcl_state_t *pcls)
hpgl_call(pcl_set_ctm(pcls, false));
hpgl_call(gs_itransform(pcls->pgs, dev_pt.x, dev_pt.y, &pt));
/* HPGL/2 uses floats for coordinates */
-/* HAS have not checked if this is properly rounded or truncated */
#define round(x) (((x) < 0.0) ? (ceil ((x) - 0.5)) : (floor ((x) + 0.5)))
pcls->cap.x = round(pt.x);
pcls->cap.y = round(pt.y);