<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jjgod / blog &#187; Browsers</title>
	<atom:link href="http://blog.jjgod.org/category/browsers/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jjgod.org</link>
	<description>Random notes &#38; thoughts by Jiang Jiang.</description>
	<lastBuildDate>Mon, 16 Jan 2012 11:08:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>浏览器如何渲染文本</title>
		<link>http://blog.jjgod.org/2011/04/09/how-do-browsers-render-text/</link>
		<comments>http://blog.jjgod.org/2011/04/09/how-do-browsers-render-text/#comments</comments>
		<pubDate>Sat, 09 Apr 2011 11:39:54 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[gecko]]></category>
		<category><![CDATA[harfbuzz]]></category>
		<category><![CDATA[icu]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=763</guid>
		<description><![CDATA[浏览器是我们最常用的软件之一，文本又是网页中最主要的元素，在浏览器显示文本的过程中有许多有趣的细节，值得展开来讲讲，或许能减少一些误解。这是一个比较粗略的，概括性的介绍，尽可能不涉及过多的技术细节和具体实现，而立足于给 Web 开发者和设计师提供一些正确的概念。 下面的介绍主要根据我对 WebKit 和 Gecko (Firefox) 的印象来谈，其他的浏览器也大致相同，如有阙漏之处欢迎指出。 解码 当浏览器收到来自 Web 服务器的网页数据之后，第一步是要把它解码成可以阅读的文本，因为历史原因，不同区域和语言的网页可能会使用不同的编码方式，而浏览器判断编码主要是依据以下方法： Web 服务器返回的 HTTP 头中的 Content-Type: text/html; charset= 信息，这一般有最高的优先级； 网页本身 meta header 中的 Content-Type 信息的 charset 部分，对于 HTTP 头未指定编码或者本地文件，一般是这么判断； 假如前两条都没有找到，浏览器菜单里一般允许用户强制指定编码； 部分浏览器 (比如 Firefox) 可以选择编码自动检测功能，使用基于统计的方法判断未定编码。 分段 编码确定后，网页就被解码成了 Unicode 字符流，可以进行进一步的处理，比如 HTML 解析了，不过我们这里跳过 HTML/XML 解析的细节，单讲得到了解析后的文本元素之后该怎么处理。 因为我们得到的文本可能是很多种语言混杂的，里面可能有中文、有英文，它们可能要用不同的字体显示；也可能有阿拉伯文、希伯来文这种从右到左书写的文字；也有可能涉及印度系文字这样涉及复杂布局规则的文字；另外，还可能有网页内自己指定的文本语言，比如 &#60;span lang="jp"&#62;日本语&#60;/span&#62; 这样的标记，使得日文汉字可以使用日文字体显示 (因为 Han Unification 导致这些汉字和中文里的汉字使用同样的代码点，尽管很多写法不同)，"lang" 属性也可以在 HTTP 头、&#60;meta&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>浏览器是我们最常用的软件之一，文本又是网页中最主要的元素，在浏览器显示文本的过程中有许多有趣的细节，值得展开来讲讲，或许能减少一些误解。这是一个比较粗略的，概括性的介绍，尽可能不涉及过多的技术细节和具体实现，而立足于给 Web 开发者和设计师提供一些正确的概念。</p>

<p>下面的介绍主要根据我对 WebKit 和 Gecko (Firefox) 的印象来谈，其他的浏览器也大致相同，如有阙漏之处欢迎指出。</p>

<h4>解码</h4>

<p>当浏览器收到来自 Web 服务器的网页数据之后，第一步是要把它解码成可以阅读的文本，因为历史原因，不同区域和语言的网页可能会使用不同的编码方式，而浏览器判断编码主要是依据以下方法：</p>

<ol>
<li>Web 服务器返回的 HTTP 头中的 <a href="http://www.w3.org/International/O-HTTP-charset"><code>Content-Type: text/html; charset=</code></a> 信息，这一般有最高的优先级；</li>
<li>网页本身 <code>meta</code> header 中的 <a href="http://www.w3.org/International/questions/qa-html-encoding-declarations#html5charset">Content-Type</a> 信息的 <code>charset</code> 部分，对于 HTTP 头未指定编码或者本地文件，一般是这么判断；</li>
<li>假如前两条都没有找到，浏览器菜单里一般允许用户强制指定编码；</li>
<li>部分浏览器 (比如 Firefox) 可以选择编码自动检测功能，使用<a href="http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html">基于统计的方法</a>判断未定编码。</li>
</ol>

<h4>分段</h4>

<p>编码确定后，网页就被解码成了 Unicode 字符流，可以进行进一步的处理，比如 HTML 解析了，不过我们这里跳过 HTML/XML 解析的细节，单讲得到了解析后的<a href="https://developer.mozilla.org/en/DOM/Text">文本元素</a>之后该怎么处理。</p>

<p>因为我们得到的文本可能是很多种语言混杂的，里面可能有中文、有英文，它们可能要用不同的字体显示；也可能有阿拉伯文、希伯来文这种从右到左书写的文字；也有可能涉及<a href="http://en.wikipedia.org/wiki/Indic_scripts">印度系文字</a>这样涉及复杂布局规则的文字；另外，还可能有网页内自己指定的文本语言，比如 <code>&lt;span lang="jp"&gt;日本语&lt;/span&gt;</code> 这样的标记，使得日文汉字可以使用日文字体显示 (因为 <a href="http://en.wikipedia.org/wiki/Han_unification">Han Unification</a> 导致这些汉字和中文里的汉字使用同样的代码点，尽管很多写法不同)，<code>"lang"</code> 属性也可以在 HTTP 头、<code>&lt;meta&gt;</code> 或者 <code>&lt;html&gt;</code> 出现，用于标记整个文档的<a href="http://www.w3.org/International/tutorials/language-decl/#Slide0090">全局语言</a>，通常这是一种好的习惯，方便浏览器进行字体匹配。</p>

<p>为了统一处理所有这些复杂的情况，我们要将文本分为由不同语言组成的小段，在有的文本布局引擎里，这个步骤称为“itemize”，分解后的文本段常被称作“text run”，但是具体划分的规则可能根据不同的引擎有所区别，比如 <a href="http://www.freedesktop.org/wiki/Software/HarfBuzz">HarfBuzz</a> 和 <a href="http://site.icu-project.org/">ICU</a> 一般是根据要使用的不同排版类来划分 (常称作“shaper”)，比如英语和法语可能使用同一个 shaper 排版，那么相邻的英语和法语文本就会划分到同一个 run 里，而希伯来文需要另一个 shaper，就划分到它自己的 run 里，以 HarfBuzz 为例，它有这样一些 shaper：</p>

<ul>
<li>通用的 (适用于中文、英文等等大多数布局规则简单的语言)</li>
<li><a href="http://en.wikipedia.org/wiki/Arabic_language">阿拉伯文</a></li>
<li><a href="http://en.wikipedia.org/wiki/Hebrew_language">希伯来文</a></li>
<li><a href="http://en.wikipedia.org/wiki/Indic_scripts">印度系文字</a></li>
<li><a href="http://en.wikipedia.org/wiki/Khmer_language">高棉文</a></li>
<li><a href="http://en.wikipedia.org/wiki/Burma#Language">缅文</a></li>
<li><a href="http://zh.wikipedia.org/zh-cn/諺文">谚文</a></li>
</ul>

<p>不少浏览器还会在这个划分下面，在确定具体使用的字体之后，根据使用字体的不同划分更细的 run，这种 run 可能称作“SimpleTextRun”，每个都会使用和相邻不同的字体，最后把它们逐一交给 shaper 进行排版得到要绘制的字形，这样一来，shaper 的工作就被简化为<strong>在确定的语言、确定的字体下排版确定的文本，生成对应的字形和它们应该放置的位置、占用的空间</strong>。下面先详细说说确定字体的步骤。</p>

<h4>字体</h4>

<p>说到字体，首先必须提到的就是 CSS 里的 <a href="http://www.w3.org/TR/css3-fonts/"><code>font</code></a> 和 <code>font-family</code> 等规则。比如这样的规则：</p>

<pre><code>p { font-family: Helvetica, Arial, sans-serif; }
strong { font-weight: bold; }
</code></pre>

<p>如果对于这样一段文本：</p>

<pre><code>&lt;p&gt;A quick brown fox &lt;strong&gt;jumps&lt;/strong&gt; over the lazy dog.&lt;/p&gt;
</code></pre>

<p>表示这个段落里优先使用 Helvetica 这个 family 的字体，如果找不到，就找 Arial，如果还是找不到，就用浏览器设置的默认非衬线字体 (有的浏览器，比如 Safari 只给你一个设置，有的像 Firefox 则允许根据不同语言设置，这时可以根据前面分析得到的文本 run 语言信息来判断该用哪个)，这个过程非常简单，大家都很好理解。稍微复杂一点的是“jumps”，它应该继承父元素的 <code>font-family</code>，也用 Helvetica，但不用默认的 Regular，而用 Bold 版本，假如找不到 Helvetica Bold，就找 Arial Bold，否则就找浏览器设置的那个字体的 Bold 版本，假如都没有呢？就要考虑用人工伪造的方式来显示粗体了，这个且按下不谈，先看对于中文常见的情况：CSS 指定的字体没有覆盖我们需要的文本时，该怎么做。比如还是上面的 CSS 规则，但对这样的文本：</p>

<pre><code>&lt;p&gt;一只敏捷的狐狸...&lt;/p&gt;
</code></pre>

<p>这里的“一只敏捷的狐狸”该用什么字体呢？假设 CSS 里具体指定了中文字体，比如 <code>Helvetica, STHeiti, sans-serif</code>，那很简单，按照英文字体一样的规则来判断：逐个字符尝试当前的字体是否提供了针对该字符的字形，如果没有则尝试下一个，要是到了最后都没找到匹配的字体呢？CSS 规范里只简单的说执行“system font fallback”，但这个过程在不同的浏览器下可能很不一样，比如 WebKit 会使用 <code>font-family</code> 列表里的<strong>第一个</strong>字体和这段文本所属的语言来寻找 fallback 字体，像 Times 这样的 serif 字体对应的中文 fallback 字体，在 Mac OS X 下是华文宋体 (STSong)；而 Firefox 则会根据 <code>sans-serif</code> 这样的通用 font family 和对应的语言匹配到设置中针对对应语言的默认字体，比如在 Mac OS X 默认的中文非衬线字体是华文黑体 (STHeiti)。Linux 下一般通过 <a href="http://fontconfig.org">fontconfig</a> 去根据语言、风格等参数来选择 fallback，但不同浏览器的实现还可能有区别；Windows 下则一般会使用系统的 Font Linking 机制，根据注册表内的 <a href="http://technet.microsoft.com/en-us/library/cc757457(v=ws.10).aspx">FontSubstitutes</a> 信息来寻找。因为在这里不同的浏览器可能有不同的行为，所以建议<strong>在 CSS 中写明对应平台该用的字体</strong>。</p>

<p>具体的字体选择还有一些不太容易注意的细节，也是各个浏览器差异比较大的一点，可能会出现这样一些问题：</p>

<ul>
<li>是否支持用字体的 PostScript name 选择：如 STHeiti 的 Light 版本又称作 <code>STXihei</code>，或者是否能用 full name 选择：有的浏览器不能正确地将 CSS 里对字体的 <code>font-weight</code> 或者 <code>font-style</code> 等要求映射到特定的字体上，尤其是在字体使用了非标准的 style 命名的情况下，考虑到很多厂商有自己的字体命名规则，这其实很容易出现，像 Helvetica Neue 的 UltraLight, Light, Regular, Medium, Bold 这些不同的 weight，是怎么对应到 CSS <a href="http://www.w3.org/TR/css3-fonts/#descdef-font-weight"><code>font-weight</code></a> 的 100 到 900 数值上的？这就是特别容易出现 bug 的地方。 </li>
<li>是否支持按 localized name 选择：比如能不能用 <code>"宋体"</code> 来代表 <code>"SimSun"</code>。以 Mac OS X 下的浏览器为例，Firefox 支持这样的写法，但基于 WebKit 的浏览器一般不支持，这样的问题 CSS 规范没有限定，所以无论哪种情况都是允许的。</li>
</ul>

<p>总的说来，如果要保证最大限度的兼容性，在 CSS 书写的时候应该<strong>尽可能选择明确、不容易出错的写法，尽量少隐式地让浏览器自己确定</strong> (be explict instead of implict)，虽然隐式写法通常比较简洁，但除非你 100% 确定想支持的浏览器在你想支持的平台下都能支持这个写法，否则还是不应该轻易用。</p>

<p>CSS3 新增的 <code>@font-face</code> 规则则是对于现有规则的扩展，提供了 web fonts 功能，但字体匹配算法的逻辑并没有改变，详细的算法可以看 <a href="http://www.w3.org/TR/css3-fonts/#font-matching-algorithm">CSS 规范里的说明</a>。</p>

<h4>渲染</h4>

<p>当确定了字体以后，就可以将文本、字体等等参数一起交给具体的排版引擎，生成字形和位置，然后根据不同的平台调用不同的字体 rasterizer 将字形转换成最后显示在屏幕上的图案，一般浏览器都会选择平台原生的 rasterizer，比如 Mac OS X 下用 Core Graphics，Linux/X11 下用 FreeType，Windows 下用 GDI/DirectWrite 等等。关于这个步骤，typekit 的这篇 <a href="http://blog.typekit.com/2010/10/15/type-rendering-operating-systems/">blog</a> 可以作为参考。各个浏览器的差异主要来自使用的排版引擎可能对不同的语言支持有差异，调用 rasterizer 使用的参数可能有差异 (比如是否启用 subpixel rendering、使用的 hinting 级别等等)，但在同一个操作系统下的效果差别不会很大。</p>

<h4>建议</h4>

<p>基于以上的介绍，可以尝试提出一个在现有浏览器下，针对中文用户的，书写 CSS 字体选择规则的建议，如下：</p>

<ol>
<li>首先确定要选择字体的元素应该使用的字体风格，比如是衬线字体、非衬线字体还是 cursive、fantasy 之类的；</li>
<li>确定了风格之后，先选择西文字体，优先把平台独特的、在该平台下效果更好的字体写上，比如 Mac OS X 下有 Helvetica 也有 Arial，但 Helvetica (可能) 效果更好，Windows 下则一般只有 Arial，那么写 <code>Helvetica, Arial</code> 就比 <code>Arial, Helvetica</code> 或者只有 <code>Arial</code> 更好；</li>
<li>然后列出中文字体，原则相同，多个平台共有的字体应该尽量放在后边，独有的字体放在前面，还需要照顾到 Mac OS X/Linux 下一般用户习惯用(细)黑体作为默认字体，Windows 下习惯以宋体作为默认字体的情况，比如 <code>STXihei, SimSun</code> 这样的写法比较常见，如果写作 <code>SimSun, STXihei</code>，但 Mac OS X 上装了 SimSun 效果就不会太好看。</li>
<li>最后还是应该放上对应的 generic family，比如 <code>sans-serif</code> 或者 <code>serif</code>。</li>
<li>尽量用字体的基本名称 (比如 English locale 下显示的)，而不要用本地化过的名称。除非特殊情况 (Windows 下“某些”浏览器在特定编码下只能支持本地化的字体名称)。Mac OS X 下字体名称可以用 Font Book 查到 (菜单 Preview -> Show Font Info)，Windows 下字体信息在微软的<a href="http://www.microsoft.com/typography/fonts/product.aspx">网站</a>可以得到，Linux/X11 下可以使用 <code>fc-list</code> 命令查到。</li>
<li>字体名称中包含空格时记住用引号扩起，比如 <code>"American Typewritter"</code> 和 <code>"Myriad Pro"</code>。</li>
<li>文档开头最好指明语言，比如 <code>&lt;html lang="zh-CN"&gt;</code>，可以使用的语言标记参见 <a href="http://www.w3.org/International/articles/language-tags/">W3C 的说明</a>。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2011/04/09/how-do-browsers-render-text/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>网页 CJK 竖排的最新进展</title>
		<link>http://blog.jjgod.org/2010/12/28/new-css3-writing-modes/</link>
		<comments>http://blog.jjgod.org/2010/12/28/new-css3-writing-modes/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 15:13:25 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[vertical]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=732</guid>
		<description><![CDATA[上个月关于 CSS 的一个重要的新闻是 WebKit 开始支持 CJK 竖排 (通过 -webkit-writing-mode)，而且时隔七年之后 (上一个版本还是 2003 年制定的)，W3C 的 CSS 工作组也发布了新的 CSS Writing Mode Level 3 工作草案，和以前的版本有较大的区别，WebKit 现在就是按照这个草案实现的竖排支持，虽然它的实现还不完整。下面简单介绍一下新草案的变化。 在原有草案中，writing-mode 属性是 direction 和 block-flow 属性的合成，你可以交叉地组合这两个属性，构成 writing-mode：比如 lr-tb 表示文字从左到右，块排列从上到下。而在新草案里，block-flow 不再是一个独立的概念，被并入了 writing-mode 中，新的 writing-mode 有以下几种选择： horizontal-tb: 默认情况，从上到下，从左到右的横排书写形式。 vertical-rl: 块按从右到左排列，文字则从上到下，这是典型的直排情况。 vertical-lr: 虽然是竖排，但块则从左到右排列。这主要用于内蒙古使用的蒙古语和满语。 还可以注意到经过讨论，非常少用的从下往上横排书写形式 (horizontal-bt) 被去除了。 保留了 direction 属性，但它和 CSS2.1 中的效果一样，仍然用于控制文本在行内是从左到右还是从右到左书写，以及 Unicode BIDI 双向混合文字的情况。 同时，新增了一个 text-orientation [...]]]></description>
			<content:encoded><![CDATA[<p>上个月关于 CSS 的一个重要的新闻是 <a href="http://blog.timc.idv.tw/posts/han-vertical-writing-in-css3-and-javascript/">WebKit 开始支持 CJK 竖排</a> (通过 <code>-webkit-writing-mode</code>)，而且时隔七年之后 (上一个版本还是 2003 年制定的)，W3C 的 CSS 工作组也发布了新的 <a href="http://www.w3.org/TR/css3-writing-modes/">CSS Writing Mode Level 3 工作草案</a>，和以前的版本有较大的区别，WebKit 现在就是按照这个草案实现的竖排支持，虽然它的实现还不完整。下面简单介绍一下新草案的变化。</p>

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

<ul>
<li><p><code>horizontal-tb</code>: 默认情况，从上到下，从左到右的横排书写形式。
<div class="wp-caption aligncenter" style="width: 229px"><img class="centered" alt="horizontal-tb" src="http://www.w3.org/TR/css3-writing-modes/horizontal.png" title="horizontal-tb" width="219" height="300" /><p class="wp-caption-text">horizontal-tb</p></div></p></li>
<li><p><code>vertical-rl</code>: 块按从右到左排列，文字则从上到下，这是典型的直排情况。
<div class="wp-caption aligncenter" style="width: 307px"><img class="centered" alt="vertical-rl" src="http://www.w3.org/TR/css3-writing-modes/vertical-rl.png" title="vertical-rl" width="297" height="191" /><p class="wp-caption-text">vertical-rl</p></div></p></li>
<li><p><code>vertical-lr</code>: 虽然是竖排，但块则从左到右排列。这主要用于内蒙古使用的<a href="http://zh.wikipedia.org/zh/蒙古语字母">蒙古语</a>和<a href="http://zh.wikipedia.org/zh/满语">满语</a>。
<div class="wp-caption aligncenter" style="width: 310px"><img class="centered" alt="vertical-lr" src="http://www.w3.org/TR/css3-writing-modes/vertical-lr.png" title="vertical-lr" width="300" height="191" /><p class="wp-caption-text">vertical-lr</p></div></p></li>
</ul>

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

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

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

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

<p>下图中左侧是 <code>vertical-right</code>/<code>auto</code> 的效果，右侧是 <code>upright</code> 的效果：
<img class="centered" alt="" src="http://www.w3.org/TR/css3-writing-modes/vert-latin-layouts.png" title="text-orientation" class="alignnone" width="104" height="205" /></p>

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

<ul>
<li><code>none</code>: 不做特殊处理。</li>
<li><code>horizontal</code>: 在竖排情况下，首先浏览器应该尝试用对应字体中提供的专门的合并后的字形替代，如果没有，则浏览器可以尝试缩小这些字符以适应宽度，或者放弃合并。效果如图：
<div class="wp-caption aligncenter" style="width: 131px"><img class="centered" alt="縦中横" src="http://www.w3.org/TR/css3-writing-modes/tate-chu-yoko.png" title="縦中横" width="121" height="326" /><p class="wp-caption-text">縦中横</p></div></li>
</ul>

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

<div class="wp-caption aligncenter" style="width: 301px"><img alt="割注" src="http://www.w3.org/International/articles/css3-text/images/Slide0190b.gif" title="割注" width="291" height="59" /><p class="wp-caption-text">割注</p></div>

<p>目前在 Mac OS X 下 WebKit 已经完整实现了这一版草案的 <code>writing-mode</code>，大部分的 bug 也都已经扫除 (其他平台的实现情况参见 <a href="http://lists.w3.org/Archives/Public/public-html-ig-zh/2010Dec/0019.html">Koan-Sin Tan 的说明</a>)，但是<a href="https://bugs.webkit.org/show_bug.cgi?id=48540">还没开始实现</a> <code>text-orientation</code>，然而要保证可用的竖排效果，<code>text-orientation</code> 的支持是不可或缺的。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2010/12/28/new-css3-writing-modes/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>State of The Art Web Typography</title>
		<link>http://blog.jjgod.org/2010/10/28/web-typography/</link>
		<comments>http://blog.jjgod.org/2010/10/28/web-typography/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 09:39:47 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=709</guid>
		<description><![CDATA[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, with this JavaScript hyphenation support, reading justified text on your browser will no longer be a pain. Knuth and Plass Line Breaking in JavaScript, combining this and Hyphenator then [...]]]></description>
			<content:encoded><![CDATA[<p>We have reached the state that Web typography can be <strong>much</strong> better than it used to be. What kind of tools is in our hands?</p>

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

<p>Think about it: what if we create an automatic web typesetting tool, combining all these efforts, how beautiful the result we will get? That&#8217;s what I am trying to do recently.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2010/10/28/web-typography/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web 字体的出路在哪里？</title>
		<link>http://blog.jjgod.org/2009/04/22/web-fonts/</link>
		<comments>http://blog.jjgod.org/2009/04/22/web-fonts/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:59:03 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[fonts]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=407</guid>
		<description><![CDATA[浏览器直接可用的 Web 字体在去年被重新提起，可是没过一段时间就沉寂下去，最近一期 A List Apart 上 Jeffrey Zeldman 采访 David Berlow 的这篇 Real Fonts on the Web 又引起了新一轮的讨论，这里摘录一些有趣的话。 David Berlow: How important dynamically rendered type is to design and use on the web must now be clear. In addition, the only other option—that the type industry cede its intellectual property to the public without [...]]]></description>
			<content:encoded><![CDATA[<p>浏览器直接可用的 Web 字体在去年被重新提起，可是没过一段时间就沉寂下去，最近一期 <a href="http://www.alistapart.com/">A List Apart</a> 上 Jeffrey Zeldman 采访 David Berlow 的这篇 <a href="http://www.alistapart.com/articles/realfontsontheweb">Real Fonts on the Web</a> 又引起了新一轮的讨论，这里摘录一些有趣的话。</p>

<p>David Berlow:</p>

<blockquote>
  <p>How important dynamically rendered type is to design and use on the web must now be clear. In addition, the only other option—that the type industry cede its intellectual property to the public without permission—is not going to happen.</p>
</blockquote>

<p><a href="http://talleming.com/2009/04/21/web-fonts/">Tal Leming</a>:</p>

<blockquote>
  <p>There should be a new file extension for this. I propose “.wtf” &#8211; “WebType Font”.</p>
</blockquote>

<p><a href="http://diveintomark.org/archives/2009/04/21/fuck-the-foundries">Mark Pilgrim</a>:</p>

<blockquote>
  <p>&#8230; What he fails to mention is that <em>every font-consuming application on every platform on every computer on Earth</em> will need to be “upgraded” to “respect” this permissions table. Because otherwise they’re not really permissions, are they? They’re just useless bits taking valuable chunks out of my metered bandwidth plan. Like the <a href="http://en.wikipedia.org/wiki/Bozo_bit">bozo bit</a> without the bozo.</p>
</blockquote>

<p><a href="http://www.typography.com/">Jonathan Hoefler</a>:</p>

<blockquote>
  <p>All of the type designers I know desperately want to find a way to enable people to use fonts online, and not just because we’re capitalist stooges, but because we live our lives online.</p>
</blockquote>

<p><a href="http://www.schneier.com/crypto-gram-0108.html#7">Bruce Schneier</a>:</p>

<blockquote>
  <p>Truth be told, I don’t know. I feel rather like the physicist who just explained relativity to a group of would-be interstellar travelers, only to be asked: ‘How do you expect us to get to the stars, then?’ I’m sorry, but I don’t know that, either.</p>
</blockquote>

<p>总结起来，未来还是很黑暗。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2009/04/22/web-fonts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>用来修正错误编码的文件名的 Safari 插件</title>
		<link>http://blog.jjgod.org/2009/03/04/safari-url-fix/</link>
		<comments>http://blog.jjgod.org/2009/03/04/safari-url-fix/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 12:15:49 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=375</guid>
		<description><![CDATA[我之前讨论过一次这种文件名的错误编码，为了在浏览器下载时的不必手工修正这个问题，这里提供一个 Safari 的 SIMBL 插件: SafariURLFix。 使用步骤如下： 如果没装过，先安装 SIMBL； 下载 SafariURLFix.zip，解压后，放到 ~/Library/Application Support/SIMBL/Plugins 目录 (如果没这个目录就自己创建)； 在 Terminal 中输入: defaults write com.apple.Safari JJURLsToFix -dict newsmth.net GBK 其中 newsmth.net 为你希望应用修正的网站域名。也可以打开 ~/Library/Preferences/com.apple.Safari.plist 文件自己编辑 JJURLsToFix 这个 Dictionary，自行添加新的，见附图。 重新启动 Safari，尝试下载这样的文件，看看文件名是否被正确纠正了。 如果还有什么问题，欢迎在下面提出。]]></description>
			<content:encoded><![CDATA[<p>我之前<a href="/2008/02/17/cocoa-nsstring-decoding-error/">讨论过</a>一次这种文件名的错误编码，为了在浏览器下载时的不必手工修正这个问题，这里提供一个 Safari 的 SIMBL 插件: SafariURLFix。</p>

<p>使用步骤如下：</p>

<ol>
<li><p>如果没装过，先<a href="http://www.culater.net/software/SIMBL/SIMBL.php">安装 SIMBL</a>；</p></li>
<li><p>下载 <a href="http://jjgod.org/program/SafariURLFix.zip">SafariURLFix.zip</a>，解压后，放到 <code>~/Library/Application Support/SIMBL/Plugins</code> 目录 (如果没这个目录就自己创建)；</p></li>
<li><p>在 Terminal 中输入:</p>

<p><code>defaults write com.apple.Safari JJURLsToFix -dict newsmth.net GBK</code></p>

<p>其中 newsmth.net 为你希望应用修正的网站域名。也可以打开 <code>~/Library/Preferences/com.apple.Safari.plist</code> 文件自己编辑 <code>JJURLsToFix</code> 这个 Dictionary，自行添加新的，见附图。<img src="http://blog.jjgod.org/wp-content/uploads/2009/03/picture-3.png" alt="Edit Safari Preferences Manually" title="Edit Safari Preferences Manually" class="alignnone wp-image-382 noline" width="95%" /></p></li>
<li><p>重新启动 Safari，尝试下载<a href="http://att.newsmth.net/att.php?p.719.275418.308.png">这样</a>的文件，看看文件名是否被正确纠正了。</p></li>
</ol>

<p>如果还有什么问题，欢迎在下面提出。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2009/03/04/safari-url-fix/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to test a proxy autoconfiguration file</title>
		<link>http://blog.jjgod.org/2009/01/29/how-to-test-a-proxy-pac/</link>
		<comments>http://blog.jjgod.org/2009/01/29/how-to-test-a-proxy-pac/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 05:38:48 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[DOM | Scripting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[gfw]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[pac]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/?p=348</guid>
		<description><![CDATA[Due to the existence of Greal Firewall, I have a terribly long proxy.pac file. Apparently, how to maintain that becomes a problem. Regularly, I use git to keep a &#8220;stable&#8221; version and make updates on it. Recently I just found the script stop working for no good reason, because the proxy server I&#8217;m using is [...]]]></description>
			<content:encoded><![CDATA[<p>Due to the existence of <a href="en.wikipedia.org/wiki/Golden_Shield_Project">Greal Firewall</a>, I have a terribly long <code>proxy.pac</code> file. Apparently, how to maintain that becomes a problem. Regularly, I use <a href="http://git-scm.com">git</a> to keep a &#8220;stable&#8221; version and make updates on it.</p>

<p>Recently I just found the script stop working for no good reason, because the proxy server I&#8217;m using is working, and I tried manually choose a proxy server (by entering its address and port into my browser directly) it also worked, so apparently there is something wrong with the script.</p>

<p>However, it has been a while since I last commit my changes to this script back to git. So there are some changes I wish to keep and I don&#8217;t want to do a binary search to find out the problem (Yep, I&#8217;m a lazy guy).</p>

<p>A few googling got me a tool called <a href="http://code.google.com/p/pactester/">pactester</a>, which turned out to be very useful. Basically it&#8217;s a Perl wrap of <a href="http://www.mozilla.org/js/spidermonkey">SpiderMonkey</a> JavaScript engine. Since the proxy autoconfiguration script is just a subset of plain JavaScript, it can safely executes that with SpiderMonkey and find out where is the problem.</p>

<p>So I installed it and did one test:</p>

<pre><code>$ pactester -p ~/Documents/Miscs/proxy.pac -u 'http://blog.iphone-dev.org'
Use of uninitialized value in numeric ne (!=) at pactester line 137.
Error: SyntaxError: missing ) after condition at line 98:
     if (dnsDomainIs(host, "cubes.fr") return "SOCKS 127.0.0.1:7777";
</code></pre>

<p>So that&#8217;s the problem. Fixed it, everything is back to normal again!</p>

<p>That&#8217;s a small tip on debugging a complex pac script, hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2009/01/29/how-to-test-a-proxy-pac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pro JavaScript Techniques 的中文版上市</title>
		<link>http://blog.jjgod.org/2008/03/19/pro-javascript-techniques-chinese-ed/</link>
		<comments>http://blog.jjgod.org/2008/03/19/pro-javascript-techniques-chinese-ed/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 17:24:47 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[DOM | Scripting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/2008/03/19/pro-javascript-techniques-uaodhiaaeeiedh/</guid>
		<description><![CDATA[相信熟悉 Web 设计的朋友已经了解，这本书是一本关于 JavaScript 的较有深度的书籍，中文版是由贤安 (realazy) 和我一起翻译的，中文译名是《精通 JavaScript》。 原书的价值，对于熟悉的朋友应该毋庸置疑，我们两人在翻译时也颇费了一番功夫，大致分工是我主要负责和语言特性相关的，贤安主要负责和 Web 应用相关的 (包括与 CSS 的配合)，如果有任何意见建议，欢迎致信 projsch@gmail.com，我们会将所有的更正与改进放在勘误页面上。]]></description>
			<content:encoded><![CDATA[<p>相信熟悉 Web 设计的朋友已经了解，这本书是一本关于 JavaScript 的较有深度的书籍，中文版是由贤安 (<a href="http://realazy.org/blog">realazy</a>) 和我一起翻译的，中文译名是《<a href="http://realazy.org/jspro/">精通 JavaScript</a>》。</p>

<p>原书的价值，对于熟悉的朋友应该毋庸置疑，我们两人在翻译时也颇费了一番功夫，大致分工是我主要负责和语言特性相关的，贤安主要负责和 Web 应用相关的 (包括与 CSS 的配合)，如果有任何意见建议，欢迎致信 <a href="mailto:projsch@gmail.com">projsch@gmail.com</a>，我们会将所有的更正与改进放在<a href="http://realazy.org/jspro/erratra">勘误页面</a>上。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2008/03/19/pro-javascript-techniques-chinese-ed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mozilla 2</title>
		<link>http://blog.jjgod.org/2006/12/04/mozilla-2/</link>
		<comments>http://blog.jjgod.org/2006/12/04/mozilla-2/#comments</comments>
		<pubDate>Mon, 04 Dec 2006 07:52:37 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://blog.jjgod.org/2006/12/04/mozilla-2/</guid>
		<description><![CDATA[Brendan Eich 的这篇 Mozilla 2，过了一个多月我才来看。还是有些新内容的。 现在“Mozilla”这个词比较怪，它不再指以前那个“Mozilla Suite”浏览器 (自从 SeaMonkey 分出去之后)，也不专指“Firefox”，更不仅限于“Gecko”渲染引擎 (虽然现在给 Mozilla 起的版本号还是和 Gecko 同步的)，按我的理解，指的是 Mozilla 组织这面大旗下的整个平台的统称，Web 渲染，XUL, XBL, JavaScript, XML/XSL 等许多引擎的统称，而其招牌产品就是 Firefox。 其中，Mozilla 1.9 将对应着 Firefox 3.0，其路线大致已经确定了。Brendan 讨论的是在架构上将有巨大变化的 Mozilla 2，它预期在 2008 年出现。 最引人注目的是基于 JIT 的 JavaScript 虚拟机的出现，加上改进的垃圾回收，将给 JavaScript 的效率 (在 DOM 访问和内存占用方面) 带来巨大提升，据说。同时，它支持的语言会是 ECMAScript 4 (俗称 JavaScript 2)。 其他的改进对普通用户则不大可见，比如放弃 XPCOM，而更多的依赖标准 C++ 的特性来写程序，去掉一些为了兼容性遗留的旧 API，简化代码组织，放弃 CVS [...]]]></description>
			<content:encoded><![CDATA[<p>Brendan Eich 的这篇 <a href="http://weblogs.mozillazine.org/roadmap/archives/2006/10/mozilla_2.html">Mozilla 2</a>，过了一个多月我才来看。还是有些新内容的。</p>

<p>现在“Mozilla”这个词比较怪，它不再指以前那个“Mozilla Suite”浏览器 (自从 SeaMonkey 分出去之后)，也不专指“Firefox”，更不仅限于“Gecko”渲染引擎 (虽然现在给 Mozilla 起的版本号还是和 Gecko 同步的)，按我的理解，指的是 Mozilla 组织这面大旗下的整个平台的统称，Web 渲染，XUL, XBL, JavaScript, XML/XSL 等许多引擎的统称，而其招牌产品就是 Firefox。</p>

<p>其中，Mozilla 1.9 将对应着 Firefox 3.0，其路线大致已经确定了。Brendan 讨论的是在架构上将有巨大变化的 Mozilla 2，它预期在 2008 年出现。</p>

<p>最引人注目的是基于 JIT 的 JavaScript 虚拟机的出现，加上改进的垃圾回收，将给 JavaScript 的效率 (在 DOM 访问和内存占用方面) 带来巨大提升，据说。同时，它支持的语言会是 <a href="http://weblogs.mozillazine.org/roadmap/archives/2006/05/javascript_2_ecmascript_editio.html">ECMAScript 4</a> (俗称 JavaScript 2)。</p>

<p>其他的改进对普通用户则不大可见，比如放弃 XPCOM，而更多的依赖标准 C++ 的特性来写程序，去掉一些为了兼容性遗留的<a href="http://wiki.mozilla.org/Gecko:Obsolete_API">旧 API</a>，简化代码组织，放弃 CVS 换用新的版本管理工具，等等。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2006/12/04/mozilla-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FreeType 2.2.1 的一点测试</title>
		<link>http://blog.jjgod.org/2006/05/13/new-freetype-test/</link>
		<comments>http://blog.jjgod.org/2006/05/13/new-freetype-test/#comments</comments>
		<pubDate>Sat, 13 May 2006 09:48:28 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://jjgod.3322.org/2006/05/13/new-freetype-test/</guid>
		<description><![CDATA[最近 FreeType 2.2.1 刚刚发布，尽管由于 API 的变化 (许多内部函数被隐藏起来了)，多数的 distro 并未把系统使用的 FreeType 升级到这一版本——我相信要过很长一段时间才有可能这 么做。但使用源代码编译的版本，我做了一点小小的对比分析。 因为精力有限，只对 FreeType 2.1.10 (目前绝大多数发行版正在使用的版本) 进行了比较，试图给出基于 FreeType 的程序 (如 fontconfig) 应当如何配置字体 才能获得最好的效果的一点建议。而事实上，font rasterizer (字体光栅化工具) 必须和其他的 rasterizer 比较才能看出明显的区别来，例如 ATSUI, Win32 GDI 等等。 同时，我也只对随 Windows 附的 simsun.ttc 做了测试。如果你有兴趣，欢迎分享 更多的测试结果。 测试的截图在 flickr 上。 经过比较，我们可以给出这样一些建议： 必须打开 anti-alias，gamma 才会起作用。 gamma = 0.0 时启用 sRGB (次像素反锯齿) 模式，这种模式要比默认的 gamma = 1.0 [...]]]></description>
			<content:encoded><![CDATA[<p>最近 <a href="http://download.savannah.gnu.org/releases/freetype/">FreeType 2.2.1</a> 
刚刚发布，尽管由于 API 的变化 (许多内部函数被隐藏起来了)，多数的 distro 
并未把系统使用的 FreeType 升级到这一版本——我相信要过很长一段时间才有可能这
么做。但使用源代码编译的版本，我做了一点小小的对比分析。</p>

<p>因为精力有限，只对 FreeType 2.1.10 (目前绝大多数发行版正在使用的版本) 
进行了比较，试图给出基于 FreeType 的程序 (如 fontconfig) 应当如何配置字体
才能获得最好的效果的一点建议。而事实上，font rasterizer (字体光栅化工具) 
必须和其他的 rasterizer 比较才能看出明显的区别来，例如 ATSUI, Win32 GDI 
等等。</p>

<p>同时，我也只对随 Windows 附的 simsun.ttc 做了测试。如果你有兴趣，欢迎分享
更多的测试结果。</p>

<p>测试的截图在 <a href="http://www.flickr.com/photos/jjgod/tags/freetype/">flickr</a> 上。</p>

<p>经过比较，我们可以给出这样一些建议：</p>

<ol>
<li>必须打开 anti-alias，gamma 才会起作用。</li>
<li>gamma = 0.0 时启用 sRGB (次像素反锯齿) 模式，这种模式要比默认的 
gamma = 1.0 显示得更清晰锐利一些。</li>
<li>绝大多数情况下，打开 hinting 能达到更好的效果。</li>
<li>小于 12px 的情况下，关闭 anti-alias，打开 hinting 能使字体勉强可读，
但仍然建议绝对不要使用这么小的字体。</li>
<li>12px 以上，即 12-16px, 18px 的汉字必须使用嵌入的 bitmap。事实上，AA + 
hinting 的汉字要到 28px 以上才可以称为比较可读。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2006/05/13/new-freetype-test/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Why Cairo?</title>
		<link>http://blog.jjgod.org/2006/04/18/why-cairo/</link>
		<comments>http://blog.jjgod.org/2006/04/18/why-cairo/#comments</comments>
		<pubDate>Mon, 17 Apr 2006 17:32:35 +0000</pubDate>
		<dc:creator>jjgod</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://jjgod.3322.org/2006/04/18/why-cairo/</guid>
		<description><![CDATA[因为想写一个 lightweight &#38; fast 的文本布局引擎，这两天在留意一些新的图形 API。其实有些都不算很新了，像 Anti-Grain Geometry、Amanith 和 Xara。 曾被誉为“Linux 图形未来希望”的 cairo 广受诟病的是它的效率，尽管从一开始 cairo 便宣称将会利用 glitz 这样的 backend 实现硬件加速的矢量图形绘制，从而达到软件绘制无法达到的效果。结果现在戏剧性的是，cairo 比所有这些用软件绘制的引擎都慢得多。 所以才有人写了这么一篇 Why Cairo?，意思大概说得很清楚了，Mozilla 选用 cairo 的借口现在看来是非常苍白无力的，比如说 cairo 引以为傲的“bring vector graphics to print”有多少人需要把网页输出到 PDF/PS？如果最基本的页面渲染都做不到高效，谈何页面印刷的高效？ 所以我觉得啊，rendering model 好当然不错，cross-platform 性能好也很好，但 cairo 是不是中 gnome 社群的毒太深了？什么东西都来搞个 backend，结果最后每个 backend 都半死不活的，没错，也许某天 David Reveman 搞定了 xgl 腾出手来整 glitz 了，可 David Reveman 就算搞定了 [...]]]></description>
			<content:encoded><![CDATA[<p>因为想写一个 lightweight &amp; fast 的文本布局引擎，这两天在留意一些新的图形 API。其实有些都不算很新了，像 <a href="http://www.antigrain.com/">Anti-Grain Geometry</a>、<a href="http://www.amanith.org">Amanith</a> 和 <a href="http://www.xaraxtreme.org/">Xara</a>。</p>

<p>曾被誉为“Linux 图形未来希望”的 <a href="http://www.cairographics.org">cairo</a> 广受诟病的是它的效率，尽管从一开始 cairo 便宣称将会利用 glitz 这样的 backend 实现硬件加速的矢量图形绘制，从而达到软件绘制无法达到的效果。结果现在戏剧性的是，cairo 比所有这些用软件绘制的引擎都<strong>慢得多</strong>。</p>

<p>所以才有人写了这么一篇 <a href="http://weblogs.mozillazine.org/tor/archives/2006/04/why_cairo.html">Why Cairo?</a>，意思大概说得很清楚了，Mozilla 选用 cairo 的借口现在看来是非常苍白无力的，比如说 cairo 引以为傲的“bring vector graphics to print”有多少人需要把网页输出到 PDF/PS？如果最基本的页面渲染都做不到高效，谈何页面印刷的高效？</p>

<p>所以我觉得啊，rendering model 好当然不错，cross-platform 性能好也很好，但 cairo 是不是中 gnome 社群的毒太深了？什么东西都来搞个 backend，结果最后每个 backend 都半死不活的，没错，也许某天 David Reveman 搞定了 xgl 腾出手来整 glitz 了，可 David Reveman 就算搞定了 glitz，也未必能在 win32 下用啊。</p>

<p>&#8230; 今天测试的结果是，pango 用 cairo 作 backend，cairo 用 win32 backend，结果渲染一行字 (4 个字母)，要半秒钟。嗯，没看错，就是 0.5s。</p>

<p>效率还是很重要的呀，虽然某位大人物说过：</p>

<p>预优化是万恶之源。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jjgod.org/2006/04/18/why-cairo/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

