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

Comments

@andybalholm
Copy link

@andybalholm andybalholm commented Aug 30, 2019

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

This comment has been minimized.

Copy link
Member

@smasher164 smasher164 commented Aug 30, 2019

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

This comment has been minimized.

Copy link
Author

@andybalholm andybalholm commented Aug 30, 2019

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.)

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.