[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 9c3d583..7525cb2 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -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;