ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to query fonts.handlers
       [not found] <7db81e7b-4524-67ed-60c9-7cd68f72ac33@gmail.com>
@ 2019-02-05 20:27 ` Henri Menke
  2019-02-06  0:10   ` Henri Menke
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Menke @ 2019-02-05 20:27 UTC (permalink / raw)
  To: ntg-context@ntg.nl >> mailing list for ConTeXt users

Dear list,

I am trying to access extra kerning that I have defined using
fonts.handlers.otf.addfeature.  Even though I query the kerning from
within a paragraph where the kerning is evidently applied I can't seem
to get the value stored earlier, see the comment in the MWE.  What am I
doing wrong?

Cheers, Henri

---

\startluacode
fonts.handlers.otf.addfeature {
    name = "ktest",
    type = "kern",
    data = {
        ["t"] = { ["e"] = 500 },
    }
}
\stopluacode

\definefontfeature[ktest][ktest=yes]

\definefont[1][Serif*ktest]

\starttext

\1 test \ctxlua{
     local fnt = font.current()
     local tfmdata = fonts.hashes.identifiers[fnt]
     local t = string.byte("t")
     local e = string.byte("e")
     local kern = fonts.handlers.otf.getkern(tfmdata,t,e)
     context(kern) % 0 instead of 500. Why?
}

\stoptext

---

P.S.: I have posted the same question on the LuaTeX list, but with a
different MWE.

-------- Forwarded Message --------
Subject: How to query fonts.handlers
Date: Mon, 4 Feb 2019 15:00:12 +1300
From: Henri Menke <henrimenke@gmail.com>
To: LuaTeX discussion. <luatex@tug.org>

Dear list,

I am trying to access extra kerning that I have defined using
fonts.handlers.otf.addfeature.  Even though I query the kerning from
within a paragraph where the kerning is evidently applied I can't seem
to get the value stored earlier, see the comment in the MWE.  What am I
doing wrong?

Cheers, Henri

---

\input luaotfload.sty

\directlua{
     fonts.handlers.otf.addfeature {
         name = "ktest",
         type = "kern",
         data = {
             ["t"] = { ["e"] = 500 },
         }
     }
}

\font\1="lmroman10-regular.otf:+ktest" at 10pt
\1

test%
\directlua{
     local fnt = font.current()
     local tfmdata = fonts.hashes.identifiers[fnt]
     local t = string.byte("t")
     local e = string.byte("e")
     local kern = fonts.handlers.otf.getkern(tfmdata,t,e)
     tex.sprint(kern) % 0 instead of 500. Why?
}

\bye


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to query fonts.handlers
  2019-02-05 20:27 ` How to query fonts.handlers Henri Menke
@ 2019-02-06  0:10   ` Henri Menke
  0 siblings, 0 replies; 2+ messages in thread
From: Henri Menke @ 2019-02-06  0:10 UTC (permalink / raw)
  To: ntg-context@ntg.nl >> mailing list for ConTeXt users

I found a solution.

\startluacode
fonts.handlers.otf.addfeature {
    name = "ktest",
    type = "kern",
    data = {
        ["t"] = { ["e"] = 500 },
    }
}
\stopluacode

\definefontfeature[ktest][ktest=yes]

\definefont[1][Serif*ktest]

\starttext

\1 test \ctxlua{
     local fnt = font.current()
     local tfmdata = fonts.hashes.identifiers[fnt]
     local t = string.byte("t")
     local e = string.byte("e")
     local kern = 0
     for kind in pairs(tfmdata.shared.rawdata.lookupcache) do
         kern = kern + fonts.handlers.otf.getkern(tfmdata,t,e,kind)
     end
     context(kern / tfmdata.parameters.factor) % 500
}

\stoptext

On 6/02/19 9:27 AM, Henri Menke wrote:
> Dear list,
> 
> I am trying to access extra kerning that I have defined using
> fonts.handlers.otf.addfeature.  Even though I query the kerning from
> within a paragraph where the kerning is evidently applied I can't seem
> to get the value stored earlier, see the comment in the MWE.  What am I
> doing wrong?
> 
> Cheers, Henri
> 
> ---
> 
> \startluacode
> fonts.handlers.otf.addfeature {
>     name = "ktest",
>     type = "kern",
>     data = {
>         ["t"] = { ["e"] = 500 },
>     }
> }
> \stopluacode
> 
> \definefontfeature[ktest][ktest=yes]
> 
> \definefont[1][Serif*ktest]
> 
> \starttext
> 
> \1 test \ctxlua{
>      local fnt = font.current()
>      local tfmdata = fonts.hashes.identifiers[fnt]
>      local t = string.byte("t")
>      local e = string.byte("e")
>      local kern = fonts.handlers.otf.getkern(tfmdata,t,e)
>      context(kern) % 0 instead of 500. Why?
> }
> 
> \stoptext
> 
> ---
> 
> P.S.: I have posted the same question on the LuaTeX list, but with a
> different MWE.
> 
> -------- Forwarded Message --------
> Subject: How to query fonts.handlers
> Date: Mon, 4 Feb 2019 15:00:12 +1300
> From: Henri Menke <henrimenke@gmail.com>
> To: LuaTeX discussion. <luatex@tug.org>
> 
> Dear list,
> 
> I am trying to access extra kerning that I have defined using
> fonts.handlers.otf.addfeature.  Even though I query the kerning from
> within a paragraph where the kerning is evidently applied I can't seem
> to get the value stored earlier, see the comment in the MWE.  What am I
> doing wrong?
> 
> Cheers, Henri
> 
> ---
> 
> \input luaotfload.sty
> 
> \directlua{
>      fonts.handlers.otf.addfeature {
>          name = "ktest",
>          type = "kern",
>          data = {
>              ["t"] = { ["e"] = 500 },
>          }
>      }
> }
> 
> \font\1="lmroman10-regular.otf:+ktest" at 10pt
> \1
> 
> test%
> \directlua{
>      local fnt = font.current()
>      local tfmdata = fonts.hashes.identifiers[fnt]
>      local t = string.byte("t")
>      local e = string.byte("e")
>      local kern = fonts.handlers.otf.getkern(tfmdata,t,e)
>      tex.sprint(kern) % 0 instead of 500. Why?
> }
> 
> \bye
> 
> 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-06  0:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7db81e7b-4524-67ed-60c9-7cd68f72ac33@gmail.com>
2019-02-05 20:27 ` How to query fonts.handlers Henri Menke
2019-02-06  0:10   ` Henri Menke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).