#14986 closed defect (fixed)

wxHTML clips the right side of text, images when ClearType enabled

Reported by: LukasK Owned by:
Priority: normal Milestone: 2.9.5
Component: wxHtml Version:
Keywords: Cc: gevorg
Blocked By: Blocking:
Patch: yes

Description

In Windows 7, with ClearType enabled, elements in html documents rendered using wxHTML are clipped a little on their right side, presumably by the next element (or spacing).

See the attached image, which is the result for this html:

<html><head><title>Test</title></head>
<body bgcolor="#eeeeee">
  <a href="test.html">BBBB BBBB</a><br>
  <i>BBB BBB</i>,<br>
  <img src="images/key_shift.png"></img>, <br>
</body>
</html>

This seems to have been introduced in r72589.

Attachments (4)

wxhtml-clipping.png download (12.2 KB) - added by LukasK 19 months ago.
Examples of clipping and not.
bgcolor-vs-background.png download (5.3 KB) - added by LukasK 19 months ago.
The clipping only happens when the outer cell has a bgcolor, not if it has a background image.
fix_clipping_unless_span.patch download (513 bytes) - added by LukasK 19 months ago.
Fixes the clipping when no span background-color is specified.
fix_clipping_unless_span_example.png download (4.7 KB) - added by LukasK 19 months ago.

Download all attachments as: .zip

Change History (10)

Changed 19 months ago by LukasK

Examples of clipping and not.

comment:1 Changed 19 months ago by vadz

  • Cc gevorg added
  • Milestone set to 3.0

Oops... So yet another problem due to #14443 :-( Honestly, I'd never consider applying it if I knew it would create so many of them but now that we did apply it and fixed 2 bugs since, it would be nice to fix this one as well instead of reverting the original change. But the trouble is that this seems to be a bug at the level of wxDC itself and I'm not sure at all whether we can fix it there.

So should we finally revert the original change?

comment:2 Changed 19 months ago by LukasK

I guess #14443 is not to blame for this one, as it reveals a wxDC bug. This seems likely to be related to this old issue: #12252, so I suppose a fix in wxDC would be nicest in the long term.

I can live with the clipping for a while, but this is probably pretty bad for applications that use wxHTML for documentation and About-dialogs.

Maybe this can be worked around in wxHTML for now (rather than changing wxDC), by filling the cell bounding boxes with the bgcolor, and then drawing text with transparent background.

comment:3 Changed 19 months ago by LukasK

...on second thought: The bug only ought to present itself for text spans with a text background color.
As it is now, even though I don't use text background, text cells clip the preceeding cell.

If I use a background image, the clipping does not happen, because the cells then know to draw with transparent background mode (see new attachment, bgcolor-vs-background.png).

Hence: When the source of the bgcolor isn't the span itself, text cells should probably draw themselves transparent.

...and a side note: Perhaps my suggestion in the previous comment, filling the background rectangle rather than using the DC-text background feature makes sense, as it is more analogous to how I imagine table backgrounds (and other cells) are drawn, and avoids a mode switch.

Changed 19 months ago by LukasK

The clipping only happens when the outer cell has a bgcolor, not if it has a background image.

comment:4 Changed 19 months ago by LukasK

  • Milestone changed from 3.0 to 2.9.5
  • Patch set

I found a simple fix which improves this a lot:

The reason that even text which isn't in a <span> with background-color style clips the preceeding element is that the BODY-tag handler (m_layout.cpp) inserts a wxHtmlColourCell with the style wxHTML_CLR_BACKGROUND.

If this is changed to wxHTML_CLR_TRANSPARENT_BACKGROUND most clipping disappears, and spans can still have a background color.

Span elements will still cause clipping on Windows with cleartype, as they use wxHTML_CLR_BACKGROUND, but that seems OK to keep, since spans didn't even support a background color before.

I changed Milestone to 2.9.5, hope this is OK.

Adding a patch.

Changed 19 months ago by LukasK

Fixes the clipping when no span background-color is specified.

Changed 19 months ago by LukasK

comment:5 Changed 19 months ago by vadz

I am not totally convinced this is not going to break something else but I guess we'll never know without trying... So let's apply this and see what happens.

Thanks for investigating!

comment:6 Changed 19 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73412]) Improve appearance of text with background colour in wxHTML.

Use wxHTML_CLR_TRANSPARENT_BACKGROUND instead of wxHTML_CLR_BACKGROUND for the
bgcolor attribute of the body tag to prevent clipping of the text cells by the
next cell with opaque background.

Closes #14986.

Note: See TracTickets for help on using tickets.