Write Modify Paragraph Font Effects
The ooodev.format.writer.modify.para.font.FontEffects
, class is used to set the paragraph style font Fig. 1085.
Setting the font
from ooodev.format.writer.modify.para.font import FontEffects, FontLine
from ooodev.format.writer.modify.para.font import FontUnderlineEnum, StyleParaKind
from ooodev.utils.color import CommonColor
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)
para_font_effects_style = FontEffects(
color=CommonColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE),
shadowed=True,
style_name=StyleParaKind.STANDARD,
)
para_font_effects_style.apply(doc)
style_obj = FontEffects.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Running the above code will produce the following results in the Writer dialog.
Getting font effects from a style
# ... other code
style_obj = FontEffects.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)