freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 2b3ccd6 2/4: [truetype] New function to skip the rand


From: Werner Lemberg
Subject: [freetype2] master 2b3ccd6 2/4: [truetype] New function to skip the randomization tag.
Date: Tue, 24 Aug 2021 03:57:59 -0400 (EDT)

branch: master
commit 2b3ccd6e266cc74740ee6157b643a0c409c5df64
Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
Commit: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>

    [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.
---
 src/truetype/ttobjs.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]