[gs-cvs] rev 7540 - in trunk/gs: doc src

leonardo at ghostscript.com leonardo at ghostscript.com
Sat Dec 30 05:31:18 PST 2006


Author: leonardo
Date: 2006-12-30 05:31:18 -0800 (Sat, 30 Dec 2006)
New Revision: 7540

Modified:
   trunk/gs/doc/pscet_status.txt
   trunk/gs/src/gspaint.c
   trunk/gs/src/gstext.c
   trunk/gs/src/gstext.h
   trunk/gs/src/zcharx.c
Log:
Fix : Don't check type of extra width elements with yshow.

DETAILS :

CET 13-29.PS page 2 defines a longer width array
then the text requires, and CPSI silently ignores extra elements.
So yshow needs to compute exact number of characters 
to know how many elements to load and type check.

The new function gs_text_size is factored out from the
recently added code so that zcharx.c can share it.

Minor change : Improving a comment in gspaint.c,
with another issue recently discovered.
It's not related to the yshow problem.

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/doc/pscet_status.txt
===================================================================
--- trunk/gs/doc/pscet_status.txt	2006-12-30 11:50:34 UTC (rev 7539)
+++ trunk/gs/doc/pscet_status.txt	2006-12-30 13:31:18 UTC (rev 7540)
@@ -3145,7 +3145,7 @@
 
 13-27-1  OK	Minor differences visually reviewed by RJJ
 
-13-27-2  DIFF	GS shows typecheck in --xshow-- for all 'Range 3' tests. - ADC
+13-27-2  OK
 
 13-27-3  DIFF	Two ILLEGAL tests succeed with GS. Different error messages,
 		different stack contents after error. Tek matches CPSI
@@ -3165,9 +3165,7 @@
 
 13-28-2  OK	Minor differences visually reviewed by RJJ
 
-13-28-3  DIFF	GS shows a typecheck in --xyshow-- in all tests in the 'Range4'
-		section of the page. - ADC
-                assign Alex.
+13-28-3  OK
 
 13-28-4  DIFF	Same as 13-27-3
 		Two ILLEGAL tests succeed with GS. Different error messages,
@@ -3186,8 +3184,7 @@
 
 13-29-1  OK	Minor differences visually reviewed by RJJ
 
-13-29-2  DIFF	Dots missing in GS output in the second section of the test. - ADC
-                assign: Igor.
+13-29-2  OK
 
 13-29-3  DIFF	Same as 13-27-3
 		Two ILLEGAL tests succeed with GS. Different error messages,

Modified: trunk/gs/src/gspaint.c
===================================================================
--- trunk/gs/src/gspaint.c	2006-12-30 11:50:34 UTC (rev 7539)
+++ trunk/gs/src/gspaint.c	2006-12-30 13:31:18 UTC (rev 7540)
@@ -295,6 +295,8 @@
 	      This case is not important for low level devices
 	      (which a printer is), because low level device doesn't accept
 	      Type 3 charproc streams immediately.
+	   6. It doesn't work properly while an insiding testing,
+	      which sets gs_hit_device, which is uncolored.
 	 */
         if (gx_device_has_color(gs_currentdevice(pgs))) {
             gs_set_object_tag(pgs, GS_PATH_TAG);

Modified: trunk/gs/src/gstext.c
===================================================================
--- trunk/gs/src/gstext.c	2006-12-30 11:50:34 UTC (rev 7539)
+++ trunk/gs/src/gstext.c	2006-12-30 13:31:18 UTC (rev 7540)
@@ -350,14 +350,54 @@
     text.data.bytes = str, text.size = size;
     return gs_text_begin(pgs, &text, mem, ppte);
 }
+
+/* Compute the number of characters in a text. */
 int
+gs_text_size(gs_state * pgs, gs_text_params_t *text, gs_memory_t * mem)
+{
+    font_proc_next_char_glyph((*next_proc)) = pgs->font->procs.next_char_glyph;
+
+    if (next_proc == gs_default_next_char_glyph)
+	return text->size;
+    else {
+	/* Do it the hard way. */
+	gs_text_enum_t *pte;	/* use a separate enumerator */
+	gs_char tchr;
+	gs_glyph tglyph;
+	int size = 0;
+	int code;
+
+	size = 0;
+	code = gs_text_begin(pgs, text, mem, &pte);
+	if (code < 0)
+	    return code;
+	while ((code = (*next_proc)(pte, &tchr, &tglyph)) != 2) {
+	    if (code < 0)
+		break;
+	    ++size;
+	}
+	gs_free_object(mem, pte, "gs_xyshow_begin");
+	if (code < 0)
+	    return code;
+	return size;
+    }
+}
+
+/* Retrieve text params from enumerator. */
+gs_text_params_t *
+gs_get_text_params(gs_text_enum_t *pte)
+{
+    return &pte->text;
+}
+
+int
 gs_xyshow_begin(gs_state * pgs, const byte * str, uint size,
 		const float *x_widths, const float *y_widths,
 		uint widths_size, gs_memory_t * mem, gs_text_enum_t ** ppte)
 {
     gs_text_params_t text;
     uint widths_needed;
-    font_proc_next_char_glyph((*next_proc)) = pgs->font->procs.next_char_glyph;
+    int code;
 
     text.operation = TEXT_FROM_STRING | TEXT_REPLACE_WIDTHS |
 	text_do_draw(pgs) | TEXT_RETURN_WIDTH;
@@ -374,33 +414,14 @@
      * must use the font's next_char_glyph procedure to determine how many
      * characters there are in the string.
      */
-    if (next_proc == gs_default_next_char_glyph) {
-	widths_needed = size;
-    } else {
-	/* Do it the hard way. */
-	gs_text_enum_t *pte;	/* use a separate enumerator */
-	gs_char tchr;
-	gs_glyph tglyph;
-	int code;
-
-	widths_needed = 0;
-	code = gs_text_begin(pgs, &text, mem, &pte);
-	if (code < 0)
-	    return code;
-	while ((code = (*next_proc)(pte, &tchr, &tglyph)) != 2) {
-	    if (code < 0)
-		break;
-	    ++widths_needed;
-	}
-	gs_free_object(mem, pte, "gs_xyshow_begin");
-	if (code < 0)
-	    return code;
-    }
+    code = gs_text_size(pgs, &text, mem);
+    if (code < 0)
+	return code;
+    widths_needed = code;
     if (x_widths && y_widths)
 	widths_needed <<= 1;
     if (widths_size < widths_needed)
 	return_error(gs_error_rangecheck);
-
     return gs_text_begin(pgs, &text, mem, ppte);
 }
 

Modified: trunk/gs/src/gstext.h
===================================================================
--- trunk/gs/src/gstext.h	2006-12-30 11:50:34 UTC (rev 7539)
+++ trunk/gs/src/gstext.h	2006-12-30 13:31:18 UTC (rev 7540)
@@ -236,6 +236,12 @@
     gs_charboxpath_begin(gs_state *, const byte *, uint, bool,
 			 gs_memory_t *, gs_text_enum_t **);
 
+/* Compute the number of characters in a text. */
+int gs_text_size(gs_state * pgs, gs_text_params_t *text, gs_memory_t * mem);
+/* Retrieve text params from enumerator. */
+gs_text_params_t *gs_get_text_params(gs_text_enum_t *pte);
+
+
 /*
  * Restart text processing with new parameters.
  */

Modified: trunk/gs/src/zcharx.c
===================================================================
--- trunk/gs/src/zcharx.c	2006-12-30 11:50:34 UTC (rev 7539)
+++ trunk/gs/src/zcharx.c	2006-12-30 13:31:18 UTC (rev 7540)
@@ -92,7 +92,7 @@
     gs_text_enum_t *penum;
     int code = op_show_setup(i_ctx_p, op - 1);
     int format;
-    uint i, size;
+    uint i, size, widths_needed;
     float *values;
 
     if (code != 0)
@@ -104,7 +104,25 @@
     values = (float *)ialloc_byte_array(size, sizeof(float), "moveshow");
     if (values == 0)
 	return_error(e_VMerror);
-    for (i = 0; i < size; ++i) {
+    memset(values, 0, size * sizeof(values[0]));
+    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, &penum)) < 0) {
+	ifree_object(values, "moveshow");
+	return code;
+    }
+    /* 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_size(igs, gs_get_text_params(penum), imemory);
+    if (code < 0)
+	return code;
+    widths_needed = code;
+    if (have_x && have_y)
+	widths_needed <<= 1;
+    for (i = 0; i < widths_needed; ++i) {
 	ref value;
 
 	switch (code = num_array_get(imemory, op, format, i, &value)) {
@@ -120,11 +138,7 @@
 	    return code;
 	}
     }
-    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, &penum)) < 0 ||
-	(code = op_show_finish_setup(i_ctx_p, penum, 2, NULL)) < 0) {
+    if ((code = op_show_finish_setup(i_ctx_p, penum, 2, NULL)) < 0) {
 	ifree_object(values, "moveshow");
 	return code;
     }



More information about the gs-cvs mailing list