[truetype] New function to skip the randomization tag.

* src/truetype/ttobjs.c (tt_skip_pdffont_random_tag):
New function to skip the randomization tag in the names of the
fonts embedded in a PDF.  It is used by tt_check_trickyness_family(),
to keep from mistaking "DLC" in the randomization tag as a
tricky font name. See discussion in:

https://lists.nongnu.org/archive/html/freetype-devel/2021-02/msg00002.html

For technical detail about the randomization tag, please find
PDF Reference 5.5.3 "Font Subsets".  Thanks to Justyna Wawrzynska
for pointing out the issue caused by the randomization tag.
This commit is contained in:
suzuki toshiya 2021-08-24 11:43:11 +09:00
parent 1c23982dd2
commit 2b3ccd6e26

View File

@ -143,6 +143,30 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
/* The fonts embedded in PDF changes their family names
* by the randomization tag. PDF Reference 5.5.3 "Font
* Subsets" defines its format as 6 uppercase letters and
* '+' sign. For safety, we do not skip the tag violating
* this rule.
*/
static const FT_String*
tt_skip_pdffont_random_tag( const FT_String* name )
{
unsigned int i;
if ( name[6] != '+' )
return name;
for ( i = 0; i < 6; i++ )
if ( !ft_isupper( name[i] ) )
return name;
FT_TRACE7(( "name without randomization tag: %s\n", name + 7 ));
return name + 7;
}
/* Compare the face with a list of well-known `tricky' fonts. */
/* This list shall be expanded as we find more of them. */
@ -199,10 +223,12 @@
};
int nn;
const FT_String* name_without_tag;
name_without_tag = tt_skip_pdffont_random_tag( name );
for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
if ( ft_strstr( name, trick_names[nn] ) )
if ( ft_strstr( name_without_tag, trick_names[nn] ) )
return TRUE;
return FALSE;