Hans Hagen wrote:
Peter Rolf wrote:
Hi all,
I've tested the latest version of \limitatefirstline and it still
doesn't work as expected. This is really a complex story (problem).
- the clip mechanism cuts off the lowest part of some special chars
(clipping graphics is easy, but I don't understand what happens here)
- text is sometimes cropped at word boundaries (example 110pt),
instead of beeing clipped
The example file is appended and I use the latest beta. There is no
timeline, so fixing is not that urgent.
add some struts:
\setbox\scratchbox\hbox{\begstrut#1\endstrut}%
\ifdim\wd\scratchbox>#2\relax
\setbox\scratchbox\hbox{\begstrut#3\endstrut}%
and remove your funny voffset
oeps, a relict from testing.
Hans
Yep, it (later example) works with the struts. Thank you Hans!
But the clipping still needs the height parameter, else you get no
drawings below the baseline. I use \struttotal in my example, which can
be too small in case of underbar/underline.
working example is attached.
Greetings,
Peter
% interface=en output=pdftex
% Time-stamp:
%
\setupcolors[state=start]
\unprotect
\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
\setbox\scratchbox\hbox{\begstrut#1\endstrut}%
\ifdim\wd\scratchbox>#2\relax
\setbox\scratchbox\hbox{\begstrut#3\endstrut}%
\hsize#2\relax
\advance\hsize-\wd\scratchbox
\setbox\scratchbox\vbox{\forgetall\veryraggedright\begstrut#1\endstrut}%
\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,\c!height=\struttotal]{\ruledhbox{\box\plusone}}
\else
\ifdim\wd\plusone<\dimexpr\hsize-2ex\relax% tolerance for "successful" breaking
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\begstrut#1\endstrut}}% must be #1 here
\else
\box\plusone
\fi
\fi
\fi
\removeunwantedspaces\hss#3}}%
\else
#1%
\fi
\egroup}
\protect
\def\CropSymbol{\red...}%
\starttext
% blue for the limitatetext examples
\setupframed[offset=overlay, framecolor=lightgray]
\framed[width=8ex,height=\struttotal,background=color,backgroundcolor=black]{\white 8ex}
\framed{\limitatefirstline{\underbar{WqTextdummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\blue\underbar{WqTextdummy}}{8ex}{\CropSymbol}}
\blank
\framed[width=120pt,height=\struttotal,background=color,backgroundcolor=black]{\white 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{120pt}{\CropSymbol}}
\framed{\limitatetext{\blue\textbar \_\textcircumflex\texttilde \%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi \textdegree <>\&}{120pt}{\CropSymbol}}
\blank
\framed[width=110pt,height=\struttotal,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}}
\framed{\limitatetext{\blue This text is definitely too long to fit this frame.}{110pt}{\CropSymbol}}
\blank
\framed[width=100pt,height=\struttotal,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: