[gs-cvs] rev 7505 - trunk/gs/src
lpd at ghostscript.com
lpd at ghostscript.com
Thu Dec 14 07:50:54 PST 2006
Author: lpd
Date: 2006-12-14 07:50:54 -0800 (Thu, 14 Dec 2006)
New Revision: 7505
Modified:
trunk/gs/src/gstext.c
Log:
Changes {x,y,xy}show to check at the beginning whether the widths array is
large enough, rather than detecting this on the fly, for Adobe
compatibility. (PS3 CET 13-27-3, 13-28-4, 13-29-3)
Modified: trunk/gs/src/gstext.c
===================================================================
--- trunk/gs/src/gstext.c 2006-12-14 13:54:09 UTC (rev 7504)
+++ trunk/gs/src/gstext.c 2006-12-14 15:50:54 UTC (rev 7505)
@@ -347,6 +347,8 @@
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;
text.operation = TEXT_FROM_STRING | TEXT_REPLACE_WIDTHS |
text_do_draw(pgs) | TEXT_RETURN_WIDTH;
@@ -354,6 +356,42 @@
text.x_widths = x_widths;
text.y_widths = y_widths;
text.widths_size = widths_size;
+
+ /*
+ * Check that the widths array is large enough. gs_text_replaced_width
+ * checks this step-by-step, but Adobe's interpreters check it ahead of
+ * time, and for CET compliance, we must also. This is very easy for
+ * font types that always have 8-bit characters, but for others, we
+ * 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;
+ }
+ 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);
}
More information about the gs-cvs
mailing list