def changing_fonts(msp, location): attribs = dict(ATTRIBS) attribs["width"] = 15.0 editor = MTextEditor("changing fonts:" + NP) editor.append("Default: Hello World!" + NP) editor.append("SimSun: ") # The font name for changing MTEXT fonts inline is the font family name! # The font family name is the name shown in font selection widgets in # desktop applications: "Arial", "Times New Roman", "Comic Sans MS" # # change font in a group to revert back to the default font at the end: simsun_editor = MTextEditor().font("SimSun").append("你好,世界" + NP) # reverts the font back at the end of the group: editor.group(str(simsun_editor)) # back to default font OpenSans: editor.append("Times New Roman: ") # change font outside of a group until next font change: editor.font("Times New Roman").append("Привет мир!" + NP) # If the font does not exist, a replacement font will be used: editor.font("Does not exist").append("This is the replacement font!") msp.add_mtext(str(editor), attribs).set_location(insert=location)
def test_grouping(): m = MTextEditor("some text") group_content = str(MTextEditor().font("Arial").append("Font=Arial")) m.group(group_content) assert str(m) == r"some text{\fArial|b0|i0;Font=Arial}"