I am trying to use an open type font. In the manual I can see a piece of Lua code for loading such a font. I "suppose" that I have to enclose it within \direclua0{}, so I wrote
 
\directlua0{function load_font (filename)
 local metrics = nil
 local font = fontforge.open(filename)
 if font then
  metrics = fontforge.to_table(font)
  fontforge.close(font)
 end
 return metrics
end
}
\directlua0{twelverm = load_font('C:/Windows/Fonts/LMRoman12-Regular.otf')}
 
but it still does not solve the problem. I have no idea of how to make the font known for TeX.
 
This is command is expandable. As an example, the following input:
$\pi = \directlua0{tex.print(math.pi)}$

will result in p = 3.1415926535898
 
But this leaves me none the wiser about fonts. The problem is: which is the equivalent of
 
\font\tenrm=cmr10
 
for OpenType (or TrueType) fonts?
 
This problem is present to some extent all troughout the manual. It seems as if you were taking always something for granted about the interaction between Lua and TeX that is not explained anywhere. You may find it obvious, but keep in mind that manuals are intended for people who still don't know.
    For somebody like me who comes from TeX, the impression got when reading the manual (or at least the impression I had) is as having all the pieces from a conglomerate rock but not having the cement. And the lack of examples is exasperating. This I understand given the development state of the program, but men, since one of the main features of LuaTeX is accesing and modifing the TeX parameters and state with Lua code, some exemples of this, even if kept to a minimum, would be very helpful.
   I wouldn't have any problem in taking the time to write them myself... if knew it, but the LuaTeX manual is still very far from serving to the learning of LuaTeX in the same way as the TeXBook serves for the learnig TeX or "the red book" serves for the learning of the postscript language.
 
Continuing with my problem with using an otf font, I found some pages below in the manual an example intended for a diferent purpose but that looked usefull for solving my problem even if not the way it should be done. So below the avobe mentioned lua code I boldly wrote
 
\directlua0 {
callback.register('define_font', function (name,size)
 if name == 'LMRoman12-Regular' then
  f = twelverm
 else
  f = font.read_tfm(name,size)
 end
 return f
end
)
}
\font\twelverm= LMRoman12-Regular
it does not work, but it exhibits a bug in LuaTeX: I get a warning at \dump time:
 
luaTeX warning: lua-loaded font [1] (<NULL>) has no character table!
 
but right afterwards the program dies and is closed by Windows.
 
--Javier A.