Package: cups-filters
Version: 1.0.2-1
Severity: wishlist
Tags: patch

Hi,

I am sorry I feel the need to re-iterate #495598, but cups's and now cups-
filters's hard dependency on ttf-freefonts package is still disturbing me.
However, this time I provide a patch.

I don't think that the cups-filters - especially the texttopdf filter - should
rely on symlinks to actual TTF fontfiles named after the file names listed in
the pdf.utf-8.* maps. Instead, if the symlink in question does not exist or
does not lead to a valid TTF font file, the filter should ask fontconfig what
the next best matching font is. That is what fontconfig is
actually for. This way, the hard dependency on ttf-freefonts could get demoted
to a Recommends or at least get some alternative dependencies added. \o/

TL;DR: Please review the attached patch!

Cheers,
Fabian



-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (901, 'testing'), (501, 'unstable'), (101, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.1.0-1-686-pae (SMP w/1 CPU core)
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages cups-filters depends on:
ii  ghostscript      9.05~dfsg-2
ii  libc6            2.13-26
ii  libcups2         1.5.2-5
ii  libcupsfilters1  1.0.2-1
ii  libcupsimage2    1.5.2-5
ii  libgcc1          1:4.6.2-12
ii  libijs-0.35      0.35-8
ii  liblcms2-2       2.2+git20110628-2
ii  libpoppler13     0.16.7-3
ii  libstdc++6       4.6.2-12
ii  ttf-freefont     20100919-1
ii  zlib1g           1:1.2.6.dfsg-1

Versions of packages cups-filters recommends:
pn  colord            0.1.16-2
pn  foomatic-filters  <none>
pn  ghostscript-cups  <none>

Versions of packages cups-filters suggests:
pn  foomatic-db-compressed-ppds | foomatic-db  <none>
--- cups-filters-1.0.2.orig/filter/Makefile
+++ cups-filters-1.0.2/filter/Makefile
@@ -329,7 +329,7 @@ fontembed/libfontembed.a:
 
 texttopdf:	texttopdf.o textcommon.o common.o pdfutils.o fontembed/libfontembed.a
 	echo Linking $@...
-	$(CC) $(LDFLAGS) -o $@ texttopdf.o textcommon.o common.o pdfutils.o -Lfontembed -lfontembed $(LIBS)
+	$(CC) $(LDFLAGS) -o $@ texttopdf.o textcommon.o common.o pdfutils.o -Lfontembed -lfontembed $(FONTCONFIG_LIBS) $(LIBS)
 
 
 #
--- cups-filters-1.0.2.orig/filter/texttopdf.c
+++ cups-filters-1.0.2/filter/texttopdf.c
@@ -32,6 +32,7 @@
 #include "fontembed/embed.h"
 #include <assert.h>
 #include "fontembed/sfnt.h"
+#include <fontconfig/fontconfig.h>
 
 /*
  * Globals...
@@ -49,6 +50,21 @@ EMB_PARAMS *font_load(const char *datadi
   snprintf(filename, sizeof(filename), "%s/fonts/%s", datadir, font);
 
   OTF_FILE *otf=otf_load(filename);
+
+  if (!otf) {
+    FcPattern *fc_pattern;
+    FcChar8   *fc_file;
+
+    FcInit();
+    fc_pattern = FcNameParse (font);
+    FcConfigSubstitute (0, fc_pattern, FcMatchPattern);
+    FcDefaultSubstitute (fc_pattern);
+    fc_pattern = FcFontMatch (0, fc_pattern, 0);
+    fc_file = FcPatternFormat (fc_pattern, "%{file|cescape}");
+    otf = otf_load(fc_file);
+    free(fc_pattern);
+  }
+
   if (!otf) {
     // TODO: try /usr/share/fonts/*/*/%s.ttf
     return NULL;

Reply via email to