[Rd] Automatic shortening of text to fit into area

Paul Murrell p.murrell at auckland.ac.nz
Sun Jan 25 23:01:51 CET 2009


Hi


Prof Brian Ripley wrote:
> Almost all devices do support clipping, so this is  rather a minority 
> interest.


As a measure of the rarity, I wrote that code almost 10 years ago and
this is the first mention of this problem (though perhaps there are
millions out there suffering in silence ...).

I agree that dropping one character at a time and trying again would be
better than just not drawing anything, and your patch is nice and light
(especially given the nasty complexity of the GEText code), but the
suggested patch only addresses the case where the text extends out the
right hand side of the device (and is not rotated).  The modification
also needs to handle the case(s) where the characters should be dropped
from the front of the text.  I also wonder whether it might be possible
to make the patch local to just the clipTextCode() function (because the
clipTextCode function that it calls does its own calculation of the text
width and height).

Paul


> The person who AFAIK worte that comment and designed the clipping in 
> the engine is Paul Murrell.  He has been on summer vacation, but it 
> looks like he has just returned.  I suggest contacting him directly if 
> he does nto respond to these postings.
> 
> On Sat, 24 Jan 2009, Sebastian Fischmeister wrote:
> 
>> Hello,
>>
>> A comment in engine.c states: "/* don't draw anything; this could be made 
>> less crude :) */". The following patch makes it less crude: If the device 
>> doesn't support clipping and the text doesn't fit into the area, then remove 
>> one character after another from the text until either the text fits or the 
>> string is empty.
>>
>> I attached the patch—it's not indented correctly to keep the patch size 
>> small—and a test script, so you can give it a try. I don't know the R core 
>> very well, so this change may need some discussion. Yet it works for my 
>> figures.
>>
>> Have fun,
>> Sebastian
>>
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-devel mailing list