-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Measuring text with TextMeasurer.Measure
is slow
#268
Comments
SkiaSharp doesn’t have a proper text layout engine though does it? We do layout and shaping as part of the measuring process so I don’t think this is a fair comparison. |
This can be proven using the following string.
This is a decomposed Hangul script that requires composing in order to measure the text properly. The correct output should be. (Note this is actually a paste of the decomposed format, GitHub automatically composes it.)
SkiaSharp doesn't do any shaping and simply renders the raw Unicode codepoints. Whereas we do the correct thing.
That doesn't mean we can't speed things up. We've done a lot of work though while building the library though to keep performance in mind so I'm not sure how much low hanging fruit there is. |
We might be able to create a closer comparison using example code from here. |
I did some profiling and added your benchmark to the solution in another branch. After removing the bounds checks from the Unicode trie lookups I'm mostly left with the lazy loading of the Unicode data. There's no way I can think of to speed that up as I'm depending heavily on runtime components there. |
Prerequisites
DEBUG
andRELEASE
modeDescription
I tried to use SixLabors.Fonts to compute widths of many different texts to produce a nice looking Excel file with Simplexcel. It turned out to be an unusable solution because it was too slow. I tracked the slowness down to the
SixLabors.Fonts.TextMeasurer.Measure
function.I ran some benchmarks, comparing
SixLabors.Fonts
toSkiaSharp
and here are the results.I eventually used SkiaSharp instead of SixLabors.Fonts and did not investigate further why measuring text is slow.
The benchmark below could help as a starting point, should someone tackle this issue (myself included if I ever find the time).
Steps to Reproduce
Run the following project with
dotnet run -c Release
MeasureTextBenchmarks.csproj
Program.cs
System Configuration
The text was updated successfully, but these errors were encountered: