Hi jjgod,<br><br>You'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> <<a href="mailto:gzjjgod@gmail.com">
gzjjgod@gmail.com</a>> 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 <<a href="mailto:yindian@gmail.com">
yindian@gmail.com</a>>:<br>> 2. Wrong width for CJK Ext-B characters.<br>><br>> This bug is introduced in revision 93 of xdvipdfmx. Revision 92 generates<br>> 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'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->
postscript.isFixedPitch (Sun-ExtB.ttf is declared as<br>fixed pitch), it will use face->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 (revision 96)<br>+++ src/dvi.c (working copy)
<br>@@ -1961,7 +1961,7 @@<br> font->glyph_widths[glyph_id] = 0;<br> }<br> else {<br>- FT_Load_Glyph(font->ft_face, glyph_id, FT_LOAD_NO_SCALE);<br>+ FT_Load_Glyph(font->ft_face, glyph_id, FT_LOAD_NO_SCALE |
<br>FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);<br> font->glyph_widths[glyph_id] = (font->layout_dir == 0)<br> ?<br>font->ft_face->glyph->metrics.horiAdvance<br>
:<br>font->ft_face->glyph->metrics.vertAdvance;<br><br><br>- Jiang<br></blockquote></div><br>