Friday, March 4, 2011

Improved Font Rendering With Lcd Filter Patches In Cairo

In a former post I wrote about a rebuilt libcairo2 with David Turner's patch to get better font rendering. Fonts looked great to my opinion, but maybe a little fuzzy to others.

So I have been looking a little bit further and came across these two pages :
(1) http://crunchbanglinux.org/forums/topic/7415/howto-font-rendering-like-ubuntu/
(2) http://lovingthepenguin.blogspot.com/2010/07/ubuntu-font-rendering-in-debian-squeeze.html

I don't think any patching of libxft2 in Debian Squeeze is needed, so I describe here what I've done to patch libcairo2 :

(1) Go to : http://aur.archlinux.org/packages/cairo-ubuntu/ and download cairo-ubuntu.tar.gz.
tar xf cairo-ubuntu.tar.gz will yield a folder cairo-ubuntu containing cairo-respect-fontconfig.patch.
(2) Go to : http://packages.ubuntu.com/lucid/libcairo2 and download cairo_1.8.10-2ubuntu1.debian.tar.gz.
tar xf tar xf cairo_1.8.10-2ubuntu1.debian.tar.gz will yield a folder debian/patches.
Inside are : 04_lcd_filter.patch and 06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch.

Install packages needed to compile :
As root : apt-get install build-essential devscripts fakeroot
apt-get build-dep cairo

Make a folder in your home directory where all the work gets done :
mkdir source && cd source Inside source : mkdir cairo-patches cairo
Move these three patches from above to folder cairo-patches :
cairo-respect-fontconfig.patch
06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch
04_lcd_filter.patch


Getting source and patching :
cd cairo
apt-get source cairo
cd ./cairo-*
cp ../../cairo-patches/* ./debian/patches/
patch -p1 -i ./debian/patches/cairo-respect-fontconfig.patch
patch -p1 -i ./debian/patches/04_lcd_filter.patch
patch -p1 -i ./debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch

Modify the changelog :
dch -i
A text editor will open ( in my case nano ) and write something after the asterisk (*) :
Additional lcd filter patches
Save and close.
Compile packges and copy it to debs folder:
dpkg-buildpackage -rfakeroot -us -uc
Move one folder up : cd ..
The one we need : libcairo2_1.8.10-6.1_amd64.deb ( in my case on a amd64 )
As root : dpkg -i libcairo2_1.8.10-6.1_amd64.deb

Enable the lcd filter :
<!-- lcdnone, lcddefault, lcdlight, lcdlegacy -->
<match target="font">
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>

My complete .fonts.conf

11 comments:

  1. Do I need to patch libcairo2 1.10.2-1 the same way you did with version 1.8.10-6? Or it is already patched?
    Thanks

    ReplyDelete
  2. No need to patch version 1.10.2-1, see : http://debian-bits-and-snips.blogspot.com/2011/03/run-iceweasel-4-on-squeeze.html

    ReplyDelete
  3. Thanks!!! and Thanks again!!!

    very useful tip, and it works like a charm!

    I wonder that this is not default in debian.

    ReplyDelete
  4. Gracias hermano. Buscando el tutorial en foros y blogs español, y nada.

    Ésta es la única solución que encontré y funciona perfecto.

    Eres un genio en éstas cosas. Gracias por compartirlo.

    ReplyDelete
  5. @1antares1 : Thanks for the complement. I had to go to http://nicetranslator.com/ for a translation. Here is your comment in English : "Thanks brother. Looking for the tutorial in Spanish blogs and forums, and nothing. This is the only solution I found and it works perfect. You are a genius at these things. Thanks for sharing."

    ReplyDelete
  6. After reading and reading and searching. The only method that worked for me, along with the patch sources and fontconfig (many who had the net) was this ....

    Indeed, a big hello and thanks for putting this tutorial. I just had to cross the "antialias" - hintfull, for firefox I see perfect.

    Greetings brother, perfect and complete tutorial.

    ReplyDelete
  7. r@ngf ~/source/cairo/cairo-1.10.2 $ patch -p1 -i ./debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch
    patching file src/cairo-xcb-surface.c
    Hunk #1 FAILED at 844.
    1 out of 1 hunk FAILED -- saving rejects to file src/cairo-xcb-surface.c.rej
    patching file src/cairo-xlib-surface.c
    Hunk #1 FAILED at 1424.
    1 out of 1 hunk FAILED -- saving rejects to file src/cairo-xlib-surface.c.rej
    r@ngf ~/source/cairo/cairo-1.10.2 $

    ReplyDelete
  8. @Anonymous

    No need to patch version 1.10.2-1, see : http://debian-bits-and-snips.blogspot.com/2011/03/run-iceweasel-4-on-squeeze.html

    ReplyDelete
  9. I want to apply a patch to libxft in Debian Squeeze
    How to impose these patches ?
    Please !

    ReplyDelete
  10. + I want to apply a patch to freetype in Debian Squeeze
    How to impose these patches ?
    Please !

    ReplyDelete
    Replies
    1. Ask your question in the Debian forum ( forums.debian.net ). Enough people to help you.

      Delete

Note: Only a member of this blog may post a comment.