From 6b9c81aa1829611094464e4885e6f1b47adf4685 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sun, 26 Mar 2017 16:30:01 +0200 Subject: [PATCH 1/5] pcre: 8.39 -> 8.40 + security fix CVE-2017-7186 refs nixos/security#57 #24319 --- .../libraries/pcre/CVE-2017-7186.patch | 52 +++++++++++++++++++ pkgs/development/libraries/pcre/default.nix | 6 ++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/libraries/pcre/CVE-2017-7186.patch diff --git a/pkgs/development/libraries/pcre/CVE-2017-7186.patch b/pkgs/development/libraries/pcre/CVE-2017-7186.patch new file mode 100644 index 000000000000..e9e1997e47c9 --- /dev/null +++ b/pkgs/development/libraries/pcre/CVE-2017-7186.patch @@ -0,0 +1,52 @@ +--- a/pcre_internal.h 2016/05/21 13:34:44 1649 ++++ b/pcre_internal.h 2017/02/24 17:30:30 1688 +@@ -2772,6 +2772,9 @@ + extern const pcre_uint16 PRIV(ucd_stage2)[]; + extern const pcre_uint32 PRIV(ucp_gentype)[]; + extern const pcre_uint32 PRIV(ucp_gbtable)[]; ++#ifdef COMPILE_PCRE32 ++extern const ucd_record PRIV(dummy_ucd_record)[]; ++#endif + #ifdef SUPPORT_JIT + extern const int PRIV(ucp_typerange)[]; + #endif +@@ -2780,9 +2783,15 @@ + /* UCD access macros */ + + #define UCD_BLOCK_SIZE 128 +-#define GET_UCD(ch) (PRIV(ucd_records) + \ ++#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \ + PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \ + UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE]) ++ ++#ifdef COMPILE_PCRE32 ++#define GET_UCD(ch) ((ch > 0x10ffff)? PRIV(dummy_ucd_record) : REAL_GET_UCD(ch)) ++#else ++#define GET_UCD(ch) REAL_GET_UCD(ch) ++#endif + + #define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype + #define UCD_SCRIPT(ch) GET_UCD(ch)->script +--- a/pcre_ucd.c 2014/06/19 07:51:39 1490 ++++ b/pcre_ucd.c 2017/02/24 17:30:30 1688 +@@ -38,6 +38,20 @@ + const pcre_uint32 PRIV(ucd_caseless_sets)[] = {0}; + #else + ++/* If the 32-bit library is run in non-32-bit mode, character values ++greater than 0x10ffff may be encountered. For these we set up a ++special record. */ ++ ++#ifdef COMPILE_PCRE32 ++const ucd_record PRIV(dummy_ucd_record)[] = {{ ++ ucp_Common, /* script */ ++ ucp_Cn, /* type unassigned */ ++ ucp_gbOther, /* grapheme break property */ ++ 0, /* case set */ ++ 0, /* other case */ ++ }}; ++#endif ++ + /* When recompiling tables with a new Unicode version, please check the + types in this structure definition from pcre_internal.h (the actual + field names will be different): diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index d3499f3e15c1..21de038f7d63 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -7,7 +7,7 @@ with stdenv.lib; assert elem variant [ null "cpp" "pcre16" "pcre32" ]; let - version = "8.39"; + version = "8.40"; pname = if (variant == null) then "pcre" else if (variant == "cpp") then "pcre-cpp" else variant; @@ -17,7 +17,7 @@ in stdenv.mkDerivation rec { src = fetchurl { url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${version}.tar.bz2"; - sha256 = "12wyajlqx2v7dsh39ra9v9m5hibjkrl129q90bp32c28haghjn5q"; + sha256 = "1x7lpjn7jhk0n3sdvggxrlrhab8kkfjwl7qix0ypw9nlx8lpmqh0"; }; outputs = [ "bin" "dev" "out" "doc" "man" ]; @@ -29,6 +29,8 @@ in stdenv.mkDerivation rec { ] ++ optional (variant != null) "--enable-${variant}"; + patches = [ ./CVE-2017-7186.patch ]; + doCheck = with stdenv; !(isCygwin || isFreeBSD); # XXX: test failure on Cygwin # we are running out of stack on both freeBSDs on Hydra From 6ef630a12549c2f36bc1706718c5ad12e0fa05f3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 27 Mar 2017 15:37:49 +0200 Subject: [PATCH 2/5] systemd: Include https://github.com/NixOS/systemd/pull/8 --- pkgs/os-specific/linux/systemd/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index db474f688e59..d1042723a71a 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -15,8 +15,8 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "nixos"; repo = "systemd"; - rev = "c110fc3504d7a2fa944575b347814f7e97d3c5a0"; - sha256 = "19carch1adad70nifbqdx649kj5m8pgpiq27hh05ig38yrbmb2vz"; + rev = "66e778e851440fde7f20cff0c24d23538144be8d"; + sha256 = "1valz8v2q4cj0ipz2b6mh5p0rjxpy3m88gg9xa2rcc4gcmscndzk"; }; outputs = [ "out" "lib" "man" "dev" ]; From 036f4b2f04b7f69e02096ed38980f989dcd25e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 27 Mar 2017 18:56:16 +0200 Subject: [PATCH 3/5] cups: fix #24339: broken paths in cups-config Note: this doesn't fix cups-dymo by itself. It causes a slightly nontrivial rebuild on Linux. --- pkgs/misc/cups/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix index f47ba022c352..38440bac81a4 100644 --- a/pkgs/misc/cups/default.nix +++ b/pkgs/misc/cups/default.nix @@ -79,7 +79,12 @@ stdenv.mkDerivation rec { # Delete obsolete stuff that conflicts with cups-filters. rm -rf $out/share/cups/banners $out/share/cups/data/testprint + # Some outputs in cups-config were unexpanded and some even wrong. moveToOutput bin/cups-config "$dev" + sed -e "/^cups_serverbin=/s|\$(lib)|$out|" \ + -e "s|\$(out)|$out|" \ + -e "s|\$(lib)|$lib|" \ + -i "$dev/bin/cups-config" # Rename systemd files provided by CUPS for f in "$out"/lib/systemd/system/*; do From 9b049849bfc385604f240157e129f7a8e3530d7f Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Tue, 28 Mar 2017 17:29:42 -0500 Subject: [PATCH 4/5] freetype: disable PCF long family names Backported several patches from upstream. The test suite patch for Fontconfig is no longer necessary. --- .../libraries/fontconfig/default.nix | 4 - .../test-pcf-family-names-freetype-2.7.patch | 18 - .../libraries/freetype/default.nix | 9 +- .../disable-pcf-long-family-names.patch | 15 + .../pcf-config-long-family-names.patch | 553 ++++++++++++++++++ .../freetype/pcf-introduce-driver.patch | 68 +++ 6 files changed, 643 insertions(+), 24 deletions(-) delete mode 100644 pkgs/development/libraries/fontconfig/test-pcf-family-names-freetype-2.7.patch create mode 100644 pkgs/development/libraries/freetype/disable-pcf-long-family-names.patch create mode 100644 pkgs/development/libraries/freetype/pcf-config-long-family-names.patch create mode 100644 pkgs/development/libraries/freetype/pcf-introduce-driver.patch diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index c44373625e0f..14983b744df9 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -33,10 +33,6 @@ stdenv.mkDerivation rec { url = "https://cgit.freedesktop.org/fontconfig/patch/?id=1ab5258f7c"; sha256 = "0x2a4qx51j3gqcp1kp4lisdzmhrkw1zw0r851d82ksgjlc0vkbaz"; }) - - # FreeType 2.7 prefixes PCF font family names with the foundry name. - # The output of fc-list and fc-query change which breaks the tests. - ./test-pcf-family-names-freetype-2.7.patch ]; # additionally required for the glibc-2.25 patch; avoid requiring gperf postPatch = '' diff --git a/pkgs/development/libraries/fontconfig/test-pcf-family-names-freetype-2.7.patch b/pkgs/development/libraries/fontconfig/test-pcf-family-names-freetype-2.7.patch deleted file mode 100644 index 24aa6e5aaa1e..000000000000 --- a/pkgs/development/libraries/fontconfig/test-pcf-family-names-freetype-2.7.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff -Nuar fontconfig-2.10.2-orig/test/out.expected fontconfig-2.10.2/test/out.expected ---- fontconfig-2.10.2-orig/test/out.expected 2017-03-06 06:45:50.876053093 -0600 -+++ fontconfig-2.10.2/test/out.expected 2017-03-06 06:48:18.012514337 -0600 -@@ -1,8 +1,8 @@ --Fixed:pixelsize=16 --Fixed:pixelsize=6 -+Misc Fixed:pixelsize=6 -+Sony Fixed:pixelsize=16 - = --Fixed:pixelsize=16 --Fixed:pixelsize=6 -+Misc Fixed:pixelsize=6 -+Sony Fixed:pixelsize=16 - = --Fixed:pixelsize=16 --Fixed:pixelsize=6 -+Misc Fixed:pixelsize=6 -+Sony Fixed:pixelsize=16 diff --git a/pkgs/development/libraries/freetype/default.nix b/pkgs/development/libraries/freetype/default.nix index f966965fa5fa..146fd66deff1 100644 --- a/pkgs/development/libraries/freetype/default.nix +++ b/pkgs/development/libraries/freetype/default.nix @@ -43,8 +43,13 @@ stdenv.mkDerivation { ++ optional (!stdenv.isLinux) gnumake; patches = - [ ./enable-table-validation.patch ] - ++ optional useEncumberedCode ./enable-subpixel-rendering.patch; + [ + ./pcf-introduce-driver.patch + ./pcf-config-long-family-names.patch + ./disable-pcf-long-family-names.patch + ./enable-table-validation.patch + ] ++ + optional useEncumberedCode ./enable-subpixel-rendering.patch; outputs = [ "out" "dev" ]; diff --git a/pkgs/development/libraries/freetype/disable-pcf-long-family-names.patch b/pkgs/development/libraries/freetype/disable-pcf-long-family-names.patch new file mode 100644 index 000000000000..e3dfe4aabd60 --- /dev/null +++ b/pkgs/development/libraries/freetype/disable-pcf-long-family-names.patch @@ -0,0 +1,15 @@ +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-41-gc330 \ No newline at end of file diff --git a/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch b/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch new file mode 100644 index 000000000000..95ed83c60f8f --- /dev/null +++ b/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch @@ -0,0 +1,553 @@ +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 ++ ++ ++ /************************************************************************* ++ * ++ * @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 ++#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-41-gc330 + diff --git a/pkgs/development/libraries/freetype/pcf-introduce-driver.patch b/pkgs/development/libraries/freetype/pcf-introduce-driver.patch new file mode 100644 index 000000000000..c1685c5116cc --- /dev/null +++ b/pkgs/development/libraries/freetype/pcf-introduce-driver.patch @@ -0,0 +1,68 @@ +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-41-gc330 + From 4df59beb017ce23465862890ffe6f6848e3a8a1b Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Thu, 30 Mar 2017 23:19:45 +0300 Subject: [PATCH 5/5] fontconfig_210: Remove reference to obsolete patch Commit 9b049849bfc385604f240157e129f7a8e3530d7f deleted the patch file (and reference to it from fontconfig default.nix), but left the one in 2.10.nix which break evaluation. As the package seems to build fine without the patch, just remove the reference. cc @ttuegel in case this was not the correct thing to do. --- pkgs/development/libraries/fontconfig/2.10.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkgs/development/libraries/fontconfig/2.10.nix b/pkgs/development/libraries/fontconfig/2.10.nix index 222dfc27256c..302992fc8c8a 100644 --- a/pkgs/development/libraries/fontconfig/2.10.nix +++ b/pkgs/development/libraries/fontconfig/2.10.nix @@ -8,12 +8,6 @@ stdenv.mkDerivation rec { sha256 = "0llraqw86jmw4vzv7inskp3xxm2gc64my08iwq5mzncgfdbfza4f"; }; - patches = [ - # FreeType 2.7 prefixes PCF font family names with the foundry name. - # The output of fc-list and fc-query change which breaks the tests. - ./test-pcf-family-names-freetype-2.7.patch - ]; - outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config propagatedBuildInputs = [ freetype ];