We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
GoXFace
For example, run this program on browsers
package main import ( "fmt" "math/rand/v2" "github.com/hajimehoshi/bitmapfont/v3" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/ebitenutil" "github.com/hajimehoshi/ebiten/v2/text/v2" ) const ( screenWidth = 640 screenHeight = 480 lineHeight = 12 ) type Game struct { face text.Face text string } func (g *Game) Update() error { if g.face == nil { g.face = text.NewGoXFace(bitmapfont.Face) } if g.text == "" { const alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" xNum := screenWidth / 6 yNum := (screenHeight / lineHeight) - 1 for j := 0; j < yNum; j++ { for i := 0; i < xNum; i++ { g.text += string(alphabets[rand.IntN(len(alphabets))]) } g.text += "\n" } } return nil } func (g *Game) Draw(screen *ebiten.Image) { ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f, TPS: %0.2f", ebiten.ActualFPS(), ebiten.ActualTPS())) op := &text.DrawOptions{} op.GeoM.Translate(0, lineHeight) op.LineSpacing = 12 text.Draw(screen, g.text, g.face, op) } func (g *Game) Layout(width, height int) (int, int) { return screenWidth, screenHeight } func main() { if err := ebiten.RunGame(&Game{}); err != nil { panic(err) } }
This reached 120 FPS on desktop, but doesn't reach 120 FPS on browsers:
..' hajimehoshi@Hajimes-MacBook-Pro ,xNMM. ------------------------------- .OMMMMo OS: macOS 15.0.1 arm64 lMM" Host: MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports) .;loddo:. .olloddol;. Kernel: 24.0.0 cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 1 day, 17 hours, 26 mins .KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 143 (brew), 2 (brew-cask) XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: zsh 5.9 ;MMMMMMMMMMMMMMMMMMMMMMMM: Display (Color LCD): 3600x2338 @ 120Hz (as 1800x1169) [Built-in] :MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua .MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Quartz Compositor kMMMMMMMMMMMMMMMMMMMMMMMMWd. WM Theme: Multicolor (Light) 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk Font: .AppleSystemUIFont [System], Helvetica [User] 'XMMMMMMMMMMMMMMMMMMMMMMMMK. Cursor: Fill - Black, Outline - White (32px) kMMMMMMMMMMMMMMMMMMMMMMd Terminal: Code Helper 1.94.2 ;KMMMMMMMWXXWMMMMMMMk. CPU: Apple M3 Pro (12) @ 4.06 GHz "cooc*" "*coo'" GPU: Apple M3 Pro (18) [Integrated] Memory: 15.13 GiB / 18.00 GiB (84%) Swap: 7.16 GiB / 8.00 GiB (89%) Disk (/): 311.66 GiB / 926.35 GiB (34%) - apfs [Read-only] Local IP (en0): 192.168.0.10/24 * Battery: 100% [AC connected] Power Adapter: 96W USB-C Power Adapter Locale: en_US.UTF-8
Here is the performance result:
No response
The text was updated successfully, but these errors were encountered:
GoTextFace has g.outputCache, while GoXFace doesn't have a counterpart.
GoTextFace
g.outputCache
Sorry, something went wrong.
48daae0
Now the bottleneck is moved from font parsing to rendering, so I'm satisfied.
No branches or pull requests
Operating System
What feature would you like to be added?
For example, run this program on browsers
This reached 120 FPS on desktop, but doesn't reach 120 FPS on browsers:
Here is the performance result:
Why is this needed?
No response
The text was updated successfully, but these errors were encountered: