McEs, A Hacker Life
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
Labels: redhat
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: andrewcrause, apress, book, cairo, gtk+, pango
Bug Fixing...
...in
seventeen minutes.
Labels: bug, pango
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: bug, funny, microwave, n'ko, opentype, pango
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: opentype, pango
My GNOME Board Performance
Unfortunately looks awfully like this Dilbert strip from Wednesday:
;-(
Labels: board, dilbert, gnome
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.
Labels: puzzle
GNOME Teddy Bears
Patched GNOME Teddy Bear
A new convert... See how he suffered in previous life. Awesome listener, wise speaker.
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
From Banff, Alberta's icy streets, working in his brand new Toronto office...
Working toghether
You see I believe in Teddy Bear Effect. (Also, nice Teddy bear photo on WP)
Labels: gnome, GNOME foot logo, office, Teddy bear
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:
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: cairo, gnome, pango, pangocairo
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: gtk+, pango, performance
Justified text with Pango
...is 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: pango, screenshot, typography