Help, NUMLOCK is Broken!

I can’t remember after which update (of Gnome/Ubuntu) this happened, but each time when I fire up the Gnome Calculator and start hitting the numbers on my keyboard’s keypad, nothing appears in the calculator’s display! Aha, of course, NUMLOCK turned off. So I hit the NUMLOCK key and start banging on the keypad again. Still no numbers appear, but… What the heck, the mouse is moving?

After consulting the all-knowing Google, I found the cause of this rather interesting behavior. Open System -> Preferences -> Keyboard. Then go to the Mouse Keys tab. Now here’s the million dollar question. Why would somebody _ever_ want to move its mouse pointer with the keypad? Maybe because you broke your mouse slamming it on your desk because you we’re so irritated that you couldn’t use your keypad? I don’t know. I’ve never had the urge to control my mouse pointer using the keyboard. Maybe they’d called it keypad-pointer if it was meant to be controlled by the keypad.

Well, they didn’t, so press Shift+NUMLOCK. This will uncheck the “Pointer can be controlled using the keypad” checkbox. Why was this box checked in the first place? Maybe its the default. Or maybe I once accidentally held down the shift key when I pressed NUMLOCK.

That must be it.

Coding Standards, But Why?

I already had a long standing draft to write something up about coding standards. To be more specific, coding standards about coding style. I’ve had many, no, too many (heated) discussions about coding standards and coding style, so I was — and am — reluctant to say something publicly about the topic. However, sometimes the momentum is just right, and you can’t resist.

As a developer, source code is your deliverable, it is the thing you produce, and you should try to make it look good. But what is good? How should it look? To debate this and find a compromise, you could as well host your own COP15. The results will be as disappointing. There is no such thing as the Best Looking Coding Style.

However, I do firmly believe in uniform coding style. In an independent team, all produced code style should be consistent. At all times. No exceptions. And I mean it: No Exceptions! Use iron fist if needed.

Well that’s what I believe. Do I need arguments? I think not; consistent coding style is intuitively a Good Thing. Unfortunately when talking to other developers, they want arguments. Of course — who doesn’t want arguments when somebody asks you to change habits?

So, to get back to the momentum I started with, while me and a colleague were in an email discussion with a certain module’s author about adapting his code into our team’s code base, the perfect opportunity revealed itself for me to get back to the dust-collecting coding standards post again.

My colleague wrote:

Just let me emphasize that we think style and code readability and consistency really is important, which is different from what a lot of people who write code think: if it works and the design is good, the code is good. This only holds when you’re the only one working on it, as soon as multiple people get involved it’s a very good thing to make all the code look uniformly, and keep the code readable and properly commented.

The main argument is that it helps shared ownership of the code (i.e. other people don’t feel reluctant editing your code to fix bugs, and won’t assume it is crap because it looks messy, to play the broken-window theory: it’s already crap so why should I care fixing it). Having all the code look the same also helps spotting inconsistencies, like parameters or functions that should be private but are public, debug code that is actually not debug code, comments that are misplaced and confusing etc.

It’s all a combination of minor nitpicking, but taking all of it together it definitely adds substantial value to a shared codebase.

Need I say more?

Ubuntu’s Small Arial

Being spoiled with the near perfect font rendering of Mac OS X on my MacBook, I always found Linux’ font appearance to be a bit behind. Especially in ye old days before libXft and FreeType2, font rendering in X11 applications was just plain ugly. However, with the introduction of font hinting, things have been improved a lot. Especially slight hinting looks very good.

As of Jaunty Jackalope, slight hinting (or “Subpixel Smooting” in Ubuntu terms) became the default in Ubuntu. But actually I kept reverting back to “Best Contrast” simply because of one annoying adverse effect of “Subpixel Smoothing”: Arial becomes too small on certain web pages. That is, on my 22″ 1920×1200 LCD screen at work. Too bad. No subpixel smoothing at work for me.

Last week, with the release of Karmic Koala, I decided to revisit my subpixel smoothing choice again. I like it, so I found it was time to resolve my Arial 12px issue once and for all, so I could have my subpixel smoothing at work. So after the install finished, I switched to “Subpixel Smoothing” using the System -> Preferences -> Appearance -> Fonts tab. Ahh, very nice… Except for Arial when I start browsing. Actually its even only Arial at a size of 12px.

So here’s what I need to solve: I don’t want any other font to change, it’s really only Arial 12px that’s bugging me. Yes, I’m being a nitpicker here, but hey, there are just too many websites that use Arial 12px, starting with my iGoogle start page already. The easiest workaround option is to remove Microsoft’s TrueType core fonts package, so Arial isn’t used, but a replacement. However, most websites do look a lot better with Microsoft’s core web fonts, and besides that, I hate workarounds. I like real solutions. So that’s when I decided to dive into fontconfig to see if that could fix my problem.

I couldn’t imagine it being so simple as putting a .fonts.conf in your home dir containing:




  
    Arial
    12
    13
  

But it really is as simple as that. In human language, the XML file tells fontconfig to set the pixelsize of Arial to 13 when any program requests Arial with pixelsize 12. How beautiful.