[reportlab-users] underline and strike parameters (and link regions)

Glenn Linderman v+python at g.nevcal.com
Tue Mar 20 14:58:10 EDT 2018


On 3/20/2018 3:53 AM, Robin Becker wrote:
> The strike and underline tags currently support no parameters. There 
> is a global setting baseUnderlineProportion which controls the widths 
> of the lines in proportion to the fontSize, but the offsets  colors 
> are not directly controllable. In addition there's a minor difference 
> in the offset calculation for single and multi fragment lines. A 
> couple of recent bug reports have indicated some reasons for change in 
> their behaviour.
>
> 0) I would like to allow for multiple underlines/strikes in the same 
> region of a paragraph. Double underlining etc etc could then be done. 
> Additionally we would be able to support underlines of 
> subscripts/superscripts etc etc.
>
> 1) I would like to introduce parameters for the strike/u/link tags as 
> follows.
>
> <strike> & <u> would have width, offset and color attributes.
>
> <link> would get uwidth, uoffset & ucolor attributes and a local 
> control for whether underlining is on with an underline attribute.
>
> 2) The width and offset parameters can obbiously be either absolute 
> or  proportional to some font size. There are several possible choices 
> of font size to use
>
>    <para fontsize="10"> <span size="11">text<u><span 
> size="12">underlined</u>...</span>...<span 
> size="14">....</span>...</para>
>
>    a) paragraph level fontSize normally set by the style parameter so 10
>    b) local fontSize at the point where the tag appears 11.
>    c) local fontSize at the point where the underline first gets drawn 
> so 12
>    d) the maximum font size over the line ie 14
>
> Currently we appear to be adhering to the d option for multi fragment 
> lines and the a/b option for single fragment lines.
>
> Given that we already allow suffices for absolute units eg pt, pica, 
> mm, in etc etc it probably makes sense to allow some sort of suffix to 
> control which proportion we desire to use. For my experiments I am using
>
>     a = F
>     c = f
>     ^ = d
>
> all others are absolute.
>
> I know how to implement b, but I haven't got any idea how to indicate 
> it; I would prefer we use only one local property position so either 
> at the tag or when the tag gets first used, but others may disagree.

I think ^ = d should be d = ^ ?? Or the chart is confusing.  I think ^ 
is a poor choice for a tag, would prefer alpha, such as  L (for line; 
uppercase, because F for para is uppercase, and both are concepts larger 
than local).

c) seems more appropriate than b) so that order of <u> and <span> is 
less important. I'm surprised your example doesn't conform to nesting 
requirements for <u> and <span>, though.

And, you've missed one concept: †) maximum fontsize for the range of the 
underline, which to me makes more sense than either b) or c).

And maybe another, if the range of the underline is multiple lines, 
maybe ‡) maximum fontsize for the range of the underline on each line. 
So it could vary based on actual usage on each line.

> 3) The color of lines may either be absolute eg red or perhaps 
> indicated by some special notation to use a default mechanism. 
> Currently we assume that the  line color will be the same as the text 
> colour of the first drawing. There are probably three sensible 
> relative defaults which could be adopted.
>
>     e) paragraph level text color
>     f) textColor at the point of definition
>     g) textColor at the point of first use.

Another missed option: *) same color as text being underlined, which 
means the underline may change colors along its length

>
> how we should indicate that these are to be used I have no idea; 
> suffices won't work.

I'm not sure where you are talking about putting the suffices for font 
size either; not on the text font size, so where? An example of usage 
would have been nice.  I'd suggest

<u ufontsize="code">

code would be one of the "which text size should I track" options, or an 
explicit font size.  Likewise for underline color...

<u ucolor="code">

where code could be a color, or a special designation for these various 
options of text color tracking. ucolor could be spelled lots of ways, 
but not conflicting with HTML attributes would be good. Using the 
well-defined user attribute naming such as data_fontsize and data_color 
might be better.

>
> 3) Currently link regions are badly computed and seem to use the 
> maximum font size of the line to get an idea of the clickable area. 
> They probably ought to use the font height at the point of use for 
> their clickable region.
>
>
> I would like some ideas on whether any of this sounds reasonable and 
> if there are better ways to indicate defaults etc etc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20180320/6a39fadb/attachment-0001.html>


More information about the reportlab-users mailing list