Skip to content

tinyfontgen: Added support for generating fonts from ttf #37

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

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

sago35
Copy link
Member

@sago35 sago35 commented Jul 16, 2022

This PR adds the ability to create tinyfont from ttf-font.

For example, it can be generated and used with the following command.

$ go run ./cmd/tinyfontgen-ttf --size 32 --package rubikmoonrocks --fontname RubikMoonrocks ./_fonts/RubikMoonrocks-Regular.ttf --output rubikmoonrocks/font.go

$ tinygo flash --target wioterminal --size short ./examples/ttf
   code    data     bss |   flash     ram
  36052     228    6240 |   36280    6468

file : ./examples/ttf

package main

import (
	"image/color"

	"tinygo.org/x/drivers/ili9341"
	"tinygo.org/x/tinyfont"
	"tinygo.org/x/tinyfont/examples/initdisplay"
	"tinygo.org/x/tinyfont/rubikmoonrocks"
)

var (
	font = &rubikmoonrocks.RubikMoonrocks
)

func main() {
	display := initdisplay.InitDisplay()
	dev := display.(*ili9341.Device)
	dev.SetRotation(ili9341.Rotation270)

	tinyfont.WriteLine(display, font, 5, 50, "tinyfont", color.RGBA{0x00, 0x00, 0x00, 0xFF})
	tinyfont.WriteLine(display, font, 5, 100, font.Name, color.RGBA{0x00, 0x00, 0x00, 0xFF})

	select {}
}

font : https://fonts.google.com/specimen/Rubik+Moonrocks?query=rub

@sago35
Copy link
Member Author

sago35 commented Jul 16, 2022

Since most of the font data is stored in ROM, it is easier to use even higher resolution fonts than before.
Currently, only the combination of white background and black text color is supported.
In the future, it should be possible to create them in a variety of colors.

@sago35
Copy link
Member Author

sago35 commented Jul 16, 2022

Copy link
Member

@deadprogram deadprogram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔡 大

@sago35
Copy link
Member Author

sago35 commented Jul 18, 2022

Thanks for the review.
Merged.

@sago35 sago35 merged commit 9b135c3 into dev Jul 18, 2022
@sago35 sago35 deleted the tinyfontgen-ttf branch July 18, 2022 11:57
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

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy