ebiten icon indicating copy to clipboard operation
ebiten copied to clipboard

text/v2: improve the performance of `Advance` with a `GoTextFace`

Open hajimehoshi opened this issue 10 months ago • 4 comments

Operating System

  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] FreeBSD
  • [ ] OpenBSD
  • [ ] Android
  • [ ] iOS
  • [ ] Nintendo Switch
  • [ ] PlayStation 5
  • [ ] Xbox
  • [ ] Web Browsers

What feature would you like to be added?

When a GoTextFace is used for Advance, glyphs shapes are created. This might be redundant when you want to know just an advanve value. Let's optimize the implementation of Advance to improve the performance.

Why is this needed?

Improve Advance performance makes us happy

hajimehoshi avatar Apr 17 '24 06:04 hajimehoshi

Hmm, is it possible to know an advance value without calculating shapes?

hajimehoshi avatar Apr 17 '24 06:04 hajimehoshi

An idea you might want to consider is to split the current GoTextFaceSource.shape into two functions : one which only performs the layout, computing a shaping.Line; the other one which takes such a line and draws it. Now, with this setup, advance would only call the first function and avoid loading the glyph segments.

benoitkugler avatar Apr 17 '24 08:04 benoitkugler

Unfortunately go-text HarfBuzzShaper.Shape function doesn't split the functions (calculating glyphs and calculating layouts), and this is the problem.

hajimehoshi avatar Apr 17 '24 08:04 hajimehoshi

Unfortunately go-text HarfBuzzShaper.Shape function doesn't split the functions (calculating glyphs and calculating layouts), and this is the problem.

I might have misunderstood the issue : I thought you wanted to avoid creating glyph shapes, that is calling Face.GlyphData.

benoitkugler avatar Apr 17 '24 09:04 benoitkugler