* OTF features
@ 2008-08-05 11:57 Willi Egger
2008-08-05 12:37 ` Olivier Guéry
2008-08-05 13:44 ` Hans Hagen
0 siblings, 2 replies; 4+ messages in thread
From: Willi Egger @ 2008-08-05 11:57 UTC (permalink / raw)
To: NTG-Context ConTeXt users
Dear OTF-users,
Is there a simple way to get to know the features wich a given OTF has?
Happy TeXing!
Willi
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: OTF features
2008-08-05 11:57 OTF features Willi Egger
@ 2008-08-05 12:37 ` Olivier Guéry
2008-08-05 13:44 ` Hans Hagen
1 sibling, 0 replies; 4+ messages in thread
From: Olivier Guéry @ 2008-08-05 12:37 UTC (permalink / raw)
To: mailing list for ConTeXt users
2008/8/5 Willi Egger <w.egger@boede.nl>:
> Dear OTF-users,
>
>
> Is there a simple way to get to know the features wich a given OTF has?
You can use otfinfo -f under linux (don't know under other OS).
Olivier.
--
[Message tapé sur un clavier Bépo : http://www.clavier-dvorak.org ]
http://nemolivier.blogspot.com
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: OTF features
2008-08-05 11:57 OTF features Willi Egger
2008-08-05 12:37 ` Olivier Guéry
@ 2008-08-05 13:44 ` Hans Hagen
2008-08-05 16:08 ` Willi Egger
1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2008-08-05 13:44 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]
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
-----------------------------------------------------------------
[-- Attachment #2: mtx-fonts.lua --]
[-- Type: text/plain, Size: 5473 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 487 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: OTF features
2008-08-05 13:44 ` Hans Hagen
@ 2008-08-05 16:08 ` Willi Egger
0 siblings, 0 replies; 4+ messages in thread
From: Willi Egger @ 2008-08-05 16:08 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-08-05 16:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-05 11:57 OTF features 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 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).