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

x/image/font/sfnt: GlyphName returns empty string on OpenType font #33990

Open
andybalholm opened this issue Aug 30, 2019 · 2 comments
Open

x/image/font/sfnt: GlyphName returns empty string on OpenType font #33990

andybalholm opened this issue Aug 30, 2019 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@andybalholm
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.13beta1 darwin/amd64

What did you do?


package main

import (
	"fmt"
	"io/ioutil"
	"log"

	"golang.org/x/image/font/sfnt"
)

func main() {
	b, err := ioutil.ReadFile("texgyrepagella-bold.otf")
	if err != nil {
		log.Fatal(err)
	}

	f, err := sfnt.Parse(b)
	if err != nil {
		log.Fatal(err)
	}

	var buffer sfnt.Buffer
	g, err := f.GlyphIndex(&buffer, '!')
	if err != nil {
		log.Fatal(err)
	}

	name, err := f.GlyphName(&buffer, g)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("The glyph name is %q.\n", name)
}

texgyrepagella-bold.otf.zip

What did you expect to see?


The glyph name is "exclam".

What did you see instead?


The glyph name is "".
@gopherbot gopherbot added this to the Unreleased milestone Aug 30, 2019
@smasher164
Copy link
Member

sfnt doesn't support post table version 3.0, which is why GlyphName returns an empty string here. See https://docs.microsoft.com/en-us/typography/opentype/spec/post#version-30
/cc @nigeltao

@andybalholm
Copy link
Contributor Author

In an OpenType PS font, I think the glyph names are stored in the CFF table along with the outlines instead of in the post table. (But I could be wrong on this; it's hard to find solid information without digging way down into the specifications.)

@katiehockman katiehockman added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants