[Dev-luatex] fontforge library can't load OpenType file correctly

luoyi luoyi.ly at gmail.com
Sun Mar 1 14:21:29 CET 2009

the following lua code is just a simple demo of TrueType&OpenType font
load process for myself use. and I've found that it can't work with
some OTF files recently. for example: AdobeSongStd-Light.otf. but it's
ok when I try to load the TrueType font for example: SimHei.ttf

    function(name, size)
      filename=kpse.find_file(name,"truetype fonts")
      if (filename) then
        ttffont = fontforge.to_table(fontforge.open(filename))
        if ttffont then
          f = { }
          f.name = ttffont.fontname
          f.fullname = ttffont.names[1].names.fullname
          f.size = size
          f.characters = {}

         for char, glyph in pairs(ttffont.map.map) do
            glyph_table = ttffont.glyphs[glyph]

            f.characters[char] = {
              index = glyph,
              width = glyph_table.width * size/ttffont.units_per_em,
              name = glyph_table.name,
          f.filename = filename
          f.type = 'real'
          f.format = 'truetype'
          f.cidinfo = {
            registry = "Adobe",
            ordering = "Identity",
            supplement = 0,
            version = 1
        f = font.read_tfm(name, size)
    return f

and luatex give me the error:
! LuaTeX error <\directlua0>:1: attempt to index field 'map' (a nil value).

I doubt  maybe the OpenType file support in the fontforge is broken
now.  Can anyone help to check this ?

More information about the dev-luatex mailing list