Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def test_change_font():
    m = MTextEditor()
    m.font("Arial", bold=False, italic=False)
    assert str(m) == r"\fArial|b0|i0;"