Ian Jackson writes ("Re: Bug#299697: fontconfig: Still unresolved"): > But yes, if you don't use pango for everything then you have to find > the places in Mozilla where it uses fontconfig and change those too, > to pass the new flag. I haven't done that at this stage because it > wasn't relevant to the configuration in Ubuntu.
It has so turned out that we (Ubuntu) have just changed our firefox setup to sometimes not use pango, so we have had to make those changes to firefox. We've also discovered that the usual way to call fontconfig when you want to present to the user a list of fonts is to supply a fairly minimal pattern and call FcFontList or the like; which doesn't work with anymetrics=1 because the pattern never matches. Personally I think this is a design error in the FC API: configuration-directing attributes like anymetrics should be removed during canonicalisation which ought to completely solve that, but this wouldn't work at present because applications generally don't do canonicalisation between pattern creation and font enumeration. Indeed, I found a couple of places in pango where a pattern was constructed and FcFontMatch was called without invoking the canonicalisation and configuration processing. It seems to me that the canonicalisation and config processing, which are supposed to be performed by all fontconfig-using programs, should be done automatically the first time a pattern is used, whether for enumeration or finding a particular font. This would eliminate mistakes of this kind (and make application code smaller and more straightforward). fontconfig would have to maintain a copy of the original pattern in case the application modified it or had other unusual flows (or at least, it would have to mark the pattern as `canonicalised' and refuse to further edit it). So, currently the correct behaviour for a non-metrics-sensitive program is to set anymetrics=1 iff it is looking for a particular font, and not to set it iff the pattern is to be used for enumeration. This is not quite correct and might lead to misbehaviour in the future, but the behaviour is correct in the current configuration. The revised patch to pango, and the patch to firefox that I mentioned earlier, are attached. Thanks, Ian.
diff -u pango1.0-1.12.1/debian/control pango1.0-1.12.1/debian/control --- pango1.0-1.12.1/debian/control +++ pango1.0-1.12.1/debian/control @@ -2,7 +2,7 @@ Section: libs Priority: optional Maintainer: Sebastien Bacher <[EMAIL PROTECTED]> -Uploaders: Debian GNOME Maintainers <[EMAIL PROTECTED]>, Akira TAGOH <[EMAIL PROTECTED]>, Andreas Rottmann <[EMAIL PROTECTED]>, Andrew Lau <[EMAIL PROTECTED]>, Carlos Perelló MarÃn <[EMAIL PROTECTED]>, Clément Stenac <[EMAIL PROTECTED]>, Ed Boraas <[EMAIL PROTECTED]>, Edd Dumbill <[EMAIL PROTECTED]>, Emil Soleyman-Zomalan <[EMAIL PROTECTED]>, Guilherme de S. Pastore <[EMAIL PROTECTED]>, Gustavo Noronha Silva <[EMAIL PROTECTED]>, J.H.M. Dassen (Ray) <[EMAIL PROTECTED]>, Joe Drew <[EMAIL PROTECTED]>, Johannes Rohr <[EMAIL PROTECTED]>, Jordi Mallach <[EMAIL PROTECTED]>, Jose Carlos Garcia Sogo <[EMAIL PROTECTED]>, Josselin Mouette <[EMAIL PROTECTED]>, Loic Minier <[EMAIL PROTECTED]>, Marc HE Brockschmidt <[EMAIL PROTECTED]>, OndÅej Surý <[EMAIL PROTECTED]>, Rob Bradford <[EMAIL PROTECTED]>, Robert McQueen <[EMAIL PROTECTED]>, Ross Burton <[EMAIL PROTECTED]>, Sjoerd Simons <[EMAIL PROTECTED]>, Takuo KITAME <[EMAIL PROTECTED]> +Uploaders: Debian GNOME Maintainers <[EMAIL PROTECTED]>, Akira TAGOH <[EMAIL PROTECTED]>, Andreas Rottmann <[EMAIL PROTECTED]>, Andrew Lau <[EMAIL PROTECTED]>, Carlos Perelló MarÃn <[EMAIL PROTECTED]>, Ed Boraas <[EMAIL PROTECTED]>, Edd Dumbill <[EMAIL PROTECTED]>, Emil Soleyman-Zomalan <[EMAIL PROTECTED]>, Gustavo Noronha Silva <[EMAIL PROTECTED]>, J.H.M. Dassen (Ray) <[EMAIL PROTECTED]>, Joe Drew <[EMAIL PROTECTED]>, Johannes Rohr <[EMAIL PROTECTED]>, Jordi Mallach <[EMAIL PROTECTED]>, Jose Carlos Garcia Sogo <[EMAIL PROTECTED]>, Josselin Mouette <[EMAIL PROTECTED]>, Marc HE Brockschmidt <[EMAIL PROTECTED]>, OndÅej Surý <[EMAIL PROTECTED]>, Rob Bradford <[EMAIL PROTECTED]>, Robert McQueen <[EMAIL PROTECTED]>, Ross Burton <[EMAIL PROTECTED]>, Sjoerd Simons <[EMAIL PROTECTED]>, Takuo KITAME <[EMAIL PROTECTED]> Build-Depends: debhelper (>= 4.9.12), libfreetype6-dev (>= 2.1.7), libx11-dev, libxrender-dev, libxt-dev, libglib2.0-dev (>= 2.10.0), pkg-config, defoma (>= 0.11.1), libxft-dev, libfontconfig1-dev (>= 2.1.91), autotools-dev, po-debconf, gnome-pkg-tools, libcairo2-dev (>= 1.0.0) Standards-Version: 3.6.2 diff -u pango1.0-1.12.1/debian/changelog pango1.0-1.12.1/debian/changelog --- pango1.0-1.12.1/debian/changelog +++ pango1.0-1.12.1/debian/changelog @@ -1,3 +1,27 @@ +pango1.0 (1.12.1-1ubuntu4) dapper; urgency=low + + * Do not use FC_ANY_METRICS while listing, because that's a property + that is never matched exactly and so only valid when matching. + + -- Ian Jackson <[EMAIL PROTECTED]> Tue, 25 Apr 2006 19:01:59 +0100 + +pango1.0 (1.12.1-1ubuntu3) dapper; urgency=low + + * Correct version for build-dependency on fontconfig, for version + with FC_ANY_METRICS. + + -- Ian Jackson <[EMAIL PROTECTED]> Mon, 24 Apr 2006 11:09:40 +0100 + +pango1.0 (1.12.1-1ubuntu2) dapper; urgency=low + + * Turn on FC_ANY_METRICS whenever looking up fonts with fontconfig. + This lets fontconfig's configuration know that we don't care about + getting a font with exactly the same shape as the family we asked for. + This fixes the (eg) firefox vs. (eg) evince font metrics ugliness + problem. + + -- Ian Jackson <[EMAIL PROTECTED]> Wed, 19 Apr 2006 12:48:06 +0100 + pango1.0 (1.12.1-1ubuntu1) dapper; urgency=low * Sync with Debian only in patch2: unchanged: --- pango1.0-1.12.1.orig/debian/patches/anymetrics.patch +++ pango1.0-1.12.1/debian/patches/anymetrics.patch @@ -0,0 +1,36 @@ +--- pango-1.12.1/pango/pangoft2.c~ 2006-02-21 10:12:01.000000000 +0000 ++++ pango-1.12.1/pango/pangoft2.c 2006-04-19 12:43:07.000000000 +0100 +@@ -98,6 +98,7 @@ + sans = FcPatternBuild (NULL, + FC_FAMILY, FcTypeString, "sans", + FC_PIXEL_SIZE, FcTypeDouble, (double)ft2font->size / PANGO_SCALE, ++ FC_ANY_METRICS, FcTypeBool, FcTrue, + NULL); + + matched = FcFontMatch (NULL, sans, &result); +--- pango-1.12.1/pango/pangofc-fontmap.c~ 2006-02-21 10:12:01.000000000 +0000 ++++ pango-1.12.1/pango/pangofc-fontmap.c 2006-04-19 12:42:50.000000000 +0100 +@@ -822,6 +822,7 @@ + #endif + FC_SIZE, FcTypeDouble, pixel_size * (72. / dpi), + FC_PIXEL_SIZE, FcTypeDouble, pixel_size, ++ FC_ANY_METRICS, FcTypeBool, FcTrue, + NULL); + + families = g_strsplit (pango_font_description_get_family (description), ",", -1); +@@ -975,6 +976,7 @@ + FcPattern *tmp = FcPatternBuild (NULL, + FC_FAMILY, FcTypeString, "Sans", + FC_SIZE, FcTypeDouble, 10., ++ FC_ANY_METRICS, FcTypeBool, FcTrue, + NULL); + if (tmp) + { +@@ -1651,6 +1653,7 @@ + match_pattern = FcPatternBuild (NULL, + FC_FAMILY, FcTypeString, fcfamily->family_name, + FC_STYLE, FcTypeString, fcface->style, ++ FC_ANY_METRICS, FcTypeBool, FcTrue, + NULL); + + g_assert (match_pattern);
diff --exclude='*~' -ruN before-this/firefox-1.5.dfsg+1.5.0.2/gfx/cairo/cairo/src/cairo-ft-font.c firefox-1.5.dfsg+1.5.0.2/gfx/cairo/cairo/src/cairo-ft-font.c --- before-this/firefox-1.5.dfsg+1.5.0.2/gfx/cairo/cairo/src/cairo-ft-font.c 2006-05-02 16:23:51.000000000 +0100 +++ firefox-1.5.dfsg+1.5.0.2/gfx/cairo/cairo/src/cairo-ft-font.c 2006-05-02 16:23:54.000000000 +0100 @@ -1574,6 +1574,7 @@ _compute_transform (&sf, &scale); FcPatternAddInteger (pattern, FC_PIXEL_SIZE, sf.y_scale); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); FcConfigSubstitute (NULL, pattern, FcMatchPattern); cairo_ft_font_options_substitute (options, pattern); diff --exclude='*~' -ruN before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/cairo/nsFontMetricsXft.cpp firefox-1.5.dfsg+1.5.0.2/gfx/src/cairo/nsFontMetricsXft.cpp --- before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/cairo/nsFontMetricsXft.cpp 2005-05-02 09:37:42.000000000 +0100 +++ firefox-1.5.dfsg+1.5.0.2/gfx/src/cairo/nsFontMetricsXft.cpp 2006-05-02 16:28:17.000000000 +0100 @@ -1059,6 +1059,8 @@ FcPatternAddInteger(mPattern, FC_WEIGHT, NS_CalculateWeight(mFont.weight)); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); + // Set up the default substitutions for this font FcConfigSubstitute(0, mPattern, FcMatchPattern); XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()), @@ -1221,6 +1223,8 @@ FcPatternAddInteger(pattern, FC_WEIGHT, NS_CalculateWeight(mFont.weight)); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); + FcConfigSubstitute(0, pattern, FcMatchPattern); XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()), pattern); diff --exclude='*~' -ruN before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/gtk/nsFontMetricsXft.cpp firefox-1.5.dfsg+1.5.0.2/gfx/src/gtk/nsFontMetricsXft.cpp --- before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/gtk/nsFontMetricsXft.cpp 2006-04-27 17:07:42.000000000 +0100 +++ firefox-1.5.dfsg+1.5.0.2/gfx/src/gtk/nsFontMetricsXft.cpp 2006-05-02 16:27:09.000000000 +0100 @@ -1106,6 +1106,8 @@ FcPatternAddInteger(mPattern, FC_WEIGHT, NS_CalculateWeight(mFont.weight)); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); + // Set up the default substitutions for this font FcConfigSubstitute(0, mPattern, FcMatchPattern); XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()), @@ -1268,6 +1270,8 @@ FcPatternAddInteger(pattern, FC_WEIGHT, NS_CalculateWeight(mFont.weight)); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); + FcConfigSubstitute(0, pattern, FcMatchPattern); XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()), pattern); diff --exclude='*~' -ruN before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/ps/nsFontMetricsPS.cpp firefox-1.5.dfsg+1.5.0.2/gfx/src/ps/nsFontMetricsPS.cpp --- before-this/firefox-1.5.dfsg+1.5.0.2/gfx/src/ps/nsFontMetricsPS.cpp 2005-04-28 09:04:00.000000000 +0100 +++ firefox-1.5.dfsg+1.5.0.2/gfx/src/ps/nsFontMetricsPS.cpp 2006-05-02 16:28:16.000000000 +0100 @@ -945,6 +945,8 @@ // Add the weight FcPatternAddInteger(pattern, FC_WEIGHT, NS_CalculateWeight(aFont.weight)); + FcPatternAddBool (pattern, FC_ANY_METRICS, FcTrue); + // Set up the default substitutions for this font FcConfigSubstitute(0, pattern, FcMatchPattern); FcDefaultSubstitute(pattern);