diff --git a/src/docx/text/font.py b/src/docx/text/font.py index acd60795b..f5e5ec51b 100644 --- a/src/docx/text/font.py +++ b/src/docx/text/font.py @@ -53,6 +53,12 @@ def color(self): font.""" return ColorFormat(self._element) + @color.setter + def color(self, value: ColorFormat): + this_color = self.color + this_color.theme_color = value.theme_color + this_color.rgb = value.rgb + @property def complex_script(self) -> bool | None: """Read/write tri-state value. diff --git a/src/docx/text/run.py b/src/docx/text/run.py index 0e2f5bc17..58fa1fb0e 100644 --- a/src/docx/text/run.py +++ b/src/docx/text/run.py @@ -2,6 +2,8 @@ from __future__ import annotations +import copy + from typing import IO, TYPE_CHECKING, Iterator, cast from docx.drawing import Drawing @@ -136,6 +138,16 @@ def font(self) -> Font: this run, such as font name and size.""" return Font(self._element) + @property + def formatting(self) -> CT_RPr: + """The |CT_RPr| object providing access to the full range of formatting properties for + this run, such as font name and size.""" + return copy.deepcopy(self._r.get_or_add_rPr()) + + @formatting.setter + def formatting(self, new_rPr: CT_RPr): + self._r.replace(self._r.get_or_add_rPr(), new_rPr) + @property def italic(self) -> bool | None: """Read/write tri-state value.