Re: [NTG-context] Scaling down symbols and emojis

2019-01-19 Thread User 19087
As far as I can tell (by experimentation), bodyfont environment
features resolve in this order:
* matching size in the current file
* default environment in the current file
* matching size in 'font-pre.mkiv'
* default environment in 'font-pre.mkiv'
* default to 1.0 otherwise
This applies to individual features such as 'a' and 'b' and not entire
blocks. For example, if the [12pt] block provides 'a' but not 'b'
while the [default] block provides 'a' and 'b', then both blocks will
be used: 'a' from [12pt] and 'b' from [default].

With one exception: the 'x' and 'xx' sizes cannot be modified by the
current file:

\setupbodyfont[12pt]
\setupbodyfontenvironment [default] [x=2.0,xx=2.0]
\starttext
  m{\tfx m}{\tfxx m}
\stoptext

Furthermore there seems to be some extraneous output when the
bodyfontenvironment matches the current bodyfont size. For example,
the following outputs: "m12.0ptm12.0ptm"

\setupbodyfontenvironment [12pt] [m=2.0,n=2.0,]
\starttext
  m{\tfm m}{\tfn m}
\stoptext

On Sat, Jan 19, 2019 at 3:59 AM Wolfgang Schuster
 wrote:
> Why do you need this when you can just change the style of commands
> with use \tfx (e.g. \high or \low) to use the \tfm size?

With that out of the way, I don't know how to change commands which
use '\tfx' to use '\tfm' instead. Unless you mean this (though
technically they still use '\tfx', it just matches '\tfm'):

\setupbodyfontenvironment [default] [m=0.8,n=0.6,x=0.8,xx=0.6]

Even if that did work, which it doesn't (see above), it would be
preferable to use the default bodyfont environment shipped by ConTeXt.
It probably exists for good reasons: matching the most common optical
font sizes, for aesthetics, and for consistency. I don't want the 'x'
and 'xx' sizes to vary between standard ConTeXt documents, and
documents which need to provide the 'n' and 'm' sizes.

It's also more work, as mentioned further up the thread. It may not be
strictly necessary to specify 'x' and 'xx' for each new size-specific
bodyfont environment, as they'll be inherited from [default]. But for
consistency each bodyfont size should have 'x' and 'xx' sizes matching
those from ConTeXt, and these vary with bodyfont size. That means
looking them up in 'font-pre.mkiv', a little math, and remembering to
do it every time you switch sizes. And that's ignoring the fact that
'\definebodyfont' can also override these sizes. I think using a macro
is simpler.
___
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
___

Re: [NTG-context] Scaling down symbols and emojis

2019-01-19 Thread User 19087
On Fri, Jan 18, 2019 at 4:44 PM User 19087  wrote:
> There must be some other method (at least via luatex) to
> obtain the 'x' and 'xx' sizes as workable dimensions.

I've come up with the following macro and I'd like some feedback. Will
it work consistently? Any suggestions for improvement?


% A '\start...\stopluacode' block inside a macro is just as bad (or worse?) to
% escape as '\ctxlua' code. So create a function here for use elsewhere.
%
% There were multiple font sizes in the "specification" and "parameters"
% tables, hopefully I picked the right one.
%
% It turns out that for ConTeXt there is a difference between the 10pt and
% 10.0pt sizes: the former is predefined in the body font environment that
% ships with ConTeXt while the latter causes ConTeXt to generate a new body
% font environment. Unfortunately '\the' displays values with trailing 0s, and
% so the result must be converted to a string and truncated in lua.
\startluacode
userdata = userdata or {}
userdata.fontsize = function ()
local fs
fs = font.getfont(font.current()).specification.size
fs = tostring(fs/2^16):gsub("%.?0+$","") .. "pt"
return fs
end
\stopluacode

% In some situations the 'tx' and 'txx' sizes are ignored by ConTeXt. This
% macro determines the font size that would have been used by such a command
% and switches the entire body font to that size for the duration of the second
% argument. The chosen size depends on the 'x' and 'xx' values of the specific
% body font environment nearest in size to the current body font, though the
% font itself (via definebodyfont) may override those values.
\define[2]\tosize{%
% Use a scratch box to prevent any typesetting. Otherwise changes to the
% font size would be compounded: 'tfxx' remaining in effect after
% 'switchtobodyfont'. I've also tried stop...starthiding, but that prevents
% all processing of contents.
\setbox\scratchbox\hbox{%
#1%
% Use a global lua variable rather than globally setting a scratch
% register.
\startluacode
userdata = userdata or {}
userdata.lastfontsize = userdata.fontsize()
\stopluacode%
}%
{\switchtobodyfont[\ctxlua{context(userdata.lastfontsize)}]#2}%
}

Test{\tfx Test}
\tosize{\tfx Unwanted}{Test{\tfx Test}}
___
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
___

Re: [NTG-context] Scaling down symbols and emojis

2019-01-18 Thread User 19087
On Wed, Jan 16, 2019 at 6:29 PM User 19087  wrote:
>> Or I use {\switchtobodyfont[...]\symbol[ShortForty]} in the document.
>> At that point the body font may have been switched to a size whose
>> environment defines different values for 'x' and 'xx'. Or perhaps the
>> current or default body font, via \definebodyfont, overrides the 'x'
>> and 'xx' sizes. In either case it would be more flexible to query the
>> current values of 'x' and 'xx' rather than hardcoding the values of
>> 'n' and 'm'.

On Fri, Jan 18, 2019 at 6:47 AM Wolfgang Schuster
 wrote:
> The default sizes (12pt, 14.4pt etc,) set the x and xx sizes to a fixed
> size which leads
> to differences and the scale factor.

That's yet another reason to avoiding fixing the values of the 'm' and
'n' sizes. As of now, you have to first decide your font size, lookup
the 'x' and 'xx' sizes in font-pre.mkiv and do a little math... every
time you switch fonts. Instead I've come up with a function that
doesn't depend on hardcoded globals:

\define[2]\tosize{%
\setbox0=\hbox{\tf x}%
\setbox1=\hbox{#1 x}%
\startluacode
tex.dimen[2] = tex.getdimen("bodyfontsize") * tex.box[1].height /
tex.box[0].height
\stopluacode%
{\switchtobodyfont[\the\dimen2]#2}%
}

\tosize{\tfx}{\symbol[ShortForty]}


However I worry that measuring individual letter sizes to deduce the
actual font size may not be foolproof, especially with optical sizes
and so on. There must be some other method (at least via luatex) to
obtain the 'x' and 'xx' sizes as workable dimensions.

thanks,
___
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
___

Re: [NTG-context] Scaling down symbols and emojis

2019-01-17 Thread User 19087
On Wed, Jan 16, 2019 at 4:24 PM Wolfgang Schuster
 wrote:
> > % Which factor should I use to match \tfxx?
> > \symbol[ShortForty]
> > \scale[factor=4]{\symbol[ShortForty]}
> x = 0.8
> xx = 0.6

That's what the ConTeXt Reference Manual also says, but that doesn't
seem to match what ConTeXt does. The 'x' ratio is 0.835 and the 'xx'
ratio is 0.6667. The 'm' ratio is 0.802 and the 'n' ratio is 0.601,
which is "close enough".

\definefontsize[m]
\definefontsize[n]

\setupbodyfontenvironment
  [default]
  [m=0.8,
   n=0.6,
  ]

\starttext
{\tfx m}{\tfm m}m
{\tfxx m}{\tfn m}m

\setbox\scratchbox\hbox{m}
\the\ht\scratchbox
\setbox\scratchbox\hbox{\tfx m}
\the\ht\scratchbox
\setbox\scratchbox\hbox{\tfxx m}
\the\ht\scratchbox

\setbox\scratchbox\hbox{m}
\the\ht\scratchbox
\setbox\scratchbox\hbox{\tfm m}
\the\ht\scratchbox
\setbox\scratchbox\hbox{\tfn m}
\the\ht\scratchbox
\stoptext
___
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
___

Re: [NTG-context] Scaling down symbols and emojis

2019-01-17 Thread User 19087
On Wed, Jan 16, 2019 at 4:24 PM Wolfgang Schuster
 wrote:
>
> User 19087 schrieb am 16.01.19 um 21:56:
> > I'm having trouble scaling down symbols and emojis. For a while I
> > assumed these don't scale with the current font size. Then I scoured
> > the mailing list and realized that while scaling down seems broken,
> > scaling up works as expected:
> \tx (or \tfx, \bfx etc.) and \txx are ignored in some cases unlike the
> other size switches (\tfa etc.).

Out of curiosity, why are these switches sometimes ignored?
___
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
___

Re: [NTG-context] Scaling down symbols and emojis

2019-01-16 Thread User 19087
On Wed, Jan 16, 2019 at 4:24 PM Wolfgang Schuster
 wrote:
> When you need a switch for a smaller size which doesn’t has these
> limitations you can just create them:
>
> \definefontsize [m]
> \definefontsize [n]
>
> \setupbodyfontenvironment
>[default]
>[m=0.8,
> n=0.6]

In case the current bodyfontenvironment overrides the smaller sizes is
it possible to define 'n' and 'm' in terms of 'x' and 'xx'?

% this should happen after \setupbodyfont so the correct values are fetched
\setupbodyfontenvironment
[default]
[m=\getcurrentbodyfontenvironment{x},
 n=\getcurrentbodyfontenvironment{xx}]

> > % This also works but is less than ideal when matching surrounding
> > font sizes.
> > % Which factor should I use to match \tfxx?
> > \symbol[ShortForty]
> > \scale[factor=4]{\symbol[ShortForty]}
> x = 0.8
> xx = 0.6

Or I use {\switchtobodyfont[...]\symbol[ShortForty]} in the document.
At that point the body font may have been switched to a size whose
environment defines different values for 'x' and 'xx'. Or perhaps the
current or default body font, via \definebodyfont, overrides the 'x'
and 'xx' sizes. In either case it would be more flexible to query the
current values of 'x' and 'xx' rather than hardcoding the values of
'n' and 'm'. Is something like this possible:

% provide size name ('xx', 'x', 'a', 'b', 'c', 'd') and contents
\define[2]\at_size_unrestricted{\switchtobodyfont[\getcurrentsize[#1]]#2}

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

[NTG-context] Scaling down symbols and emojis

2019-01-16 Thread User 19087
I'm having trouble scaling down symbols and emojis. For a while I assumed
these don't scale with the current font size. Then I scoured the mailing
list and realized that while scaling down seems broken, scaling up works as
expected:


\usesymbols[mvs]

\setupsymbolset[martinvogel 2]

%\showallmakeup

\starttext
% Progressively larger as expected.
\symbol[ShortForty]
{\tfa\symbol[ShortForty]}
{\tfb\symbol[ShortForty]}
{\tfc\symbol[ShortForty]}
{\tfd\symbol[ShortForty]}

% Unexpectedly all the same size.
\symbol[ShortForty]
{\tfx\symbol[ShortForty]}
{\tfxx\symbol[ShortForty]}

% This works, but why? Isn't \small just a synonym for \tfx via
% \definealternativestyle? Anyway there is no synonym for \tfxx.
\symbol[ShortForty]
{\switchtobodyfont[small]\symbol[ShortForty]}
{\small\symbol[ShortForty]}

% This also works but is less than ideal when matching surrounding font
sizes.
% Which factor should I use to match \tfxx?
\symbol[ShortForty]
\scale[factor=4]{\symbol[ShortForty]}

% Same as above comment, more or less.
\symbol[ShortForty]
{\switchtobodyfont[5pt]\symbol[ShortForty]}
\stoptext


* MWE for builtin symbols; emojis require local fonts. I assume whichever
solution would apply equally to either.

thanks,
___
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
___

Re: [NTG-context] issue: multiple viewer layers

2019-01-08 Thread User 19087
You're right, my example was broken. With \stops it works as intended, as
does your example.

Thanks,
___
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
___

[NTG-context] Fwd: issue: multiple viewer layers

2019-01-07 Thread User 19087
Layers are not properly closed when using more than one layer, so that each
layer subsumes all subsequent content. Tested in Adobe Reader 11. I first
mentioned this at https://tex.stackexchange.com/a/467005/174577, so I'm
basically rehashing all the examples:

When \showallmakeup is enabled, all content after \viewerlayer[print]
belongs to that layer:

\defineviewerlayer[print][state=stop,printable=yes,]
\showallmakeup
\starttext
\viewerlayer[print]{One} more.
\samplefile{knuth}
\stoptext



The same problem as above, demonstrated with \start...stopviewerlayer
rather than \viewerlayer:

\defineviewerlayer[print][state=stop,printable=yes,]
\showallmakeup
\starttext
\startviewerlayer[print]
And then:
\stopviewerlayer
\samplefile{knuth}
\stoptext



Rather than two independent layers, the print layer (along with other
content) belongs to the view layer. So hiding the view layer hides all
content in this document:

 [view]
--- first
--- \samplefile{knuth}
--- [print]
-- second

\defineviewerlayer[print][state=stop,printable=yes,]
\defineviewerlayer[view][state=start,printable=no,]
\starttext
\startviewerlayer[view]{first}
\samplefile{knuth}
\startviewerlayer[print]{second}
\stoptext
___
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
___

[NTG-context] Fwd: issue: "printable" viewer layers lack compatibility

2019-01-07 Thread User 19087
In 2017 ghostscript added support for the /Print and /View keys of the
Optional Content /Usage dictionary[1]. The use of '-dPrinted' should
display the print-only layer, per the documentation[2]:

gs -o output.pdf -sDEVICE=pdfwrite -dPrinted input.pdf

>From their repository you can see that poppler (i.e. evince) also checks
the /Print and /View keys[3].

I'm reporting this here since neither render ConTeXt's "printable" viewer
layers - not while viewing, and not after printing.

[1]
http://git.ghostscript.com/?p=ghostpdl.git;h=9e621d6ffb0e29c5de8331bf2c95003c8cf85941
[2] https://ghostscript.com/doc/current/Use.htm#PDF_switches
[3]
https://gitlab.freedesktop.org/poppler/poppler/blob/master/poppler/OptionalContent.cc#L328
___
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
___