[Dev-luatex] Chars to glyphs. How to?
taco at elvenkind.com
Wed Dec 5 11:38:39 CET 2007
Jonathan Sauer wrote:
> if I understand the svn version of the manual correctly, after
> hyphenation, character nodes are converted to glyph nodes (BTW:
> The new section 5 is very good, as it is very detailed). During
> this step, first ligatures are created, then kerning is applied.
> Now, LuaTeX uses Unicode internally, but current font need not
> be Unicode.
However, by default it is assumed to be. This assumption has to be
made because there is no way to get the required mappings from a
tfm file if this were not the case. So for remapping to happen,
you have to write and register a bit of lua code. (there was a
choice between this assumption and inventing a new dedicated
font-related file format)
> Given the letter "ä" and a font in OT1-encoding,
> how would I convert this "ä" to an accented glyph *after*
> hyphenation has happened (to be able to hyphenate words
> containing "ä")?
The logical place is in the ligaturing callback, because
for tfm-based fonts, the actual ligature insertions can be
done in one line via the node.ligaturing() built-in function.
callback.register('ligaturing', function (head, tail)
Note: you don't have to worry about return values because the head
node that is passed on to the callback is guaranteed not to be a
glyph_node (if need be, a temporary node will be inserted), and
therefore it cannot be affected by the mutations that take place.
In this case, the 'tail' node is not used (the link of 'tail' is
guaranteed to be 'nil').
You have to write the convert_to_glyphs function of course,
and it could look like this:
function find_font_glyph (f,c)
% you should do some real work here!
function convert_to_glyphs (head)
for v in node.traverse_id(head) do
if v.subtype=1 then
v.character = find_font_glyph(v.font,v.character)
> I looked into the manual, but found only two callbacks for
> inserting ligatures and kerning, not for converting characters
> to glyphs (incidentally, the documentation for these callbacks
> is very meager).
The manual was not finished yet, I have just added a few paragraphs
on this subject.
More information about the dev-luatex