[XeTeX] Linking with FreeType 2 on Mac OS X

Jjgod Jiang gzjjgod at gmail.com
Sun Feb 11 08:51:41 CET 2007

Hi Jonathan,

2007/2/11, Jonathan Kew <jonathan_kew at sil.org>:
> I haven't checked the truetype spec, but I seem to remember that it's
> legal for a font to have fewer metrics than glyphs, and then all the
> remaining glyphs have the same metrics as the last entry.... perhaps
> the code in xdvipdfmx doesn't handle this case, and tries to read
> beyond the end of the hmtx table. I don't have time to investigate
> tonight, though.

Yes, According to

    Number of VMetrics entries in the 'vmtx' table -- this value can be
    smaller than the total number of glyphs in the font.

I believe I have corrected this problem, here is the patch:

Index: tt_table.c
--- tt_table.c  (revision 83)
+++ tt_table.c  (working copy)
@@ -314,12 +314,15 @@
   struct tt_longMetrics *m;
   USHORT gid, last_adv = 0;
+  SHORT last_sb;

   m = NEW(numGlyphs, struct tt_longMetrics);
   for (gid = 0; gid < numGlyphs; gid++) {
-    if (gid < numLongMetrics)
+    if (gid < numLongMetrics) {
       last_adv = sfnt_get_ushort(sfont);
-    m[gid].sideBearing = sfnt_get_short(sfont);
+      last_sb = sfnt_get_short(sfont);
+    }
+    m[gid].sideBearing = last_sb;
     m[gid].advance     = last_adv;

But there is still a small warning I can not understand, with -vv,
I got:

~/Documents/tex/experiments jjgod$ xdvipdfm -vv xtx-cjk-extb
DVI Comment:  XeTeX output 2007.02.11:0736
xtx-cjk-extb.xdv -> xtx-cjk-extb.pdf
fontmap: Sun-ExtB/H/65536/0 -> Sun-ExtB/H/65536/0(Identity-H)

pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "Sun-ExtB/H/65536/0".
pdf_font>> Type0 font "Sun-ExtB/H/65536/0" cmap_id=<Identity-H,0>
opened at font_id=<Sun-ExtB/H/65536/0,0>.
fontmap: Sun-ExtB/H/65536/0 -> Sun-ExtB/H/65536/0(Identity-H)[map:<00>]
pdf_font>> Type0 font "Sun-ExtB/H/65536/0" cmap_id=<Identity-H,0>
opened at font_id=<Sun-ExtB/H/65536/0,1>.
otf_cmap>> Creating ToUnicode CMap for "Sun-ExtB/H/65536/0"...

** WARNING ** No Unicode mapping available: GID=0, name=(none)

Looks like this warning code does not belongs to dvipdfmx, it was added
in xdvipdfmx. (in tt_cmap.c, line 876)

- jjgod.

More information about the XeTeX mailing list