Write Modify Character FontPosition Class
The ooodev.format.writer.modify.char.font.FontPosition
class is used to modify the values seen in Fig. 1063 of a character style.
Before Settings
Setting the font position
from ooodev.format.writer.modify.char.font import FontPosition, FontScriptKind, StyleCharKind
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)
font_style = FontPosition(
script_kind=FontScriptKind.SUBSCRIPT,
raise_lower=10,
rotation=270,
scale=85,
spacing=3,
pair=True,
style_name=StyleCharKind.EXAMPLE,
)
font_style.apply(doc)
style_obj = FontPosition.from_style(doc=doc, style_name=StyleCharKind.EXAMPLE)
assert style_obj.prop_style_name == str(StyleCharKind.EXAMPLE)
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
After applying the font position.
Getting the font position from a style
We can get the font position from the document.
# ... other code
style_obj = FontPosition.from_style(doc=doc, style_name=StyleCharKind.EXAMPLE)
assert style_obj.prop_style_name == str(StyleCharKind.EXAMPLE)