Hi jjgod,<br><br>You&#39;ve done quite a good job! Thanks a lot.<br><br>Regards.<br><span class="sg"><br>-Yin</span><br><br><div><span class="gmail_quote">On 10/19/07, <b class="gmail_sendername">Jjgod Jiang</b> &lt;<a href="mailto:gzjjgod@gmail.com">
gzjjgod@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Yin, Jonathan,<br><br>2007/10/18, Yin Dian &lt;<a href="mailto:yindian@gmail.com">
yindian@gmail.com</a>&gt;:<br>&gt; 2. Wrong width for CJK Ext-B characters.<br>&gt;<br>&gt; This bug is introduced in revision 93 of xdvipdfmx. Revision 92 generates<br>&gt; the correct result, while the following revisions not.
<br><br>After some debugging, it turns out this bug is introduced by<br>do_glyph_array() in<br>dvi.c of xdvipdfmx, after r93, it use FreeType version to determinate whether<br>to retrieve the horiAdvance data directly from FreeType or load it by
<br>itself, but<br>there is a little difference between these two cases, which results the<br>miscalculation for Sun-ExtB.ttf font.<br><br>Let&#39;s see the calling sequence of case 1:<br><br>xdvipdfmx: dvi.c: FT_Load_Glyph
<br>freetype: truetype/ttgload.c: TT_Load_Glyph<br>freetype: truetype/ttgload.c: load_truetype_glyph<br>freetype: truetype/ttgload.c: Get_HMetrics<br><br>In Get_HMetrics(), if flag FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH<br>is not set, and face-&gt;
postscript.isFixedPitch (Sun-ExtB.ttf is declared as<br>fixed pitch), it will use face-&gt;horizontal.advance_Width_Max as the advance<br>width. (which is 299, but that glyph advance should be 256, as recorded in<br>SFNT table).
<br><br>So here is a simple patch of xdvipdfmx to fix this:<br><br>Index: src/dvi.c<br>===================================================================<br>--- src/dvi.c&nbsp;&nbsp; (revision 96)<br>+++ src/dvi.c&nbsp;&nbsp; (working copy)
<br>@@ -1961,7 +1961,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; font-&gt;glyph_widths[glyph_id] = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FT_Load_Glyph(font-&gt;ft_face, glyph_id, FT_LOAD_NO_SCALE);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FT_Load_Glyph(font-&gt;ft_face, glyph_id, FT_LOAD_NO_SCALE |
<br>FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; font-&gt;glyph_widths[glyph_id] = (font-&gt;layout_dir == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?<br>font-&gt;ft_face-&gt;glyph-&gt;metrics.horiAdvance<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br>font-&gt;ft_face-&gt;glyph-&gt;metrics.vertAdvance;<br><br><br>- Jiang<br></blockquote></div><br>