Building a tool

I’m thinking on doing some more work on the FreeType font hinting code sometime soon, so I’ve spent some time the last few weekends building a program to view hinted outlines. The way that hinting fonts for the screen works is that the outline is modified to better fit the grid of pixels, then the modified outline is scan-converted. My program allows looking at a magnified version of the modified outline and comparing it to the resulting pixels.

As you might guess from the spiffy, antialiased, alpha-blended graphics, I’m using Cairo to do the main drawing. It’s been a lot of fun to write a very small, limited purpose application and really nail the details. To list a few:

  • The toplevel window automatically resizes as you zoom in
    or out and change the text. But it respects the workarea
    of your desktop and scrollbars appear when the contents
    get bigger than that.
  • The 1:1 image in the upper left is actually on overlay that
    doesn’t scroll with the contents. It can be dragged around
    and if you drag it to an edge, it sticks to the edge
    as the window resizes.
  • The entire state of the application is saved to GConf,
    so the next time you start it, it remembers your last
    selected font, all the hinting and display options,
    the text being used and so forth.
  • The dropdown on the combo contains a history of the
    10 last strings you’ve used, plus a set of fixed strings
    in different scripts.
  • You can save the output to a PNG image, and the output
    is annotated with the selected font, the hinting style,
    and the 1:1 image that normally appears in the overlay.

I was suprised by how well saving the entire application state to GConf worked. There is no separation between preferences and transient state. You can just exit the viewer at any time and bring it up and it remembers where you were. This clearly isn’t the right model for most applications, but I wonder if there are places in the GNOME desktop where idea could be effectively applied; perhaps desk accessories like gcalctool, gconf-editor, and gucharmap should work like that. For the viewer, the code flow for interacting with GConf is a little unusual; instead of monitoring GConf actively as the “model” of the application, the viewer simply initializes from GConf on startup and saves changes to GConf as they happen. This allows having multiple viewers usefully running at once.

Sweet Corn

One of the best benefits of being back up North is the ability to get good, fresh sweet corn. Now, I need to say here that corn sold in a supermarket is almost certainly not fresh. Corn that wasn’t picked the same day you eat it is not fresh. If you have ever ordered an item that comes with “corn on the cob” in a restaurant in January, that’s a good sign that you have no idea what real corn tastes like. With that definition out of the way, I never was able to find a single decent ear of corn in the 6 years I lived in North Carolina. The few times I actually found local corn at a farmer’s market or farm stand it was a poor, undergrown, worm-eaten approximation of the real thing. I don’t know if the problem down there was climate, soil, or culture. But no problem here in Massachusetts so far.

So, how do you cook and eat corn? You husk it, drop it in boiling water for as short as time as possible (5-6 minutes is about right), butter it, salt it, and as soon as you can pick up the ear without burning yourself, dive in. I take no position on eating pattern; linear, spiral, and random access all work.

Corn goes well with other summer flavors. Tomatoes, fresh basil, grilled meats, and so forth. In fact, fresh corn and fresh tomatoes, with nothing but butter and salt for the corn and salt for the tomatoes is a meal fit for a king. I haven’t seen good tomatoes yet this year, but I’ve had good luck the last few weeks with other accompaniments. Last Saturday, in celebration of the beginning of corn season, I had broiled lamb chops with a peach-habeñero salsa. (slightly green peach, onion, finely chopped habeñero, red wine vinegar). This week, I made a Thai-inspired sautée of scallops with basil, garlic, fish sauce, and strips of chili. Both were easy to make, really tasty. Both went well with the corn. In the end analysis I probably preferred the scallops because they distracted less from the corn. Which, after all, was the real point of the meal. Most things you can cook 52 weeks a year these days. Corn season is 6 weeks a year, if you are lucky. Or 6 weeks after 6 years if you’ve been living down south.