~eliasnaur/gio#221: 
Compute renderer text issues

I'm able to reproduce that problem in multiple devices (Motorola E6S, Xiaomi 7A, Motorola Maxx). The text is issue only happens on the new compute renderer. I didn't try to change the font itself.

Screenshot (on Motorola E6S): https://i.imgur.com/ds2c3k1.png

Status
REPORTED
Submitter
~inkeliz
Assigned to
No-one
Submitted
11 days ago
Updated
10 days ago
Labels
No labels applied.

~eliasnaur 11 days ago

What font are you using? Can you create a small, standalone program that demonstrates the problem?

~inkeliz 10 days ago*

I'm using "Nunito" ().

I made one program that can reproduce that issue (https://imgur.com/a/SdNPA3W):

package main

import (
	_ "embed"
	"fmt"
	"gioui.org/app"
	"gioui.org/font/opentype"
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/text"
	"gioui.org/unit"
	"gioui.org/widget"
	"image/color"
	"os"
)

func init() {
	//force new renderer
	os.Setenv("GIORENDERER", "forcecompute")
}

var (
	// Download font at https://fonts.google.com/specimen/Nunito

	//go:embed "Nunito-Regular.ttf"
	assetsFontNunito []byte
)

func main() {
	w := app.NewWindow()
	defer w.Close()

	go func() {
		b := Body{
			shaper: text.NewCache([]text.FontFace{
				{Font: text.Font{Typeface: "Nunito"}, Face: decodeFontFace(assetsFontNunito)},
			}),
		}

		b.Loop(w)

		os.Exit(0)
	}()

	app.Main()
}

func decodeFontFace(f []byte) text.Face {
	face, err := opentype.Parse(f)
	if err != nil {
		panic(err)
	}
	return face
}

type Body struct {
	ops    op.Ops
	shaper *text.Cache
}

func (e *Body) Loop(w *app.Window) {
	for evt := range w.Events() {
		switch evt := evt.(type) {
		case system.DestroyEvent:
			break
		case *system.CommandEvent:
			evt.Cancel = true
		case system.FrameEvent:
			fmt.Println("frame")
			e.Render(evt)
		}
	}
}

func (e *Body) Render(evt system.FrameEvent) {
	gtx := layout.NewContext(&e.ops, evt)

	stack := op.Save(gtx.Ops)
	paint.ColorOp{Color: color.NRGBA{A: 255}}.Add(gtx.Ops)
	widget.Label{MaxLines: 1, Alignment: text.Middle}.Layout(gtx, e.shaper, text.Font{Typeface: "Nunito"}, unit.Sp(18), "testing text on new renderer")
	stack.Load()

	evt.Frame(&e.ops)
}

Go 1.16 is required. The Nunito-Regular.ttf must be placed in the same folder where that example will run.

~inkeliz 10 days ago

I forget to add the link to Nunito, so you can take it from https://fonts.google.com/specimen/Nunito.

Register here or Log in to comment, or comment via email.