Hi, is there an easy way to get a list of all features that a font has and typeset a sample text to see the result of every single feature? There probably is, but I couldn't find anything... All best Thomas
Am 03.11.22 um 12:37 schrieb Thomas A. Schmitz via ntg-context:
Hi,
is there an easy way to get a list of all features that a font has and typeset a sample text to see the result of every single feature? There probably is, but I couldn't find anything...
You'll get only the features with otfinfo in the terminal. For example: iMac:~ voss$ otfinfo -f `kpsewhich LibertinusSerif-Regular.otf` c2sc Small Capitals From Capitals calt Contextual Alternates case Case-Sensitive Forms ccmp Glyph Composition/Decomposition cpsp Capital Spacing dlig Discretionary Ligatures frac Fractions hlig Historical Ligatures kern Kerning liga Standard Ligatures lnum Lining Figures mark Mark Positioning mkmk Mark to Mark Positioning onum Oldstyle Figures pnum Proportional Figures salt Stylistic Alternates smcp Small Capitals ss01 Stylistic Set 1 ss02 Stylistic Set 2 ss03 Stylistic Set 3 ss04 Stylistic Set 4 ss05 Stylistic Set 5 ss06 Stylistic Set 6 ss07 Stylistic Set 7 subs Subscript sups Superscript tnum Tabular Figures zero Slashed Zero Herbert
On 11/3/22 12:52, Herbert Voss via ntg-context wrote:
You'll get only the features with otfinfo in the terminal. For example:
Thank you, I was aware of that. But that's only the first step: you still have to use this list to define ConTeXt featuresets and then typeset. I was trying to build a cld document that automates this process, but can't get it to work. And I suspect that somewhere in the distribution, there is already a module that does exactly that. Thomas
On 11/3/2022 12:52 PM, Herbert Voss via ntg-context wrote:
Am 03.11.22 um 12:37 schrieb Thomas A. Schmitz via ntg-context:
Hi,
is there an easy way to get a list of all features that a font has and typeset a sample text to see the result of every single feature? There probably is, but I couldn't find anything...
You'll get only the features with otfinfo in the terminal. For example:
iMac:~ voss$ otfinfo -f `kpsewhich LibertinusSerif-Regular.otf` c2sc Small Capitals From Capitals calt Contextual Alternates case Case-Sensitive Forms ccmp Glyph Composition/Decomposition cpsp Capital Spacing dlig Discretionary Ligatures frac Fractions hlig Historical Ligatures kern Kerning liga Standard Ligatures lnum Lining Figures mark Mark Positioning mkmk Mark to Mark Positioning onum Oldstyle Figures pnum Proportional Figures salt Stylistic Alternates smcp Small Capitals ss01 Stylistic Set 1 ss02 Stylistic Set 2 ss03 Stylistic Set 3 ss04 Stylistic Set 4 ss05 Stylistic Set 5 ss06 Stylistic Set 6 ss07 Stylistic Set 7 subs Subscript sups Superscript tnum Tabular Figures zero Slashed Zero
mtxrun --script fonts --list --info --file LibertinusSerif-Regular.otf mtx-fonts | mtx-fonts | mapping : 1 mtx-fonts | fontname : libertinusserifregular mtx-fonts | fullname : libertinusserifregular mtx-fonts | filename : LibertinusSerif-Regular.otf mtx-fonts | family : libertinusserif mtx-fonts | weight : normal mtx-fonts | style : normal mtx-fonts | width : normal mtx-fonts | variant : normal mtx-fonts | fweight : conflict: regular mtx-fonts | mtx-fonts | gpos features: mtx-fonts | mtx-fonts | feature script languages mtx-fonts | mtx-fonts | cpsp cyrl dflt mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | latn dflt mtx-fonts | kern cyrl dflt mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | latn dflt mtx-fonts | mark cyrl dflt mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn dflt mtx-fonts | mkmk cyrl dflt mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn dflt mtx-fonts | mtx-fonts | gsub features: mtx-fonts | mtx-fonts | feature script languages mtx-fonts | mtx-fonts | c2sc cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | calt cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | case cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ccmp cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | dlig cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | frac cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | hlig cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | liga cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | lnum cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | locl cyrl mkd srb mtx-fonts | latn aze crt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | mark cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | onum cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | pnum cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | salt cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | smcp cyrl dflt mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | latn aze crt dflt kaz tat trk mtx-fonts | ss01 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss02 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss03 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss04 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss05 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss06 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ss07 cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | subs cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | sups cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | tnum cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | zero cyrl dflt mkd srb mtx-fonts | dflt dflt mtx-fonts | grek dflt mtx-fonts | hebr dflt mtx-fonts | latn aze crt dflt fin ism kaz lsm nor nsm sks ssm sve tat trk mtx-fonts | ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Am 03.11.22 um 12:37 schrieb Thomas A. Schmitz via ntg-context:
Hi,
is there an easy way to get a list of all features that a font has and typeset a sample text to see the result of every single feature? There probably is, but I couldn't find anything...
You get a lot of information with mtxrun --script fonts --info <fontname> but no samples. You can also get font information via mtxrun --script server --start and then open the given address in your browser; AFAIR you get samples, but it doesn’t work for me ATM, because the server script is not found in the current directory (might be a misconfiguration on my side). Hraban
Am 03.11.22 um 13:20 schrieb Henning Hraban Ramm via ntg-context:
Am 03.11.22 um 12:37 schrieb Thomas A. Schmitz via ntg-context:
You can also get font information via mtxrun --script server --start and then open the given address in your browser; AFAIR you get samples, but it doesn’t work for me ATM, because the server script is not found in the current directory (might be a misconfiguration on my side).
If you cd to .../tex/texmf-context/scripts/context/lua, start mtxrun --script server --start then open http://localhost:8088/mtx-server-ctx-fonttest.lua You should be able to check font samples with different features enabled. But I get another 404 on /mtx-server-ctx-fonttest-temp-02.pdf If it works for you, then it’s a problem of my installation, otherwise a regression in current LMTX... Hraban
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. Thomas
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*
On 11/3/2022 2:03 PM, Thomas A. Schmitz via ntg-context wrote: 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 -----------------------------------------------------------------
On 11/3/22 19:24, Hans Hagen via ntg-context wrote:
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:
Thank you, Hans! Yes, I had a hunch that most of this was unnecessary because the information is already there. I also thought it would be convenient to have a helper script that could display everything before I decide whether I want to add a font to my texmf-font tree... Will play with this and then wikify! All best Thomas
participants (4)
-
Hans Hagen
-
Henning Hraban Ramm
-
Herbert Voss
-
Thomas A. Schmitz