Wednesday, November 22, 2006

Resolution independence for icons

Jakub Steiner wrote an interesting blog about woes of creating resolution independent icons. It's a problem I've been thinking about during the last few days, one that has been solved, at least to some extend, already.

It was solved for fonts. Grid-fitting (aka. "font hinting") is a crucial step on the way to produce legible output at small sizes for any font. Hinting can be manual (e.g TrueType has a stack-based language for it, each glyph in the font contains its own little hint program and as a result of running that program control points for the outlines can be adjusted in any way the creator of the hints desired) or automatic (as used by FreeType). An interesting medium is described in "Example-Based Hinting of TrueType Fonts" paper, in which a method of reusing hints from one font for another are described. All in all it's a very common problem for fonts.

The iSlayer blog that Jakub mentioned makes it very clear we need it fast. His example showing how much worse his logo looks in the vector form than the as bitmap looks almost precisely like the "example of hinting" image that can be found on Wikipedia:
(The upper sample in each case is unhinted)
When talking about fonts we're just dealing with a subset of our exact problem.

In Qt, Gunnar just implemented support for non-scaling stroke, which is great. Now we need to figure out a way of doing automatic hinting for vector shapes and we'll be set.

I've always been all for manual adjustment of icons on a pixel-by-pixel basis, simply because they looked a lot better, but during the last few days I've became convinced that we can, in fact, create resolution independent icons. Or let me rephrase, not "resolution independent icons" but "icons that preserve their good looks across resolutions". We have the former, we need the latter.

I'm taking a week off and that's exactly what I'll work now.

I think manual hinting is too cumbersome and we'd need a new container format for icons to make it really work. A way of specifying a whole icon theme along hints for each icon to make them look good across different resolutions wouldn't necessarily be a bad idea. In fact that would be great, it's the problem of developing the way of storing and producing those hints that would be quite challenging. XML format (with some namespace of course) that can be embedded right in the SVG's would probably work fairly well but I'm afraid wouldn't be enough. Then there's also a question of how would we get artists to create those hints.

No, I think auto-hinting makes a lot more sense here. The research FreeType people did in that area is outstanding.

All in all, I think I can make it work =)

Oh, and if you have a SVG icon that you hand-adjusted to produce a better looking bitmap, I'd appreciate a lot if you could send me both examples via email to <my first name> address so that I have some testcases to work with :)

Monday, November 20, 2006

WebKit and new examples

With 4.3 snapshots out I updated the list of my examples with a few new ones:
Animation along a path,

And text on a path that I mentioned in the previous blog.

And two examples showing perspective transformations here and here.

Last week I finally got a new laptop. I bought a Sony Vaio SZ340. Mainly because it came with two gpu's, and for a 13"" laptop that's a very unique feature. In general everything works ok (sleeping, cpu frequency scaling, ethernet, wifi, audio). Battery life for some reason is abysmal at around 1.5 hours even though both cores seem to be scaled correctly. I haven't had the time or motivation to figure out what's causing it though. All in all I'm pretty happy with it so far.

In completely unrelated news I became a WebKit reviewer. To answer all the questions about what does that mean for KDE I have to say that right now it doesn't mean anything. KDE is a community, in which technical decisions emerge in the process of natural selection. If we'll manage to get WebKit Qt/KDE ports working better than KHTML does right now, the transition from our own KHTML repository is going to be fluent and natural. If we won't be able to do that, then we'll still have our own version of KHTML. In my opinion, working on WebKit is, from a purely pragmatic point of view, the right thing to do. Working on new features and maintaining a web engine are very complex tasks that we can make a lot, lot simpler by sharing the burden with WebKit contributors.

Tuesday, November 07, 2006

Text on a path

Yesterday a rather large selection of trolls went to see Borat and while waiting for the movie to start Simon and I started talking about adding support for layouting of text on a path in Qt. I've sat down today, did the necessary math and added some extra members to QPainterPath and QBezier to make it all work. As always I wrote a short demo to illustrate what I'm talking about. I felt a little guilty tough because while I never blog about politics I see more and more people on planetkde feeling obliged to share their opinions on the world of politics. So my hard hitting politically charged statement for today is "i really like cookies". Discuss among yourselves.
With visual aids the results of it all are shown in this short Ogg Theora video file here and the screenshots look like this:

It's actually pretty neat (the code, not the fact that I like cookies). It's not yet integrated at all within the QTextDocument (also the code and not the cookies) framework but hopefully we'll be able to figure something out (both the code and the cookies) before Qt 4.3.

Thursday, November 02, 2006

Expressing myself

Simon and I went for a few days to Berlin. It was a lot of fun. Being able to hang out with Ellen, Scott, Espen and Matthias is always great.
Ellen is vegetarian, so thanks to her I've eaten better in Berlin than I think I did the whole last year (granted that my frame of reference is all messed up when it comes to food, but still).
On Tuesday Scott dragged us to a free jazz concert. Simon even contemplated joining and playing along. I was busy being generally freaked out. In the middle of the thing one of the guys playing, walked away from his keyboard, lied down in the middle, on his back, hiked his legs way up in the air and started wiggling his feet. Everyone was clapping and cheering. I've learned that he was not "messed up" as I, personally thought, but was "expressing himself" which is a good thing. I'm not 100% certain how to distinguish between the two but I'm sure I can use this "expressing myself" thing to my advantage. In fact Simon and I kept expressing ourselves throughout our stay in Berlin by getting lost all the time. It's not that we had no clue where we were going - we were simply trying to show that humans, as individuals, are sometimes getting lost in this great world, but no matter how lost one gets, how smelly the subway is that took one the wrong direction or how funny the word "wurst" is, there always is Ellen waiting with some food or maybe even Snapple's... Or something along those lines. I'm still trying to work out this pretentious art thing, but I think I almost got it.
Simon and I even had a few minutes to look at WebKit. I haven't looked at it since we have done the initial port. We fixed most of the serious issues. The rendered pages should all look fine.

I still have 3 patches in WebKit's bugzilla but hopefully they'll get in soon. It feels a little weird to be writing patches, for code that I wrote, fixing my bugs in a project I've been working on for so long and not being able to commit myself. Waiting for others to review and commit my patches to my code is a little, well, silly. But I understand, they changed some style rules and are trying to keep it consistent, while my motivation to read "style guide" documents is basically zero so it's ok to have people look over the patches to make sure they match the style guide.

Right now it mostly sucks for me because I'm forced to keep a few patchsets and since a few of them are not in the main repository, I have to be reverting them to work on fixing something else and wait for them to be committed to the main repository. I think it will take me two or three days of spare-time work to get it to a point where it's more/less usable and once it's there I can comfortably leave it to George and Niko who did amazing job up till now. Plus there seems to be great interest in it from others. Personally, with my todo, I couldn't be bothered to work like I am right now - maintaining local patchsets and reverting and applying them over again, that workflow is just too painful to keep it up. I have this strange perversion where I like to commit my patches to my code myself =) But as I found out in Germany, that's not weird, that's just me expressing myself.