2010 年终总结

今年是我的生活变化较大的一年:结束了三年的研究生学业,离开长待了六年之久的北京,到奥斯陆开始我的第一份工作。所以数起来从头到尾都过得很充实:一二月份是面试、确定工作,三四月份忙学位论文,五六月忙答辩和毕业的琐事,七月份搬家、开始工作,八月到十一月都在适应新的环境,学习新的体育运动 (骑车、攀岩、滑雪等),十二月底则花了一周去西班牙旅行。感觉这一年过得飞快,但偶尔又觉得很漫长。下面还是按照[去年的格式](http://blog.jjgod.org/2010/01/01/summary-of-2009/),对今年作一简要小结。

* 最喜欢的电影:[Inception](http://www.imdb.com/title/tt1375666/)
* 最喜欢的读物:[Out of Mao’s Shadow](http://www.outofmaosshadow.com/)
* 用得最多的电子产品:[Apple iPhone 4](http://www.apple.com/iphone/)
* 参与最多的软件项目:[Qt](http://qt.nokia.com)
* 花时间最多的翻译作品:[Cocoa 编程开发者手册](http://www.amazon.com/Cocoa-Programming-Developers-Handbook-Chisnall/dp/0321639634) (未完成)

总的说来,今年写 blog 少了,写 [twitter](http://twitter.com/jjgod) 多了;花在游戏上的时间少了,出门运动的时间多了;浏览网页泡论坛 BBS 的时间少了,看书的时间多了;做自己个人项目的时间少了,花在工作上的时间多了;这些趋势并不所有都是好的,但至少多读书、多运动,有时间多走走看,正是我对明年的期望。

网页 CJK 竖排的最新进展

上个月关于 CSS 的一个重要的新闻是 [WebKit 开始支持 CJK 竖排](http://blog.timc.idv.tw/posts/han-vertical-writing-in-css3-and-javascript/) (通过 `-webkit-writing-mode`),而且时隔七年之后 (上一个版本还是 2003 年制定的),W3C 的 CSS 工作组也发布了新的 [CSS Writing Mode Level 3 工作草案](http://www.w3.org/TR/css3-writing-modes/),和以前的版本有较大的区别,WebKit 现在就是按照这个草案实现的竖排支持,虽然它的实现还不完整。下面简单介绍一下新草案的变化。

在原有草案中,`writing-mode` 属性是 `direction` 和 `block-flow` 属性的合成,你可以交叉地组合这两个属性,构成 `writing-mode`:比如 `lr-tb` 表示文字从左到右,块排列从上到下。而在新草案里,`block-flow` 不再是一个独立的概念,被并入了 `writing-mode` 中,新的 `writing-mode` 有以下几种选择:

* `horizontal-tb`: 默认情况,从上到下,从左到右的横排书写形式。

horizontal-tb
horizontal-tb

* `vertical-rl`: 块按从右到左排列,文字则从上到下,这是典型的直排情况。

vertical-rl
vertical-rl

* `vertical-lr`: 虽然是竖排,但块则从左到右排列。这主要用于内蒙古使用的[蒙古语](http://zh.wikipedia.org/zh/蒙古语字母)和[满语](http://zh.wikipedia.org/zh/满语)。

vertical-lr
vertical-lr

还可以注意到经过讨论,非常少用的从下往上横排书写形式 (`horizontal-bt`) 被去除了。

保留了 `direction` 属性,但它和 CSS2.1 中的效果一样,仍然用于控制文本在行内是从左到右还是从右到左书写,以及 Unicode BIDI 双向混合文字的情况。

同时,新增了一个 `text-orientation` 属性用于控制行内字符的旋转,例如在典型的中文竖排文稿中,拉丁字符应该顺时针旋转 90 度。目前的草案规定了以下这些模式:

* `vertical-right`: 默认的情况,将非文本语言的字符 (比如汉字中间嵌入的拉丁字符) 顺时针旋转 90 度,其他字符不变。
* `upright`: 不旋转上述字符,保持和其他字符一样的方向。(这是目前 WebKit 实现的做法,等于什么都没处理)
* `rotate-right`: 把所有字符都顺时针旋转 90 度。
* `rotate-left`: 把所有字符都逆时针旋转 90 度。
* `rotate-normal`: 在 `vertical-rl` 书写模式中等于 `rotate-right`,在 `vertical-lr` 中等于 `rotate-left`。
* `auto`: 除了对 SVG1 的 glyph orientation mode 支持以外,其他情况下等于 `vertical-right`。

下图中左侧是 `vertical-right`/`auto` 的效果,右侧是 `upright` 的效果:

最后,新增了 `text-combine` 属性用于控制在竖排时同一行内要塞进多个非 CJK 字符的情况,在日文排版中称为“縦中横”。它有两个选择:

* `none`: 不做特殊处理。
* `horizontal`: 在竖排情况下,首先浏览器应该尝试用对应字体中提供的专门的合并后的字形替代,如果没有,则浏览器可以尝试缩小这些字符以适应宽度,或者放弃合并。效果如图:

縦中横
縦中横

不过这个属性目前还很不成熟,仅仅初步把概念规范化了,短期内估计不会有浏览器尝试实现。此外这份草案还没考虑行内割注 (日文中称为 warichu) 的情况:

割注
割注

目前在 Mac OS X 下 WebKit 已经完整实现了这一版草案的 `writing-mode`,大部分的 bug 也都已经扫除 (其他平台的实现情况参见 [Koan-Sin Tan 的说明](http://lists.w3.org/Archives/Public/public-html-ig-zh/2010Dec/0019.html)),但是[还没开始实现](https://bugs.webkit.org/show_bug.cgi?id=48540) `text-orientation`,然而要保证可用的竖排效果,`text-orientation` 的支持是不可或缺的。

Apple 27″ LED Cinema Display 使用感受

ָApple 早在 7 月份的时候就随新的 iMac 和 Mac Pro 一起公布了新的 27″ LED Cinema Display,同时将原有的 24″ LED Cinema Display 降价、停产,而因为迟迟没有替代仍然一直在产的 30″ Cinema Display 也宣布销完存货不再生产,可是新的 27″ LCD 要到 9 月才可以订购,而从订购到送货在欧洲这个犄角旮旯又得等上一个月,所以直到 10 月中旬我才用上这款显示器。

技术上的评测在 anandtech 上已经非常详尽,这里不加赘述,关心技术参数比较的可以看那篇评测,这里只讲一点作为普通使用者的感受。

这款显示器的重量是 10.7 KG,接近一台 27″ iMac 的重量了,绝对不算轻,但相比以前的 Apple Display 显得薄了不少,尤其是相比 30″ ACD 所占桌面空间大为减少,我用的是一张 120x70cm 的桌子,感觉桌上放下两个这样的显示器仍然不会觉得太挤。

如同往常一样,27″ LCD 的设计非常简洁,没有外置的电源适配器,只需要从背后接一条线即可,支架设计了一个圆孔可以把线从中穿过方便整理,但支架只能调整上下角度,无法调整高度和旋转。接口也非常简洁,只有三个 USB 2.0 接口,三条连接 Mac 的接线分别是 Magsafe、Mini DisplayPort 和 USB。其中 Magsafe 可以直接给 Mac 笔记本提供电源——这几乎是 Apple 显示器唯一的“绝活”了。USB 用于同时提供与机器的数据传输和不支持 Mini DisplayPort Audio 机型的音频输出。

可是 27″ 版本的 USB 输出存在问题,表现是有时在机器休眠恢复之后就无法向显示器输出音频,音量调节 HUD 出现缓慢,Console 中也会输出一些错误信息,这个问题似乎不是硬件问题,但非常普遍,包括我在内的很多用户都遇到了,可以参见 Apple discussion 和 <a href="http://forums viagra au pharmacie maroc.macrumors.com/showthread.php?t=1027419″>macrumors 上的讨论,目前只有断开显示器电源重新接上,或者重置 SMC 两种解决方案,但效果都是临时的而非永久的。

因为是家里的环境,所以可以自己选择灯光,镜面屏幕在我这里并没有造成多大的困扰。如果觉得实在没法忍受镜面屏幕的当然 Dell 的 U2711 会是非常好的替代。因为工作性质的缘故,我不觉得在色域 (gamut) 上的缺乏对我有什么影响,但色彩的感受与我的 MacBook Pro 屏幕非常接近,这样就不需要自己调整显示器了。在有了 2560×1440 像素之后,全屏观看 720p 的 H.264 视频开始显得有点模糊了,而之前都很难看出和 1080p 的区别。

除了前面提到的问题,音频的效果其实是不错的,相比 MacBook Pro 的内置扬声器提升明显,虽然肯定不能和昂贵的音响系统比,但在桌面空间紧张,不想放多余杂物的情况下,这台显示器的扬声器效果足够令人满意了。

我之前主要的顾虑是接口实在太少,相比 Dell U2711 的所有接口都全 (DVI, HDMI, DisplayPort, VGA, Component),只有 Mini DisplayPort 实在不方便连接其他的设备,但后来考虑到手头其他设备的接口也只有 HDMI 一种了,用投影足够处理,而笔记本的 Mini DisplayPort 输出要转到 U2711 上却需要用到 Mini DisplayPort 到 Dual-link DVI 或者 DisplayPort 的转接,也稍嫌麻烦。如果实在需要把 HDMI 输出转接到 Mini DisplayPort 上,也可以用 Kanex XD

State of The Art Web Typography

We have reached the state that Web typography can be **much** better than it used to be. What kind of tools is in our hands?

* [Hyphenator](http://code.google.com/p/hyphenator/), with this JavaScript hyphenation support, reading justified text on your browser will no longer be a pain.
* [Knuth and Plass Line Breaking](http://www.bramstein.com/projects/typeset/) in JavaScript, combining this and Hyphenator then you will get beautiful typesetting like [this sample](http://www.bramstein.com/projects/typeset/flatland/).
* [optimizeLegibility](http://www.aestheticallyloyal.com/public/optimize-legibility/), CSS rule `text-rendering: optimizeLegibility;` will turn on cross browser kerning-pairs & ligatures, which is also critical for good typography. It does have some drawbacks though.
* Web fonts solutions like [TypeKit](http://typekit.com/) and high quality free web fonts from websites like [Font Squirrel](http://www.fontsquirrel.com/), provided much more vivid user experience than standard web fonts like Verdana and Georgia, but they should be chosen very carefully, otherwise the results can be much worse.
* [-moz-font-feature-settings](https://developer.mozilla.org/en/CSS/-moz-font-feature-settings), this feature, although it’s Firefox 4 only, can be very fun to experiment with, since it opens an [entire new world](http://hacks.mozilla.org/2009/10/font-control-for-designers/) of rich OpenType typography to the web. Combining this with web fonts solutions can make it even more useful.
* [-webkit-font-smoothing](http://maxvoltar.com/archive/-webkit-font-smoothing), when used in a clever way, can improve legibility (and some designers prefer grayscale antialiasing to subpixel antialiasing, that’s why it’s so popular nowadays). Unfortunately there are many existing websites abusing this CSS rule, including [Apple](http://www.apple.com) and [Twitter](http://www.twitter.com). In general, I suggest leaving it alone unless it’s absolutely necessary.
* [SmartyPants](http://daringfireball.net/projects/smartypants/) will convert ugly quotes, dashes and consecutive dots into beautiful punctuations that you really meant to use. It saves a lot of editing efforts.
* [MathJax](http://www.mathjax.org/), the only weakness of web typography comparing to [TeX](http://en.wikipedia.org/wiki/TeX) is math equations, MathJax is so good that it totally eliminated this weakness.

Think about it: what if we create an automatic web typesetting tool, combining all these efforts, how beautiful the result we will get? That’s what I am trying to do recently.

Becoming a Troll

As many of you may have known, since 19th last month, I started working for [Nokia, Qt Development Frameworks](http://qt.nokia.com) (formerly [Trolltech](http://en.wikipedia.org/wiki/Qt_Development_Frameworks)) as a software engineer. It is [my first job](http://no.linkedin.com/in/jjgod). My focus will be the graphics and text rendering area of Qt. Since the work is based at the [Oslo office of Nokia](http://qt.nokia.com/about), I’ve moved to Oslo, Norway. It is an entirely new environment for me to get used to, also a lot of challenges and fun. As Trolltech people usually call themselves, I can now officially declare myself as a “troll”.

As a side note, I will continue working on my open source projects (vim-cocoa, DictUnifier, TextEdit+, etc.) as usual, though this relocation stuff took most of my energy for a month, updates (including blog updates) will be back to normal soon.