Skip to content
New issue

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

const2bit is broken #43

Open
oxplot opened this issue Jul 15, 2023 · 3 comments
Open

const2bit is broken #43

oxplot opened this issue Jul 15, 2023 · 3 comments

Comments

@oxplot
Copy link

oxplot commented Jul 15, 2023

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
Copy link
Member

sago35 commented Aug 3, 2023

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
Copy link
Member

sago35 commented Aug 3, 2023

const2bit works with the following versions of tinyfont.

$ go get tinygo.org/x/tinyfont@34f5899f6c1e34aa6daa4e12e2b96a2ea370dff9

@scraly
Copy link
Contributor

scraly commented Jan 2, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants