freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 3576487: [pcf] Enrich family name with foundry name a


From: Werner LEMBERG
Subject: [freetype2] master 3576487: [pcf] Enrich family name with foundry name and glyph width info.
Date: Fri, 30 Sep 2016 06:12:29 +0000 (UTC)

branch: master
commit 3576487add2f0e9691e8c43f8b0cd8e61aebf14f
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [pcf] Enrich family name with foundry name and glyph width info.
    
    This is a very old patch from openSuSE (from 2006, submitted to
    FreeType in 2011) that I forgot to apply.
    
      
https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch
    
    Prepend the foundry name plus a space to the family name.  There are
    many fonts just called `Fixed' which look completely different, and
    which have nothing to do with each other.  When selecting `Fixed' in
    KDE or Gnome one gets results that appear rather random, the style
    changes often if one changes the size and one cannot select some
    fonts at all.
    
    We also check whether we have `wide' characters; all put together,
    we get family names like `Sony Fixed' or `Misc Fixed Wide'.
    
    * src/pcf/pcfread.c (pcf_load_font): Implement it.
    
    * docs/CHANGES: Document it.
---
 ChangeLog         |   23 +++++++++++++++++++++++
 docs/CHANGES      |    6 ++++++
 src/pcf/pcfread.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce78d60..6c67f87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2016-09-29  Werner Lemberg  <address@hidden>
 
+       [pcf] Enrich family name with foundry name and glyph width info.
+
+       This is a very old patch from openSuSE (from 2006, submitted to
+       FreeType in 2011) that I forgot to apply.
+
+         
https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch
+
+       Prepend the foundry name plus a space to the family name.  There are
+       many fonts just called `Fixed' which look completely different, and
+       which have nothing to do with each other.  When selecting `Fixed' in
+       KDE or Gnome one gets results that appear rather random, the style
+       changes often if one changes the size and one cannot select some
+       fonts at all.
+
+       We also check whether we have `wide' characters; all put together,
+       we get family names like `Sony Fixed' or `Misc Fixed Wide'.
+
+       * src/pcf/pcfread.c (pcf_load_font): Implement it.
+
+       * docs/CHANGES: Document it.
+
+2016-09-29  Werner Lemberg  <address@hidden>
+
        [ftfuzzer] Speed up.
 
        * src/tools/ftfuzzer/ftfuzzer.cc (LLVMFuzzerTestOneInput): Don't
diff --git a/docs/CHANGES b/docs/CHANGES
index 307d83c..c7c2cd4 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -24,6 +24,12 @@ CHANGES BETWEEN 2.7 and 2.7.1
       and the number of CVT entries.  Please report if you encounter a
       font where the selected values are not adequate.
 
+    - PCF family names are made more `colourful'; they now include the
+      foundry  and information  whether they contain  wide characters.
+      For example,  you no longer get `Fixed' but  rather `Sony Fixed'
+      or `Misc Fixed Wide'.
+
+
 ======================================================================
 
 CHANGES BETWEEN 2.6.5 and 2.7
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 3917a75..60a6e92 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1266,8 +1266,57 @@ THE SOFTWARE.
       prop = pcf_find_property( face, "FAMILY_NAME" );
       if ( prop && prop->isString )
       {
-        if ( FT_STRDUP( root->family_name, prop->value.atom ) )
-          goto Exit;
+        /* Prepend the foundry name plus a space to the family name.      */
+        /* There are many fonts just called `Fixed' which look completely */
+        /* different, and which have nothing to do with each other.  When */
+        /* selecting `Fixed' in KDE or Gnome one gets results that appear */
+        /* rather random, the style changes often if one changes the size */
+        /* and one cannot select some fonts at all.                       */
+        /*                                                                */
+        /* We also check whether we have `wide' characters; all put       */
+        /* together, we get family names like `Sony Fixed' or `Misc Fixed */
+        /* Wide'.                                                         */
+        PCF_Property  foundry_prop, point_size_prop, average_width_prop;
+
+        int  l    = ft_strlen( prop->value.atom ) + 1;
+        int  wide = 0;
+
+
+        foundry_prop       = pcf_find_property( face, "FOUNDRY" );
+        point_size_prop    = pcf_find_property( face, "POINT_SIZE" );
+        average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
+
+        if ( point_size_prop && average_width_prop )
+        {
+          if ( average_width_prop->value.l >= point_size_prop->value.l )
+          {
+            /* This font is at least square shaped or even wider */
+            wide = 1;
+            l   += ft_strlen( " Wide" );
+          }
+        }
+
+        if ( foundry_prop && foundry_prop->isString )
+        {
+          l += ft_strlen( foundry_prop->value.atom ) + 1;
+
+          if ( FT_NEW_ARRAY( root->family_name, l ) )
+            goto Exit;
+
+          ft_strcpy( root->family_name, foundry_prop->value.atom );
+          ft_strcat( root->family_name, " " );
+          ft_strcat( root->family_name, prop->value.atom );
+        }
+        else
+        {
+          if ( FT_NEW_ARRAY( root->family_name, l ) )
+            goto Exit;
+
+          ft_strcpy( root->family_name, prop->value.atom );
+        }
+
+        if ( wide )
+          ft_strcat( root->family_name, " Wide" );
       }
       else
         root->family_name = NULL;



reply via email to

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