Friday, November 21, 2008

Spotify, Guitar Pro, Wine = Messed up fonts

Some context, I got an invite to Spotify from a friend. They say that Spotify works under Wine in Linux so I decided to try it out.

The program works very well, it's very snappy and well thought out. I really like the service, it makes it easy to find new music and to share it with other people (who also needs to have Spotify or something similar of course).

There was only one issue. Spotify allows you to play their Radio, which is pretty much a shuffle over the genre you have specified and the years you have specified.

However, In wine I got bad fonts for all the buttons on that page, instead of Roman letters, I got musical notation. I thought that this was a bug I could live with until I tried it at another Linux installation which did not have this bug. So, how can this happen?








Well, it is a font-issue in Wine. Wine creates a small filesystem that looks like a Windows-filesystem with a few necessary catalogs. Like for example windows/Fonts. Your programs are then installed into this mini-filesystem into for example the "Program Files" directory.

Now for the bug I encountered. Or, I don't think that it is an actual bug per se, just an unwanted effect.

Wine typically stores its fonts in /usr/share/wine/fonts or in /usr/share/fonts/wine.
Now, if you install your own fonts, they go into the directory windows/Fonts in your mini-filesystem. This is also where all your Windows-programs will store its fonts as they think they are running on Windows.

The issue comes from the ordering of locations to search for fonts. Wine first checks the windows/Fonts directory and if it can't find the font there, then it will go to its own fonts.
So if any of your Windows-programs have installed fonts there (in my case, it was Guitar Pro which had installed a musical notation font) Then that will be searched first.

I got the issue, I believe, because the font requested by Spotify wasn't in my windows/fonts directory, and then it wasn't found among Wines core-fonts, so it defaulted to take the first font it could find - which was the Guitar Pro font.

The fix?

$ cp /usr/share/wine/fonts/tahoma.ttf ~/.wine/drive_c/windows/Fonts/a.ttf

Saturday, November 15, 2008

My hate for tapping and an introduction to modifying drivers in Ubuntu

First, a little background. On most laptops you have a touchpad which you can use to move your mouse-pointer around. Then someone came up with the twisted idea that you could use the touchpad to click on stuff. I have always turned this off, both when sitting on Windows and Linux. But for some reason, the driver-makers seem to conspire against me. In windows, the setting won't get stored on my laptop, so after every reboot, it is turned on again. In linux, well, there are a few occasions when it just turns itself on again. Not to mention that if some tool decides to modify your xorg.conf, you probably will get it turned back on again.

Some time ago, I got really tired of this and decided to download the source for the linux-driver and remove the possibility to tap on the touchpad alltogether. :)

On ubuntu you just run:

$ apt-get source xserver-xorg-input-synaptics

To download the source.
When you have downloaded it, make a copy of it, in this post I will call them $ORIG and $COPY.

The reason for this is that in Ubuntu they package unmodified source for a particular release of the software and then they have a set of patches that they apply when they build the packages. So what we want to do is to create a patch that will apply cleanly just as if it had been a part of the Ubuntu release.

Some things about structure of the source package, if you go inside $COPY, you can see a debian catalog, this is where patches and configuration is stored, you can also see a src, for source. These are the two catalogs that we will be looking at.

Let's begin by finding what it is we want to change. You can turn off tapping by setting MaxTapTime to 0 in xorg.conf, so we begin by finding where this is read with:

$ grep MaxTapTime $COPY/src/*

So, it is in synaptics.c?
This line:
pars->tap_time = xf86SetIntOption(opts, "MaxTapTime", 180);
Let's do a google search on what xf86SetIntOption is supposed to return.
So, it returns the integer that is read from xorg.conf. This will be a quite easy patch then, since we always want this value to be 0.

So, let's set everything up and start working. Begin by applying all patches that are shipped.
While standing in $COPY, run:

$ for file in `ls debian/patches`; do patch -p1 < debian/patches/$file; done"

Now it is ready for our patch. Do a:

$ cp synaptics.c synaptics.c.orig

We need the original file so we can create a patch. Open the synaptics.c file in your favorite editor (emacs) go to the pars->tap_time line and change it to: pars->tap_time = 0;.

Now it's time to create the patch, quit the editor. Run:

$ diff -Naur synaptics.c.orig synaptics.c > $ORIG/debian/patches/107_no_more_tapping.patch

Add the new file to $ORIG/debian/patches/series

Now, modify the head of the patch to have the same style as the others. It should look something like this:

$ head -n5 107_no_more_tapping.patch

Index: xfree86-driver-synaptics-0.15.2/src/synaptics.c
===================================================================
--- xfree86-driver-synaptics-0.15.2.orig/src/synaptics.c 2008-11-15 13:35:36.000000000 +0100
+++ xfree86-driver-synaptics-0.15.2/src/synaptics.c 2008-11-15 13:36:07.000000000 +0100


After you have done this, it's time to build the new deb by running:

$ apt-get build-dep xserver-xorg-input-synaptics

This will install everything you need to have in order to compile the package.

Then go to $ORIG and run:

$ dpkg-buildpackage -rfakeroot

This will create the deb for you and put it in the directory above. To install your new tap-free driver, just run:

$ dpkg -i xserver-xorg-input-synaptics_0.15.2-0ubuntu7_amd64.deb

Be aware though that when a new version is released, it will by default overwrite your patched binary.. but just keep the patch and do the same procedure then.

And for a time, it was good.

Tapping was no more.

Friday, November 14, 2008

Fun with moab/maui

So, some context, I work a lot with scheduling of computational jobs.

That means that we have a lot of jobs/programs that need to be scheduled on different resources. We do this with the scheduler moab. In order to visualize how resources are utilized we plot this into graphs.
I got this idea a few weeks ago, wouldn't it be quite fun to draw pictures in these graphs by creating reservations?

Said and done, I sat down and wrote a small python-script that takes an ascii-art image and creates reservations that you can then put into your system. :)

A text image example can be found here: image.txt

And the python script is here: generate_allocation_image.py

The result after running it a few times with different offsets;



Well, you got to do something with your spare time ;)