/* <cx> <cy> <char> <string> widthshow - */ static int zwidthshow(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_text_enum_t *penum; double cxy[2]; int code; if ((code = op_show_setup(i_ctx_p, op)) != 0 ) return code; check_type(op[-1], t_integer); if (gs_currentfont(igs)->FontType == ft_composite) { if ((gs_char) (op[-1].value.intval) != op[-1].value.intval) return_error(e_rangecheck); } else { if (op[-1].value.intval < 0 || op[-1].value.intval > 255) return_error(e_rangecheck); /* per PLRM and CET 13-26 */ } if ((code = num_params(op - 2, 2, cxy)) < 0 ) return code; if ((code = gs_widthshow_begin(igs, cxy[0], cxy[1], (gs_char) op[-1].value.intval, op->value.bytes, r_size(op), imemory, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = zwidthshow; if ((code = op_show_finish_setup(i_ctx_p, penum, 4, finish_show)) < 0) { ifree_object(penum, "op_show_enum_setup"); return code; } return op_show_continue_pop(i_ctx_p, 4); }
/* <proc> <string> kshow - */ static int zkshow(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_text_enum_t *penum; int code; check_read_type(*op, t_string); check_proc(op[-1]); /* * Per PLRM Section xx.x, kshow is illegal if the current font is a * composite font. The graphics library does not have this limitation, * so we check for it here. */ if (gs_currentfont(igs)->FontType == ft_composite) return_error(e_invalidfont); if ((code = op_show_setup(i_ctx_p, op)) != 0 || (code = gs_kshow_begin(igs, op->value.bytes, r_size(op), imemory, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = zkshow; if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) { ifree_object(penum, "op_show_enum_setup"); return code; } sslot = op[-1]; /* save kerning proc */ return op_show_continue_pop(i_ctx_p, 2); }
/* <charname> .glyphwidth <wx> <wy> */ static int zglyphwidth(i_ctx_t *i_ctx_p) { gs_glyph glyph; gs_text_enum_t *penum; int code; if ((code = glyph_show_setup(i_ctx_p, &glyph)) != 0 || (code = gs_glyphwidth_begin(igs, glyph, imemory, &penum)) < 0) return code; if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_stringwidth)) < 0) { ifree_object(penum, "zglyphwidth"); return code; } return op_show_continue_pop(i_ctx_p, 1); }
/* <string> show - */ static int zshow(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_text_enum_t *penum; int code = op_show_setup(i_ctx_p, op); if (code != 0 || (code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = zshow; if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_show)) < 0) { ifree_object(penum, "op_show_enum_setup"); return code; } return op_show_continue_pop(i_ctx_p, 1); }
/* <charname> glyphshow - */ static int zglyphshow(i_ctx_t *i_ctx_p) { gs_glyph glyph; gs_text_enum_t *penum; int code; if ((code = glyph_show_setup(i_ctx_p, &glyph)) != 0 || (code = gs_glyphshow_begin(igs, glyph, imemory_local, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = zglyphshow; if ((code = op_show_finish_setup(i_ctx_p, penum, 1, NULL)) < 0) { ifree_object(penum, "zglyphshow"); return code; } return op_show_continue_pop(i_ctx_p, 1); }
/* <ax> <ay> <string> ashow - */ static int zashow(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_text_enum_t *penum; double axy[2]; int code = num_params(op - 1, 2, axy); if (code < 0 || (code = op_show_setup(i_ctx_p, op)) != 0 || (code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = zashow; if ((code = op_show_finish_setup(i_ctx_p, penum, 3, finish_show)) < 0) { ifree_object(penum, "op_show_enum_setup"); return code; } return op_show_continue_pop(i_ctx_p, 3); }
/* Common code for charpath and .charboxpath. */ static int zchar_path(i_ctx_t *i_ctx_p, op_proc_t proc, int (*begin)(gs_state *, const byte *, uint, bool, gs_memory_t *, gs_text_enum_t **)) { os_ptr op = osp; gs_text_enum_t *penum; int code; check_type(*op, t_boolean); code = op_show_setup(i_ctx_p, op - 1); if (code != 0 || (code = begin(igs, op[-1].value.bytes, r_size(op - 1), op->value.boolval, imemory, &penum)) < 0) return code; *(op_proc_t *)&penum->enum_client_data = proc; if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) { ifree_object(penum, "op_show_enum_setup"); return code; } return op_show_continue_pop(i_ctx_p, 2); }
/* <string> <numarray|numstring> xyshow - */ static int moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y) { os_ptr op = osp; gs_text_enum_t *penum = NULL; int code = op_show_setup(i_ctx_p, op - 1); int format; uint i, size, widths_needed; float *values; bool CPSI_mode = gs_currentcpsimode(imemory); if (code != 0) return code; format = num_array_format(op); if (format < 0) return format; size = num_array_size(op, format); values = (float *)ialloc_byte_array(size, sizeof(float), "moveshow"); if (values == 0) return_error(gs_error_VMerror); if (CPSI_mode) memset(values, 0, size * sizeof(values[0])); /* Safety. */ if ((code = gs_xyshow_begin(igs, op[-1].value.bytes, r_size(op - 1), (have_x ? values : (float *)0), (have_y ? values : (float *)0), size, imemory_local, &penum)) < 0) { ifree_object(values, "moveshow"); if (penum) /* if there was an error, the text_enum may not have been allocated */ penum->text.x_widths = penum->text.y_widths = NULL; return code; } if (CPSI_mode) { /* CET 13-29.PS page 2 defines a longer width array then the text requires, and CPSI silently ignores extra elements. So we need to compute exact number of characters to know how many elements to load and type check. */ code = gs_text_count_chars(igs, gs_get_text_params(penum), imemory); if (code < 0) return code; widths_needed = code; if (have_x && have_y) widths_needed <<= 1; } else widths_needed = size; for (i = 0; i < widths_needed; ++i) { ref value; switch (code = num_array_get(imemory, op, format, i, &value)) { case t_integer: values[i] = (float)value.value.intval; break; case t_real: values[i] = value.value.realval; break; case t_null: code = gs_note_error(gs_error_rangecheck); /* falls through */ default: ifree_object(values, "moveshow"); penum->text.x_widths = penum->text.y_widths = NULL; return code; } } if ((code = op_show_finish_setup(i_ctx_p, penum, 2, NULL)) < 0) { ifree_object(values, "moveshow"); penum->text.x_widths = penum->text.y_widths = NULL; return code; } pop(2); return op_show_continue(i_ctx_p); }