From 3fd158d0ce3662f370b49b3a84ad59a1e09b4340 Mon Sep 17 00:00:00 2001 From: Bram Tassyns Date: Mon, 7 Mar 2011 09:33:53 +0100 Subject: [PATCH] Fix Savannah bug #27988. * src/cff/cffobjs.c (remove_style): New function. (cff_face_init): Use it to strip off the style part of the family name. --- ChangeLog | 10 +++++++++- src/cff/cffobjs.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8fa467179..d55640dca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-27 Bram Tassyns + + Fix Savannah bug #27988. + + * src/cff/cffobjs.c (remove_style): New function. + (cff_face_init): Use it to strip off the style part of the family + name. + 2011-03-07 Werner Lemberg * docs/CHANGES: Updated. @@ -145,7 +153,7 @@ [truetype] Improve handling of stack underflow. * src/truetype/ttinterp.c (TT_RunIns, Ins_FLIPPT, Ins_DELTAP, - Ins_DELTAC): Exit with error only if `pedantic_hinting' is set. + Ins_DELTAC): Exit with error only if `pedantic_hinting' is set. Otherwise, try to do something sane. 2011-01-30 Werner Lemberg diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index d8913c28a..fdb58a496 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -429,6 +429,51 @@ } + /* Remove the style part from the family name (if present). */ + + static void + remove_style( FT_String* family_name, + const FT_String* style_name ) + { + FT_Int32 family_name_length, style_name_length; + + + family_name_length = strlen( family_name ); + style_name_length = strlen( style_name ); + + if ( family_name_length > style_name_length ) + { + FT_Int idx; + + + for ( idx = 1; idx <= style_name_length; ++idx ) + { + if ( family_name[family_name_length - idx] != + style_name[style_name_length - idx] ) + break; + } + + if ( idx > style_name_length ) + { + /* family_name ends with style_name; remove it */ + idx = family_name_length - style_name_length - 1; + + /* also remove special characters */ + /* between real family name and style */ + while ( idx > 0 && + ( family_name[idx] == '-' || + family_name[idx] == ' ' || + family_name[idx] == '_' || + family_name[idx] == '+' ) ) + --idx; + + if ( idx > 0 ) + family_name[idx + 1] = '\0'; + } + } + } + + FT_LOCAL_DEF( FT_Error ) cff_face_init( FT_Stream stream, FT_Face cffface, /* CFF_Face */ @@ -758,6 +803,9 @@ /* case, the remaining string in `fullp' will be used as */ /* the style name. */ style_name = cff_strcpy( memory, fullp ); + + /* remove the style part from the family name (if present) */ + remove_style( cffface->family_name, style_name ); } break; }