media-libs/freetype: Revbump to fix pfc font handling (bug #606688).
authorLars Wendler <polynomial-c@gentoo.org>
Sat, 21 Jan 2017 16:55:49 +0000 (17:55 +0100)
committerLars Wendler <polynomial-c@gentoo.org>
Sat, 21 Jan 2017 16:56:04 +0000 (17:56 +0100)
Package-Manager: Portage-2.3.3, Repoman-2.3.1

media-libs/freetype/files/freetype-2.7.1-pcf_fix.patch [new file with mode: 0644]
media-libs/freetype/freetype-2.7.1-r1.ebuild [new file with mode: 0644]

diff --git a/media-libs/freetype/files/freetype-2.7.1-pcf_fix.patch b/media-libs/freetype/files/freetype-2.7.1-pcf_fix.patch
new file mode 100644 (file)
index 0000000..5b89121
--- /dev/null
@@ -0,0 +1,711 @@
+From f837a50ec3a4f240d73f018f237f9f58631e2ba5 Mon Sep 17 00:00:00 2001
+From: Werner Lemberg <wl@gnu.org>
+Date: Mon, 9 Jan 2017 10:49:03 +0100
+Subject: [pcf] Introduce a driver structure.
+
+To be filled later on with something useful.
+
+* src/pcf/pcf.h (PCF_Driver): New structure.
+
+* src/pcf/pcfdrivr.c (pcf_driver_init, pcf_driver_done): New dummy
+functions.
+(pcf_driver_class): Updated.
+---
+ src/pcf/pcf.h      |  7 +++++++
+ src/pcf/pcfdrivr.c | 24 ++++++++++++++++++++----
+ 3 files changed, 39 insertions(+), 4 deletions(-)
+
+diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
+index c726e5e..830cabe 100644
+--- a/src/pcf/pcf.h
++++ b/src/pcf/pcf.h
+@@ -163,6 +163,13 @@ FT_BEGIN_HEADER
+   } PCF_FaceRec, *PCF_Face;
++  typedef struct  PCF_DriverRec_
++  {
++    FT_DriverRec  root;
++
++  } PCF_DriverRec, *PCF_Driver;
++
++
+   /* macros for pcf font format */
+ #define LSBFirst  0
+diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
+index 10d5c20..8f4a90d 100644
+--- a/src/pcf/pcfdrivr.c
++++ b/src/pcf/pcfdrivr.c
+@@ -691,22 +691,38 @@ THE SOFTWARE.
+   }
++  FT_CALLBACK_DEF( FT_Error )
++  pcf_driver_init( FT_Module  module )      /* PCF_Driver */
++  {
++    FT_UNUSED( module );
++
++    return FT_Err_Ok;
++  }
++
++
++  FT_CALLBACK_DEF( void )
++  pcf_driver_done( FT_Module  module )      /* PCF_Driver */
++  {
++    FT_UNUSED( module );
++  }
++
++
+   FT_CALLBACK_TABLE_DEF
+   const FT_Driver_ClassRec  pcf_driver_class =
+   {
+     {
+       FT_MODULE_FONT_DRIVER        |
+       FT_MODULE_DRIVER_NO_OUTLINES,
+-      sizeof ( FT_DriverRec ),
++      sizeof ( PCF_DriverRec ),
+       "pcf",
+       0x10000L,
+       0x20000L,
+-      NULL,    /* module-specific interface */
++      NULL,   /* module-specific interface */
+-      NULL,                     /* FT_Module_Constructor  module_init   */
+-      NULL,                     /* FT_Module_Destructor   module_done   */
++      pcf_driver_init,          /* FT_Module_Constructor  module_init   */
++      pcf_driver_done,          /* FT_Module_Destructor   module_done   */
+       pcf_driver_requester      /* FT_Module_Requester    get_interface */
+     },
+-- 
+cgit v1.0
+
+From 08fd250e1af0aa16d18012d39462e6ca9bbc6e90 Mon Sep 17 00:00:00 2001
+From: Werner Lemberg <wl@gnu.org>
+Date: Mon, 9 Jan 2017 11:30:32 +0100
+Subject: [pcf] Make long family names configurable.
+
+The change from 2016-09-29 was too radical (except for people using
+the openSuSE GNU/Linux distribution).  To ameliorate the situation,
+PCF_CONFIG_OPTION_LONG_FAMILY_NAMES gets introduced which controls
+the feature; if set, a new PCF property option
+`no-long-family-names' can be used to switch this feature off.
+
+* include/freetype/config/ftoption.h, devel/ftoption.h
+(PCF_CONFIG_OPTION_LONG_FAMILY_NAMES): New option.
+
+* include/freetype/ftpcfdrv.h: New header file (only containing
+comments currently, used for building the documentation).
+
+* include/freetype/config/ftheader.h (FT_PCF_DRIVER_H): New macro.
+
+* src/pcf/pcf.h (PCF_Driver): Add `no_long_family_names' field.
+
+* src/pcf/pcfdrivr.c: Include FT_SERVICE_PROPERTIES_H and
+FT_PCF_DRIVER_H.
+(pcf_property_set, pcf_property_get): New functions.
+(pcf_service_properties): New service.
+(pcf_servives): Updated.
+(pcf_driver_init) [PCF_CONFIG_OPTION_LONG_FAMILY_NAMES]: Handle
+`no_long_family_names'.
+
+* src/pcf/pcfread.c (pcf_load_font): Handle `no_long_family_names'
+and PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
+
+* docs/CHANGES: Updated.
+---
+ devel/ftoption.h                   |  31 +++++++++-
+ docs/CHANGES                       |  16 ++++++
+ include/freetype/config/ftheader.h |  13 +++++
+ include/freetype/config/ftoption.h |  31 +++++++++-
+ include/freetype/ftchapters.h      |   1 +
+ include/freetype/ftpcfdrv.h        | 105 ++++++++++++++++++++++++++++++++++
+ src/pcf/pcf.h                      |   2 +
+ src/pcf/pcfdrivr.c                 | 114 +++++++++++++++++++++++++++++++++++++
+ src/pcf/pcfread.c                  |  98 ++++++++++++++++++-------------
+ 10 files changed, 400 insertions(+), 44 deletions(-)
+ create mode 100644 include/freetype/ftpcfdrv.h
+
+diff --git a/devel/ftoption.h b/devel/ftoption.h
+index 3b63931..b8b0a8d 100644
+--- a/devel/ftoption.h
++++ b/devel/ftoption.h
+@@ -82,8 +82,8 @@ FT_BEGIN_HEADER
+   /* to control the various font drivers and modules.  The controllable    */
+   /* properties are listed in the section `Controlling FreeType Modules'   */
+   /* in the reference's table of contents; currently there are properties  */
+-  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and  */
+-  /* TrueType (file `ftttdrv.h').                                          */
++  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'),      */
++  /* TrueType (file `ftttdrv.h'), and PCF (file `ftpcfdrv.h').             */
+   /*                                                                       */
+   /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
+   /* multiple lines for better readability).                               */
+@@ -835,6 +835,33 @@ FT_BEGIN_HEADER
+   /*************************************************************************/
+   /*************************************************************************/
+   /****                                                                 ****/
++  /****         P C F   D R I V E R    C O N F I G U R A T I O N        ****/
++  /****                                                                 ****/
++  /*************************************************************************/
++  /*************************************************************************/
++
++
++  /*************************************************************************/
++  /*                                                                       */
++  /* There are many PCF 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.  This option makes the PCF module    */
++  /* prepend the foundry name (plus a space) to the family name.           */
++  /*                                                                       */
++  /* We also check whether we have `wide' characters; all put together, we */
++  /* get family names like `Sony Fixed' or `Misc Fixed Wide'.              */
++  /*                                                                       */
++  /* If this option is activated, it can be controlled with the            */
++  /* `no-long-family-names' property of the pcf driver module.             */
++  /*                                                                       */
++#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++
++
++  /*************************************************************************/
++  /*************************************************************************/
++  /****                                                                 ****/
+   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
+   /****                                                                 ****/
+   /*************************************************************************/
+diff --git a/docs/CHANGES b/docs/CHANGES
+index cb3b327..3823395 100644
+--- a/docs/CHANGES
++++ b/docs/CHANGES
+@@ -1,4 +1,20 @@
++CHANGES BETWEEN 2.7.1 and 2.7.2
++
++  I. IMPORTANT CHANGES
++
++    - The PCF change to show more `colourful' family names (introduced
++      in version 2.7.1) was too radical; it can now be configured with
++      PCF_CONFIG_OPTION_LONG_FAMILY_NAMES   at   compile   time.    If
++      activated, it can  be switched off at run time  with the new pcf
++      property  `no-long-family-names'.  If  the `FREETYPE_PROPERTIES'
++      environment variable is available, you can say
++
++        FREETYPE_PROPERTIES=pcf:no-long-family-names=1
++
++
++======================================================================
++
+ CHANGES BETWEEN 2.7 and 2.7.1
+   I. IMPORTANT CHANGES
+diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
+index 950d36c..d491af5 100644
+--- a/include/freetype/config/ftheader.h
++++ b/include/freetype/config/ftheader.h
+@@ -357,6 +357,19 @@
+   /*************************************************************************
+    *
+    * @macro:
++   *   FT_PCF_DRIVER_H
++   *
++   * @description:
++   *   A macro used in #include statements to name the file containing
++   *   structures and macros related to the PCF driver module.
++   *
++   */
++#define FT_PCF_DRIVER_H  <freetype/ftpcfdrv.h>
++
++
++  /*************************************************************************
++   *
++   * @macro:
+    *   FT_TYPE1_TABLES_H
+    *
+    * @description:
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index f5bc540..5676074 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -82,8 +82,8 @@ FT_BEGIN_HEADER
+   /* to control the various font drivers and modules.  The controllable    */
+   /* properties are listed in the section `Controlling FreeType Modules'   */
+   /* in the reference's table of contents; currently there are properties  */
+-  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and  */
+-  /* TrueType (file `ftttdrv.h').                                          */
++  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'),      */
++  /* TrueType (file `ftttdrv.h'), and PCF (file `ftpcfdrv.h').             */
+   /*                                                                       */
+   /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
+   /* multiple lines for better readability).                               */
+@@ -835,6 +835,33 @@ FT_BEGIN_HEADER
+   /*************************************************************************/
+   /*************************************************************************/
+   /****                                                                 ****/
++  /****         P C F   D R I V E R    C O N F I G U R A T I O N        ****/
++  /****                                                                 ****/
++  /*************************************************************************/
++  /*************************************************************************/
++
++
++  /*************************************************************************/
++  /*                                                                       */
++  /* There are many PCF 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.  This option makes the PCF module    */
++  /* prepend the foundry name (plus a space) to the family name.           */
++  /*                                                                       */
++  /* We also check whether we have `wide' characters; all put together, we */
++  /* get family names like `Sony Fixed' or `Misc Fixed Wide'.              */
++  /*                                                                       */
++  /* If this option is activated, it can be controlled with the            */
++  /* `no-long-family-names' property of the pcf driver module.             */
++  /*                                                                       */
++#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++
++
++  /*************************************************************************/
++  /*************************************************************************/
++  /****                                                                 ****/
+   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
+   /****                                                                 ****/
+   /*************************************************************************/
+diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h
+index ab43895..a0a121b 100644
+--- a/include/freetype/ftchapters.h
++++ b/include/freetype/ftchapters.h
+@@ -77,6 +77,7 @@
+ /*    auto_hinter                                                          */
+ /*    cff_driver                                                           */
+ /*    tt_driver                                                            */
++/*    pcf_driver                                                           */
+ /*                                                                         */
+ /***************************************************************************/
+diff --git a/include/freetype/ftpcfdrv.h b/include/freetype/ftpcfdrv.h
+new file mode 100644
+index 0000000..6622c93
+--- /dev/null
++++ b/include/freetype/ftpcfdrv.h
+@@ -0,0 +1,105 @@
++/***************************************************************************/
++/*                                                                         */
++/*  ftpcfdrv.h                                                             */
++/*                                                                         */
++/*    FreeType API for controlling the PCF driver (specification only).    */
++/*                                                                         */
++/*  Copyright 2017 by                                                      */
++/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
++/*                                                                         */
++/*  This file is part of the FreeType project, and may only be used,       */
++/*  modified, and distributed under the terms of the FreeType project      */
++/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
++/*  this file you indicate that you have read the license and              */
++/*  understand and accept it fully.                                        */
++/*                                                                         */
++/***************************************************************************/
++
++
++#ifndef FTPCFDRV_H_
++#define FTPCFDRV_H_
++
++#include <ft2build.h>
++#include FT_FREETYPE_H
++
++#ifdef FREETYPE_H
++#error "freetype.h of FreeType 1 has been loaded!"
++#error "Please fix the directory search order for header files"
++#error "so that freetype.h of FreeType 2 is found first."
++#endif
++
++
++FT_BEGIN_HEADER
++
++
++  /**************************************************************************
++   *
++   * @section:
++   *   pcf_driver
++   *
++   * @title:
++   *   The PCF driver
++   *
++   * @abstract:
++   *   Controlling the PCF driver module.
++   *
++   * @description:
++   *   While FreeType's PCF driver doesn't expose API functions by itself,
++   *   it is possible to control its behaviour with @FT_Property_Set and
++   *   @FT_Property_Get.  Right now, there is a single property
++   *   `no-long-family-names' available if FreeType is compiled with
++   *   PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
++   *
++   *   The PCF driver's module name is `pcf'.
++   *
++   */
++
++
++  /**************************************************************************
++   *
++   * @property:
++   *   no-long-family-names
++   *
++   * @description:
++   *   If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling
++   *   FreeType, the PCF driver constructs long family names.
++   *
++   *   There are many PCF 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.  The improve this situation, the PCF
++   *   module prepends the foundry name (plus a space) to the family name. 
++   *   It also checks whether there are `wide' characters; all put together,
++   *   family names like `Sony Fixed' or `Misc Fixed Wide' are constructed.
++   *
++   *   If `no-long-family-names' is set, this feature gets switched off.
++   *
++   *   {
++   *     FT_Library  library;
++   *     FT_Bool     no_long_family_names = TRUE;
++   *
++   *
++   *     FT_Init_FreeType( &library );
++   *
++   *     FT_Property_Set( library, "pcf",
++   *                               "no-long-family-names",
++   *                               &no_long_family_names );
++   *   }
++   *
++   * @note:
++   *   This property can be used with @FT_Property_Get also.
++   *
++   *   This property can be set via the `FREETYPE_PROPERTIES' environment
++   *   variable (using values 1 and 0 for `on' and `off', respectively).
++   *
++   */
++
++
++FT_END_HEADER
++
++
++#endif /* FTPCFDRV_H_ */
++
++
++/* END */
+diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
+index 830cabe..f0390cb 100644
+--- a/src/pcf/pcf.h
++++ b/src/pcf/pcf.h
+@@ -167,6 +167,8 @@ FT_BEGIN_HEADER
+   {
+     FT_DriverRec  root;
++    FT_Bool  no_long_family_names;
++
+   } PCF_DriverRec, *PCF_Driver;
+diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
+index 8f4a90d..bc65423 100644
+--- a/src/pcf/pcfdrivr.c
++++ b/src/pcf/pcfdrivr.c
+@@ -49,6 +49,8 @@ THE SOFTWARE.
+ #include FT_SERVICE_BDF_H
+ #include FT_SERVICE_FONT_FORMAT_H
++#include FT_SERVICE_PROPERTIES_H
++#include FT_PCF_DRIVER_H
+   /*************************************************************************/
+@@ -667,6 +669,110 @@ THE SOFTWARE.
+   };
++  /*
++   *  PROPERTY SERVICE
++   *
++   */
++  static FT_Error
++  pcf_property_set( FT_Module    module,         /* PCF_Driver */
++                    const char*  property_name,
++                    const void*  value,
++                    FT_Bool      value_is_string )
++  {
++#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++
++    FT_Error    error  = FT_Err_Ok;
++    PCF_Driver  driver = (PCF_Driver)module;
++
++#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
++    FT_UNUSED( value_is_string );
++#endif
++
++
++    if ( !ft_strcmp( property_name, "no-long-family-names" ) )
++    {
++#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
++      if ( value_is_string )
++      {
++        const char*  s   = (const char*)value;
++        long         lfn = ft_strtol( s, NULL, 10 );
++
++
++        if ( lfn == 0 )
++          driver->no_long_family_names = 0;
++        else if ( lfn == 1 )
++          driver->no_long_family_names = 1;
++        else
++          return FT_THROW( Invalid_Argument );
++      }
++      else
++#endif
++      {
++        FT_Bool*  no_long_family_names = (FT_Bool*)value;
++
++
++        driver->no_long_family_names = *no_long_family_names;
++      }
++
++      return error;
++    }
++
++#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++
++    FT_UNUSED( module );
++    FT_UNUSED( value );
++    FT_UNUSED( value_is_string );
++
++#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++
++    FT_TRACE0(( "pcf_property_set: missing property `%s'\n",
++                property_name ));
++    return FT_THROW( Missing_Property );
++  }
++
++
++  static FT_Error
++  pcf_property_get( FT_Module    module,         /* PCF_Driver */
++                    const char*  property_name,
++                    const void*  value )
++  {
++#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++
++    FT_Error    error  = FT_Err_Ok;
++    PCF_Driver  driver = (PCF_Driver)module;
++
++
++    if ( !ft_strcmp( property_name, "no-long-family-names" ) )
++    {
++      FT_Bool   no_long_family_names = driver->no_long_family_names;
++      FT_Bool*  val                  = (FT_Bool*)value;
++
++
++      *val = no_long_family_names;
++
++      return error;
++    }
++
++#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++
++    FT_UNUSED( module );
++    FT_UNUSED( value );
++
++#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++
++    FT_TRACE0(( "pcf_property_get: missing property `%s'\n",
++                property_name ));
++    return FT_THROW( Missing_Property );
++  }
++
++
++  FT_DEFINE_SERVICE_PROPERTIESREC(
++    pcf_service_properties,
++
++    (FT_Properties_SetFunc)pcf_property_set,      /* set_property */
++    (FT_Properties_GetFunc)pcf_property_get )     /* get_property */
++
++
+  /*
+   *
+   *  SERVICE LIST
+@@ -677,6 +783,7 @@ THE SOFTWARE.
+   {
+     { FT_SERVICE_ID_BDF,         &pcf_service_bdf },
+     { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF },
++    { FT_SERVICE_ID_PROPERTIES,  &pcf_service_properties },
+     { NULL, NULL }
+   };
+@@ -694,7 +801,14 @@ THE SOFTWARE.
+   FT_CALLBACK_DEF( FT_Error )
+   pcf_driver_init( FT_Module  module )      /* PCF_Driver */
+   {
++#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++    PCF_Driver  driver = (PCF_Driver)module;
++
++
++    driver->no_long_family_names = 0;
++#else
+     FT_UNUSED( module );
++#endif
+     return FT_Err_Ok;
+   }
+diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
+index 38ba110..3eacf2b 100644
+--- a/src/pcf/pcfread.c
++++ b/src/pcf/pcfread.c
+@@ -1393,57 +1393,75 @@ THE SOFTWARE.
+       prop = pcf_find_property( face, "FAMILY_NAME" );
+       if ( prop && prop->isString )
+       {
+-        /* 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 )
++
++#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++
++        PCF_Driver  driver = (PCF_Driver)FT_FACE_DRIVER( face );
++
++
++        if ( !driver->no_long_family_names )
+         {
+-          if ( average_width_prop->value.l >= point_size_prop->value.l )
++          /* 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 )
+           {
+-            /* This font is at least square shaped or even wider */
+-            wide = 1;
+-            l   += ft_strlen( " Wide" );
++            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 ( foundry_prop && foundry_prop->isString )
++          {
++            l += ft_strlen( foundry_prop->value.atom ) + 1;
+-          if ( FT_NEW_ARRAY( root->family_name, l ) )
+-            goto Exit;
++            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, foundry_prop->value.atom );
+-          ft_strcat( root->family_name, " " );
+-          ft_strcat( root->family_name, prop->value.atom );
++            ft_strcpy( root->family_name, prop->value.atom );
++          }
++
++          if ( wide )
++            ft_strcat( root->family_name, " Wide" );
+         }
+         else
++
++#endif /* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++
+         {
+-          if ( FT_NEW_ARRAY( root->family_name, l ) )
++          if ( FT_STRDUP( root->family_name, prop->value.atom ) )
+             goto Exit;
+-
+-          ft_strcpy( root->family_name, prop->value.atom );
+         }
+-
+-        if ( wide )
+-          ft_strcat( root->family_name, " Wide" );
+       }
+       else
+         root->family_name = NULL;
+-- 
+cgit v1.0
+
+From 7ccca6aec167c2c30c569765ece808f0eee023a6 Mon Sep 17 00:00:00 2001
+From: Werner Lemberg <wl@gnu.org>
+Date: Mon, 9 Jan 2017 19:54:44 +0100
+Subject: [pcf] Disable long family names by default.
+
+* include/freetype/config/ftoption.h
+(PCF_CONFIG_OPTION_LONG_FAMILY_NAMES): Comment out.
+---
+ include/freetype/config/ftoption.h | 2 +-
+ 2 files changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index 5676074..37a0d00 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -856,7 +856,7 @@ FT_BEGIN_HEADER
+   /* If this option is activated, it can be controlled with the            */
+   /* `no-long-family-names' property of the pcf driver module.             */
+   /*                                                                       */
+-#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
++/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+   /*************************************************************************/
+-- 
+cgit v1.0
+
diff --git a/media-libs/freetype/freetype-2.7.1-r1.ebuild b/media-libs/freetype/freetype-2.7.1-r1.ebuild
new file mode 100644 (file)
index 0000000..d245429
--- /dev/null
@@ -0,0 +1,179 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+inherit autotools flag-o-matic multilib multilib-build multilib-minimal toolchain-funcs
+
+INFINALITY_PATCH="03-infinality-2.6.3-2016.03.26.patch"
+
+DESCRIPTION="A high-quality and portable font engine"
+HOMEPAGE="http://www.freetype.org/"
+SRC_URI="mirror://sourceforge/freetype/${P/_/}.tar.bz2
+       mirror://nongnu/freetype/${P/_/}.tar.bz2
+       utils?  ( mirror://sourceforge/freetype/ft2demos-${PV}.tar.bz2
+               mirror://nongnu/freetype/ft2demos-${PV}.tar.bz2 )
+       doc?    ( mirror://sourceforge/freetype/${PN}-doc-${PV}.tar.bz2
+               mirror://nongnu/freetype/${PN}-doc-${PV}.tar.bz2 )"
+
+LICENSE="|| ( FTL GPL-2+ )"
+SLOT="2"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~x86-interix ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
+IUSE="X +adobe-cff bindist bzip2 +cleartype_hinting debug doc fontforge harfbuzz
+       infinality png static-libs utils"
+RESTRICT="!bindist? ( bindist )" # bug 541408
+
+CDEPEND=">=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
+       bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
+       harfbuzz? ( >=media-libs/harfbuzz-0.9.19[truetype,${MULTILIB_USEDEP}] )
+       png? ( >=media-libs/libpng-1.2.51:=[${MULTILIB_USEDEP}] )
+       utils? (
+               X? (
+                       >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
+                       >=x11-libs/libXau-1.0.7-r1[${MULTILIB_USEDEP}]
+                       >=x11-libs/libXdmcp-1.1.1-r1[${MULTILIB_USEDEP}]
+               )
+       )"
+DEPEND="${CDEPEND}
+       virtual/pkgconfig"
+RDEPEND="${CDEPEND}
+       abi_x86_32? ( utils? ( !app-emulation/emul-linux-x86-xlibs[-abi_x86_32(-)] ) )"
+PDEPEND="infinality? ( media-libs/fontconfig-infinality )"
+
+PATCHES=(
+       # This is the same as the 01 patch from infinality
+       "${FILESDIR}"/${PN}-2.7-enable-valid.patch
+
+       "${FILESDIR}"/${PN}-2.4.11-sizeof-types.patch # 459966
+
+       # patches from upstream (can be removed with the next version bump)
+       "${FILESDIR}"/${P}-pcf_fix.patch #606688
+)
+
+src_prepare() {
+       enable_option() {
+               sed -i -e "/#define $1/ { s:/\* ::; s: \*/:: }" \
+                       include/${PN}/config/ftoption.h \
+                       || die "unable to enable option $1"
+       }
+
+       disable_option() {
+               sed -i -e "/#define $1/ { s:^:/* :; s:$: */: }" \
+                       include/${PN}/config/ftoption.h \
+                       || die "unable to disable option $1"
+       }
+
+       default
+
+       # Will be the new default for >=freetype-2.7.0
+       disable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  2"
+
+       if use infinality && use cleartype_hinting; then
+               enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  ( 1 | 2 )"
+       elif use infinality; then
+               enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  1"
+       elif use cleartype_hinting; then
+               enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  2"
+       fi
+
+       if ! use bindist; then
+               # See http://freetype.org/patents.html
+               # ClearType is covered by several Microsoft patents in the US
+               enable_option FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+       fi
+
+       if ! use adobe-cff; then
+               enable_option CFF_CONFIG_OPTION_OLD_ENGINE
+       fi
+
+       if use debug; then
+               enable_option FT_DEBUG_LEVEL_TRACE
+               enable_option FT_DEBUG_MEMORY
+       fi
+
+       if use utils; then
+               cd "${WORKDIR}/ft2demos-${PV}" || die
+               # Disable tests needing X11 when USE="-X". (bug #177597)
+               if ! use X; then
+                       sed -i -e "/EXES\ +=\ ftdiff/ s:^:#:" Makefile || die
+               fi
+               cd "${S}" || die
+       fi
+
+       # we need non-/bin/sh to run configure
+       if [[ -n ${CONFIG_SHELL} ]] ; then
+               sed -i -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
+                       "${S}"/builds/unix/configure || die
+       fi
+
+       elibtoolize --patch-only
+}
+
+multilib_src_configure() {
+       append-flags -fno-strict-aliasing
+       type -P gmake &> /dev/null && export GNUMAKE=gmake
+
+       local myeconfargs=(
+               --enable-biarch-config
+               --enable-shared
+               $(use_with bzip2)
+               $(use_with harfbuzz)
+               $(use_with png)
+               $(use_enable static-libs static)
+
+               # avoid using libpng-config
+               LIBPNG_CFLAGS="$($(tc-getPKG_CONFIG) --cflags libpng)"
+               LIBPNG_LDFLAGS="$($(tc-getPKG_CONFIG) --libs libpng)"
+       )
+
+       ECONF_SOURCE="${S}" \
+               econf "${myeconfargs[@]}"
+}
+
+multilib_src_compile() {
+       default
+
+       if multilib_is_native_abi && use utils; then
+               einfo "Building utils"
+               # fix for Prefix, bug #339334
+               emake \
+                       X11_PATH="${EPREFIX}/usr/$(get_libdir)" \
+                       FT2DEMOS=1 TOP_DIR_2="${WORKDIR}/ft2demos-${PV}"
+       fi
+}
+
+multilib_src_install() {
+       default
+
+       if multilib_is_native_abi && use utils; then
+               einfo "Installing utils"
+               rm "${WORKDIR}"/ft2demos-${PV}/bin/README || die
+               local ft2demo
+               for ft2demo in ../ft2demos-${PV}/bin/*; do
+                       ./libtool --mode=install $(type -P install) -m 755 "$ft2demo" \
+                               "${ED}"/usr/bin || die
+               done
+       fi
+}
+
+multilib_src_install_all() {
+       if use fontforge; then
+               # Probably fontforge needs less but this way makes things simplier...
+               einfo "Installing internal headers required for fontforge"
+               local header
+               find src/truetype include/freetype/internal -name '*.h' | \
+               while read header; do
+                       mkdir -p "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
+                       cp ${header} "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
+               done
+       fi
+
+       dodoc docs/{CHANGES,CUSTOMIZE,DEBUG,INSTALL.UNIX,*.txt,PROBLEMS,TODO}
+       if use doc ; then
+               docinto html
+               dodoc -r docs/*
+       fi
+
+       prune_libtool_files --all
+}