[Pkg-cups-devel] Bug#662660: Bug#662660: cups-filters: Please drop ttf-freefonts and use fontconfig to find the best-matching similar font
Fabian Greffrath
fabian at greffrath.com
Wed Mar 7 09:30:15 UTC 2012
Hi Till and Martin,
please find my improved patch attached.
If direct loading of the TTF font file passed to font_load() fails,
turn the file name into a fontconfig "pattern" (see below!) and use it
to receive a list of similar fonts from fontconfig that somehow match
this pattern. Then iterate through this list to find the first
candidate that is both in TrueType format and monospaced. If none is
found, fontname will still point to NULL and the function returns NULL
just as before.
With this patch, texttopdf should work whether ttf-freefonts is
installed or not, whether the symlinks are there or not, whether they
are dangling or not - it just shouldn't matter, *as long as at least
on monospaced TrueType font is installed on the system*. This may be
provided by fonts-liberation, ttf-dejavu, fonts-consolidata or
whatever. However, if ttf-freefonts is installed, the symlinks will
point to these fonts and they take preference over all the others. I
think this still makes sense, because ttf-freefonts may still have the
widest unicode coverage of them all. I think this fact should also get
reflected in the package dependencies, which could get changed from
"Depends: ttf-freefonts" to "Depends: ttf-freefonts | fonts-liberation
| ttf-dejavu" or similar. This would close #662660 and #495598. ;)
There is one drawback with this patch (but I think the net win
overweights): The file names passed to font_load() are in fact no
valid fontconfig patterns, even with their .ttf extensions removed.
That is, fontconfig cannot know that "FreeMonoBold" means that we
want the bold face of the FreeMono or any other valid monospaced font.
I should be called "FreeMono:Bold" to achieve this, but this in turn
is incompatible with the file names found in ttf-freefonts. I think it
still works well enough as a fallback as it is now, but in the long
term one should consider switching from actual font file names to
fontconfig patterns in pdf.utf-8.* altogether!
Another warning: This is my very first encounter with fontconfig, so I
suggest someone with a bit more fontconfig-fu should have a look at it
before applying it upstream. ;)
Regards,
- Fabian
PS: The cups-filters package currently FTBFS if built twice in a row,
because there are object files left in pdftoopvp/oprs/ and
filter/fontembed/. Maybe those two directories should get added to the
DIRS variable in the top-level Makefile.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: texttopdf_fontconfig.patch
Type: text/x-diff
Size: 2222 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-cups-devel/attachments/20120307/28eb5641/attachment.patch>
More information about the Pkg-cups-devel
mailing list