[NTG-context] accessing glyphs in the private area

Hans Hagen j.hagen at xs4all.nl
Mon Oct 1 10:20:07 CEST 2018


On 9/30/2018 10:08 PM, Ulrike Fischer wrote:
> 
> The font Coelacanth (on CTAN) has glyphs in the private area.
> 
> Between 2/2017 (luaotfload in texlive 2017) and now the storing and
> accessing of this glyphs has changed.
> 
> In the lua of the font of 2017 I find e.g.
> 
>    [62860]={
>     ["boundingbox"]=165,
>     ["index"]=2622,
>     ["unicode"]=62860,
>     ["width"]=523,
> 
> and the glyph can be accessed with \Uchar62860
> 
> In the current lua I now find
> 
>   [983910]={
>     ["boundingbox"]=195,
>     ["index"]=2622,
>     ["unicode"]=62860,
>     ["width"]=523,
>    },
> 
> and \Uchar62860 not longer works, one has to use \Uchar983910.
> 
> Is this change intentional? How is one supposed to access such
> chars? The manual says about \Uchar that it "expands to the
> associated Unicode character." but this seems no longer to be true.
> 
> A context example to test is
> 
> \starttext
> \font\test={name:Coelacanth:mode=node;script=latn;language=DFLT;+tlig;}
> \test
> 1.: \Uchar62860
> 
> 2.: \Uchar983910
> 
> \stoptext
\Uchar expands to the character in the font, so to whatever sits in that 
slot ... in fact, fonts in luatex are not that different from 
traditional tex: slot 123 can be anything but it happens that we use 
unicode in the fontloader ..

anyway, the problem, with these private areas is that they are also used 
by the loader (and context) so in order to avoid clashes we move all 
private chars in the font to a dedicated private range

in your case the glyphs have no real useful names so basically i wonder 
what their use it (are they meant for direct access?)

you can define

\def\byindex#1{\ctxlua{
     for k, v in pairs(fonts.hashes.identifiers[true].characters) do
         if v.index == #1 then
             tex.print(utf.char(k))
             break
         end
     end
}}

{\definedfont[Coelacanth] test \byindex{\number"00A33}}

I can remap those privates to a normalized private name, like P0F581 but 
it depends on how bloated fonts become that have lots of privates.

In that case you can have:

\def\byname#1{\ctxlua{
     for k, v in 
pairs(fonts.hashes.identifiers[true].shared.rawdata.descriptions) do
         if v.name == "#1" then
             tex.print(utf.char(k))
             break
         end
     end
}}

{\definedfont[Coelacanth] test \byname {P0F581}}

(btw,  This code is not for context users! They have other means; this 
is typically stuff that differs per macro package. One might for 
instance make a list per font with meaningfull names or so that can be 
accessed in a more friendly way.)

Hans

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


More information about the ntg-context mailing list