Calc Modify Cell Font Effects

The ooodev.format.calc.modify.cell.font.FontEffects class is used to modify the font values seen in Fig. 421 of a cell style.

Before Settings

Calc dialog style font default

Fig. 421 Calc dialog style font default

Setting the font name and size

import uno
from ooodev.office.calc import Calc
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.format.calc.modify.cell.font import FontEffects, FontLine
from ooodev.format.calc.modify.cell.font import StyleCellKind, FontUnderlineEnum
from ooodev.utils.color import StandardColor

def main() -> int:
    with Lo.Loader(connector=Lo.ConnectSocket()):
        doc = Calc.create_doc()
        GUI.set_visible(True, doc)
        Lo.delay(500)
        Calc.zoom(doc, GUI.ZoomEnum.ZOOM_100_PERCENT)

        font_style = FontEffects(color=StandardColor.BLUE_LIGHT1, underline=FontLine(line=FontUnderlineEnum.DOUBLE))
        font_style.apply(doc)

        style_obj = FontEffects.from_style(doc=doc, style_name=StyleCellKind.DEFAULT)
        assert style_obj.prop_style_name == str(StyleCellKind.DEFAULT)

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


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

After applying the font name and size

Calc dialog style font default changed

Fig. 422 Calc dialog style font default changed

Getting the font from a style

We can get the font name and size from the document.

# ... other code

style_obj = FontEffects.from_style(doc=doc, style_name=StyleCellKind.DEFAULT)
assert style_obj.prop_style_name == str(StyleCellKind.DEFAULT)