Skip to content

SP5 Becomes Slow When Calling Font.Automatic() Method (>=5.0.35) #4049

@zxy874175242

Description

@zxy874175242

Starting from version 5.0.35, there is a slowdown in SP5 when using the Plot.Font.Automatic() method (as shown in the figure).

In previous versions, the rendering speed was consistently above 500 FPS. However, after version 5.0.35, it suddenly dropped to below 10 FPS (as shown in the figure, from the Automatic Font Detection example in the cookbook).

BillfishQgnhHm
BillfishvdXzxx

I investigated the issue and found that it seems to be related to the SetBestFont() method.

In the method, FontName = Fonts.Detect(Text); returns an empty FontName when Text is an empty string, causing an abnormal slowdown.

I added a condition that returns Fonts.Default when Text is empty, and the slowdown disappeared.

public void SetBestFont()
{
    Typeface = null;
    // FontName = Fonts.Detect(Text);
    FontName = Text == "" ? Fonts.Default : Fonts.Detect(Text);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions