Skip to content

[FEATURE] Add caching in DrawShapedText #3032

Open
@MichaelRumpler

Description

@MichaelRumpler

Is your feature request related to a problem?

The DrawShapedText method is meant to be an easy replacement for DrawText which adds text shaping via HarfBuzz but otherwise uses the same parameters as DrawText. It creates and disposes a SKShaper at every call which is very slow.

Describe the solution you would like

The SKShaper should not be created and disposed at every call. It should be cached and reused instead.

Furthermore also the result of the text shaping should be cached. This would improve the performance even more.

Describe alternatives you have considered

There is an overload of DrawShapedText which takes a SKShaper and does not create/dispose it at every call, but people need to have more insider knowledge of HarfBuzzSharp to use it. Also the caching of the results is something which everybody has to do to use HarfBuzz efficiently. It would be better if it was built in.

Additional context

I wrote a blog post about this problem. It also includes benchmarks which show the possible improvement.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready For Work

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions