Wednesday, January 6, 2010

QEMU/KVM, Windows 7, blurry text

My mom got me a copy of Windows 7 for Christmas so I could run it in virtualization under Linux for development purposes (Audacity, mostly). That's been somewhat successful. I'm using KVM/QEMU and none of the audio devices that QEMU emulates have 64-bit Win7 drivers. Maybe I'll look at writing an emulation layer for a more modern sound card (it might be slightly easier to write a new 64-bit Windows driver for one of the cards QEMU already emulates, but it might be easier to get an addition to QEMU distributed widely). Anyway. I'm mostly writing this because I just solved a smaller, odder problem: the text in Windows just looked horrible! I generally prefer my text on Kubuntu to text on Windows*, but I didn't remember it being bad on Windows.

* I think people come to prefer the fonts and rendering style of the systems they use every day. I mostly use Kubuntu, and I find text easier to read there than anywhere else. It could just be that I like the font shapes better. FreeType (X11) and ClearType (Windows) look pretty similar given the same fonts, although there are some things FreeType can't do with hinting information because of patents. I find Mac OS X's font rendering ugly and hard to read, but that's probably just because it's more different and I'm not used to it.

So these days QEMU's virtual VGA window can be resized. When you do this it just scales everything in the window. Unfortunately this makes anti-aliased, sub-pixel rendered text (ClearType) and deliberately sharp graphics (Diesel Sweeties) look really bad. KDE lets you set a window to an exact numerical size, which should fix the problem, but it doesn't; the size includes window decorations. Lame.

So I found a little program called xdotool that, among many other things, lets you resize windows from the command line by client size. Rad. It's in the Ubuntu repos, even. But setting the client size to exactly Windows' resolution didn't help.

So I took some screenshots, blew 'em up in the GIMP, and found that the window size was one pixel too large in each dimension. With my Windows resolution set to 1152x864 I actually need the QEMU window's client size to be 1151x863. I'm not sure if this is a weird problem with Windows, QEMU, or X11... but it's weird. And now that it's fixed, everything looks OK in virtualized Windows.

3 comments:

Anonymous said...

Thanks for this post. That blurriness was driving me crazy! I had set my resolution to 1024x768 and setting my window size to 1023x767 made everything clear as can be!

Anonymous said...

Thank-you! You may want to look at devilspie and or wmctrl.

Ninjix said...

Thank you for posting this. Using the xdotool windows 1151 863 corrected the blurry problem of my WinXP KVM on my Ubuntu Lucid machine.