summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-12-21 09:03:21 +0000
committerKen Sharp <ken.sharp@artifex.com>2022-12-21 09:03:21 +0000
commitf486147fad0b0f9c440a2a4405d48861eedac4b1 (patch)
tree78591abaf330189731a83a4e62fa2574e8b86055 /pdf
parente5f67462860af8e69977e84c8704c23ed9e1455a (diff)
downloadghostpdl-f486147fad0b0f9c440a2a4405d48861eedac4b1.tar.gz
GhostPDF - PDF 2.0, Halftones can be arrays
/tests_private/pdf/PDF_2.0_FTS/fts_24_2432.pdf Missed this somewhere along the way; in PDF 2.0 a /HT (halftone) can have an array value which is an array of spot names, the consumer is supposed to use the first one it recognises..... We weren't expecting an array and returned a typecheck error. This was masked by the fact that some of the halftones in the test file genuinely don't contain usable halftone names so an error is to be expected. Add code to deal with an array by trying to find each spot name in turn in the list of spot names we know about. Causes diffs in /tests_private/pdf/PDF_2.0_FTS/fts_24_2432.pdf because we now use a different spot shape in two cases.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_gstate.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/pdf/pdf_gstate.c b/pdf/pdf_gstate.c
index 632329ce5..8a6c114ec 100644
--- a/pdf/pdf_gstate.c
+++ b/pdf/pdf_gstate.c
@@ -1119,7 +1119,7 @@ error:
static int build_type1_halftone(pdf_context *ctx, pdf_dict *halftone_dict, pdf_dict *page_dict, gx_ht_order *porder, gs_halftone_component *phtc, char *name, int len, int comp_num)
{
- int code, i;
+ int code, i, j;
pdf_obj *obj = NULL, *transfer = NULL;
double f, a;
float values[2] = {0, 0}, domain[4] = {-1, 1, -1, 1}, out;
@@ -1164,8 +1164,10 @@ static int build_type1_halftone(pdf_context *ctx, pdf_dict *halftone_dict, pdf_d
if (pdfi_name_is((pdf_name *)obj, spot_table[i]))
break;
}
- if (i >= (sizeof(spot_table) / sizeof (char *)))
- return gs_note_error(gs_error_rangecheck);
+ if (i >= (sizeof(spot_table) / sizeof (char *))) {
+ code = gs_note_error(gs_error_rangecheck);
+ goto error;
+ }
}
code = pdfi_build_halftone_function(ctx, &pfn, (byte *)spot_functions[i], strlen(spot_functions[i]));
if (code < 0)
@@ -1177,6 +1179,39 @@ static int build_type1_halftone(pdf_context *ctx, pdf_dict *halftone_dict, pdf_d
if (code < 0)
goto error;
break;
+ case PDF_ARRAY:
+ for (j = 0; j < pdfi_array_size((pdf_array *)obj); j++) {
+ pdf_name *n = NULL;
+
+ code = pdfi_array_get(ctx, (pdf_array *)obj, j, (pdf_obj **)&n);
+ if (code < 0)
+ goto error;
+ if (pdfi_type_of(n) != PDF_NAME)
+ pdfi_set_error(ctx, 0, NULL, E_PDF_BAD_TYPE, "build_type1_halftone", "Halftone array element is not a name");
+ else {
+ for (i = 0; i < (sizeof(spot_table) / sizeof (char *)); i++) {
+ if (pdfi_name_is((pdf_name *)n, spot_table[i])) {
+ pdfi_countdown(n);
+ n = NULL;
+ code = pdfi_build_halftone_function(ctx, &pfn, (byte *)spot_functions[i], strlen(spot_functions[i]));
+ if (code < 0)
+ goto error;
+ break;
+ }
+ }
+ if (i >= (sizeof(spot_table) / sizeof (char *))) {
+ pdfi_countdown(n);
+ n = NULL;
+ } else
+ break;
+ }
+ pdfi_countdown(n);
+ }
+ if (j >= pdfi_array_size((pdf_array *)obj)) {
+ code = gs_note_error(gs_error_rangecheck);
+ goto error;
+ }
+ break;
default:
code = gs_note_error(gs_error_typecheck);
goto error;