Skip to content

Conversation

@vincedarley
Copy link

  • Skip drawing borders when color has alpha channel = 00 (transparent)
  • Parse ALIGNVCENTER from textFormat element and vertically center text in frame
  • Fixes cover page text rendering issues where transparent borders appeared black and text was not centered despite ALIGNVCENTER attribute

This PR fixes two text rendering issues:

Transparent borders appearing as black - When text areas have a border color with alpha channel = 00 (transparent), the border should not be drawn. Now checks the color format #RRGGBBAA and returns early if AA == 00. At least on my version of CEWE it seems to like creating a transparent text border when I tell it I don't want a border at all.

ALIGNVCENTER not being applied - Text with ALIGNVCENTER in the textFormat element was not being vertically centered. Now parses the textFormat child element (not attribute), checks for ALIGNVCENTER in the Alignment attribute, and applies proper vertical centering by shrinking the frame to text size and positioning it centered within the original area.

Changes:

Line ~453: Add alpha channel detection in processDecorationBorders()
Lines ~780-787: Parse textFormat element for ALIGNVCENTER flag
Lines ~1134-1145: Apply vertical centering offset when rendering text frames

- Skip drawing borders when color has alpha channel = 00 (transparent)
- Parse ALIGNVCENTER from textFormat element and vertically center text in frame
- Fixes cover page text rendering issues where transparent borders appeared black
  and text was not centered despite ALIGNVCENTER attribute
@vincedarley
Copy link
Author

Further testing shows this patch is not quite right - it breaks borders on photos. The correct fix for the border issues is this:

    if "color" in border.attrib:
        colorAttrib = border.get('color')
        # The border colour is weirdly handled by CEWE. The transparency seems to
        # be ignored. And, non-borders are sometimes stored as borders with no colour.
        if colorAttrib == '#00000000':
            # Not a border - don't draw it
            return
        bcolor = reportlab.lib.colors.HexColor(colorAttrib)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant