* using lua fonts
@ 2018-05-03 18:26 Ulrike Fischer
2018-05-08 8:43 ` Hans Hagen
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ulrike Fischer @ 2018-05-03 18:26 UTC (permalink / raw)
To: ntg-context
I'm trying to run one of the examples of fonts-mkiv.pdf
I copied the code from 4.5 Lua fonts to a file
"fonts-demo-rule.lua". This lua file is in the same directory as my
test file.
Then I tried
\definefont
[MyRuleFont]
[file:fonts-demo-rule.lua*default sa 1]
\starttext
{\MyRuleFont So when we use it we get text }
\stoptext
but I get in the log
fonts > defining > forced type 'lua' of 'fonts-demo-rule' not found
fonts > defining > font with asked name 'fonts-demo-rule' is not
found using lookup 'file'
fonts > defining > unknown font 'fonts-demo-rule', loading aborted
fonts > defining > unable to define 'fonts-demo-rule.lua' as
'MyRuleFont--0'
The file itself is found (I can see its path later on). What is
going on here?
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
___________________________________________________________________________________
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] 9+ messages in thread
* Re: using lua fonts
2018-05-03 18:26 using lua fonts Ulrike Fischer
@ 2018-05-08 8:43 ` Hans Hagen
2018-05-08 14:01 ` Ulrike Fischer
2018-05-08 14:46 ` Ulrike Fischer
2018-05-09 1:02 ` Henri Menke
2 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-05-08 8:43 UTC (permalink / raw)
To: ntg-context
On 5/3/2018 8:26 PM, Ulrike Fischer wrote:
> I'm trying to run one of the examples of fonts-mkiv.pdf
>
> I copied the code from 4.5 Lua fonts to a file
> "fonts-demo-rule.lua". This lua file is in the same directory as my
> test file.
>
> Then I tried
>
> \definefont
> [MyRuleFont]
> [file:fonts-demo-rule.lua*default sa 1]
>
> \starttext
>
> {\MyRuleFont So when we use it we get text }
>
> \stoptext
>
> but I get in the log
>
> fonts > defining > forced type 'lua' of 'fonts-demo-rule' not found
> fonts > defining > font with asked name 'fonts-demo-rule' is not
> found using lookup 'file'
> fonts > defining > unknown font 'fonts-demo-rule', loading aborted
> fonts > defining > unable to define 'fonts-demo-rule.lua' as
> 'MyRuleFont--0'
>
> The file itself is found (I can see its path later on). What is
> going on here?
i have no clue as it works ok here
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 / 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] 9+ messages in thread
* Re: using lua fonts
2018-05-08 8:43 ` Hans Hagen
@ 2018-05-08 14:01 ` Ulrike Fischer
2018-05-08 14:17 ` Hans Hagen
0 siblings, 1 reply; 9+ messages in thread
From: Ulrike Fischer @ 2018-05-08 14:01 UTC (permalink / raw)
To: ntg-context
Am Tue, 8 May 2018 10:43:00 +0200 schrieb Hans Hagen:
> i have no clue as it works ok here
;-(.
Where is the fonts-demo-rule.lua on your system? I don't think that
it is actually loaded in my test file. I can write nonsense in it
and get no error.
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
___________________________________________________________________________________
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] 9+ messages in thread
* Re: using lua fonts
2018-05-08 14:01 ` Ulrike Fischer
@ 2018-05-08 14:17 ` Hans Hagen
0 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2018-05-08 14:17 UTC (permalink / raw)
To: ntg-context
On 5/8/2018 4:01 PM, Ulrike Fischer wrote:
> Am Tue, 8 May 2018 10:43:00 +0200 schrieb Hans Hagen:
>
>> i have no clue as it works ok here
>
> ;-(.
>
> Where is the fonts-demo-rule.lua on your system? I don't think that
> it is actually loaded in my test file. I can write nonsense in it
> and get no error.
current directory
-----------------------------------------------------------------
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 / 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] 9+ messages in thread
* Re: using lua fonts
2018-05-03 18:26 using lua fonts Ulrike Fischer
2018-05-08 8:43 ` Hans Hagen
@ 2018-05-08 14:46 ` Ulrike Fischer
2018-05-09 1:02 ` Henri Menke
2 siblings, 0 replies; 9+ messages in thread
From: Ulrike Fischer @ 2018-05-08 14:46 UTC (permalink / raw)
To: ntg-context
Am Thu, 3 May 2018 20:26:20 +0200 schrieb Ulrike Fischer:
> I'm trying to run one of the examples of fonts-mkiv.pdf
>
> I copied the code from 4.5 Lua fonts to a file
> "fonts-demo-rule.lua". This lua file is in the same directory as my
> test file.
>
...
>
> but I get in the log
>
> fonts > defining > forced type 'lua' of 'fonts-demo-rule' not found
For the record: It was a silly error. As the lua file is not in the
sources I had to copy & paste from the fonts-mkiv.pdf and overlooked
that the code has a last "end" on the next page. After adding it to
the lua everything worked as expected.
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
___________________________________________________________________________________
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] 9+ messages in thread
* Re: using lua fonts
2018-05-03 18:26 using lua fonts Ulrike Fischer
2018-05-08 8:43 ` Hans Hagen
2018-05-08 14:46 ` Ulrike Fischer
@ 2018-05-09 1:02 ` Henri Menke
2018-05-09 7:56 ` Hans Hagen
2 siblings, 1 reply; 9+ messages in thread
From: Henri Menke @ 2018-05-09 1:02 UTC (permalink / raw)
To: ntg-context
Dear list,
this is a follow-up on Ulrike's post, so I'm just hijacking the thread.
How can I use the Lua fonts in Plain? It works fine if I just remove
ConTeXt-specific actualtext bits but as soon as I add features to the
font, the name resolution fails with something like
! Font
\mainfont=file:fonts-demo-rule.lua:original=file:texgyrepagella-regular.
otf not loadable: metric data not found or bad.
MWE is below as always.
Cheers, Henri
----------- test.tex -----------
\input luaotfload.sty
\font\mainfont="file:fonts-demo-rule.lua":original=file:texgyrepagella-regular.otf
\mainfont
This code is stored in fonts-demo-rule.lua and we can load that font in
the usual way,
by specifying a filename.
\bye
----------- fonts-demo-rule.lua -----------
return function(specification)
local features = specification.features.normal
local name = features.original or "dejavu-serif"
local option = features.option -- we only support "line"
local size = specification.size -- always set
local detail = specification.detail -- e.g. default
if detail then
name = name .. "*" .. detail
end
local f, id = fonts.constructors.readanddefine(name,size)
if f then
f.properties.name = specification.name
f.properties.virtualized = true
f.fonts = {
{ id = id },
}
for s in string.gmatch("aeuioy",".") do
local n = utf.byte(s)
local c = f.characters[n]
if c then
local w = c.width or 0
local h = c.height or 0
local d = c.depth or 0
if option == "line" then
f.characters[n].commands = {
{ "rule", option == "line" and size/10, w },
}
else
f.characters[n].commands = {
{ "down", d },
{ "rule", h + d, w },
}
end
else
-- probably a real bad font
end
end
end
return f
end
On 04/05/18 06:26, Ulrike Fischer wrote:
> I'm trying to run one of the examples of fonts-mkiv.pdf
>
> I copied the code from 4.5 Lua fonts to a file
> "fonts-demo-rule.lua". This lua file is in the same directory as my
> test file.
>
> Then I tried
>
> \definefont
> [MyRuleFont]
> [file:fonts-demo-rule.lua*default sa 1]
>
> \starttext
>
> {\MyRuleFont So when we use it we get text }
>
> \stoptext
>
> but I get in the log
>
> fonts > defining > forced type 'lua' of 'fonts-demo-rule' not found
> fonts > defining > font with asked name 'fonts-demo-rule' is not
> found using lookup 'file'
> fonts > defining > unknown font 'fonts-demo-rule', loading aborted
> fonts > defining > unable to define 'fonts-demo-rule.lua' as
> 'MyRuleFont--0'
>
> The file itself is found (I can see its path later on). What is
> going on here?
>
___________________________________________________________________________________
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] 9+ messages in thread
* Re: using lua fonts
2018-05-09 1:02 ` Henri Menke
@ 2018-05-09 7:56 ` Hans Hagen
2018-05-09 10:40 ` Ulrike Fischer
0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-05-09 7:56 UTC (permalink / raw)
To: ntg-context
On 5/9/2018 3:02 AM, Henri Menke wrote:
> Dear list,
>
> this is a follow-up on Ulrike's post, so I'm just hijacking the thread.
>
> How can I use the Lua fonts in Plain? It works fine if I just remove
> ConTeXt-specific actualtext bits but as soon as I add features to the
> font, the name resolution fails with something like
>
> ! Font
> \mainfont=file:fonts-demo-rule.lua:original=file:texgyrepagella-regular.
> otf not loadable: metric data not found or bad.
>
> MWE is below as always.
(1) This lua font stuff was mostly written for demonstration purposes so
anything done like should really use the mechanisms available in the
macro package used
(2) If you use plain and want to play with the font interface you can
better use the plain code that comes with context because that is what I
can run here (this plain version has always been present btw).
(3) Examples coming from the font manual can use feaures only present in
context (for instance because it uses other code present in context or
because i didn't bother to make in generic).
(4) File lookup is macro package specific.
So, say that you have:
\font\mainfont="file:fonts-demo-rule.lua":original=texgyrepagellaregular;
\mainfont
This code is stored in fonts-demo-rule.lua and we can load that font in
the usual way, by specifying a filename.
\bye
and then in that lua file
if detail then
name = name .. ":" .. detail
end
watch how i replaced the * by : because only context has the * syntax
while you use/want the xetex syntax
mtxrun --script plain yourtexfile
should work gven that you made a format with
mtxrun --script plain --make
(mtxrun --script font --reload --simple will make a plain database if
needed)
It uses luatex-plain that ships with context as format (there's also a
luatex-test file that shows some font stuff).
Fwiw, the latest version also supports font effects at the font level
but one needs luatex 1.08 (which is the current garden version).
> Cheers, Henri
>
> ----------- test.tex -----------
>
> \input luaotfload.sty
>
> \font\mainfont="file:fonts-demo-rule.lua":original=file:texgyrepagella-regular.otf
>
> \mainfont
>
> This code is stored in fonts-demo-rule.lua and we can load that font in
> the usual way,
> by specifying a filename.
>
> \bye
>
> ----------- fonts-demo-rule.lua -----------
>
> return function(specification)
> local features = specification.features.normal
> local name = features.original or "dejavu-serif"
> local option = features.option -- we only support "line"
> local size = specification.size -- always set
> local detail = specification.detail -- e.g. default
> if detail then
> name = name .. "*" .. detail
> end
> local f, id = fonts.constructors.readanddefine(name,size)
> if f then
> f.properties.name = specification.name
> f.properties.virtualized = true
> f.fonts = {
> { id = id },
> }
> for s in string.gmatch("aeuioy",".") do
> local n = utf.byte(s)
> local c = f.characters[n]
> if c then
> local w = c.width or 0
> local h = c.height or 0
> local d = c.depth or 0
> if option == "line" then
> f.characters[n].commands = {
> { "rule", option == "line" and size/10, w },
> }
> else
> f.characters[n].commands = {
> { "down", d },
> { "rule", h + d, w },
> }
> end
> else
> -- probably a real bad font
> end
> end
> end
> return f
> end
>
> On 04/05/18 06:26, Ulrike Fischer wrote:
>> I'm trying to run one of the examples of fonts-mkiv.pdf
>>
>> I copied the code from 4.5 Lua fonts to a file
>> "fonts-demo-rule.lua". This lua file is in the same directory as my
>> test file.
>>
>> Then I tried
>>
>> \definefont
>> [MyRuleFont]
>> [file:fonts-demo-rule.lua*default sa 1]
>>
>> \starttext
>>
>> {\MyRuleFont So when we use it we get text }
>>
>> \stoptext
>>
>> but I get in the log
>>
>> fonts > defining > forced type 'lua' of 'fonts-demo-rule' not found
>> fonts > defining > font with asked name 'fonts-demo-rule' is not
>> found using lookup 'file'
>> fonts > defining > unknown font 'fonts-demo-rule', loading aborted
>> fonts > defining > unable to define 'fonts-demo-rule.lua' as
>> 'MyRuleFont--0'
>>
>> The file itself is found (I can see its path later on). What is
>> going on here?
>>
> ___________________________________________________________________________________
>
> 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
> ___________________________________________________________________________________
--
-----------------------------------------------------------------
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 / 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] 9+ messages in thread
* Re: using lua fonts
2018-05-09 7:56 ` Hans Hagen
@ 2018-05-09 10:40 ` Ulrike Fischer
2018-05-09 11:05 ` Hans Hagen
0 siblings, 1 reply; 9+ messages in thread
From: Ulrike Fischer @ 2018-05-09 10:40 UTC (permalink / raw)
To: ntg-context
Am Wed, 9 May 2018 09:56:50 +0200 schrieb Hans Hagen:
> watch how i replaced the * by : because only context has the * syntax
Thank you very much for this explanation. I was wondering about the
same thing and replacing this made the code going.
Perhaps a general remark: I and certainly Henry too are quite aware
that some of the code is context specific. But it is often quite
difficult to see the boundaries -- which part of the examples are
generic and which rely on context (and on how much in context). It
is also not easy to decide which (lua) functions are "public" and
won't break at the next update of the font handler.
Henri: As you are interested in these things too, do you think it
would be a good idea to setup a github repository where we collect
such (plain and latex and context) examples?
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
___________________________________________________________________________________
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] 9+ messages in thread
* Re: using lua fonts
2018-05-09 10:40 ` Ulrike Fischer
@ 2018-05-09 11:05 ` Hans Hagen
0 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2018-05-09 11:05 UTC (permalink / raw)
To: ntg-context
On 5/9/2018 12:40 PM, Ulrike Fischer wrote:
> Am Wed, 9 May 2018 09:56:50 +0200 schrieb Hans Hagen:
>
>> watch how i replaced the * by : because only context has the * syntax
>
> Thank you very much for this explanation. I was wondering about the
> same thing and replacing this made the code going.
>
> Perhaps a general remark: I and certainly Henry too are quite aware
> that some of the code is context specific. But it is often quite
> difficult to see the boundaries -- which part of the examples are
> generic and which rely on context (and on how much in context). It
> is also not easy to decide which (lua) functions are "public" and
> won't break at the next update of the font handler.
normally function that are part of the generic loader code are publis
(one can argue about the low level helpers as these are only loaded for
the code to work i.e. i have no clue how useful these are outside
context) .. that code doesn't change that much nowadays (just assume
that i also use it in modules sometimes and i don't want to change that
too often)
then there is the wrapper code (that hooks into callbacks) which is also
mostly stable (unless we add something fundamental)
for instance, the effects feature has a sort of sub syntax that suits
context feature definitions, so for latex you probably need to map onto
that somehow ... i happily leave that to others to figure out as i don't
want to impose something (the same is true for variable fonts)
the big font manual is a context one so there can be examples that
assume the context user interface and there is not much we can do about
that (and i don't know much about latex apart from what i occasionally
see at some tex meeting) ... wrrt the font loader: the luatex-plain
version is sort of the generic reference ... anything written on top of
that is specific for a macro package
another difference is the font database ... i'm pretty sure that the
context one is quite generic but latex folks wanted their own so ...
> Henri: As you are interested in these things too, do you think it
> would be a good idea to setup a github repository where we collect
> such (plain and latex and context) examples?
anyway, if something doesn't work at some point we can always see why
and provide a compatibility hack in luatex-fonts-hacks or so
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 / 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] 9+ messages in thread
end of thread, other threads:[~2018-05-09 11:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 18:26 using lua fonts Ulrike Fischer
2018-05-08 8:43 ` Hans Hagen
2018-05-08 14:01 ` Ulrike Fischer
2018-05-08 14:17 ` Hans Hagen
2018-05-08 14:46 ` Ulrike Fischer
2018-05-09 1:02 ` Henri Menke
2018-05-09 7:56 ` Hans Hagen
2018-05-09 10:40 ` Ulrike Fischer
2018-05-09 11:05 ` Hans Hagen
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).