[Dev-luatex] Chars to glyphs. How to?

Hans Hagen pragma at wxs.nl
Wed Dec 5 13:40:11 CET 2007

Jonathan Sauer wrote:
> Hello,
>>> Shouldn't the subtype be "2"? In setion, bit 1 is used
>>> to denote a glyph, if I understand the manual correctly. Since
>>> I convert the character to a glyph in the font, this bit should
>>> be set afterwards.
>> I am somewhat in doubt about that. The manual and my coding
>> practise do not quite agree on what the value really should be,
>> but bit zero should definately be cleared (in fact, that is
>> the only test made, right now).
> Mmm ... if the subtype is a bitfield, IMO one bit should be set;
> otherwise the subtype would be undefined.
> Still, why is the subtype ia bitfield anyway? Can a glyph node
> i.e. be both a character node as well as a ligature node?

a ligature is not really a character -)

anyhow, zero means 'nothing done', while other values < 256 means, 
something done; you can use bits >= 256 for your own usage since luatex 
only looks at the first 8 bits

> Let me see if I get this right:
> 1. I load the font, i.e. in OT1-encoding, just like any other TeX
>    font.
> 2. I modify the font's table (i.e. by using the "define_font" callback):
>    I add all characters I want to support to the font's "characters"
>    array. Each of these new characters contains a "commands" field 
>    which constructs the character from several others in the font.
> 3. I use the (artificial, as described in section 6.2.1) font and am
>    a happy clam.

indeed; of course you can also make the virtual font independent of luatex

> Questions:
> - Section 6 of the manual states that the key of the "characters"
>   table is the "internal code TeX knows this character by". How do
>   I determine this code? Is this simply the Unicode code point?

your choice, as long as you also provide the index i.e. where to find 
the glyph in the font file

> - If I handle accented characters this way, I do not have to create
>   a "ligaturing" callback, do I?

no, this is controlled by the ligature subtable; if such a table is 
there (in the font that is) then things happen automatically (same for 

> - Does the "char" font command move the output pointer?


>>>  How do I tell this new node to overlap the 'a'?
>> By adding some extra kerning around it, and/or tweaking the
>> values of the "xoffset" and "yoffset" fields (the need for such
>> node list manipulations is the main reason why a virtual font
>> is easier).
> It seems like it, especially since I would need some kind of
> data structure to describe the character-replacements anyway.
> Also, a virtual font would most likely be easier on the garbage
> collector.

fonts are not garbage collected (well, at the lua end the table may be 
collected of course) but in tex itself it's allocated permanently


                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl

More information about the dev-luatex mailing list