summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2021-08-24 11:43:11 +0900
committersuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2021-08-24 16:49:34 +0900
commit2b3ccd6e266cc74740ee6157b643a0c409c5df64 (patch)
tree8e36b19f79f5992042fbc0972adabe6f144080a0
parent1c23982dd2b91b31f7988ba36ce7bafd8df001a7 (diff)
downloadfreetype2-2b3ccd6e266cc74740ee6157b643a0c409c5df64.tar.gz
[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.
-rw-r--r--src/truetype/ttobjs.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 9c3d5838f..7525cb204 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;