tinygo-org / tinyfont

Text library for TinyGo displays
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
50 stars 12 forks source link

const2bit is broken #43

Open oxplot opened 1 year ago

oxplot commented 1 year ago

Due to the change from Glypher to Glyph.

Attempting to use a font created by tinyfontgen-ttf and using it, yields:

main.go:31:28: cannot use font (variable of type *Font) as tinyfont.Fonter value in argument to tinyfont.WriteLine: *Font does not implement tinyfont.Fonter (wrong type for method GetGlyph)
        have GetGlyph(rune) tinyfont.Glypher
        want GetGlyph(rune) tinyfont.Glyph

Relevant code:

tinyfont.WriteLine(&ssd, TinyFont, 0, 20, "Hi there", color.RGBA{1, 0, 0, 0})
sago35 commented 1 year ago

const2bit is for representing 2-bit color fonts. Glyph cannot handle 2-bit colors. In addition, we would like to support colored emoji in the future, but tinyfont.Glyph cannot handle them either.

However, trying to return a Glypher results in heap allocs for each call to GetGlyph().

Any suggestions? @deadprogram @aykevl @conejoninja

sago35 commented 1 year ago

const2bit works with the following versions of tinyfont.

$ go get tinygo.org/x/tinyfont@34f5899f6c1e34aa6daa4e12e2b96a2ea370dff9
scraly commented 10 months ago

I've tried to convert a TTF font to a tiny go format:

$ go run ./cmd/tinyfontgen-ttf --package fonts --size 32 --fontname Regular58pt ./CharacterCats.ttf --output cats
58.go

But I can`t use it

    tinyfont.DrawChar(&display, &fonts.Regular58pt, 5, 140, 'B', green)
# command-line-arguments
main.go:87:30: cannot use fonts.Regular58pt (variable of type const2bit.Font) as tinyfont.Fonter value in argument to tinyfont.DrawChar: const2bit.Font does not implement tinyfont.Fonter (method GetGlyph has pointer receiver)
sago35 commented 1 month ago

This issue should be fixed in PR #46.

sago35 commented 4 weeks ago

Since #46 has been merged, this issue should be resolved.

deadprogram commented 4 weeks ago

Added label to close on next release.