[cff] Fix family name logic of pure CFF fontdata (#52056).

1. If `FamilyName' is present in the CFF font, use this for
   FT_Face's `family_name'.
2. Otherwise, use the face name and chop off any subset prefix.
3. If at this point FT_Face's `family_name' is set, use this
   together with the full name to determine the style.
4. Otherwise, use `CIDFontName' as FT_Face's `family_name'.
5. If we don't have a valid style, use "Regular".

Previously, FT_Face's `family_name' entry for pure CFF fontdata
nearly always was the fontname itself, instead of the `FamilyName'
entry in the CFF font (assuming there is one).

* src/cff/cffobjs.c (cff_face_init) [pure_cff]: Implement it.
This commit is contained in:
John Tytgat 2017-09-19 07:12:03 +02:00 committed by Werner Lemberg
parent 8b0d2e9e02
commit b00be9f609
2 changed files with 39 additions and 15 deletions

View File

@ -1,3 +1,21 @@
2017-09-19 John Tytgat <John.Tytgat@esko.com>
[cff] Fix family name logic of pure CFF fontdata (#52056).
1. If `FamilyName' is present in the CFF font, use this for
FT_Face's `family_name'.
2. Otherwise, use the face name and chop off any subset prefix.
3. If at this point FT_Face's `family_name' is set, use this
together with the full name to determine the style.
4. Otherwise, use `CIDFontName' as FT_Face's `family_name'.
5. If we don't have a valid style, use "Regular".
Previously, FT_Face's `family_name' entry for pure CFF fontdata
nearly always was the fontname itself, instead of the `FamilyName'
entry in the CFF font (assuming there is one).
* src/cff/cffobjs.c (cff_face_init) [pure_cff]: Implement it.
2017-09-18 Alexei Podtelezhnikov <apodtele@gmail.com>
[build] Declutter Visual C++ 2010-2017 project.

View File

@ -876,7 +876,8 @@
cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 );
if ( cffface->height < cffface->ascender - cffface->descender )
cffface->height = (FT_Short)( cffface->ascender - cffface->descender );
cffface->height = (FT_Short)( cffface->ascender -
cffface->descender );
cffface->underline_position =
(FT_Short)( dict->underline_position >> 16 );
@ -884,28 +885,33 @@
(FT_Short)( dict->underline_thickness >> 16 );
/* retrieve font family & style name */
cffface->family_name = cff_index_get_name(
cff,
(FT_UInt)( face_index & 0xFFFF ) );
if ( dict->family_name )
{
char* family_name;
family_name = cff_index_get_sid_string( cff, dict->family_name );
if ( family_name )
cffface->family_name = cff_strcpy( memory, family_name );
}
if ( !cffface->family_name )
{
cffface->family_name = cff_index_get_name(
cff,
(FT_UInt)( face_index & 0xFFFF ) );
if ( cffface->family_name )
remove_subset_prefix( cffface->family_name );
}
if ( cffface->family_name )
{
char* full = cff_index_get_sid_string( cff,
dict->full_name );
char* fullp = full;
char* family = cffface->family_name;
char* family_name = NULL;
remove_subset_prefix( cffface->family_name );
if ( dict->family_name )
{
family_name = cff_index_get_sid_string( cff,
dict->family_name );
if ( family_name )
family = family_name;
}
/* We try to extract the style name from the full name. */
/* We need to ignore spaces and dashes during the search. */
if ( full && family )