dotnet / dotnet/wpf

TextFormatter.FormatLine has O(n^2) performance when called multiple times

Open
#6,304 6 comments 2 reactions 0 assignees View on GitHub
help wanted Performance
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: .net 6
* Windows version: 11
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? no

**Actual behavior:**

TextFormatter.FormatLine has O(n^2) performance

**Expected behavior:**

TextFormatter.FormatLine exhibits linear performance

**Minimal repro:**
[WpfFontRepro.zip](https://github.com/dotnet/wpf/files/8336231/WpfFontRepro.zip)

**Remarks**

Disposing the formatted lines or creating new TextFormatter instances prevents the O(n^2) behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.