[gs-cvs] rev 7025 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Thu Sep 7 04:59:04 PDT 2006
Author: leonardo
Date: 2006-09-07 04:59:03 -0700 (Thu, 07 Sep 2006)
New Revision: 7025
Modified:
trunk/gs/src/gdevpdtf.c
trunk/gs/src/gdevpdtf.h
trunk/gs/src/gdevpdtt.c
Log:
Fix (pdfwrite) : Provide a conservative choice of BaseEncoiding.
DETAILS :
Bug 688823 "large files embedding AndaleMonoWTG".
The old code choosen BaseEncoding for each text string independently
on others. It caused creating multiple font copies due to encoding conflict.
The new code implements a new font resource property
preferred_encoding_index to make the choice be conservative
in case of multiple possibilities.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevpdtf.c
===================================================================
--- trunk/gs/src/gdevpdtf.c 2006-09-07 06:41:20 UTC (rev 7024)
+++ trunk/gs/src/gdevpdtf.c 2006-09-07 11:59:03 UTC (rev 7025)
@@ -434,6 +434,7 @@
pfres->u.simple.FirstChar = 256;
pfres->u.simple.LastChar = -1;
pfres->u.simple.BaseEncoding = -1;
+ pfres->u.simple.preferred_encoding_index = -1;
*ppfres = pfres;
return 0;
}
Modified: trunk/gs/src/gdevpdtf.h
===================================================================
--- trunk/gs/src/gdevpdtf.h 2006-09-07 06:41:20 UTC (rev 7024)
+++ trunk/gs/src/gdevpdtf.h 2006-09-07 11:59:03 UTC (rev 7025)
@@ -263,6 +263,7 @@
* ENCODING_INDEX_MACROMAN, ENCODING_INDEX_MACEXPERT, or -1.
*/
gs_encoding_index_t BaseEncoding;
+ gs_encoding_index_t preferred_encoding_index;
pdf_encoding_element_t *Encoding; /* [256], not for Type 3 */
gs_point *v; /* [256], glyph origin for WMode 1 */
Modified: trunk/gs/src/gdevpdtt.c
===================================================================
--- trunk/gs/src/gdevpdtt.c 2006-09-07 06:41:20 UTC (rev 7024)
+++ trunk/gs/src/gdevpdtt.c 2006-09-07 11:59:03 UTC (rev 7025)
@@ -1293,11 +1293,13 @@
gs_font *font, const gs_string *pstr, const gs_glyph *gdata,
int *ps_encoding_index)
{
- int i, ei;
+ int i, ei, j;
gs_char ch;
gs_const_string gname;
gs_glyph *gid = (gs_glyph *)pstr->data; /* pdf_text_process allocs enough space. */
+ gs_font_base *bfont;
bool unknown = false;
+ int start_ei;
/* Translate glyph name indices into gscencs.c indices. */
for (i = 0; i < pstr->size; i++) {
@@ -1314,8 +1316,20 @@
}
if (unknown)
return 0; /* Using global glyph names. */
- /* Find an acceptable encodng. */
- for (ei = 0; gs_c_known_encodings[ei]; ei++) {
+ /* Now we know it's a base font, bcause it has glyph names. */
+ bfont = (gs_font_base *)font;
+ start_ei = *ps_encoding_index;
+ if (start_ei < 0)
+ start_ei = bfont->nearest_encoding_index;
+ if (start_ei < 0)
+ start_ei = 0;
+ /* Find an acceptable encodng, starting from start_ei.
+ We need a conservative search to minimize the probability
+ of encoding conflicts.
+ */
+ for (j = 0, ei = start_ei; gs_c_known_encodings[j]; j++, ei++) {
+ if (!gs_c_known_encodings[ei])
+ ei = 0;
cgp->num_unused_chars = 0;
cgp->num_all_chars = 0;
for (i = 0; i < pstr->size; i++) {
@@ -1535,6 +1549,8 @@
if (code < 0)
return code;
/* *ppdfont is NULL if no resource attached. */
+ if (*ppdfont != NULL)
+ ps_encoding_index = (*ppdfont)->u.simple.preferred_encoding_index;
if (penum->cgp == NULL) {
code = pdf_alloc_text_glyphs_table(pdev, penum, pstr);
if (code < 0)
@@ -1547,6 +1563,7 @@
code = pdf_obtain_font_resource_encoded(pdev, font, ppdfont, penum->cgp);
if (code < 0)
return code;
+ (*ppdfont)->u.simple.preferred_encoding_index = ps_encoding_index;
code = pdf_attached_font_resource(pdev, font, ppdfont,
&glyph_usage, &real_widths, &char_cache_size, &width_cache_size);
if (code < 0)
More information about the gs-cvs
mailing list