Write Modify Character FontEffects Class

The ooodev.format.writer.modify.char.font.FontEffects class is used to modify the values seen in Fig. 1059 of a character style.

Before Settings

Writer dialog Character font effects default

Fig. 1059 Writer dialog Character font effects default

Setting the font effects

from ooodev.format.writer.modify.char.font import FontEffects, StyleCharKind
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo

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 = FontEffects(color=StandardColor.BLUE_LIGHT1, underline=FontLine(line=FontUnderlineEnum.DOUBLE))
        font_style.apply(doc)

        cursor = Write.get_cursor(doc)
        Write.append_para(cursor=cursor, text="Hello World!")

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

        Lo.close_doc(doc)

    return 0

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

After applying the font effects.

Writer dialog character font style changed

Fig. 1060 Writer dialog character font style changed

Getting the font effects from a style

We can get the font effects from the document.

# ... other code

style_obj = FontEffects.from_style(doc=doc, style_name=StyleCharKind.SOURCE_TEXT)
assert style_obj.prop_style_name == str(StyleCharKind.SOURCE_TEXT)