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: negative XHeight and CapHeight with M+ 1p Font #69378

Open
hajimehoshi opened this issue Sep 10, 2024 · 3 comments
Open

x/image/font: negative XHeight and CapHeight with M+ 1p Font #69378

hajimehoshi opened this issue Sep 10, 2024 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@hajimehoshi
Copy link
Member

Go version

go version go1.22.6 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/hajimehoshi/Library/Caches/go-build'
GOENV='/Users/hajimehoshi/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/hajimehoshi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/hajimehoshi/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.6'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/hajimehoshi/ebiten/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/go-build3402016389=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

  1. Download MPLUS1p-Regular.ttf at https://fonts.google.com/specimen/M+PLUS+1p
  2. Run this program
package main

import (
	"fmt"
	"os"

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

func showMetrics() error {
	file, err := os.ReadFile("MPLUS1p-Regular.ttf")
	if err != nil {
		return err
	}

	f, err := opentype.Parse(file)
	if err != nil {
		return err
	}
	face, err := opentype.NewFace(f, &opentype.FaceOptions{
		Size: 12,
		DPI:  72,
	})
	if err != nil {
		return err
	}
	m := face.Metrics()
	fmt.Printf("x-height: %s\n", m.XHeight.String())
	fmt.Printf("cap-height: %s\n", m.CapHeight.String())
	return nil
}

func main() {
	if err := showMetrics(); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}

What did you see happen?

Negative values are shown

x-height: -6:15
cap-height: -8:49

What did you expect to see?

Positive values are shown

@gopherbot gopherbot added this to the Unreleased milestone Sep 10, 2024
@hajimehoshi
Copy link
Member Author

@nigeltao ?

@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@hajimehoshi
Copy link
Member Author

@timothy-king timothy-king added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 11, 2024
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