Пример #1
0
/* <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);
}
Пример #2
0
/* <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);
}
Пример #3
0
/* <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);
}
Пример #4
0
/* <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);
}
Пример #5
0
/* 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);
}
Пример #6
0
/* <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);
}