A fix for Bug 687172 "Jaggies appearing for some characters" (continued)
"Igor V. Melichev" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
[Log message beg]
Fix (pdfwrite) : Type 1,2 composite glyphs could point to wrong subglyphs.
DETAILS :
This is a continuation of the recent patch for
Bug 687172 "Jaggies appearing for some characters".
The old code converted subglyph names to char codes with the font's
Encoding.
However arguments of 'seac' command always encode glyphs by
StandardEncoding.
If the font's Encoding specifies different codes, the result was wrong.
Since the font copying routine uses gs_glyph values taken from the global
interpreter's space (see gsccode.h), which are PS name indices.
Thus it needs to convert a glyph name string to a name index.
Before now we had no support for this.
To provide it we add a new graphics library callback
gs_font_dir::global_glyph_code.
There exists a connected minor problem, which this patch doesn't fix.
If a font is freed and then reloaded, the glyph names can get
different name indices, if a garbager is invoked and freed
the names before the second loading. As the result, the copied font
can embed duplicated glyph definitions (charstrings).
It can't give an invalid PDF, but it's size may increase. Hopely this case
is rare.
Opening a new bug 687187 about this.
EXPECTED DIFFERENCES :
None with comparefiles.
[Log message end]
Changes:
*** f:\casper\HEAD\gs\src\gsfont.c Thu Dec 4 15:35:35 2003
--- files\gs\src\gsfont.c Sun Dec 7 01:08:51 2003
***************
*** 271,274 ****
--- 271,275 ----
#endif
#endif
+ pdir->global_glyph_code = NULL;
return pdir;
}
*** f:\casper\HEAD\gs\src\gxfcache.h Mon Nov 17 19:42:48 2003
--- files\gs\src\gxfcache.h Sun Dec 7 01:04:44 2003
***************
*** 305,308 ****
--- 305,309 ----
#endif
#endif
+ int (*global_glyph_code)(gs_const_string *gstr, gs_glyph *pglyph);
};
*** f:\casper\HEAD\gs\src\gxfcopy.c Thu Dec 4 15:35:35 2003
--- files\gs\src\gxfcopy.c Sun Dec 7 01:16:33 2003
***************
*** 32,35 ****
--- 32,36 ----
#include "gxfcid.h"
#include "gxfcopy.h"
+ #include "gxfcache.h" /* for gs_font_dir_s */
#include "gxistate.h" /* for Type 1 glyph_outline */
#include "gxtext.h" /* for BuildChar */
***************
*** 864,879 ****
* copied to their proper positions, so it is simple.
*/
! /*
! * Retrieving the glyph name to gstr is not implemented.
! */
! gs_glyph glyph = copied_encode_char((gs_font *)pfont, (gs_char)ccode,
! GLYPH_SPACE_NAME);
if (glyph == GS_NO_GLYPH)
return_error(gs_error_rangecheck);
if (pglyph)
! *pglyph = glyph;
if (pgd)
! return copied_type1_glyph_data(pfont, glyph, pgd);
else
return 0;
--- 865,884 ----
* copied to their proper positions, so it is simple.
*/
! gs_glyph glyph = gs_c_known_encode((gs_char)ccode,
ENCODING_INDEX_STANDARD);
! gs_glyph glyph1;
! int code;
if (glyph == GS_NO_GLYPH)
return_error(gs_error_rangecheck);
+ code = gs_c_glyph_name(glyph, gstr);
+ if (code < 0)
+ return code;
+ code = pfont->dir->global_glyph_code(gstr, &glyph1);
+ if (code < 0)
+ return code;
if (pglyph)
! *pglyph = glyph1;
if (pgd)
! return copied_type1_glyph_data(pfont, glyph1, pgd);
else
return 0;
*** f:\casper\HEAD\gs\src\lib.mak Thu Dec 4 13:10:21 2003
--- files\gs\src\lib.mak Sun Dec 7 01:11:10 2003
***************
*** 2091,2095 ****
$(GLOBJ)gxfcopy.$(OBJ) : $(GLSRC)gxfcopy.c $(memory__h) $(GXERR)\
$(gscencs_h) $(gsline_h) $(gspaint_h) $(gspath_h) $(gsstruct_h)
$(gsutil_h)\
! $(gxfont_h) $(gxfont1_h) $(gxfont42_h) $(gxfcid_h) $(gxfcopy_h)\
$(gxistate_h) $(gxtext_h) $(gxtype1_h)\
$(gzstate_h)\
--- 2091,2095 ----
$(GLOBJ)gxfcopy.$(OBJ) : $(GLSRC)gxfcopy.c $(memory__h) $(GXERR)\
$(gscencs_h) $(gsline_h) $(gspaint_h) $(gspath_h) $(gsstruct_h)
$(gsutil_h)\
! $(gxfont_h) $(gxfont1_h) $(gxfont42_h) $(gxfcid_h) $(gxfcopy_h)
$(gxfcache_h)\
$(gxistate_h) $(gxtext_h) $(gxtype1_h)\
$(gzstate_h)\
*** f:\casper\HEAD\gs\src\zfont.c Tue Oct 21 11:50:13 2003
--- files\gs\src\zfont.c Sun Dec 7 01:05:08 2003
***************
*** 49,52 ****
--- 49,65 ----
}
+ /* Get a global glyph code. */
+ private int
+ zfont_global_glyph_code(gs_const_string *gstr, gs_glyph *pglyph)
+ {
+ ref v;
+ int code = name_ref(gstr->data, gstr->size, &v, 0);
+
+ if (code < 0)
+ return code;
+ *pglyph = (gs_glyph)name_index(&v);
+ return 0;
+ }
+
/* Initialize the font operators */
private int
***************
*** 55,58 ****
--- 68,72 ----
ifont_dir = gs_font_dir_alloc2(imemory, &gs_memory_default);
ifont_dir->ccache.mark_glyph = zfont_mark_glyph_name;
+ ifont_dir->global_glyph_code = zfont_global_glyph_code;
return gs_register_struct_root(imemory, NULL, (void **)&ifont_dir,
"ifont_dir");
_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
patch.txt
(application/octet-stream, 3.5 KB) - not displayed