font: add Metrics.Descent.
Change-Id: Id38e7e54264e0e77a28afd8e10cf574610b47336 Reviewed-on: https://go-review.googlesource.com/21019 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
7b1c29e1d6
commit
f1e9747265
|
@ -75,6 +75,7 @@ func (f *Face) Metrics() font.Metrics {
|
|||
return font.Metrics{
|
||||
Height: fixed.I(f.Height),
|
||||
Ascent: fixed.I(f.Ascent),
|
||||
Descent: fixed.I(f.Height - f.Ascent),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
font/font.go
10
font/font.go
|
@ -74,11 +74,17 @@ type Face interface {
|
|||
// Metrics holds the metrics for a Face. A visual depiction is at
|
||||
// https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
|
||||
type Metrics struct {
|
||||
// Height is the recommended amount of vertical space between two lines of
|
||||
// text.
|
||||
Height fixed.Int26_6
|
||||
|
||||
// Ascent is the distance from the top of a line to its baseline.
|
||||
Ascent fixed.Int26_6
|
||||
|
||||
// Height is the recommended amount of vertical space between two lines of text.
|
||||
Height fixed.Int26_6
|
||||
// Descent is the distance from the bottom of a line to its baseline. The
|
||||
// value is typically positive, even though a descender goes below the
|
||||
// baseline.
|
||||
Descent fixed.Int26_6
|
||||
}
|
||||
|
||||
// TODO: Drawer.Layout or Drawer.Measure methods to measure text without
|
||||
|
|
|
@ -69,6 +69,7 @@ func (f *subface) Metrics() font.Metrics {
|
|||
return font.Metrics{
|
||||
Height: fixed.I(f.height),
|
||||
Ascent: fixed.I(f.ascent),
|
||||
Descent: fixed.I(f.height - f.ascent),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,6 +151,7 @@ func (f *face) Metrics() font.Metrics {
|
|||
return font.Metrics{
|
||||
Height: fixed.I(f.height),
|
||||
Ascent: fixed.I(f.ascent),
|
||||
Descent: fixed.I(f.height - f.ascent),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user