Skip to content

feature: Font.shading #309

@ellabebop

Description

@ellabebop

font.highlight_color appears to work fine when applied directly to a run's font, this way.

run=para.add_run("this should have a yellow background, but with no style (!)")
run.font.highlight_color=docx.enum.text.WD_COLOR.YELLOW

When applied using a style, it seems to have no effect.

style=doc.styles.add_style("highlightYellow",docx.enum.style.WD_STYLE_TYPE.CHARACTER)
style.base_style=doc.styles["Normal"]
style.font.highlight_color=docx.enum.text.WD_COLOR.YELLOW

para.add_run("this should have a yellow background, but does not",style)

In Microsoft Word, I can see that the style is being applied to that run, but it's background isn't yellow. If I look at the style using the Modify Style dialog, the sample text snippet shows a yellow background, oddly enough. But in that dialog, Format/Border.../Shading says that Fill is No Color. Selecting yellow there fixes it. Another oddity is that I do get a yellow background opening the same document in LibreOffice, oowriter.

I'm gathering some XML to help isolate this, and will attach it to the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions