/* * IN = DF (see below) */ int hpgl_IN( hpgl_args_t * pargs, hpgl_state_t * pgls ) { int code = 0; hpgl_args_t args; /* handle the work or an implicit reset */ code = hpgl_IN_implicit(pgls); /* set up the default palette (8 entries, not-fixed) */ if (code == 0) code = pcl_palette_IN(pgls); /* default color range */ hpgl_args_setup(&args); hpgl_CR(&args, pgls); /* pen width units - metric, also reset pen widths. This is also done in hpgl_IN_implicit() above but we have to set the pen widths again in the case a new palette was created. The default width values in a fresh palette do not account for scaling effects of the hpgl/2 picture frame. */ hpgl_args_setup(&args); hpgl_WU(&args, pgls); return code; }
/* IR; */ 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); if ( i != 0 ) { hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) * rptxy[0] / 100.0); 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; }
/* * The "implicit" portion of the IN command. * * With the advent of PCL 5c, both PCL and GL want to reset the current * palette. The difficulty is that they want to reset it to different things. * * The proper way to handle this would be to implement IN as a reset type, * create a single palette reset routine, and have it do different things * depending on the nature of the reset. * * At the time this comment was written, such a change was larger than could * be easily accommodated. Hence, a less drastic alternative was employed: * split the IN command into implicit and explicit portions, and only use the * latter when the IN command is explicitly invoked. */ int hpgl_IN_implicit( hpgl_state_t * pgls\ ) { hpgl_args_t args; /* cancel rotation */ pgls->g.rotation = 0; /* restore defaults */ hpgl_DF(&args, pgls); /* if in RTL mode provided initial values for PS */ if ( pgls->personality == rtl ) { hpgl_args_setup(&args); hpgl_PS(&args, pgls); } /* defaults P1 and P2 */ hpgl_args_setup(&args); hpgl_IP(&args, pgls); /* pen width units - metric, also resets pen widths. */ 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 * the gl/2 state, we subsequently clear the path because we * do not want to create a live gs path. */ hpgl_args_set_real2(&args, 0.0, 0.0); hpgl_PU(&args, pgls); hpgl_args_set_real2(&args, 0.0, 0.0); hpgl_PA(&args, pgls); hpgl_call(hpgl_clear_current_path(pgls)); return 0; }
/* 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 */ } } hpgl_args_setup(&args); hpgl_IN(&args, pgls); return 0; }
/* Select font by ID (FI, FN). */ 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; } 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 (pfs->font->scaling_technology == plfst_bitmap) { hpgl_args_t args; hpgl_args_setup(&args); hpgl_args_add_int(&args, 1); hpgl_SB(&args, pgls); } /* note pcltrm 23-54 - only select if the table (primary or secondary) matches the currently selected table. */ if (index == pgls->g.font_selected) { hpgl_select_font(pgls, index); } return 0; }
/* 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)); hpgl_args_setup(&args); hpgl_FT(&args, pgls); hpgl_args_setup(&args); hpgl_IW(&args, pgls); hpgl_set_line_attribute_defaults(pgls); hpgl_args_setup(&args); hpgl_LA(&args, pgls); hpgl_set_line_pattern_defaults(pgls); hpgl_args_setup(&args); hpgl_RF(&args, pgls); hpgl_args_set_int(&args, 0); hpgl_SV(&args, pgls); hpgl_args_setup(&args); hpgl_UL(&args, pgls); hpgl_args_setup(&args); hpgl_SB(&args, pgls); return 0; }
void hpgl_do_reset(pcl_state_t * pcs, pcl_reset_type_t type) { /* pgframe.c (Chapter 18) */ hpgl_args_t hpgl_args; if ((type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_cold)) != 0) { if ((type & (pcl_reset_initial | pcl_reset_cold)) != 0) { gx_path_alloc_contained(&pcs->g.polygon.buffer.path, pcs->memory, "hpgl_do_reset polygon buffer"); gs_setlimitclamp(pcs->pgs, true); } else gx_path_new(&pcs->g.polygon.buffer.path); /* provide default anchor point, plot size and picture frame size */ hpgl_default_coordinate_system(pcs); /* we should not have a path at this point but we make sure */ hpgl_clear_current_path(pcs); /* Initialize stick/arc font instances */ hpgl_initialize_stick_fonts(pcs); /* intialize subpolygon started hack flag */ pcs->g.subpolygon_started = false; /* indicates a line down operation has been done in polygon mode */ pcs->g.have_drawn_in_path = false; /* execute only the implicit portion of IN */ hpgl_IN_implicit(pcs); /* we select the default pen 1 here, oddly, IN does not select the default pen even though it sets pen widths and units of measure */ pcs->g.pen.selected = 1; } /* NB check all of these */ if ((type & pcl_reset_page_params) != 0) { /* provide default anchor point, plot size and picture frame size. Oddly HP does not reset the scaling parameters when the page size is changed. */ int scale_type = pcs->g.scaling_type; hpgl_scaling_params_t params = pcs->g.scaling_params; hpgl_default_coordinate_system(pcs); /* restore the scaling parameter. */ pcs->g.scaling_type = scale_type; pcs->g.scaling_params = params; hpgl_args_setup(&hpgl_args); hpgl_IW(&hpgl_args, pcs); hpgl_args_set_int(&hpgl_args, 0); hpgl_PM(&hpgl_args, pcs); hpgl_args_set_int(&hpgl_args, 2); hpgl_PM(&hpgl_args, pcs); hpgl_args_setup(&hpgl_args); hpgl_IP(&hpgl_args, pcs); } if ((type & pcl_reset_picture_frame) != 0) { /* this shouldn't happen. Picture frame side effects are handled directly by the command picture frame command. */ dmprintf(pcs->memory, "PCL reset picture frame received\n"); } if ((type & pcl_reset_overlay) != 0) /* ignore return */ (void)hpgl_reset_overlay(pcs); if ((type & (pcl_reset_plot_size)) != 0) { /* this shouldn't happen. Plot size side effects are handled directly by the command picture frame command. */ dmprintf(pcs->memory, "PCL reset plot received\n"); } if ((type & (pcl_reset_permanent)) != 0) { gx_path_free(&pcs->g.polygon.buffer.path, "hpgl_do_reset polygon buffer"); /* if we have allocated memory for a stick font free the memory */ hpgl_free_stick_fonts(pcs); } return; }
/* The part of the DF command applicable for overlay macros */ 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 */ 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)); hpgl_call(gs_transform(pgls->pgs, pt.x, pt.y, &dpt)); pgls->g.scaling_type = hpgl_scaling_none; hpgl_call(hpgl_set_ctm(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 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); #ifdef LJ6_COMPAT /* 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); #endif return 0; }