hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11.03k stars 661 forks source link

text: redesign APIs (text/v2) #2454

Closed hajimehoshi closed 11 months ago

hajimehoshi commented 1 year ago

Operating System

What feature would you like to be added?

No concrete plan, but there are multiple better text APIs than golang.org/x/image/font. Let's investigate this.

Why is this needed?

The current text APIs are not matured e.g. this lacks layoutings.

hajimehoshi commented 1 year ago
hajimehoshi commented 1 year ago

We might add text/v2 to keep the compatibility. (See also https://github.com/golang/go/discussions/60751#discussioncomment-6158369)

hajimehoshi commented 1 year ago

I am now working on a GUI application with Ebitengine, and I would like to plan the new API based on my experience of this. So, I need more time.

hajimehoshi commented 1 year ago

Another consideration is to enable variables https://pkg.go.dev/github.com/go-text/typesetting@v0.0.0-20230803102845-24e03d8b5372/opentype/api/font#Face.SetVariations (e.g. https://rsms.me/inter/#features)

EDIT https://pkg.go.dev/github.com/go-text/typesetting@v0.0.0-20230803102845-24e03d8b5372/opentype/api/font#Feature is the correct link

tinne26 commented 1 year ago

To be fair, font variations are a very questionable feature. If support for any single feature should be added, colored glyphs and embedded bitmaps would be much more relevant than font variations. The open type format is already very bloated, but font variations must be one of its most unnecessary and gimmicky features. They can be used in ways that seem logical, but outside tech demos, in real world scenarios, you just use two or three different font weights instead. Many type designers are skeptical of variable fonts and consider them gimmicky. Others say it may revolutionize text animation, but there's no sign of that yet. Maybe because it turns out that... that's not practical with CPU rasterization.

In conclusion, I think that font variations should be considered, at most, a very low priority issue. Also, if you cross that threshold you may also have to start considering separate text/sfnt/render and text/typesetting/render packages, because otherwise the feature support across the public API may become swiss cheese.

hajimehoshi commented 1 year ago

To be fair, font variations are a very questionable feature.

Is that true? I came up with one use case (e.g. tabular numbers for GUI applications). I'll consider this when I really need. Or, even I don't implement this, I'll leave API to be extensible for the future.

hajimehoshi commented 1 year ago

I'll try to write a design document this week for text/v2.

hajimehoshi commented 1 year ago

https://docs.google.com/document/d/1sEuNezPULkR60jk89QHfQ7hhoyuPgKRfZ-CpqnoidWI/edit?usp=sharing

I've written a design document for the proposal text/v2. Feedbacks are welcome!

hajimehoshi commented 11 months ago

Almost done. Let me close this. For other remaining tasks, use other issues.