Пример #1
0
/* xyshow[_n] */
int
gs_xyshow_n_init(gs_show_enum * penum,
		 gs_state * pgs, const char *str, uint size)
{
    gs_text_enum_t *pte;
    int code = gs_xyshow_begin(pgs, (const byte *)str, size, NULL, NULL, 0,
			       pgs->memory, &pte);

    return show_n_begin(penum, pgs, code, pte);
}
Пример #2
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);
}