-
Notifications
You must be signed in to change notification settings - Fork 185
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
truetype: parse TTF failed with "bad TTF version" #76
Comments
the equivalent program, using
package main
import (
"log"
"github.com/go-fonts/latin-modern/lmroman12regular"
"golang.org/x/image/font/sfnt"
)
func main() {
fnt, err := sfnt.Parse(lmroman12regular.TTF)
if err != nil {
log.Fatalf("could not parse TTF data: %+v", err)
}
log.Printf("num-glyphs: %d", fnt.NumGlyphs())
} |
did you find a good solution for this? I have to use free-type library to draw text onto image, but I failed loading ttf file with exception“invalid TrueType format: bad TTF version” |
I've migrated to using |
|
hum... last time I tried, opentype was able to parse |
How to convert a collection to a font face? |
something like that should work: package main
import (
"fmt"
"log"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
func main() {
fmt.Println("Hello, playground")
var raw []byte // = ... some TTC collection
ttc, err := opentype.ParseCollection(raw)
if err != nil {
log.Fatalf("could not parse collection: %+v", err)
}
fmt.Printf("# of fonts in collection: %d\n", ttc.NumFonts())
fnt, err := ttc.Font(0) // get first font.
if err != nil {
log.Fatalf("could not open font #0: %+v", err)
}
face, err := opentype.NewFace(fnt, &opentype.FaceOptions{
Size: 32,
DPI: 72,
Hinting: font.HintingNone,
})
if err != nil {
log.Fatalf("could not open face #0: %+v", err)
}
defer face.Close()
fmt.Printf("face: %+v\n", face)
} |
Is it possible to use all fonts? |
of course. |
the following program:
fails with:
The text was updated successfully, but these errors were encountered: