Bug 690644 - Driver Text processing
Summary: Driver Text processing
Status: NOTIFIED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 8.63
Hardware: PC Windows XP
: P2 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-21 12:12 UTC by Tony Teveris
Modified: 2011-09-18 21:46 UTC (History)
0 users

See Also:
Customer: 400
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Teveris 2009-07-21 12:12:51 UTC
In our cuurent GS driver when processing text all I have done is call 
the "gx_default_text_begin" function in the following routine. Then text is 
then broken down into vectors which I just build into Gerber objects.

I'm now trying to build GS text back into a higher level edittable Gerber text 
object(s). In the code below you can see where I added the Gerber Begin / End 
text function calls.

If I do not want GS to process any text (I do not want vectors) how do I stop 
GS from generating vectors. The documentation is not clear. There will be 
times that I will need vector (i.e. a font is not found on the users syste, 
etc). So I need to turn it (vector text on / off based on a return code from 
the Gerber BeginText().

Thanks in advance
Tony

static int
gimp_text_begin(gx_device * dev, gs_imager_state * pis,
		 const gs_text_params_t * text, gs_font * font,
		 gx_path * path, const gx_device_color * pdcolor,
		 const gx_clip_path * pcpath, gs_memory_t * memory,
		 gs_text_enum_t ** ppenum)
{
    int code = 0;
	
	gx_device_gimp *const pdev = (gx_device_gimp *) dev;

	if (pdev->m_PFN_BeginText)
		{
		GS_TEXTINFO TI;
		gs_fixed_point origin;

		gx_path_current_point(path, &origin);

		TI.dX = fixed2float(origin.x);
		TI.dY = fixed2float(origin.y);

		TI.pFontTitle = font->font_name.chars;

		TI.pCharacters = text->data.bytes;
		TI.nCount = text->size;


		TI.xx = pis->ctm.xx;
		TI.xy = pis->ctm.xy;
		TI.yx = pis->ctm.yx;
		TI.yy = pis->ctm.yy;
		TI.tx = pis->ctm.tx;
		TI.ty = pis->ctm.ty;

		pdev->m_PFN_BeginText(&TI);
		}

	code = gx_default_text_begin(dev, pis, text, font, path, pdcolor, 
pcpath, memory, ppenum);

	if (pdev->m_PFN_EndText)
		pdev->m_PFN_EndText();

	return code;
Comment 1 Ken Sharp 2009-07-21 13:35:50 UTC
Its late here, but since nobody else has replied yet....

I think the answer is simple, when you don't want GS to do anything with the
text, don't call gx_default_text_begin, when you want it to process the text,
you should call gx_default_text_begin.

Comment 2 Tony Teveris 2009-07-23 04:30:49 UTC
No that will not work because when you return from my gimp_text_begin() it 
will GPF in the following function.

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;
CRASH HERE    *(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);

So I assume some "dummy" functions must be setup or a special return code.
}
Comment 3 Ken Sharp 2009-07-23 09:09:25 UTC
OK, that's really a different question. You *do* need to set up the text
enumerator. As long as you call gx_default_text_begin it will do that for you.

However, you probably don't want to call any of the default text functions, so
you need to create (or at least initialise) the enumerator yourself. I was
assuming you were already aware of this, my mistake.

You will need to define you own methods in the enumerator, I'd suggest looking
at gdev_pdf_text_begin in gdevpdtt.c. This is the pdfwrite device text
processing code, in this routine it allocates an enumerator (subclassed from the
default text enumerator), sets up some PDF-specific fields and calls
gs_text_enum_init in order to set up the methods for dealing with text.

You will need to do much of the same work.
Comment 4 Tony Teveris 2009-07-23 09:11:23 UTC
OK, I got it.
Comment 5 Marcos H. Woehrmann 2011-09-18 21:46:20 UTC
Changing customer bugs that have been resolved more than a year ago to closed.