Write Modify Character Highlight Class

The ooodev.format.writer.modify.char.highlight.Highlight class is used to modify the highlight value. As seen in Fig. 1065 by default no color is set for the Example style.

Before Settings

Writer dialog Character highlight default

Fig. 1065 Writer dialog Character highlight default

Setting the font effects

from ooodev.format.writer.modify.char.highlight import Highlight, StyleCharKind
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.utils.color import StandardColor

def main() -> int:
   with Lo.Loader(Lo.ConnectPipe()):
        doc = Write.create_doc()
        GUI.set_visible(doc=doc)
        Lo.delay(300)
        GUI.zoom(GUI.ZoomEnum.ZOOM_150_PERCENT)

        font_style = Highlight(color=StandardColor.YELLOW_LIGHT2, style_name=StyleCharKind.EXAMPLE)
        font_style.apply(doc)

        style_obj = Highlight.from_style(doc=doc, style_name=StyleCharKind.EXAMPLE)
        assert style_obj.prop_style_name == str(StyleCharKind.EXAMPLE)
        Lo.delay(1_000)

        Lo.close_doc(doc)

    return 0

if __name__ == "__main__":
    SystemExit(main())

After applying the font highlight.

Writer dialog character highlight style changed

Fig. 1066 Writer dialog character highlight style changed

Getting the highlight from a style

We can get the highlight from the document.

# ... other code

style_obj = Highlight.from_style(doc=doc, style_name=StyleCharKind.EXAMPLE)
assert style_obj.prop_style_name == str(StyleCharKind.EXAMPLE)