Draw Modify Font Effects

The ooodev.format.draw.modify.font.FontEffects, class is used to modify the values seen in Fig. 891 of a style.

Draw dialog Font Effects default

Fig. 891 Draw dialog Font Effects default

Setting the Font Effects

from __future__ import annotations
import uno
from ooodev.draw import Draw, DrawDoc, ZoomKind
from ooodev.format.draw.modify import FamilyGraphics, DrawStyleFamilyKind
from ooodev.format.draw.modify.font import FontEffects, FontUnderlineEnum
from ooodev.format.draw.modify.font import FontLine
from ooodev.utils.color import CommonColor
from ooodev.loader.lo import Lo

def main() -> int:
    with Lo.Loader(connector=Lo.ConnectSocket()):
        doc = DrawDoc(Draw.create_draw_doc())
        doc.set_visible()
        Lo.delay(700)
        doc.zoom(ZoomKind.ZOOM_75_PERCENT)

        slide = doc.get_slide()

        width = 100
        height = 50
        x = 10
        y = 10

        rect = slide.draw_rectangle(x=x, y=y, width=width, height=height)
        rect.set_string("Hello World!")
        font_style = FontEffects(
            color=CommonColor.RED,
            underline=FontLine(line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE),
            shadowed=True,
            style_name=FamilyGraphics.DEFAULT_DRAWING_STYLE,
            style_family=DrawStyleFamilyKind.GRAPHICS,
        )
        doc.apply_styles(font_style)

        Lo.delay(1_000)
        doc.close_doc()
    return 0

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

Running the above code will produce the following results in the Draw dialog.

Draw dialog Font Effects style changed

Fig. 892 Draw dialog Font Effects style changed

Shape after applying style.

Shape after Style applied

Fig. 893 Shape after Style applied

Getting font effects from a style

# ... other code

f_style = FontEffects.from_style(
    doc=doc.component,
    style_name=FamilyGraphics.DEFAULT_DRAWING_STYLE,
    style_family=DrawStyleFamilyKind.GRAPHICS,
)
assert f_style.prop_style_name == str(FamilyGraphics.DEFAULT_DRAWING_STYLE)