Pages

July 13, 2010

Firefox 3.6 with pretty fonts in Debian Squeeze

[Update 2011-06-25: You should consider this post obsolete. See this post for more info.] 

Iceweasel 3.6 has yet to trickle down to Debian Testing and very well may not make it before the freeze. However, some of us would like to have some 3.6iness in spite of this. If you've tried downloading SwiftFox, IceCat or the Firefox 3.6 binaries, you know that you get a 3.6, but the font rendering looks poopy.

Here's what I did to compile FF 3.6 from sources and get the same smooth font rendering that you get with Iceweasel 3.5 from the Squeeze repo. I'm not an expert, but this seems to have worked.

The following is based mostly on Mozilla's documentation on a Simple Firefox Build and Linux Prerequisites.

Preproduction
First, create a working directory. I called mine firefox-mercurial. The reason for the name will become obvious shortly.

Next, get the tools you need to build stuff. Since there's no firefox package in the Debian repos, I used (as root):

# apt-get build-dep iceweasel

Then install a bunch of other stuff that is supposedly needed:

# apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13 yasm

You will also have to add:

# apt-get install libidl-dev

This isn't documented anywhere that I know of. I found this out the hard way after my first attempts to compile failed.

Get sources
With a regular user terminal open in firefox-mercurial, use mercurial to get the sources:

hg clone http://hg.mozilla.org/releases/mozilla-1.9.2/ 192src

This will get you the latest, most update, bleeding edge version of 3.6--which may or may not be the same as the release version. For example, at the time of this writing, the latest version is 3.6.8pre and the latest release is 3.6.6. To specify the exact version you want, use #{tag}, where {tag} is  one of tags listed at http://hg.mozilla.org/releases/mozilla-1.9.2/. For example, to get and build FF 3.6.6:

hg clone http://hg.mozilla.org/releases/mozilla-1.9.2/#FIREFOX_3_6_6_RELEASE 192src

Getting the sources will take a long time, but not nearly as long as compiling will later on.

Next we need to move into the 192src directory and set up the mozconfig file that tells the system how to build firefox:

cd 192src
echo '. $topsrcdir/browser/config/mozconfig' > mozconfig
echo 'mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release' >> mozconfig
echo 'mk_add_options MOZ_MAKE_FLAGS="-j4"' >> mozconfig
echo 'ac_add_options --disable-debug' >> mozconfig
echo 'ac_add_options --disable-tests' >> mozconfig
echo 'ac_add_options --enable-optimize' >> mozconfig
echo 'ac_add_options --enable-system-cairo' >> mozconfig


The objdir-ff-release is the name of the directory that built stuff will end up in. You can change this name if you want. The line with --enable-optimize is optional. The last option above, --enable-system-cairo, I found looking through the list of available options, and I'm pretty sure it's what gives you nice font rendering in GTK+ environments.

Build the beast with

make -f client.mk

The build will take forever. Once the compile is done, the binaries will be in
{whatever}/firefox-mercurial/192src/objdir-ff-release/dist/bin/.
Execute the file firefox to make it go.

When you make it go, you'll notice that the app is identified by its code name, Namoroka.

Updating
I have not yet tried this, but according to Mozilla's documentation, to build a new version you'll need to update the sources with

hg pull -r default
hg update


I suspect you do this in the 192src directory and I suspect you'll need to rebuild as above afterward. Also, I suspect that in place of default above you'll want to use a valid tag (as when you first cloned the sources), but until I actually update I won't be able to say for sure.

Extra credit
Once I've done some more testing, I will be move the built files to /opt/firefox and add a *.desktop entry for it. The big question is whether I should call it 'Firefox' or 'Namoroka'.

July 09, 2010

Ubuntu font rendering in Debian Squeeze

[Update 2011-06-25: Confirmed. Updating Iceweasel from http://mozilla.debian.net/ fixes fonts. See this post for more info. So there's no longer any real need to do what's below.]
[Update 2011-06-24: This whole business may be unnecessary as it appears installing a recent version of Iceweasel from http://mozilla.debian.net/ also installs new libcairo2 with decent font rendering. I've yet to do careful comparisons, but it's possible that this solves both "ugly rendering in general" as well as "ugly rendering in Firefox" issues.]
[Update 2011-03-08:]  Reader datSilencer points out that the location of the Arch patch has moved. Therefore, the process for extracting and applying the Arch patch won't work. I am updating the script but I won't be updating this post. If you want to do things manually, please consult the script for the needed changes.]
[Update 2010-09-23: I made a script to semi-automate a lot of the following.]

I love Debian. I really do. But one thing I don't love about Debian is the way it renders fonts in GTK. Or rather, the way Ubuntu renders fonts has spoiled me. After reading about how some people have successfully patched their libraries to use the same changes used by Ubuntu, I've finally succeeded myself. It's been so gratifying and such a good learning experience that I wanted to share.

The process below is based on information from the CrunchBang Linux Forums and from one quanliking. Huge, huge thanks to those people.

To get Ubuntu font rendering in Debian Squeeze, we need to download, patch, rebuild, and reinstall the libcairo2 package. If this breaks your system don't sue me. I am not an expert nor do I play one on TV.

Pre-production
Begin by making sure downloading of package sources is enabled for apt. The line below should be in /etc/apt/sources.list and not commented out:

deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib

The actual address will differ depending on which mirror you set up your system to use, but there should be a line that begins "deb-src", has a mirror's address in the middle, and ends with "squeeze main non-free contrib" or "testing main non-free contrib".

Install the needed build tools (as root):

# apt-get install build-essential devscripts fakeroot
# apt-get build-dep cairo


As a regular user, create a new directory called patched-packages in your home directory.

Get the patches
Open the patched-packages directory you created above in a terminal (i.e., the prompt should read something like username@computername:~/patched-packages$).

At the command prompt:

mkdir libcairo2
cd libcairo2
mkdir downloaded-patches


We now need to get two sets of patches, one from Ubuntu and the other from Arch Linux. To get the Ubuntu patches, go to http://packages.ubuntu.com/lucid/libcairo2 and look at the list of links on the right. We want the file cairo_1.8.10-{#}ubuntu1.debian.tar.gz. Download it into ~/patched-packages/downloaded-patches and expand it. This should produce a new directory inside ~/patched-packages/downloaded-patches called debian (i.e., you should now have a ~/patched-packages/downloaded-patches/debian).

I'm not yet sure what the original source of the Arch Linux patch is, but apparently we need it. So go to http://aur.archlinux.org/packages.php?ID=17327 and download the file cairo-respect-fontconfig.patch into ~/patched-packages/downloaded-patches

You're done getting patches.

Get the sources
We now need to get the Debian source package for libcairo2. In a terminal inside ~/patched-packages/libcario2,

mkdir deb-sources
cd deb-sources
apt-get source cairo
cd ./cairo-*


Then copy the patches we downloaded earlier to the Debian package's patches directory:

cp ../../downloaded-patches/cairo-respect-fontconfig.patch ./debian/patches/
cp ../../downloaded-patches/debian/patches/04_lcd_filter.patch ./debian/patches/
cp ../../downloaded-patches/debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch ./debian/patches/


Next, apply the patches to the sources:

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


We now need to modify the changelog to indicate that we've diddled with the package and set a version increment:

dch -i

This will open a text editor. Once there, add

David Turner's ClearType-like LCD filtering patch and fix.

after the asterisk at the top and then save and exit.

(Note: Instead of dch -i above you can also use dch -l {your initials}.)

Build and install
Time to build it. Continuing from where we were in the terminal above (i.e., inside something like ~/patched-packages/libcairo2/deb-sources/cairo-1.8.10) do

dpkg-buildpackage -rfakeroot -us -uc

The result should be a bunch of new packages inside ~/patched-packages/libcairo2/deb-sources/

Look if you don't believe me. All that's left is to install. Open a root terminal and go to the ~/patched-packages/libcairo2/deb-sources/ directory. Then do:

# dpkg -i *.deb

This will install all the debs that were made, of which you may actually only need a subset. Apart from taking up some disk space the extra packages won't hurt anything, and if you install a package in the future that needs one of these, you'l be glad you installed them now.

Congrats. You should now have (IMHO) much improved font rendering. This should hold you until Debian releases a new libcairo2. If the new libcairo2 release doesn't have the "Ubuntu patches" already built in, you'll have to repeat the above process, making sure you get patches that are appropriate for the new version and that there are no additional patch files. (If there are, you will need to copy/add them before rebuilding.)

Rolling back your system to the original Debian packages should be as easy as using Synaptic to "Package -> Force Version..." to the original libcairo2 packages.

Happy building.

July 04, 2010

Debranding Firefox in PCLinuxOS

I'm not a huge fan of third-party branding. One of my (minor, when put into perspective) gripes about PCLinuxOS is that they sorta go nuts with it. One of the apps that's the target of their branding is Firefox. If you are equally bugged by this, debranding the default profile used as the template for new profiles isn't that hard.
  1. Download the official firefox-3.{whatever}.tar.bz2 archive from Mozilla's servers. Be sure to download the version that's the same as the one that is already installed on your machine.
  2. As root, deflate the archive. I am pretending we're in /opt and got a /opt/firefox directory:
    # tar -jxvf firefox-3.{whatever}.tar.bz2
  3. Again as root, replace /usr/lib/firefox-3.{whatever}/defaults/profile with /opt/firefox/defaults/profile
Now you can delete the profiles in ~/.mozilla/firefox. (This will of course wipe out all your old bookmarks, etc. Jump through the needed hoops now if you want to save anything.) When you restart Firefox you'll now get the profile defaults, links, etc. that the Mozilla upstream devs thought you would want. The same will be true for any new users or profiles you create from now on.

The downside to this is that to keep the PCLinuxOS branding at bay you'll need to repeat steps 1-3 every time a new FF update is installed.

July 03, 2010

Fixing ugly fonts in Sabayon Firefox

I've been taking the Gentoo-based Sabayon rolling release distribution for a spin. One of the things that you'll notice is that some fonts in Firefox look ghastly horrible. Luckily, there's an easy fix. The problem involves the rendering of Helvetica, Lucida, and Times fonts and is discussed (and solved) on the Gentoo mailing list.

Instead of editing /etc/fonts/local.conf, I changed my ~/.fonts.conf file. I got better results using "Sans" than "DejaVu Sans" and in a similar spirit I used "Serif" instead of "DejaVu Serif". My entire .fonts.config looks like:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

<!-- see http://www.mail-archive.com/gentoo-user@lists.gentoo.org/msg83300.html -->
<!-- Replace Helvetica with DejaVu Sans -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Helvetica</string></test>
        <edit name="family" mode="assign">
                <string>Sans</string>
        </edit>
</match>

<!-- Replace Lucida with DejaVu Sans -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Lucida</string></test>
        <edit name="family" mode="assign">
                <string>Sans</string>
        </edit>
</match>

<!-- Replace Times with DejaVu Serif -->
<match target="pattern" name="family">
        <test name="family" qual="any"><string>Times</string></test>
        <edit name="family" mode="assign">
                <string>Serif</string>
        </edit>
</match>
<!-- -->

<match target="font" >
  <edit mode="assign" name="hinting" >
   <bool>true</bool>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="hintstyle" >
<!--
   <const>hintmedium</const>
-->
   <const>hintslight</const>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="rgba" >
   <const>rgb</const>
  </edit>
</match>
<match target="font" >
  <edit mode="assign" name="antialias" >
   <bool>true</bool>
  </edit>
</match>

</fontconfig>

Speaking of font rendering, Sabayon has default font rendering that's almost as nice as Ubuntu's. IMHO the only thing that gives Ubuntu the edge is a bit more contrast. If I find a fix for this, I will post this as well.

June 27, 2010

Thunderbird 3 new account config workaround

Thunderbird versions 3.0 and 3.1 have a feature that's meant to make configuring new accounts easier but in fact may just make life more complicated for some users. When you set up a new account, the new Tbird account wizard asks you for your name, email address, and password. It then automatically tries to configure the account for you by probing various "best options" using common conventions for port numbers, server names, etc. ... then Voila! you have a fully functioning account configured with SSL and the like if it's available, all without the hassle of dealing with entering server name and port numbers and "Use TLS/Use SSL" options.

The problem is that there's no way to override this. The new account wizard doesn't ask if you want to try an autoconfig or do a manual config--it just starts the autoconfig automatically. There is a "Manual Setup" button on the autoconfig dialog, but there's no way to press it before the autoconfig starts.

"No big deal," you say. "Just wait for the autoconfig to run its course and then go back and manually set the parameters you don't like." Well, that only works for some options. In particular, the "Account Settings" dialog doesn't let you change from IMAP to POP--so if the autoconfig decided that IMAP was your "best option", then that's what you're stuck with. And I've found no way to hit the "Manual Setup" button on the autoconfig dialog before the IMAP/POP selection has been made.

The problem has been reported in bug reports, and the developers' response seems to be, "We will address this in a future release."

"Ah," you say. "It's best to stick with Thunderbird 2 then." However, that's not such an attractive option. Quoting from the Mozilla website: "Please note that Thunderbird 2.0.0.24 is the last planned security and stability release of Thunderbird 2.0. We encourage you to update to Thunderbird 3.1."

So here's a workaround for dealing with v3's new account issues.

In the new account wizard dialog, enter a short bogus email address:
Then click "Continue".

The wizard will vainly try to find the bogus address and eventually give up.
Now is the time to select whether you want POP or IMAP. You will not get a second chance to do this. After you have made the appropriate selection, click "Manual Setup..." and then enter the real account details.

It may not be a pretty, but it seems to work.

June 17, 2010

(No) icons in GTK buttons

I don't know if this has anything to do with the no icons in menus issue, but the solution is darned near the same. I noticed that my Ubuntu Karmic doesn't serve up icons in its buttons with GTK apps in GNOME. The fix comes from someone trying remove his icons:
There is now a new key in GNOME Configurator Editor. Below are the steps to disable buttons on icons in GNOME 2.26 and above.
  1. Press Alt + F2
  2. Type gconf-editor and hit Enter.
  3. Go to Desktop –> GNOME –> Interface
  4. Uncheck the key buttons_have_icons

Just check the box to get your icons back.

May 12, 2010

startupmanager is your friend

After a recent update to my Karmic system, I noticed my boot screen icon's colors went all hallucinogenic. I later noticed that doing a Ctl-Alt-F1 resulted in a console that was nearly impossible to read: the text was a veeery dark grey. I figured the problems were related and I was right.

Using startupmanager (in the repositories), I was able to fix both problems by setting the boot screen bit depth from 8 bits to 16 bits. Dunno exactly what happened, but it's fixed now.

Configuring grub2/boot stuff is definitely easier with the startupmanager around. Recommended.