On 11/3/2022 2:03 PM, Thomas A. Schmitz via ntg-context wrote:
On 11/3/22 13:27, Henning Hraban Ramm via ntg-context wrote:
If it works for you, then it’s a problem of my installation, otherwise a regression in current LMTX...

No, I get the same error message, this looks promising but doesn't work.

And at the risk of sounding grumpy, but all of this is too much manual intervention; I would like to have a completely automated script. So I'll show what I have and add a few comments:

local Feature_Table = { }
local Parsed_Features = { }

local My_Font = environment.arguments["font"]

local Font_Features = os.resultof("otfinfo -f " .. My_Font)

for Feature_Sigla, Feature_Name in
   string.gmatch(Font_Features, "(%S-)\t(.-)\n") do
   Feature_Table[Feature_Sigla] = Feature_Name
end

COMMENTS

Expectation: this should return a list of all features and their descriptions as a lua table. If you run the file as

context test.cld --font="/path/to/font"

this works, and you get a table

Feature_Table={
  ["aalt"]="Access All Alternates",
  ["c2sc"]="Small Capitals From Capitals"} etc.

CODE

for name, _ in pairs(Feature_Table) do
   Context_Name = "f:" .. name
   Parsed_Features[name] = Context_Name
   context.definefontfeature( { Context_Name }, { name="yes" } )
end

COMMENTS

This should produce a lua table with ConTeXt fontfeatures and define those features. The table appears to be correct:

Parsed_Features={
  ["aalt"]="f:aalt",
  ["c2sc"]="f:c2sc"} etc.

So I expected that this should be equivalent to

\definefontfeature [f:aalt] [aalt=yes]

and return a list of defined features.

CODE

local Test_String = [[
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890 1/4 2/8 3/9 ffi ft fi fl ffl
]]

local Font_Name =  os.resultof("otfinfo -a " .. My_Font)

context.definefontfamily( { "Test" }, { "serif" }, { Font_Name }, {} )

context.setupbodyfont{ "Test, 12pt" }

COMMENTS

Again, this works; the font is set as bodyfont.

CODE

context.starttext()

for name, feature in pairs(Feature_Table) do
   context.start ()
   context.addfeature { Parsed_Features[name] }
   context.midaligned (feature)
   context.bold (Parsed_Features[name])
   context.par ()
   context.blank{ "medium" }
   context(Test_String)
   context.par ()
   context.stop ()
end

context.stoptext()

COMMENTS

And this doesn't work: the names are picked up, but the font features are not defined; the sample text does not reflect any features. So this is what I've got... maybe one of the wizards can help.
You're going way too complex. Access to features and info has alwaye been part of mkic (and therefore lmtx). You can peek into the s-font* styles for all kind of ways to get overviews. Anyway, the following helper operates on the current font:

\starttext

\startluacode
    function document.ShowFeatures(script)
        local test = [[
            ABCDEFGHIJKLMNOPQRSTUVWXYZ
            abcdefghijklmnopqrstuvwxyz
            1234567890
            1/4 2/8 3/9
            ffi ft fi fl ffl
        ]]

        local font     = fonts.hashes.identifiers[true]
        local features = font.resources.features
     -- inspect(features)
        for name, detail in table.sortedhash(features.gsub) do
            if #name == 4 then
                context.type(name)
                context.quad()
                if script then
                    context.type(script)
                    context.quad()
                end
                -- this should be doen once in order to save memory
                -- not too hard to do ..
                context.definefontfeature(
                  { "f:"..name },
                  { [name] = "yes", script = script }
                )
                context.start()
                context.addff("f:"..name)
                context(test)
                context.stop()
                context.blank()
            end
        end
    end
\stopluacode

\definedfont[LibertinusSerif-Regular.otf*always]

\ctxlua{document.ShowFeatures()}
% \ctxlua{document.ShowFeatures("latn")}
% \ctxlua{document.ShowFeatures("grek")}

\stoptext

But, be aware that (1) features can combine in weird ways, (2) some features are only meant to be applied to a sunset of characters, (3) some are driven by script and/or language. Also, (4) you need to load the font without any features except the ones that enable node mode.

So, now you need to wikify ...

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
-----------------------------------------------------------------

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

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

Reply via email to