Behdad Esfahbod's daily notes on GNOME, Pango, Fedora, Persian Computing, Bob Dylan, and Dan Bern!

My Photo
Location: Toronto, Ontario, Canada

Ask Google.

Contact info
Hacker Emblem Become a Friend of GNOME I Power Blogger
follow me on Twitter
July 2003
August 2003
October 2003
November 2003
December 2003
March 2004
April 2004
May 2004
July 2004
August 2004
September 2004
November 2004
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
December 2007
January 2008
February 2008
March 2008
April 2008
May 2008
June 2008
July 2008
August 2008
October 2008
November 2008
December 2008
January 2009
March 2009
April 2009
May 2009
June 2009
July 2009
August 2009
November 2009
December 2009
March 2010
April 2010
May 2010
June 2010
July 2010
October 2010
November 2010
April 2011
May 2011
August 2011
September 2011
October 2011
November 2011
November 2012
June 2013
January 2014
May 2015
Current Posts
McEs, A Hacker Life
Thursday, May 31, 2007
 First Year at Red Hat

Passed so fast!

My undergrad friends seem to be ending up around the Bay area one after the other. When they ask me if I'm going to give Google a try, I just tell them that I love my job at Red Hat.

Time is a jet plane, it moves too fast
Oh, but what a shame if all we've shared can't last.
I can change, I swear, oh, oh,
See what you can do.
I can make it through,
You can make it too.

You're A Big Girl Now, Bob Dylan


Thursday, May 24, 2007
 Foundations of Gtk+ Development

Yesterday I shortly reviewed the new Gtk+ book by Andrew Krause, Foundations of Gtk+ Development, that I received as an ebook thanks to Apress.

I just searched Pango and cairo in it and read those parts. All in all, pretty good. Doesn't get into Pango at all, just defined PangoFontDescription and Pango markup and uses those with Gtk+ widgets all over the place. As for cairo, it has a short (2 3 page) intro to using cairo to draw paths.

The ebook is quite searchable which is a huge advantage over the dead=tree version. So far so good, but I doubt that I'll do a more in depth review staring at the monitor (or printing the 600+ page beast). Of course the fact that I lost my last pair of glasses this past weekend doesn't help either...

Labels: , , , , ,

Tuesday, May 22, 2007
 Bug Fixing... seventeen minutes.

Labels: ,

Wednesday, May 16, 2007
 Pango OpenType Update

All other modules are ported to new OpenType API now. I really hope I've not broken any of them in the way.

In other news, Pango's Arabic module is now extended to support the N'Ko script. I believe Pango is the first Unicode rendering system to support N'Ko!

Seems like my optimization in Pango's line-breaking algorithm introduced a bug that I hope is fixed now.

Also came across this hilarious bug titled "My microwave doesn't work any more because of gnome"!

Labels: , , , , ,

Monday, May 14, 2007
 Advanced OpenType Features in Pango

Last week I worked on bringing Pango's OpenType engine into shape. Something that has been long overdue. Not anymore.

Pango can now select arbitrary OpenType script and language systems, and in near future arbitrary OpenType features too. The basic, arabic, and syriac modules are ported to use these features. More modules to follow.

Finishing off that feature is addition of another one, that pango will read env vars PANGO_LANGUAGE or LANGUAGE and use that for making better guesses to tag runs of text with languages.


First window is rendering of Pango's test-mixed.txt using the command line pango-view tool.

Second window is the same, but with env var PANGO_LANGUAGE="en:ur". As you can notice, an Arabic font more suitable in style for Urdu is selected instead of my default Persian fonts.

Third window is vertical rendering of the same text. If you look at the last, Japanese, line, in the vertical window, the brackets around the text are correctly rotated, unlike previous versions of Pango.

This and previous works are all in Pango 1.17.0.

Labels: ,

Friday, May 11, 2007
 My GNOME Board Performance

Unfortunately looks awfully like this Dilbert strip from Wednesday:


Labels: , ,

Monday, May 07, 2007
 PUZZLE: Group Strategy

Coming back from Montreal yesterday, Peyman told me the following puzzle which is probably the coolest of its kind I've ever heard. Quite the like that you try hard proving to be wrong first. Anyway:

(I first tried to write it down as prisoners and all, but gave up. Here it goes bare:)
There are 2k men numbered 1 to 2k. And a room with 2k boxes inside (also numbered 1 to 2k), and each man's number is written on a paper and placed in one of the boxes, such that every box has a number in it and the distribution is uniform.

Now there is a game (trial, whatever): each man goes into the room, opens and sees the number inside k of the boxes of his choice, and comes out, altering nothing in the room, and not communicating with anyone during the experience. Before the game starts the men have a chance to develop a strategy, but other than that they can't communicate at all. Anyway, after everyone has visited the room, if all of the men can tell in which box their number is placed, they win, otherwise they lose.

Show that the men can develop a strategy with a expected winning probability that is not less than a positive constant regardless of k.


 GNOME Teddy Bears

Patched GNOME Teddy Bear
Patched GNOME Teddy Bear
A new convert... See how he suffered in previous life. Awesome listener, wise speaker.

Charming Quebecistani GNOME Teddy Bear
Charming Quebecistani GNOME Teddy Bear
From Montreal trip this past weekend, home to second LGM. Likes his coffee in personal mug...

Brave GNOME Hacker Bear
Brave GNOME Hacker Teddy Bear
From Banff, Alberta's icy streets, working in his brand new Toronto office...

Working toghether
GNOME Teddy Bears
You see I believe in Teddy Bear Effect. (Also, nice Teddy bear photo on WP)

Labels: , , ,

Friday, May 04, 2007
 PangoCairo arbitrary shape rendering

On Tuesday I met Travis Griggs, the author of cairo Smalltalk bindings, who was presenting about cairo at IT360°. He made his slide deck using cairo and Pango, using a background and font that resembled Egyptian papyrus scroll using the cairo beetle logo instead of bullet points. I asked him how he did that and of course the hard way. I then explained how pango supports shape attributes that can be used by a custom made PangoRenderer to render arbitrary shapes.

Last night I thought there should be an easier way to do that, and so I added pango_cairo_context_set_shape_renderer().

Obligatory screenshot:

PangoCairo shape rendering

Source code.

Lets see how long I can go with a Pango feature a day. Today excluded as I'll be driving to LGM. Weekends too as I've finally got myself spending the weekend with species other than computers.

Labels: , , ,

Thursday, May 03, 2007
 Avoiding extra work

When working on justification support in Pango, I found a loop that could use some optimization.

The loop in question is to decide how much of a piece of text (called item. For normal text it typically is the rest of the paragraph) we can fit into the current line. The implementation was removing one character at a time from the end until we find a break spot and the width of remaining chars fits the available width.

Think about it. If the entire item fits the available width the loop is not reached at all, but otherwise, unless the paragraph fits in exactly two lines, we are doing a lot of extra work. Say the paragraph takes 10 lines. Then for the first line we have to remove 9 lines worth of text before finding the right break point. For next line we have to remove 8 lines... and so on. It's quadratic in the number of lines, so to speak.

What I did was to start inserting chars from the beginning of the item until no more fits.

For a really long paragraph (pango/pango-view/test-long-paragraph.txt) the number of times the loop contents are run came down from ~1,000,000 to about 13,000. Not bad.

This was all in my quest to make gedit run faster when viewing a REALLY LONG paragraph. I was under the impression that some silly quadratic algorithms in Pango are responsible for the slow speed, but apparently I'm wrong. In short, Gtk+ recreates the Pango layout on EVERY CURSOR MOVEMENT OR CURSOR BLINKING. This is mostly a result of having a very extensible and powerful text object in Gtk+ that supports multiple marks, some of them may be cursors. I've already attached a patch to improve it for cursor blinking, but that's not very interesting. I want to be able to put my finger on the left or right arrow and don't see a gedit that is frozen as a result. Way to go...

Labels: , ,

Wednesday, May 02, 2007
 Justified text with Pango not unsupported anymore.


The first paragraph has positive letter spacing, and then justified. As you see the third line didn't hvae any space chars and so is justified by applying more letter spacing. Now the Latin part has unfairly long words and short lines, but Arabic works much better than I expected.

It's a very simple greedy algorithm. Mathias Hasselmann start writing patches, and hours later and three ~100 line patches, I've got it all working and nicely interacting with letter-spacing too.

Six year old bugzilla entry here.

Labels: , ,