Skip to content

Why does set_fontproperties copy? #3356

Closed
@JamesRamm

Description

@JamesRamm

The set_fontproperties method of Text copies the FontProperties instance:

if is_string_like(fp):
        fp = FontProperties(fp)
       self._fontproperties = fp.copy()

this prevents doing stuff like:

fnt = FontProperties(family = 'Arial', size = 12)

# Make titles share the same font properties
axes.set_xlabel('xlabel', fontproperties = fnt)
axes.set_ylabel('ylabel', fontproperties = fnt)
axes.set_title('Title', fontproperties = fnt)]

# But a change in the font object is not reflected in the text properties..
fnt.set_family('Times New Roman')
fnt.set_size(14)

Ideally, I would have the fontproperties attribute of Text be a reference to a FontProperties instance and leave it up to the user to decide whether they need a copy or not?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions