From b1169da2d6c791b1c3a2ffd27d020fe2ef228a00 Mon Sep 17 00:00:00 2001 From: Igor Melichev Date: Sun, 9 Nov 2008 19:09:30 +0000 Subject: Fix (CID font emulation) : CID from another writing mode rendered a wrong glyph (part 1). This revision is incomplete due to a commitment error. Please use next revision. DETAILS : This is a second partial fix for Bug 689304 "improper handling of vertical japanese text", related to Comment #30, #31. When emulating a CID font with an Open Type font, a CID is first mapped to an OpenType encoding and then to a glyph index. However OpenType provides same character codes for glyph variants, which render differently depending on writing mode. The glyph '(' is an example. This patch works for OpenType fonts only, which provide a GSUB for vertical writing mode. It is not working for True Type collections with no GSUB. They need a further improvement. The patch assumes that all interpreters initialize a Type 42 font with zeroing all its fields. Postscript interpreter does so since a long ago, but we're not sure about others. They may need an improvement. 1. Define a new resource category SubstCID (Resource/Init/gs_ciddc.ps). 2. Provide a tool for generating resources for that category (toolbin/GenSubstCID). 3. Provide resources for various orderings (Resource/SubstCID/CNS1-WMode, Resource/SubstCID/GB1-WMode, Resource/SubstCID/Japan1-WMode, Resource/SubstCID/Korea1-WMode). 4. When loading a TrueType or OpenType font for a CID font emulation, associate an appropriate SubstCID resource to it (Resource/Init\gs_cidtt.ps). (We do associate the resource with TrueType hoping that some True Type fonts may provide GSUB). 5. Define a new structure gs_subst_CID_on_WMode_s for storing that information for the graphics library (base\gxfcid.h), and its garbager descriptor (base/gsfcid.c). Since it may duplicate for several fonts, it is shared and reference-counted. 6. The new function get_subst_CID_on_WMode loads the resource data for the graphics library in psi\zfcid1.c . Note it is implemented for PS interpreter only. 7. Generalized gs_type42_substitute_glyph_index_vertical with providing a CID in base/gstype42.c and made it be a virtual function of gs_font_type42 (base/gxfont42.c). We're not sure how other interpreters initialize the font, so we're checking it for NULL for safety and use gs_type42_substitute_glyph_index_vertical as a default implementation. 8. font11_substitute_glyph_index_vertical is another implementation of that function, which accounts gs_subst_CID_on_WMode_s data for providing a right glyph depending on WMode. Rather a SubstCID resource provides a substitution, currently we only use the fact that a CID is substituted, and never use the substituting CID. Nevertheless we prefer to define and store the resource in the complete form for possible improvements in future (zfcid1.c). 9. release_subst_CID_on_WMode automatically releases the resource data when all fonts (that use it) are released. 10. Added SubstCID to the ROM file system in psi/psromfs.mak . 11. Minor unrelated fix : propagate errors from gs_font_notify_register for (7) in base/gstype42.c . EXPECTED DIFFERENCES : None. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9212 a1074d23-0009-0410-80fe-cf8c14f379e6 --- gs/base/gxfont42.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gs/base/gxfont42.h') diff --git a/gs/base/gxfont42.h b/gs/base/gxfont42.h index 164ba070e..e83e486be 100644 --- a/gs/base/gxfont42.h +++ b/gs/base/gxfont42.h @@ -75,6 +75,8 @@ struct gs_type42_data_s { int (*get_metrics)(gs_font_type42 *pfont, uint glyph_index, gs_type42_metrics_options_t options, float *sbw_bbox/* See comment for gs_type42_default_get_metrics */); + uint (*substitute_glyph_index_vertical)(gs_font_type42 *pfont, uint glyph_index, + int WMode, gs_glyph glyph); /* The following are cached values. */ ulong cmap; /* offset to cmap table (not used by */ @@ -172,6 +174,6 @@ int gs_type42_font_info(gs_font *font, const gs_point *pscale, int members, int gs_truetype_font_info(gs_font *font, const gs_point *pscale, int members, gs_font_info_t *info); -uint gs_type42_substitute_glyph_index_vertical(gs_font_type42 *pfont, uint glyph_index); - +uint gs_type42_substitute_glyph_index_vertical(gs_font_type42 *pfont, uint glyph_index, + int WMode, gs_glyph glyph); #endif /* gxfont42_INCLUDED */ -- cgit v1.2.3