diff --git a/src/docx/oxml/text/font.py b/src/docx/oxml/text/font.py index 140086aab..ce0f61075 100644 --- a/src/docx/oxml/text/font.py +++ b/src/docx/oxml/text/font.py @@ -45,7 +45,9 @@ class CT_Fonts(BaseOxmlElement): hAnsi: str | None = OptionalAttribute( # pyright: ignore[reportAssignmentType] "w:hAnsi", ST_String ) - + cs: str | None = OptionalAttribute( # pyright: ignore[reportGeneralTypeIssues] + "w:cs", ST_String + ) class CT_Highlight(BaseOxmlElement): """`w:highlight` element, specifying font highlighting/background color.""" @@ -222,6 +224,21 @@ def rFonts_hAnsi(self, value: str | None): rFonts = self.get_or_add_rFonts() rFonts.hAnsi = value + @property + def rFonts_cs(self) -> str | None: + """The value of `w:rFonts/@w:cs` or |None| if not present.""" + rFonts = self.rFonts + if rFonts is None: + return None + return rFonts.cs + + @rFonts_cs.setter + def rFonts_cs(self, value: str | None): + if value is None and self.rFonts is None: + return + rFonts = self.get_or_add_rFonts() + rFonts.cs = value + @property def style(self) -> str | None: """String in `./w:rStyle/@val`, or None if `w:rStyle` is not present.""" diff --git a/src/docx/text/font.py b/src/docx/text/font.py index acd60795b..fda728985 100644 --- a/src/docx/text/font.py +++ b/src/docx/text/font.py @@ -199,6 +199,23 @@ def name(self, value: str | None) -> None: rPr.rFonts_ascii = value rPr.rFonts_hAnsi = value + @property + def name_cs(self) -> str | None: + """The cs typeface name for this |Font|. + + Causes the text it controls to appear in the named font, if a matching font is + found. |None| indicates the typeface is inherited from the style hierarchy. + """ + rPr = self._element.rPr + if rPr is None: + return None + return rPr.rFonts_cs + + @name.setter + def name_cs(self, value: str | None) -> None: + rPr = self._element.get_or_add_rPr() + rPr.rFonts_cs = value + @property def no_proof(self) -> bool | None: """Read/write tri-state value.