* MkIV problem+fix with \framed[location=depth / height / hanging]
@ 2013-05-14 21:00 Sietse Brouwer
2013-05-14 22:12 ` Wolfgang Schuster
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sietse Brouwer @ 2013-05-14 21:00 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 3090 bytes --]
Hi Hans,
I believe that in MkIV some \framed[location=...] keys are not
working, namely `depth`, `height`, and `hanging`. In MkIV these all
place the bottom of the frame flush with the baseline, like
[location=]. In MkII they behave more sensibly, as follows:
* depth: place bottom of frame flush with bottom of the line (i.e.
\strutdepth below baseline)
* height: place top of frame flush with top of line
* hanging: place top of frame flush with baseline
Test code below, mkii and mkiv output attached.
I have produced a fix for the code in pack-rul.mkiv [1], placed at the
very bottom of this e-mail. It works; but it is a pure-bred example of
cargo cult programming, i.e. lots of 'making it look right' and very
little understanding, so you will probably want to check it.
[1] http://repo.or.cz/w/context.git/blob/HEAD:/tex/context/base/pack-rul.mkiv
All the best,
Sietse
\setupcolors[state=start]
\setupblackrules[depth=\strutdepth,height=\strutheight,width=1mm,color=red]
\starttext
\ruledhbox
{A
\framed[width=2cm,align=middle,location=]
{location\\equals\\(nothing)}%
\blackrule
\framed[width=2cm,align=middle,location=depth]
{location\\equals\\depth}%
\blackrule
\framed[width=2cm,align=middle,location=height]
{location\\equals\\height}%
\blackrule
\framed[width=2cm,align=middle,location=hanging]{location\\equals\\hanging}
B}
\vskip2cm
\ruledhbox
{A
\framed[width=2cm,align=middle,location=low] {location\\equals\\low}
\framed[width=2cm,align=middle,location=line] {location\\equals\\line}
\framed[width=2cm,align=middle,location=high] {location\\equals\\high}
B}
\vskip2cm
\ruledhbox
{A
\framed[width=2cm,align=middle,location=bottom] {location\\equals\\bottom}
\framed[width=2cm,align=middle,location=lohi] {location\\equals\\lohi}
\framed[width=2cm,align=middle,location=middle] {location\\equals\\middle}
\framed[width=2cm,align=middle,location=top] {location\\equals\\top}
B}
\stoptext
------- This is the fixed code --------
\installframedlocator \v!hanging % best with strut=no
{}
- {\dp\b_framed_normal\scratchdimen
+ {\scratchdimen\ht\b_framed_normal
+ \setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
+ \dp\b_framed_normal\scratchdimen
\ht\b_framed_normal\zeropoint
\hbox{\box\b_framed_normal}}
\installframedlocator \v!depth
{}
- \ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
+ {\setbox\b_framed_normal\hbox{\lower\strutdp\box\b_framed_normal}%
+ \ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
\dp\b_framed_normal\strutdp
\hbox{\box\b_framed_normal}}
\installframedlocator \v!height
{}
- {\dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
+ {\scratchdimen\dimexpr \ht\b_framed_normal - \strutht \relax
+ \setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
+ \dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
\ht\b_framed_normal\strutht
\hbox{\box\b_framed_normal}}
[-- Attachment #2: mwe-framed-mkii.pdf --]
[-- Type: application/pdf, Size: 28676 bytes --]
[-- Attachment #3: mwe-framed-mkiv.pdf --]
[-- Type: application/pdf, Size: 9677 bytes --]
[-- Attachment #4: Type: text/plain, Size: 485 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: MkIV problem+fix with \framed[location=depth / height / hanging]
2013-05-14 21:00 MkIV problem+fix with \framed[location=depth / height / hanging] Sietse Brouwer
@ 2013-05-14 22:12 ` Wolfgang Schuster
2013-05-15 7:54 ` Hans Hagen
2013-05-15 7:58 ` Hans Hagen
2 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2013-05-14 22:12 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
Am 14.05.2013 um 23:00 schrieb Sietse Brouwer <sbbrouwer@gmail.com>:
> Hi Hans,
>
> I believe that in MkIV some \framed[location=...] keys are not
> working, namely `depth`, `height`, and `hanging`. In MkIV these all
> place the bottom of the frame flush with the baseline, like
> [location=]. In MkII they behave more sensibly, as follows:
>
> * depth: place bottom of frame flush with bottom of the line (i.e.
> \strutdepth below baseline)
> * height: place top of frame flush with top of line
> * hanging: place top of frame flush with baseline
The reason why all the location alternatives don’t work is because
the original \vbox for the content is converted to a \hbox which ignores
the changed values (even though the changed values for the height/depth
are used as seen at the surrounding box). The process to create a \hbox
happens when the background is applied with:
\def\pack_framed_add_background
{\setbox\b_framed_normal\hbox % was vbox
...
\egroup}}
Wolfgang
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: MkIV problem+fix with \framed[location=depth / height / hanging]
2013-05-14 21:00 MkIV problem+fix with \framed[location=depth / height / hanging] Sietse Brouwer
2013-05-14 22:12 ` Wolfgang Schuster
@ 2013-05-15 7:54 ` Hans Hagen
2013-05-15 7:58 ` Hans Hagen
2 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2013-05-15 7:54 UTC (permalink / raw)
To: ntg-context
On 5/14/2013 11:00 PM, Sietse Brouwer wrote:
> ------- This is the fixed code --------
>
> \installframedlocator \v!hanging % best with strut=no
> {}
> - {\dp\b_framed_normal\scratchdimen
> + {\scratchdimen\ht\b_framed_normal
> + \setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
> + \dp\b_framed_normal\scratchdimen
> \ht\b_framed_normal\zeropoint
> \hbox{\box\b_framed_normal}}
>
> \installframedlocator \v!depth
> {}
> - \ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
> + {\setbox\b_framed_normal\hbox{\lower\strutdp\box\b_framed_normal}%
> + \ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
> \dp\b_framed_normal\strutdp
> \hbox{\box\b_framed_normal}}
>
> \installframedlocator \v!height
> {}
> - {\dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
> + {\scratchdimen\dimexpr \ht\b_framed_normal - \strutht \relax
> + \setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
> + \dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
> \ht\b_framed_normal\strutht
> \hbox{\box\b_framed_normal}}
no need for the last \hbox then ..
\installframedlocator \v!hanging % best with strut=no
{}
{\scratchdimen\ht\b_framed_normal
\setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
\dp\b_framed_normal\scratchdimen
\ht\b_framed_normal\zeropoint
\box\b_framed_normal}
\installframedlocator \v!depth
{}
{\setbox\b_framed_normal\hbox{\lower\strutdp\box\b_framed_normal}%
\ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
\dp\b_framed_normal\strutdp
\box\b_framed_normal}
\installframedlocator \v!height
{}
{\scratchdimen\dimexpr \ht\b_framed_normal - \strutht \relax
\setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
\dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
\ht\b_framed_normal\strutht
\box\b_framed_normal}
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| 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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: MkIV problem+fix with \framed[location=depth / height / hanging]
2013-05-14 21:00 MkIV problem+fix with \framed[location=depth / height / hanging] Sietse Brouwer
2013-05-14 22:12 ` Wolfgang Schuster
2013-05-15 7:54 ` Hans Hagen
@ 2013-05-15 7:58 ` Hans Hagen
2013-05-15 10:26 ` Sietse Brouwer
2 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2013-05-15 7:58 UTC (permalink / raw)
To: ntg-context
On 5/14/2013 11:00 PM, Sietse Brouwer wrote:
> \setupcolors[state=start]
this is no longer needed in mkiv where colors are enabled by default
> \setupblackrules[depth=\strutdepth,height=\strutheight,width=1mm,color=red]
> ...
.. added to test zip ...
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| 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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-15 10:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-14 21:00 MkIV problem+fix with \framed[location=depth / height / hanging] Sietse Brouwer
2013-05-14 22:12 ` Wolfgang Schuster
2013-05-15 7:54 ` Hans Hagen
2013-05-15 7:58 ` Hans Hagen
2013-05-15 10:26 ` Sietse Brouwer
2013-05-15 10:36 ` Wolfgang Schuster
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).