diff --git a/ChangeLog b/ChangeLog index 854823ffd..cc0a0c645 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-12-18 Werner Lemberg + + * src/cff/cfftypes.h (CFF_FontRecDictRec): Change type of + `cid_count' to `FT_ULong'. + + * src/cff/cffgload.c (cff_slot_load): Take care of empty `cids' + array. + + * src/cff/cffload.c (cff_charset_done): Free `cids' array. + (cff_font_load): Create cids array only for CID-keyed fonts which + are subsetted. + + * src/cff/cffobjs.c (cff_face_init): Check the availability of + the PSNames modules for non-pure CFFs also. + Set FT_FACE_FLAG_GLYPH_NAMES for a non-pure CFF also if it isn't + CID-keyed. + + * src/cff/rules.mk (CFF_DRV_H): Add cfftypes.h. + 2003-12-17 Werner Lemberg * src/sfnt/sfobjs.c (sfnt_init_face): Don't set diff --git a/docs/CHANGES b/docs/CHANGES index ab9d913ab..09026b9a4 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -14,8 +14,8 @@ LATEST CHANGES BETWEEN 2.1.8 and 2.1.7 correctly treated as a CID, similar to FreeType's CID driver module. Note that CID CMaps support is still missing. - - SFNT based fonts no longer set the FT_FACE_FLAGS_GLYPH_NAMES - flag if a version 3.0 `post' table is present. + - The FT_FACE_FLAGS_GLYPH_NAMES is now set correctly for all font + formats. II. IMPORTANT CHANGES diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index 0388b75ce..a905b8407 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -2316,8 +2316,10 @@ /* in a CID-keyed font, consider `glyph_index' as a CID and map */ - /* it immediately to the real glyph_index */ - if ( cff->top_font.font_dict.cid_registry != 0xFFFFU ) + /* it immediately to the real glyph_index -- if it isn't a */ + /* subsetted font, glyph_indices and CIDs are identical, though */ + if ( cff->top_font.font_dict.cid_registry != 0xFFFFU && + cff->charset.cids ) glyph_index = cff->charset.cids[glyph_index]; cff_decoder_init( &decoder, face, size, glyph, hinting, diff --git a/src/cff/cffload.c b/src/cff/cffload.c index 68bac3e47..f63d7fdf4 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -1501,6 +1501,7 @@ FT_FREE( charset->sids ); + FT_FREE( charset->cids ); charset->format = 0; charset->offset = 0; } @@ -1672,7 +1673,7 @@ } } - /* we have to invert the `sids' array for CID-keyed fonts */ + /* we have to invert the `sids' array for subsetted CID-keyed fonts */ if ( invert ) { FT_UInt i; @@ -2244,9 +2245,13 @@ /* read the Charset and Encoding tables if available */ if ( font->num_glyphs > 0 ) { + FT_Bool invert; + + + invert = dict->cid_registry != 0xFFFFU && + font->charstrings_index.count != dict->cid_count; error = cff_charset_load( &font->charset, font->num_glyphs, stream, - base_offset, dict->charset_offset, - dict->cid_registry != 0xFFFFU ); + base_offset, dict->charset_offset, invert ); if ( error ) goto Exit; diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 15540b792..8d45165a7 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -337,10 +337,11 @@ /* now load and parse the CFF table in the file */ { - CFF_Font cff; - FT_Memory memory = face->root.memory; - FT_Face root; - FT_Int32 flags; + CFF_Font cff; + CFF_FontRecDict dict; + FT_Memory memory = face->root.memory; + FT_Face root; + FT_Int32 flags; if ( FT_NEW( cff ) ) @@ -360,23 +361,24 @@ root = &face->root; root->num_glyphs = cff->num_glyphs; + dict = &cff->top_font.font_dict; + + /* we need the `PSNames' module for CFF and CEF formats */ + /* which aren't CID-keyed */ + if ( dict->cid_registry == 0xFFFFU && !psnames ) + { + FT_ERROR(( "cff_face_init:" )); + FT_ERROR(( " cannot open CFF & CEF fonts\n" )); + FT_ERROR(( " " )); + FT_ERROR(( " without the `PSNames' module\n" )); + goto Bad_Format; + } + if ( pure_cff ) { - CFF_FontRecDict dict = &cff->top_font.font_dict; - char* style_name; + char* style_name; - /* we need the `PSNames' module for pure-CFF and CEF formats */ - /* which aren't CID-keyed */ - if ( dict->cid_registry == 0xFFFFU && !psnames ) - { - FT_ERROR(( "cff_face_init:" )); - FT_ERROR(( " cannot open CFF & CEF fonts\n" )); - FT_ERROR(( " " )); - FT_ERROR(( " without the `PSNames' module\n" )); - goto Bad_Format; - } - /* Set up num_faces. */ root->num_faces = cff->num_faces; @@ -483,12 +485,6 @@ flags |= FT_FACE_FLAG_KERNING; #endif -#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES - /* CID-keyed CFF fonts don't have glyph names */ - if ( dict->cid_registry == 0xFFFFU ) - flags |= FT_FACE_FLAG_GLYPH_NAMES; -#endif - root->face_flags = flags; /*******************************************************************/ @@ -515,6 +511,13 @@ root->style_flags = flags; } +#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES + /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */ + /* has unset this flag because of the 3.0 `post' table */ + if ( dict->cid_registry == 0xFFFFU ) + root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; +#endif + /*******************************************************************/ /* */ /* Compute char maps. */ diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h index 83b7d194c..4508d98e5 100644 --- a/src/cff/cfftypes.h +++ b/src/cff/cfftypes.h @@ -123,7 +123,7 @@ FT_BEGIN_HEADER FT_Long cid_font_version; FT_Long cid_font_revision; FT_Long cid_font_type; - FT_Long cid_count; + FT_ULong cid_count; FT_ULong cid_uid_base; FT_ULong cid_fd_array_offset; FT_ULong cid_fd_select_offset; diff --git a/src/cff/rules.mk b/src/cff/rules.mk index 579f144e0..4100c8068 100644 --- a/src/cff/rules.mk +++ b/src/cff/rules.mk @@ -34,6 +34,7 @@ CFF_DRV_SRC := $(CFF_DIR)/cffobjs.c \ # CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \ $(CFF_DIR)/cfftoken.h \ + $(CFF_DIR)/cfftypes.h \ $(CFF_DIR)/cfferrs.h