ref: 26377008e7fe6fac6bc5fd6a1ebd929a8b542bbf
parent: a62007fb175a8bed1eb32baa9a1eb950502877a4
author: Werner Lemberg <[email protected]>
date: Tue Mar 21 13:41:40 EST 2006
* src/cff/cfftypes.h (CFF_CharsetRec): Add `max_cid' member. * src/cff/cffload.c (cff_charset_load): Set `charset->max_cid'. * src/cff/cffgload.c (cff_slot_load): Change type of third parameter to `FT_UInt'. Check range of `glyph_index'. * src/cff/cffgload.h: Updated.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
-2006-03-21 David Turner <[email protected]>
+2006-03-21 Werner Lemberg <[email protected]>
+
+ * src/cff/cfftypes.h (CFF_CharsetRec): Add `max_cid' member.
+
+ * src/cff/cffload.c (cff_charset_load): Set `charset->max_cid'.
+
+ * src/cff/cffgload.c (cff_slot_load): Change type of third parameter
+ to `FT_UInt'.
+ Check range of `glyph_index'.
+ * src/cff/cffgload.h: Updated.
+
+2006-03-21 David Turner <[email protected]>
* src/autofit/aflatin.c (af_latin_metrics_scale): Fix small bug
that crashes the auto-hinter (introduced by previous patch).
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2272,7 +2272,7 @@
FT_LOCAL_DEF( FT_Error )
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
- FT_Int glyph_index,
+ FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
@@ -2318,7 +2318,7 @@
error = sfnt->load_sbit_image( face,
size->strike_index,
- (FT_UInt)glyph_index,
+ glyph_index,
(FT_Int)load_flags,
stream,
&glyph->root.bitmap,
@@ -2381,7 +2381,12 @@
/* 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];
+ {
+ if ( glyph_index < cff->charset.max_cid )
+ glyph_index = cff->charset.cids[glyph_index];
+ else
+ glyph_index = 0;
+ }
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -196,7 +196,7 @@
FT_LOCAL( FT_Error )
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
- FT_Int glyph_index,
+ FT_UInt glyph_index,
FT_Int32 load_flags );
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1688,6 +1688,8 @@
for ( i = 0; i < num_glyphs; i++ )
charset->cids[charset->sids[i]] = (FT_UShort)i;
+
+ charset->max_cid = max_cid;
}
Exit:
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
-/* Copyright 1996-2001, 2002, 2003 by */
+/* Copyright 1996-2001, 2002, 2003, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -84,6 +84,7 @@
FT_UShort* sids;
FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
/* for CID-keyed fonts */
+ FT_UInt max_cid;
} CFF_CharsetRec, *CFF_Charset;