fbox: add padding only to framed boxes generated by \fbox, \framebox - #2820
fbox: add padding only to framed boxes generated by \fbox, \framebox#2820xworld21 wants to merge 1 commit into
Conversation
44c4593 to
38aa6cb
Compare
|
Cool! I like where you're going with this. I think it would be better if integrated after the changes in #2798, however; there's at least additional properties ( Rather than you including lots of boiler plate code, perhaps I should introduce a In fact, it's annoying to have all those 3pt, 1pt defaults in |
interesting
|
|
I'd think that anything framed probably has some notion of sep or margin, but not necessarily |
|
OBTW, #2829 is now finished, and should be a good basis for simplifying this one (and resolving the conflicts :> ) |
38aa6cb to
3bc3212
Compare
| if ((my $framesep = LookupValue('LST@framesep'))) { | ||
| $whatsit->setProperties(padtop => $framesep, padbottom => $framesep, padleft => $framesep, padright => $framesep); | ||
| $whatsit->setProperties(cssstyle => 'padding:' . $framesep->toAttribute) if $framesep->ptValue != 3 ; } | ||
| return; }); |
There was a problem hiding this comment.
We could drop \lst@@frame in favour for something like this, by the way, and avoid the LISTINGS_INLINE checks.
There was a problem hiding this comment.
But \lst@@frame is called by listings in response to the frame keyval (I think), so we can't drop it (or I misunderstood your suggestion). But maybe \lst@@@set@frame should call framedProperties with LST@framesep and store all of the frame/sep/color stuff? Then you could avoid the `LISTINGS_INLINE test, if only the block version uses those properties. (but don't you need to add the framed, framecolor attributes?)
Either way, shouldn't the block you added above only happen when a frame has been selected?
There was a problem hiding this comment.
But
\lst@@frameis called by listings in response to theframekeyval (I think), so we can't drop it (or I misunderstood your suggestion)
I meant to say, if we do not define \lst@@frame, the value will be saved in \LST@frame, and we can access it from the constructor in the same way as for framesep here.
Either way, shouldn't the block you added above only happen when a frame has been selected?
Yeah, I decided to apply the padding regardless, so that if you create two listings with and without frame, they remain aligned to the pixel ugh, no, if you use border-box for box sizing, adding the frame will squeeze the content a little!
The context is that in PDF, the listings content is always \textwidth wide with or without frame, because frame and padding are drawn outside, spilling into the margins. So listings with and without frames are aligned with each other. In HTML... well, I just realised that the frame itself will shift and shrink the listing, so the alignment is lost anyway even if we apply the padding unconditionally. What was I thinking.
Let me update the PR with both changes (i.e. implement the frame without \lst@@frame so it all gets easier to understand).
There was a problem hiding this comment.
I folded \lst@@frame inside afterDigest, and used framedProperties. I have added support for the 'tlbr' frame specifiers. I couldn't get rid of LISTINGS_INLINE because it's used by \lst@@backgroundcolor which has a mergeFont, so probably not something that can be moved to afterDigest.
| if ((my $framesep = LookupValue('LST@framesep'))) { | ||
| $whatsit->setProperties(padtop => $framesep, padbottom => $framesep, padleft => $framesep, padright => $framesep); | ||
| $whatsit->setProperties(cssstyle => 'padding:' . $framesep->toAttribute) if $framesep->ptValue != 3 ; } | ||
| return; }); |
There was a problem hiding this comment.
But \lst@@frame is called by listings in response to the frame keyval (I think), so we can't drop it (or I misunderstood your suggestion). But maybe \lst@@@set@frame should call framedProperties with LST@framesep and store all of the frame/sep/color stuff? Then you could avoid the `LISTINGS_INLINE test, if only the block version uses those properties. (but don't you need to add the framed, framecolor attributes?)
Either way, shouldn't the block you added above only happen when a frame has been selected?
3bc3212 to
ba8cfb5
Compare
ba8cfb5 to
a17569c
Compare
| $frame =~ m/l/i ? ('left') : (), | ||
| $frame =~ m/r/i ? ('right') : ()); | ||
| } | ||
| $whatsit->setProperties(framedProperties(frame => $border, margin => LookupValue('LST@framesep'))); } |
There was a problem hiding this comment.
The only thing that makes me slightly nervous now is that the color is resolved in afterDigest. As far as I can tell, by this point, the color is reset to whatever it was at the start of the listing, so it gets the correct value (I checked!).
Apply
padding:3ptonly to boxes generated by\fboxand\framebox, or more precisely the ones that respect\fboxsep. That includes a few other boxes I have found by grepping forframed.This resolves issues like
\textul,\underbargaining padding that they should not have.While I was there, I have added support for
\fboxsepwhere it was missing in amsmath, color, xcolor. amsmath now also uses the current color as frame color.