Package: cups-filters
Version: 1.0.4-1
Severity: normal
Tags: patch upstream
Hi,
I have decided to open a new bug to complete the switch to font selection based
on fontconfig patterns instead of file names. The attached patch applies to the
current cups-filters 1.0.4 release and *replaces all the patches I have
previously sent* to the now closed #662660.
It also fixes some Errata in my previous patches from #662660, namely:
- In filter/pdf.utf-8.heavy I replaced the font file name "COUR.TTF" (and its
variants) with the fontconfig pattern "Courier", whereas the file actually
contains the "CourierNew" font.
- In filter/texttopdf.c the line "#include <string.h>" isn't needed anymore,
since we are not handling file names anymore and thus do not need to remove
file name extensions.
- The "int index" variable is not needed actually. The FcPatternFormat()
function knows the "%{index}" part of its format string on its own.
- The indentation of the new code was still 4 blanks, as if it was still inside
the "if (!otf)" condition, which got removed.
So, please, forget about the patches I sent to #662660, apply only this one and
the transition to font selection based on fontconfig patterns instead of file
names in clean and complete. In its current state, i.e. as released with 1.0.4
it is a mixture of both and none of both done right. ;)
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)
Description: Completely implement the switch to font selection
based on fontconfig patterns instead of file names.
Author: Fabian Greffrath <[email protected]>
--- cups-filters-1.0.4.orig/filter/pdf.utf-8.heavy
+++ cups-filters-1.0.4/filter/pdf.utf-8.heavy
@@ -28,13 +28,13 @@ charset utf8
# printing.
#
-0000 00FF ltor single COUR.TTF COURBD.TTF COURI.TTF COURBI.TTF
-0100 02FF ltor single DejaVuSansMono.ttf DejaVuSansMono-Bold.ttf DejaVuSansMono-Oblique.ttf DejaVuSansMono-BoldOblique.ttf
-0300 03FF ltor single DejaVuSansMono.ttf
-0400 04FF ltor single DejaVuSansMono.ttf DejaVuSansMono-Bold.ttf DejaVuSansMono-Oblique.ttf DejaVuSansMono-BoldOblique.ttf
-0500 05FF rtol single FreeMono.ttf
-1E00 1EFF ltor single COUR.TTF COURBD.TTF COURI.TTF COURBI.TTF
-2000 21FF ltor single DejaVuSansMono.ttf DejaVuSansMono-Bold.ttf DejaVuSansMono-Oblique.ttf DejaVuSansMono-BoldOblique.ttf
-2200 23FF ltor single SYMBOL.TTF
-3000 9FFF ltor double uming.ttc/0
-#0400 04FF ltor single FreeMono.ttf FreeMonoBold.ttf FreeMonoOblique.ttf FreeMonoBoldOblique.ttf
+0000 00FF ltor single CourierNew CourierNew:bold CourierNew:italic CourierNew:bold:italic
+0100 02FF ltor single DejaVuSansMono DejaVuSansMono:bold DejaVuSansMono:oblique DejaVuSansMono:bold:oblique
+0300 03FF ltor single DejaVuSansMono
+0400 04FF ltor single DejaVuSansMono DejaVuSansMono:bold DejaVuSansMono:oblique DejaVuSansMono:bold:oblique
+0500 05FF rtol single FreeMono
+1E00 1EFF ltor single CourierNew CourierNew:bold CourierNew:italic CourierNew:bold:italic
+2000 21FF ltor single DejaVuSansMono DejaVuSansMono:bold DejaVuSansMono:oblique DejaVuSansMono:bold:oblique
+2200 23FF ltor single Symbol
+3000 9FFF ltor double ARPLUMingCN
+#0400 04FF ltor single FreeMono FreeMono:bold FreeMono:oblique FreeMono:bold:oblique
--- cups-filters-1.0.4.orig/filter/pdf.utf-8.simple
+++ cups-filters-1.0.4/filter/pdf.utf-8.simple
@@ -28,5 +28,5 @@ charset utf8
# printing.
#
-0000 04FF ltor single FreeMono.ttf FreeMonoBold.ttf FreeMonoOblique.ttf FreeMonoBoldOblique.ttf
-0500 05FF rtol single FreeMono.ttf
+0000 04FF ltor single FreeMono FreeMono:bold FreeMono:oblique FreeMono:bold:oblique
+0500 05FF rtol single FreeMono
--- cups-filters-1.0.4.orig/filter/texttopdf.c
+++ cups-filters-1.0.4/filter/texttopdf.c
@@ -33,7 +33,6 @@
#include <assert.h>
#include "fontembed/sfnt.h"
#include <fontconfig/fontconfig.h>
-#include <string.h>
/*
* Globals...
@@ -43,51 +42,40 @@
int UTF8 = 1; /* Use UTF-8 encoding? */
#endif /* CUPS_1_4 */
-EMB_PARAMS *font_load(const char *datadir,const char *font);
+EMB_PARAMS *font_load(const char *font);
-EMB_PARAMS *font_load(const char *datadir,const char *font)
+EMB_PARAMS *font_load(const char *font)
{
- char filename[1024]; /* Glyph filenames */
- snprintf(filename, sizeof(filename), "%s/fonts/%s", datadir, font);
-
- OTF_FILE *otf=otf_load(filename);
-
- if (!otf) {
+ OTF_FILE *otf;
- FcPattern *pattern;
- FcFontSet *candidates;
- FcChar8 *fontformat, *fontname = NULL;
- int i, spacing;
-
- /* Remove extension from the passed file name
- to turn it into a minimal "pattern" in the fontconfig sense */
- if (strrchr(filename, '.'))
- *strrchr(filename, '.') = '\0';
-
- FcInit ();
- pattern = FcNameParse (filename);
- FcConfigSubstitute (0, pattern, FcMatchPattern);
- FcDefaultSubstitute (pattern);
-
- /* Receive a sorted list of fonts matching our pattern */
- candidates = FcFontSort (0, pattern, FcTrue, 0, 0);
- FcPatternDestroy (pattern);
-
- /* In the list of fonts returned by FcFontSort()
- find the first one that is both in TrueType format and monospaced */
- for (i = 0; i < candidates->nfont; i++) {
- FcPatternGetString (candidates->fonts[i], FC_FONTFORMAT, 0, &fontformat);
- FcPatternGetInteger (candidates->fonts[i], FC_SPACING, 0, &spacing);
-
- if ((strcmp(fontformat, "TrueType") == 0) && (spacing == FC_MONO)) {
- fontname = FcPatternFormat (candidates->fonts[i], "%{file|cescape}");
- break;
- }
+ FcPattern *pattern;
+ FcFontSet *candidates;
+ FcChar8 *fontformat, *fontname = NULL;
+ int i, spacing;
+
+ FcInit ();
+ pattern = FcNameParse (font);
+ FcConfigSubstitute (0, pattern, FcMatchPattern);
+ FcDefaultSubstitute (pattern);
+
+ /* Receive a sorted list of fonts matching our pattern */
+ candidates = FcFontSort (0, pattern, FcTrue, 0, 0);
+ FcPatternDestroy (pattern);
+
+ /* In the list of fonts returned by FcFontSort()
+ find the first one that is both in TrueType format and monospaced */
+ for (i = 0; i < candidates->nfont; i++) {
+ FcPatternGetString (candidates->fonts[i], FC_FONTFORMAT, 0, &fontformat);
+ FcPatternGetInteger (candidates->fonts[i], FC_SPACING, 0, &spacing);
+
+ if ((strcmp(fontformat, "TrueType") == 0) && (spacing == FC_MONO)) {
+ fontname = FcPatternFormat (candidates->fonts[i], "%{file|cescape}/%{index}");
+ break;
}
- FcFontSetDestroy (candidates);
-
- otf = otf_load(fontname);
}
+ FcFontSetDestroy (candidates);
+
+ otf = otf_load(fontname);
if (!otf) {
// TODO: try /usr/share/fonts/*/*/%s.ttf
@@ -560,7 +548,7 @@ WriteProlog(const char *title, /* I - T
}
if (k==num_fonts) { // not found
- fonts[num_fonts] = Fonts[NumFonts][i] = font_load(datadir,valptr);
+ fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr);
if (!fonts[num_fonts]) { // font missing/corrupt, replace by first
fprintf(stderr,"WARNING: Ignored bad font \"%s\"\n",valptr);
break;
@@ -744,7 +732,7 @@ WriteProlog(const char *title, /* I - T
}
if (k==num_fonts) { // not found
- fonts[num_fonts] = Fonts[NumFonts][i] = font_load(datadir,valptr);
+ fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr);
if (!fonts[num_fonts]) { // font missing/corrupt, replace by first
fprintf(stderr,"WARNING: Ignored bad font \"%s\"\n",valptr);
break;