[Dev-luatex] bug with \ifcsname, ttf font spacing problems, and catcode initialisation for utf8 beyond ascii

Olivier Binda olivier.binda at wanadoo.fr
Thu Sep 13 22:16:37 CEST 2007


I have been testing luatex some more and I have made the following 
discoveries :

A) The \ifcsname macro doesn't behave as it should when you use non 
ascii char between \ifcsname and \endcsname,
as you can see if you try to luatex this minimal file :

\expandafter\def\csname A人\endcsname{success}%
1) % succeeds
\csname A人\endcsname
2) % fails...this is a \ifcsname bug
\ifcsname A人\endcsname
it should write this but it doesn't
it writes this and it shouldn't% it goes this way, sigh....

B) non-ascii utf8 char don't seem to have their catcodes initialized to 
"letter" (catcode 11).
Is this normal ? Is it a bug ? a feature ?

XeTeX initializes all non ascii char as letters. This is quite usefull 
(and quite logical too).
Shouldn't it be the same in luatex, at least for the sake of compatibility ?

C) I have tried using a ttf font in luatex but It was only half a success :

I read the luatex manual but was really at a loss to guess how to code a 
function in lua to load the .ttf font,
so I did a lot of googling and I finally found this luatex-wiki (started 
by Yannis Haralambous) :

I tried Yannis Haralambous's code sample to load a ttf font :

    function(name, size)
      filename=kpse.find_file(name,"truetype fonts")
      if (filename) then 
         if (size < 0) then size = (- 655.36) * size end
        ttffont = fontforge.to_table(fontforge.open(filename))
        if ttffont then
          f = { }
          f.name = ttffont.fontname
          f.fullname = ttffont.names[1].names.fullname
          f.parameters = { }
          f.designsize = size
          f.size = size
          direction = 0
          f.parameters.slant = 0
          f.parameters.space = size * 0.25
          f.parameters.space_stretch = 0.3 * size
          f.parameters.space_shrink = 0.1 * size
          f.parameters.x_height = 0.4 * size
          f.parameters.quad = 1.0 * size
          f.parameters.extra_space = 0
          f.characters = { }
          mag = size / 2048

           names_of_char = { }
          for char, glyph in pairs(ttffont.map.map)
              = ttffont.map.backmap[glyph]

          names_of_glyph = { }
          for char, glyph in pairs(ttffont.map.map)
              = glyph

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

            f.characters[char] = {
              index = glyph,
              width = glyph_table.width * mag,
              name = glyph_table.name,
            if glyph_table.kerns then
              local kerns = { }
              for _, kern in pairs(glyph_table.kerns)
                kerns[names_of_char[kern.char]] = kern.off * mag
            f.characters[char].kerns = kerns
          f.filename = filename
          f.type = 'real'
          f.format = 'truetype'
          f.embedding = "full"
          f.cidinfo = {
            registry = "Adobe",
            ordering = "Identity",
            supplement = 0,
            version = 1
        f = font.read_tfm(name, size)
    return f

\font\myfont=skullz.ttf at 8pt
abcdefABCDEF %%% it prints but the all the chars are stacked upon 
another (they must have near 0pt width).

Luatex managed to load the ttf font (it stopped whining about not 
finding metrics) yet, when I write something with this font,
the spacing is all wrong (all the letter stack in one place). So I guess 
the metrics that luatex managed to produce is wrong (the char seem to 
have near 0 width).

What could be wrong ?

D) Please, could you put more code snipets in the luatex manual (this 
piece of code from yannis would be a good candidate) ?
I welcome Yannis' decision to build a luatex wiki and it would be even 
nicer if someone knowledgeable wrote a little luatex macro library to do 
(the right way) basic things like : loading utf/opentype fonts....
To help beginners jump on the luatex bandwagon....

Best regards,
Olivier Binda
ps : now that the \atop bug is resolved...my 150+ page maths course does 
compile with luatex (yeepee).
My japanese dictionnary does compile too but it doesn't produce the 
expected result because of the \ifcsname behavior ^_^

More information about the dev-luatex mailing list