Friday, January 25, 2008

Lambda the Ultimate! Mayest thou wrap with great haste.

While reading this interesting thread about "concept [representation?] programming", I immediately became frustrated at the massively long lines which forced me to scroll left to right and back constantly.

I started to search the web for a fix, tried using Google Translate (Chinese to English) to see if it would somehow fix the problem and when this failed, took a quick look in Opera's "view" menu. There I saw the obvious solution, "Fit to width". I kind of expected this to zoom the whole page out so small that I wouldn't be able to read anything, but nope; it just forces the page layout to conform to your browser window's width, effectively forcing word-wrapping. I love Opera.

Saturday, January 12, 2008

Dude, where's my fonts?

After a bad crash on my MacBook, I rebooted via the power button and logged in again to find my fonts banjaxed (i.e. most of them missing, notably Chinese character fonts). A cursory investigation led me to check the Font Book application, which should contain two libraries called User and Computer, which contain the default set of fonts.
In my case, only the All Fonts and Gaeilge libraries were left, both empty. Trying to add more fonts had no effect, until I eventually realised I had to create a new library as a workaround and add fonts to that.
This worked, although due to the aforementioned .CFUserTextEncoding problem I had to open Font Book every login before applications that used interesting fonts, or they wouldn't find any.

Just for the sake of it, I opened up a bug report with Apple, not really expecting to hear anything back. A few weeks later though, I did hear back from them, with a solution that worked:

"Look for a directory called: inside of /var/folders

Once you find it, copy this directory to another location and then remove it."

Doing this and rebooting the MacBook, I logged in again and started Font Book to find, lo and behold (drumroll and angel choir) that the User and Computer font libraries were automatically added again and all the fonts loaded back into them. BRILLIANT, thanks Apple, I totally didn't expect that. Thumbs up from me!

Friday, January 11, 2008

The middle finger of .CFUserTextEncoding

Recently, I had a bad crash on my MacBook while it was downloading some torrents. When I came back, I had to use the power button to restart the machine, and after the reboot, some things were broken. First, Font Book contained no fonts. Second, LyX didn't run. Third, Atlantis (a MUD client) didn't run either.

The LyX error looked like this:
LyX: Creating directory
Same as entered returned
Failed to create directory. Exiting.

And Atlantis didn't give me any error message. So, after a long time fiddling around with directory permissions, changing my group from admin to user and chowning a bit, I noticed from a dtruss log of failed and successful (by simply running as another user with sudo) runs of the affected programs that the file ~/.CFUserTextEncoding was being accessed at some point.
So I had a quick look at this file in the failure (first) and success (...second) cases:
Macintosh:~ oisin$ more .CFUserTextEncoding
Macintosh:~ oisin$ more ../yunqing/.CFUserTextEncoding
../yunqing/.CFUserTextEncoding: Permission denied
Macintosh:~ oisin$ sudo more ../yunqing/.CFUserTextEncoding

Replacing mine with 0:0 and su'ing to myself to get a new shell, I was able to run LyX and Atlantis with no problems. So, I'm not sure what this means - maybe the crash wiped out an encoding method or wrote the wrong data to that file, and when applications read from .CFUserTextEncoding they tried to look for/save their settings in the wrong place.

Confusing, but at least there's a fix.