Home/ Reference/ Pitfalls

Wrong font name fails silently

No exception, no font change, no warning. You have to read it back to find out it failed.

Symptom

Wrong font name fails silently

Notes

No exception, no font change, no warning. You have to read it back to find out it failed.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
import time

shape = app.ActiveSelectionRange(1)
FONT = "Source Han Sans Bold"

shape.Text.Story.Characters.All.Font = FONT
time.sleep(0.3)                                            # let it settle
if shape.Text.Story.Characters.All.Font != FONT:           # always read back
    print("The font did not take; check the name against what is installed")

About this section: Pitfalls

Pitfalls — errors that fail without raising.

Other entries in this section