ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* cropping with \limitatefirstline
@ 2005-09-07 14:33 Peter Rolf
  2005-09-07 15:55 ` Hans Hagen
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Rolf @ 2005-09-07 14:33 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 276 bytes --]

Sorry to bother you Hans, but the macro is not working as expected...

I can see the cropped text (\underbar + special symbols) and there is an
hyphen symbol in the text only example.

I've added the example code I used for tests with \limitatetext and
\doboundtext.

Peter



[-- Attachment #2: crop.tex --]
[-- Type: text/plain, Size: 1772 bytes --]

% interface=en output=pdftex
% Time-stamp: <Mittwoch, 07 September 2005 16:25:40; crop.tex>
%

\setupcolors[state=start]

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{#1}%
  \ifdim\wd\scratchbox>#2\relax
    \setbox\scratchbox\hbox{#3}%
    \hsize#2\relax
    \advance\hsize-\wd\scratchbox
    \setbox\scratchbox\vbox{\forgetall#1}%
    \setbox\scratchbox\vsplit\scratchbox to \lineheight
    \vbox{\unvbox\scratchbox}%
    #3%
  \else
    #1%
  \fi
  \egroup}

\def\CropSymbol{\red...}%

\starttext

\setupframed[offset=overlay, height=\struttotal, framecolor=lightgray]

\framed[width=8ex,background=color,backgroundcolor=black]{\white 8ex}
\framed{\limitatefirstline{\underbar{Text dummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\underbar{Text dummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,background=color,backgroundcolor=black]{\white 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,background=color,backgroundcolor=black]{\white 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,background=color,backgroundcolor=black]{\white 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi \textdegree <>\&}{100pt}{\CropSymbol}}


\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: ""
%%% End:

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-07 14:33 cropping with \limitatefirstline Peter Rolf
@ 2005-09-07 15:55 ` Hans Hagen
  2005-09-07 16:18   ` Peter Rolf
  2005-09-08 14:24   ` Peter Rolf
  0 siblings, 2 replies; 11+ messages in thread
From: Hans Hagen @ 2005-09-07 15:55 UTC (permalink / raw)


Peter Rolf wrote:

>Sorry to bother you Hans, but the macro is not working as expected...
>
>I can see the cropped text (\underbar + special symbols) and there is an
>hyphen symbol in the text only example.
>
>I've added the example code I used for tests with \limitatetext and
>\doboundtext.
>  
>
\def\limitatefirstline#1#2#3%
  {\hbox\bgroup\strut
   \setbox\scratchbox\hbox{#1}%
   \ifdim\wd\scratchbox>#2\relax
     \setbox\scratchbox\hbox{#3}%
     \hsize#2\relax
     \advance\hsize-\wd\scratchbox
     \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
     \setbox\scratchbox\vsplit\scratchbox to \lineheight
     \vbox
       {\unvbox\scratchbox
        \global\setbox\plusone\lastbox
        \global\setbox\plusone\hbox{\unhbox\plusone}}%
     \box\plusone\removeunwantedspaces#3%
   \else
     #1%
   \fi
   \egroup}

of course there must be something to break (not possible with the non letters, so there you either need to add \hskip0pt's or do real clipping 

Hans 

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-07 15:55 ` Hans Hagen
@ 2005-09-07 16:18   ` Peter Rolf
  2005-09-08 14:24   ` Peter Rolf
  1 sibling, 0 replies; 11+ messages in thread
From: Peter Rolf @ 2005-09-07 16:18 UTC (permalink / raw)


Hans Hagen wrote:
> Peter Rolf wrote:
> 
>> Sorry to bother you Hans, but the macro is not working as expected...
>>
>> I can see the cropped text (\underbar + special symbols) and there is an
>> hyphen symbol in the text only example.
>>
>> I've added the example code I used for tests with \limitatetext and
>> \doboundtext.
>>  
>>
> \def\limitatefirstline#1#2#3%
>  {\hbox\bgroup\strut
>   \setbox\scratchbox\hbox{#1}%
>   \ifdim\wd\scratchbox>#2\relax
>     \setbox\scratchbox\hbox{#3}%
>     \hsize#2\relax
>     \advance\hsize-\wd\scratchbox
>     \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
>     \setbox\scratchbox\vsplit\scratchbox to \lineheight
>     \vbox
>       {\unvbox\scratchbox
>        \global\setbox\plusone\lastbox
>        \global\setbox\plusone\hbox{\unhbox\plusone}}%
>     \box\plusone\removeunwantedspaces#3%
>   \else
>     #1%
>   \fi
>   \egroup}
> 
> of course there must be something to break (not possible with the non
> letters, so there you either need to add \hskip0pt's or do real clipping

I'll try to understand your code later (make no sense at 30° and I need
to read again about the \lastbox trick and unboxing).
The text will be generated from XML source, so there is no problem in
inserting something (although clipping would be the cleaner solution).
Later....

So again many thanks!

Greetings,

Peter

> Hans
> -----------------------------------------------------------------
>                                          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
> -----------------------------------------------------------------
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-07 15:55 ` Hans Hagen
  2005-09-07 16:18   ` Peter Rolf
@ 2005-09-08 14:24   ` Peter Rolf
  2005-09-08 15:28     ` Hans Hagen
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Rolf @ 2005-09-08 14:24 UTC (permalink / raw)


Hi,

Hans Hagen wrote:
> Peter Rolf wrote:
> 
>> Sorry to bother you Hans, but the macro is not working as expected...
>>
>> I can see the cropped text (\underbar + special symbols) and there is an
>> hyphen symbol in the text only example.
>>
>> I've added the example code I used for tests with \limitatetext and
>> \doboundtext.
>>  
>>
> \def\limitatefirstline#1#2#3%
>  {\hbox\bgroup\strut
>   \setbox\scratchbox\hbox{#1}%
>   \ifdim\wd\scratchbox>#2\relax
>     \setbox\scratchbox\hbox{#3}%
>     \hsize#2\relax
>     \advance\hsize-\wd\scratchbox
>     \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
>     \setbox\scratchbox\vsplit\scratchbox to \lineheight
>     \vbox
>       {\unvbox\scratchbox
>        \global\setbox\plusone\lastbox
>        \global\setbox\plusone\hbox{\unhbox\plusone}}%
^^^^

>     \box\plusone\removeunwantedspaces#3%
>   \else
>     #1%
>   \fi
>   \egroup}
> 
> of course there must be something to break (not possible with the non
> letters, so there you either need to add \hskip0pt's or do real clipping
> Hans

So it fails in any case of nonbreakable text.

How about adding a failsafe test ala

\ifdim\dimexpr\wd\plusone+\wd of sentinel\relax>#2\relax
  \clip[width=\wd\plusone,...]{...#1...}\removeunwantedspaced#3%
\else
  \box\plusone\removeunwantedspaces#3%
\fi

One (ugly looking) partial character is still better than a bunch of
characters, that cross the width border.

I have played around with \clip, but it acts a little wild (vertical
position and height). Can't subdue it myself...

Greetings,

Peter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 14:24   ` Peter Rolf
@ 2005-09-08 15:28     ` Hans Hagen
  2005-09-08 15:56       ` Peter Rolf
  2005-09-08 16:34       ` Peter Rolf
  0 siblings, 2 replies; 11+ messages in thread
From: Hans Hagen @ 2005-09-08 15:28 UTC (permalink / raw)


Peter Rolf wrote:

>Hi,
>
>Hans Hagen wrote:
>  
>
>>Peter Rolf wrote:
>>
>>    
>>
>>>Sorry to bother you Hans, but the macro is not working as expected...
>>>
>>>I can see the cropped text (\underbar + special symbols) and there is an
>>>hyphen symbol in the text only example.
>>>
>>>I've added the example code I used for tests with \limitatetext and
>>>\doboundtext.
>>> 
>>>
>>>      
>>>
>>\def\limitatefirstline#1#2#3%
>> {\hbox\bgroup\strut
>>  \setbox\scratchbox\hbox{#1}%
>>  \ifdim\wd\scratchbox>#2\relax
>>    \setbox\scratchbox\hbox{#3}%
>>    \hsize#2\relax
>>    \advance\hsize-\wd\scratchbox
>>    \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
>>    \setbox\scratchbox\vsplit\scratchbox to \lineheight
>>    \vbox
>>      {\unvbox\scratchbox
>>       \global\setbox\plusone\lastbox
>>       \global\setbox\plusone\hbox{\unhbox\plusone}}%
>>    
>>
>^^^^
>
>  
>
>>    \box\plusone\removeunwantedspaces#3%
>>  \else
>>    #1%
>>  \fi
>>  \egroup}
>>
>>of course there must be something to break (not possible with the non
>>letters, so there you either need to add \hskip0pt's or do real clipping
>>Hans
>>    
>>
>
>So it fails in any case of nonbreakable text.
>
>How about adding a failsafe test ala
>
>\ifdim\dimexpr\wd\plusone+\wd of sentinel\relax>#2\relax
>  \clip[width=\wd\plusone,...]{...#1...}\removeunwantedspaced#3%
>\else
>  \box\plusone\removeunwantedspaces#3%
>\fi
>
>One (ugly looking) partial character is still better than a bunch of
>characters, that cross the width border.
>
>I have played around with \clip, but it acts a little wild (vertical
>position and height). Can't subdue it myself...
>  
>
\unprotect

\def\limitatefirstline#1#2#3%
  {\hbox\bgroup\strut
   \setbox\scratchbox\hbox{#1}%
   \ifdim\wd\scratchbox>#2\relax
     \setbox\scratchbox\hbox{#3}%
     \hsize#2\relax
     \advance\hsize-\wd\scratchbox
     \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
     \setbox\scratchbox\vsplit\scratchbox to \lineheight
     \vbox
       {\unvbox\scratchbox
        \global\setbox\plusone\lastbox
        \global\setbox\plusone\hbox{\unhbox\plusone}%
        \ifx\clip\undefined
          \box\plusone\removeunwantedspaces#3%
        \else\ifdim\wd\plusone>\hsize
          \hbox{\clip[\c!width=\hsize]{\box\plusone}#3}%
        \else
          \box\plusone\removeunwantedspaces#3%
        \fi\fi}%
   \else
     #1%
   \fi
   \egroup}

\protect

\ruledhbox{\limitatefirstline{xxxxxxxxxxxxxxxxxxxx}{3cm}{...}}


now you owe this list at least three wiki pages -) 

Hans 

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 15:28     ` Hans Hagen
@ 2005-09-08 15:56       ` Peter Rolf
  2005-09-08 17:22         ` Patrick Gundlach
  2005-09-08 16:34       ` Peter Rolf
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Rolf @ 2005-09-08 15:56 UTC (permalink / raw)


Hans Hagen wrote:
> Peter Rolf wrote:

....
> 
> now you owe this list at least three wiki pages -)
:))

I'll do my best. 'cropping text' is allready done,
but \limitatefirstline doesn't work on the wiki yet.


> Hans
> -----------------------------------------------------------------
>                                          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
> -----------------------------------------------------------------
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 15:28     ` Hans Hagen
  2005-09-08 15:56       ` Peter Rolf
@ 2005-09-08 16:34       ` Peter Rolf
  2005-09-08 17:21         ` Hans Hagen
  2005-09-08 18:55         ` Hans Hagen
  1 sibling, 2 replies; 11+ messages in thread
From: Peter Rolf @ 2005-09-08 16:34 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 105 bytes --]

Hans, is this a trick to get even more wiki pages?
\clip is still running wild... :)

Greetings,

Peter


[-- Attachment #2: crop.tex --]
[-- Type: text/plain, Size: 2213 bytes --]

% interface=en output=pdftex
% Time-stamp: <Donnerstag, 08 September 2005 18:28:23; crop.tex>
%

\setupcolors[state=start]

\unprotect

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{#1}%
  \ifdim\wd\scratchbox>#2\relax
    \setbox\scratchbox\hbox{#3}%
    \hsize#2\relax
    \advance\hsize-\wd\scratchbox
    \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
    \setbox\scratchbox\vsplit\scratchbox to \lineheight
    \vbox
      {\unvbox\scratchbox
       \global\setbox\plusone\lastbox
       \global\setbox\plusone\hbox{\unhbox\plusone}%
       \ifx\clip\undefined
         \box\plusone\removeunwantedspaces#3%
       \else\ifdim\wd\plusone>\hsize
         \hbox{\clip[\c!width=\hsize]{\box\plusone}#3}%
       \else
         \box\plusone\removeunwantedspaces#3%
       \fi\fi}%
  \else
    #1%
  \fi
  \egroup} 

\protect


\def\CropSymbol{\red...}%

\starttext

\setupframed[offset=overlay, height=\struttotal, framecolor=lightgray]
\setupframed[offset=overlay, height=\struttotal, framecolor=lightgray]

\framed[width=8ex,background=color,backgroundcolor=black]{\white 8ex}
\framed{\limitatefirstline{\underbar{Text dummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\underbar{Text dummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,background=color,backgroundcolor=black]{\white 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,background=color,backgroundcolor=black]{\white 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,background=color,backgroundcolor=black]{\white 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi \textdegree <>\&}{100pt}{\CropSymbol}}

\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: ""
%%% End:

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 16:34       ` Peter Rolf
@ 2005-09-08 17:21         ` Hans Hagen
  2005-09-08 17:32           ` Peter Rolf
  2005-09-08 18:55         ` Hans Hagen
  1 sibling, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2005-09-08 17:21 UTC (permalink / raw)


Peter Rolf wrote:

>Hans, is this a trick to get even more wiki pages?
>\clip is still running wild... :)
>  
>

hm, clipping looks ok here; is ok here; what version do you use? what 
sample text?

Hans

-- 

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 15:56       ` Peter Rolf
@ 2005-09-08 17:22         ` Patrick Gundlach
  0 siblings, 0 replies; 11+ messages in thread
From: Patrick Gundlach @ 2005-09-08 17:22 UTC (permalink / raw)




> I'll do my best. 'cropping text' is allready done,
> but \limitatefirstline doesn't work on the wiki yet.

Yes, it does ;-)

Patrick

(... now)
-- 
ConTeXt wiki and more: http://contextgarden.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 17:21         ` Hans Hagen
@ 2005-09-08 17:32           ` Peter Rolf
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Rolf @ 2005-09-08 17:32 UTC (permalink / raw)


Hans Hagen wrote:
> Peter Rolf wrote:
> 
>> Hans, is this a trick to get even more wiki pages?
>> \clip is still running wild... :)
>>  
>>
> 
> hm, clipping looks ok here; is ok here; what version do you use? what
> sample text?
> 
seems to be my fault, but I have no time at the moment to find the
cause. more tomorrow...anyhow, thanks.

> Hans
> 

Peter

P.S.: I will also fix the wiki page (with \limintatefirstline support).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cropping with \limitatefirstline
  2005-09-08 16:34       ` Peter Rolf
  2005-09-08 17:21         ` Hans Hagen
@ 2005-09-08 18:55         ` Hans Hagen
  1 sibling, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2005-09-08 18:55 UTC (permalink / raw)


Peter Rolf wrote:

>Hans, is this a trick to get even more wiki pages?
>\clip is still running wild... :)
>  
>
\unprotect

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{#1}%
  \ifdim\wd\scratchbox>#2\relax
    \setbox\scratchbox\hbox{#3}%
    \hsize#2\relax
    \advance\hsize-\wd\scratchbox
    \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
    \setbox\scratchbox\vsplit\scratchbox to \lineheight
    \vbox
      {\unvbox\scratchbox
       \global\setbox\plusone\lastbox
       \global\setbox\plusone\hbox{\unhbox\plusone}%
       \hbox to #2
         {\ifx\clip\undefined
            \box\plusone
          \else\ifdim\wd\plusone>\hsize
            \clip[\c!width=\hsize]{\box\plusone}%
          \else
            \box\plusone
          \fi\fi
          \removeunwantedspaces\hss#3}}%
  \else
    #1%
  \fi
  \egroup}

\protect

indeed, 4 wiki pages now -) 

Hans 

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-09-08 18:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-07 14:33 cropping with \limitatefirstline Peter Rolf
2005-09-07 15:55 ` Hans Hagen
2005-09-07 16:18   ` Peter Rolf
2005-09-08 14:24   ` Peter Rolf
2005-09-08 15:28     ` Hans Hagen
2005-09-08 15:56       ` Peter Rolf
2005-09-08 17:22         ` Patrick Gundlach
2005-09-08 16:34       ` Peter Rolf
2005-09-08 17:21         ` Hans Hagen
2005-09-08 17:32           ` Peter Rolf
2005-09-08 18:55         ` 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).