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: provide access to font height and ascent. #14885

Closed
eaburns opened this issue Mar 20, 2016 · 6 comments
Closed

x/image/font: provide access to font height and ascent. #14885

eaburns opened this issue Mar 20, 2016 · 6 comments

Comments

@eaburns
Copy link

eaburns commented Mar 20, 2016

There is no way to access the height and ascent metrics of a font with x/image/font. The per-glyph bounds are available, but the global height and ascent are needed to properly space lines.

  1. What version of Go are you using (go version)?
$ go version
go version go1.6 linux/amd64
  1. What operating system and processor architecture are you using (go env)?
$ go env
GOARCH="amd64"
GOOS="linux"
[…]
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

Read the godoc x/image/font.

  1. What did you expect to see?

A way to access the font's height and ascent metrics.

  1. What did you see instead?

It's possible to get the metrics for individual glyphs, but fonts typically have a global height and ascent that can be used for spacing lines. These aren't available.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 20, 2016
@ianlancetaylor
Copy link
Contributor

CC @nigeltao

@nigeltao
Copy link
Contributor

Yes, that's the "TODO: per-font Metrics" in x/image/font/font.go. See also issue #14436 and golang/freetype#15

As for a specific API, it's probably be something like:

Face.Metrics() Metrics
and
type Metrics struct{ etc }

instead of

Face.VerticalMetrics() (height, ascent fixed.Int26_6)

in case we want to add other Metrics fields in the future (e.g. descent). But I haven't given this a lot of thought yet.

@nigeltao nigeltao self-assigned this Mar 21, 2016
@eaburns
Copy link
Author

eaburns commented Mar 21, 2016

Perfect. Mind if I send you a CL?

@nigeltao
Copy link
Contributor

Go for it. My instincts would be to say

type Metrics struct {
Height fixed.Int26_6
Ascent fixed.Int26_6
Descent fixed.Int26_6 // Usually positive, not negative.
}

(plus comments, of course) so that, for TTFs, Height = Ascent + Descent + LineGap. But I'm open to discussing other ideas (e.g. inspired by what Win / Mac / Linux APIs offer). We can do that on the CL.

@nigeltao
Copy link
Contributor

CC @josharian @stephenwithav.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/21035 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 23, 2017
mrhyperbit23z0d added a commit to mrhyperbit23z0d/bhegde8 that referenced this issue Jun 6, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
GalaxyForcew added a commit to GalaxyForcew/A1bisshy that referenced this issue Jun 6, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
yi-ge3 added a commit to yi-ge3/wislie that referenced this issue Jun 6, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
balloontmz6 added a commit to balloontmz6/Likewise42l that referenced this issue Jun 6, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
snapbakkhfbav added a commit to snapbakkhfbav/SayedBaladohr that referenced this issue Oct 6, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
MiderWong5ddop added a commit to MiderWong5ddop/sidie88f that referenced this issue Oct 7, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
rorypeckwnt4v added a commit to rorypeckwnt4v/LearnByBhanuPrataph that referenced this issue Oct 7, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
egorovcharenko9 added a commit to egorovcharenko9/RiceBIOC470z that referenced this issue Oct 7, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
RafayGhafoorf added a commit to RafayGhafoorf/dustinsand8 that referenced this issue Oct 7, 2022
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants