summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'devices/vector/gdevpdtt.c')
-rw-r--r--devices/vector/gdevpdtt.c59
1 files changed, 39 insertions, 20 deletions
diff --git a/devices/vector/gdevpdtt.c b/devices/vector/gdevpdtt.c
index 3091a18d..98ce8892 100644
--- a/devices/vector/gdevpdtt.c
+++ b/devices/vector/gdevpdtt.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -114,7 +114,7 @@ pdf_text_set_cache(gs_text_enum_t *pte, const double *pw,
* NOT the identity, but we want the cache device values to be in
* font co-ordinate space, so we need to undo that scale here.
*/
- if (pdev->PS_accumulator){
+ if (pdev->PS_accumulator || pdev->Scaled_accumulator){
gs_matrix_scale(&ctm_only(pte->pgs), .01, .01, &m);
gs_distance_transform(pw[0], pw[1], &m, &pdev->char_width);
} else {
@@ -133,7 +133,7 @@ pdf_text_set_cache(gs_text_enum_t *pte, const double *pw,
* NOT the identity, but we want the cache device values to be in
* font co-ordinate space, so we need to undo that scale here.
*/
- if (pdev->PS_accumulator){
+ if (pdev->PS_accumulator || pdev->Scaled_accumulator){
gs_matrix_scale(&ctm_only(pte->pgs), .01, .01, &m);
gs_distance_transform(pw[0], pw[1], &m, &pdev->char_width);
} else {
@@ -214,7 +214,7 @@ pdf_text_set_cache(gs_text_enum_t *pte, const double *pw,
* needs to be in the 100x100 space so that it doesn't clip
* out marking operations.
*/
- if (pdev->PS_accumulator)
+ if (pdev->PS_accumulator || pdev->Scaled_accumulator)
gs_matrix_scale(&ctm_only(penum_s->pgs), .01, .01, &m);
else
m = ctm_only(penum_s->pgs);
@@ -225,7 +225,7 @@ pdf_text_set_cache(gs_text_enum_t *pte, const double *pw,
pw1[i] = p.x;
pw1[i + 1] = p.y;
}
- if (!pdev->PS_accumulator)
+ if (!pdev->PS_accumulator && !pdev->Scaled_accumulator)
code = pdf_set_charproc_attrs(pdev, pte->current_font,
pw1, narg, control, penum->returned.current_char, false);
else
@@ -1114,11 +1114,10 @@ pdf_is_compatible_encoding(gx_device_pdf *pdev, pdf_font_resource_t *pdfont,
if (pfont->data.FMapType == fmap_CMap) {
const gs_cmap_t *pcmap = pfont->data.CMap;
- const gs_const_string *s0 = &pdfont->u.type0.CMapName;
const gs_const_string *s1 = &pcmap->CMapName;
- return (s0->size == s1->size &&
- !memcmp(s0->data, s1->data, s0->size));
+ return (pdfont->u.type0.CMapName_size == s1->size &&
+ !memcmp(pdfont->u.type0.CMapName_data, s1->data, pdfont->u.type0.CMapName_size));
}
}
return false;
@@ -1283,9 +1282,9 @@ pdf_find_type0_font_resource(gx_device_pdf *pdev, const pdf_font_resource_t *pds
*/
if (pdfont->BaseFont.size != pdsubf->BaseFont.size)
continue;
- if (pdfont->u.type0.CMapName.size != CMapName->size)
+ if (pdfont->u.type0.CMapName_size != CMapName->size)
continue;
- if (memcmp(pdfont->u.type0.CMapName.data, CMapName->data, CMapName->size))
+ if (memcmp(pdfont->u.type0.CMapName_data, CMapName->data, CMapName->size))
continue;
}
@@ -2290,9 +2289,16 @@ int
pdf_obtain_parent_type0_font_resource(gx_device_pdf *pdev, pdf_font_resource_t *pdsubf,
uint font_index, const gs_const_string *CMapName, pdf_font_resource_t **pdfont)
{
+ gs_const_string s1;
+
+ if (pdsubf->u.cidfont.parent != 0) {
+ s1.data = pdsubf->u.cidfont.parent->u.type0.CMapName_data;
+ s1.size = pdsubf->u.cidfont.parent->u.type0.CMapName_size;
+ }
+
if (pdsubf->u.cidfont.parent != 0 &&
font_index == pdsubf->u.cidfont.parent->u.type0.font_index &&
- strings_equal(CMapName, &pdsubf->u.cidfont.parent->u.type0.CMapName))
+ strings_equal(CMapName, &s1))
*pdfont = pdsubf->u.cidfont.parent;
else {
/*
@@ -2868,7 +2874,7 @@ pdf_choose_output_char_code(gx_device_pdf *pdev, pdf_text_enum_t *penum, gs_char
}
static int
-pdf_choose_output_glyph_name(gx_device_pdf *pdev, pdf_text_enum_t *penum, gs_const_string *gnstr, gs_glyph glyph)
+pdf_choose_output_glyph_name(gx_device_pdf *pdev, pdf_text_enum_t *penum, gs_const_string *gnstr, gs_glyph glyph, bool *cleanup)
{
if (penum->orig_font->FontType == ft_composite || penum->orig_font->procs.glyph_name(penum->orig_font, glyph, gnstr) < 0
|| (penum->orig_font->FontType > 42 && gnstr->size == 7 && strcmp((const char *)gnstr->data, ".notdef")== 0)) {
@@ -2887,9 +2893,10 @@ pdf_choose_output_glyph_name(gx_device_pdf *pdev, pdf_text_enum_t *penum, gs_con
p = (byte *)gs_alloc_string(pdev->pdf_memory, gnstr->size, "pdf_text_set_cache");
if (p == NULL)
return_error(gs_error_VMerror);
- gs_sprintf(buf, "g%04x", (unsigned int)(glyph & 0xFFFF));
+ gs_snprintf(buf, sizeof(buf), "g%04x", (unsigned int)(glyph & 0xFFFF));
memcpy(p, buf, 5);
gnstr->data = p;
+ *cleanup = true;
}
return 0;
}
@@ -3041,6 +3048,12 @@ static int install_charproc_accumulator(gx_device_pdf *pdev, gs_text_enum_t *pte
executed gsave, so we are safe to change CTM now.
Note that BuildChar may change CTM before calling setcachedevice. */
gs_make_identity(&m);
+ if (penum->current_font->FontType == ft_PDF_user_defined) {
+ pdev->width *= 100;
+ pdev->height *= 100;
+ gs_matrix_scale(&m, 100, 100, &m);
+ pdev->Scaled_accumulator = 1;
+ }
gs_matrix_fixed_from_matrix(&penum->pgs->ctm, &m);
/* Choose a character code to use with the charproc. */
@@ -3074,10 +3087,11 @@ static int complete_charproc(gx_device_pdf *pdev, gs_text_enum_t *pte,
{
gs_const_string gnstr;
int code;
+ bool cleanup = false;
if (pte_default->returned.current_glyph == GS_NO_GLYPH)
return_error(gs_error_undefined);
- code = pdf_choose_output_glyph_name(pdev, penum, &gnstr, pte_default->returned.current_glyph);
+ code = pdf_choose_output_glyph_name(pdev, penum, &gnstr, pte_default->returned.current_glyph, &cleanup);
if (code < 0) {
return code;
}
@@ -3109,26 +3123,30 @@ static int complete_charproc(gx_device_pdf *pdev, gs_text_enum_t *pte,
stream_puts(pdev->strm, "0 0 0 0 0 0 d1\n");
}
- if (was_PS_type3) {
+ if (was_PS_type3 || pdev->Scaled_accumulator) {
/* See below, we scaled the device height and width to prevent
* clipping of the CharProc operations, now we need to undo that.
*/
pdev->width /= 100;
pdev->height /= 100;
+ pdev->Scaled_accumulator = 0;
}
code = pdf_end_charproc_accum(pdev, penum->current_font, penum->cgp,
pte_default->returned.current_glyph, penum->output_char_code, &gnstr);
if (code < 0)
- return code;
+ goto exit;
pdev->accumulating_charproc = false;
penum->charproc_accum = false;
code = gx_default_text_restore_state(pte_default);
if (code < 0)
- return code;
+ goto exit;
gs_text_release(NULL, pte_default, "pdf_text_process");
penum->pte_default = 0;
- return 0;
+exit:
+ if (cleanup)
+ gs_free_string(pdev->pdf_memory, (byte *)gnstr.data, gnstr.size, "pdf_text_set_cache free working name");
+ return code;
}
/* Nasty hackery. The PCL 'stick font' is drawn by constructing a path, and then stroking it.
@@ -3449,7 +3467,8 @@ pdf_text_process(gs_text_enum_t *pte)
/* We need a special 'initial matrix' method for stick fonts,
* See pdf_type3_get_initial_matrix above.
*/
- pdev->procs.get_initial_matrix = pdf_type3_get_initial_matrix;
+ if (penum->current_font->FontType != ft_PDF_user_defined)
+ pdev->procs.get_initial_matrix = pdf_type3_get_initial_matrix;
pdev->pte = (gs_text_enum_t *)penum; /* CAUTION: See comment in gdevpdfx.h . */
/* In case of error, text_process will restore back to the enumerator 'level'
@@ -3524,7 +3543,7 @@ pdf_text_process(gs_text_enum_t *pte)
/* end of code copied from show_cache_setup */
/* This copied from set_cache */
- code = gx_alloc_char_bits(pte->current_font->dir, dev, NULL,
+ code = gx_alloc_char_bits(pte->current_font->dir, dev,
0, 0, &log2_scale, 1, &cc);
if (code < 0)
return code;