From: Willi Egger <w.egger@boede.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: OTF features
Date: Tue, 5 Aug 2008 18:08:13 +0200 [thread overview]
Message-ID: <8B8D073C-4B5E-4EB0-AADF-F7ED510FAFA1@boede.nl> (raw)
In-Reply-To: <48985934.9030501@wxs.nl>
Hans, thanks! That is great.
Willi
On Aug 5, 2008, at 3:44 PM, Hans Hagen wrote:
> Willi Egger wrote:
>> Dear OTF-users,
>> Is there a simple way to get to know the features wich a given OTF
>> has?
>
> ok, there is one now ... (attached file goes to scripts/context/lua
>
> >mtxrun --script font --list "zapfinoextra.*four" --info
> MtxRun |
> MtxRun | fontname: zapfinoextralt-four
> MtxRun | fullname: ZapfinoExtraLT-Four
> MtxRun | filename: zapfinoextralt-four.otf
> MtxRun |
> MtxRun | feature : -> latn rom
> MtxRun | feature : aalt -> latn dflt
> MtxRun | feature : case -> latn afk nld rom trk dflt
> MtxRun | feature : crcy -> latn afk nld rom trk dflt
> MtxRun | feature : dlig -> latn afk nld rom trk dflt
> MtxRun | feature : dnom -> latn afk nld rom trk dflt
> MtxRun | feature : dpng -> latn afk nld rom trk dflt
> MtxRun | feature : frac -> latn afk nld rom trk dflt
> MtxRun | feature : liga -> latn afk nld rom trk dflt
> MtxRun | feature : locl -> latn afk nld rom trk dflt
> MtxRun | feature : numr -> latn afk nld rom trk dflt
> MtxRun | feature : ordn -> latn afk nld rom trk dflt
> MtxRun | feature : ornm -> latn dflt
> MtxRun | feature : sups -> latn afk nld rom trk dflt
> MtxRun |
>
>
> -----------------------------------------------------------------
> 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
> -----------------------------------------------------------------
> if not modules then modules = { } end modules ['mtx-fonts'] = {
> version = 1.001,
> comment = "companion to mtxrun.lua",
> author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
> copyright = "PRAGMA ADE / ConTeXt Development Team",
> license = "see context related readme files"
> }
>
> dofile(input.find_file("font-syn.lua"))
>
> scripts = scripts or { }
> scripts.fonts = scripts.fonts or { }
>
> function scripts.fonts.reload(verbose)
> fonts.names.load(true,verbose)
> end
>
> local function showfeatures(v,n,f,s)
> local filename = input.find_file(f,type) or ""
> if filename ~= "" then
> local ff = fontforge.open(filename)
> if ff then
> local data = fontforge.to_table(ff)
> fontforge.close(ff)
> local features = { }
> local function collect(what)
> if data[what] then
> for _, d in ipairs(data[what]) do
> if d.features then
> for _, df in ipairs(d.features) do
> features[df.tag] = features[df.tag]
> or { }
> for _, ds in ipairs(df.scripts) do
> features[df.tag][ds.script] =
> features[df.tag][ds.script] or { }
> for _, lang in ipairs(ds.langs) do
> features[df.tag][ds.script]
> [lang] = true
> end
> end
> end
> end
> end
> end
> end
> collect('gsub')
> collect('gpos')
> input.verbose = true
> input.report("")
> input.report("fontname: %s",v)
> input.report("fullname: %s",n)
> input.report("filename: %s",f)
> input.report("")
> for _, f in ipairs(table.sortedkeys(features)) do
> local ff = features[f]
> for _, s in ipairs(table.sortedkeys(ff)) do
> local ss = ff[s]
> input.report("feature : %s -> %s %s",f,s,
> (table.concat(table.sortedkeys(ss), " ")):lower())
> end
> end
> input.report("")
> end
> end
> end
>
> function scripts.fonts.list(pattern,reload,all,info)
> if reload then
> input.report("fontnames, reloading font database")
> end
> local t = fonts.names.list(pattern,reload)
> if reload then
> input.report("fontnames, done\n\n")
> end
> if t then
> local s, w = table.sortedkeys(t), { 0, 0, 0 }
> local function action(f)
> for k,v in pairs(s) do
> if all or v == t[v][2]:lower() then
> local type, name, file, sub = unpack(t[v])
> f(v,name,file,sub)
> end
> end
> end
> action(function(v,n,f,s)
> if #v > w[1] then w[1] = #v end
> if #n > w[2] then w[2] = #n end
> if #f > w[3] then w[3] = #f end
> end)
> action(function(v,n,f,s)
> if s then s = "(sub)" else s = "" end
> if info then
> showfeatures(v,n,f,s)
> else
> local str = string.format("%s %s %s %s",v:padd(w
> [1]," "),n:padd(w[2]," "),f:padd(w[3]," "), s)
> print(str:strip())
> end
> end)
> end
> end
>
> function scripts.fonts.save(name,sub)
> local function save(savename,fontblob)
> if fontblob then
> savename = savename:lower() .. ".lua"
> input.report("fontsave, saving data in %s",savename)
> table.tofile(savename,fontforge.to_table
> (fontblob),"return")
> fontforge.close(fontblob)
> end
> end
> if name and name ~= "" then
> local filename = input.find_file(name) -- maybe also search
> for opentype
> if filename and filename ~= "" then
> local suffix = file.extname(filename)
> if suffix == 'ttf' or suffix == 'otf' or suffix ==
> 'ttc' then
> local fontinfo = fontforge.info(filename)
> if fontinfo then
> if fontinfo[1] then
> for _, v in ipairs(fontinfo) do
> save(v.fontname,fontforge.open
> (filename,v.fullname))
> end
> else
> save(fontinfo.fullname,fontforge.open
> (filename))
> end
> end
> end
> end
> end
> end
>
> banner = banner .. " | font tools "
>
> messages.help = [[
> --reload generate new font database
> --list [--info] list installed fonts (show info)
> --save save open type font in raw table
>
> --pattern=str filter files
> --all provide alternatives
> ]]
>
> if environment.argument("reload") then
> local verbose = environment.argument("verbose")
> scripts.fonts.reload(verbose)
> elseif environment.argument("list") then
> local pattern = environment.argument("pattern") or
> environment.files[1] or ""
> local all = environment.argument("all")
> local info = environment.argument("info")
> local reload = environment.argument("reload")
> scripts.fonts.list(pattern,reload,all,info)
> elseif environment.argument("save") then
> local name = environment.files[1] or ""
> local sub = environment.files[2] or ""
> scripts.fonts.save(name,sub)
> else
> input.help(banner,messages.help)
> end
> ______________________________________________________________________
> _____________
> 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://tex.aanhet.net
> archive : https://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ______________________________________________________________________
> _____________
___________________________________________________________________________________
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://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2008-08-05 16:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 11:57 Willi Egger
2008-08-05 12:37 ` Olivier Guéry
2008-08-05 13:44 ` Hans Hagen
2008-08-05 16:08 ` Willi Egger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8B8D073C-4B5E-4EB0-AADF-F7ED510FAFA1@boede.nl \
--to=w.egger@boede.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).