[Gs-devel] stringwidth in cshow with CIDFont

Masatake YAMATO masata-y at is.aist-nara.ac.jp
Fri Oct 19 12:35:41 PDT 2001


During debugging cshow operator, I've gotten a question.

The question is whether stringwidth operator is a variants of show
operator or not.

    % NOTE: Kochi-Mincho is a free Japanese CIDFont.
    % ----------------------------------------------------------
    % Script A
    /Kochi-Mincho-EUC-H findfont setfont
    0 0 moveto {pop pop pop (a) stringwidth pop pop} (a) cshow
    % ----------------------------------------------------------

    % ----------------------------------------------------------
    % Script B
    /Kochi-Mincho-EUC-H findfont setfont
    0 0 moveto {pop pop pop (b) stringwidth pop pop} (a) cshow
    % ----------------------------------------------------------

The script A works fine. however, the script B returns rangecheck error.

In the 3rd paragraph of cshow operator of PLRM 3rd,

    cshow takes special measures so that proc can execute show (or any 
    of its variants) ... the string passed to show must consist of
    a sngile byte equal to the code given to proc, or a rangecheck 
    error occurs;...

If stringwidth is a variants of show operator, the result of 
the script B is correct. However, if stringwidth is not a
variants of show operator, the result of the script B is incorrect;
no error should be returned and if-condition in zchar.c:op_show_finish_setup
should be change to reject stringwidth(and glyphwidth?).

    /* Finish setting up a text operator. */
    int
    op_show_finish_setup(i_ctx_t *i_ctx_p, gs_text_enum_t * penum, int npop,
			 op_proc_t endproc /* end procedure */ )
    {
	gs_text_enum_t *osenum = op_show_find(i_ctx_p);
	es_ptr ep = esp + snumpush;
	gs_glyph glyph;

	/*
	 * If we are in the procedure of a cshow for a CID font and this is
	 * a show operator, do something special, per the Red Book.
	 */
	if (osenum &&
	    SHOW_IS_ALL_OF(osenum,
			   TEXT_FROM_STRING | TEXT_DO_NONE | TEXT_INTERVENE) &&
	    SHOW_IS_ALL_OF(penum, TEXT_FROM_STRING | TEXT_RETURN_WIDTH) &&
	    (glyph = gs_text_current_glyph(osenum)) != gs_no_glyph &&
	    glyph >= gs_min_cid_glyph
	    ) {

Masatake YAMATO, jet at gyve.org



More information about the gs-devel mailing list