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
|
@ -73,8 +73,9 @@ func (f *Face) Kern(r0, r1 rune) fixed.Int26_6 { return 0 }
|
||||||
|
|
||||||
func (f *Face) Metrics() font.Metrics {
|
func (f *Face) Metrics() font.Metrics {
|
||||||
return font.Metrics{
|
return font.Metrics{
|
||||||
Height: fixed.I(f.Height),
|
Height: fixed.I(f.Height),
|
||||||
Ascent: fixed.I(f.Ascent),
|
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
|
// 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
|
// https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
|
||||||
type Metrics struct {
|
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 is the distance from the top of a line to its baseline.
|
||||||
Ascent fixed.Int26_6
|
Ascent fixed.Int26_6
|
||||||
|
|
||||||
// Height is the recommended amount of vertical space between two lines of text.
|
// Descent is the distance from the bottom of a line to its baseline. The
|
||||||
Height fixed.Int26_6
|
// 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
|
// TODO: Drawer.Layout or Drawer.Measure methods to measure text without
|
||||||
|
|
|
@ -67,8 +67,9 @@ func (f *subface) Kern(r0, r1 rune) fixed.Int26_6 { return 0 }
|
||||||
|
|
||||||
func (f *subface) Metrics() font.Metrics {
|
func (f *subface) Metrics() font.Metrics {
|
||||||
return font.Metrics{
|
return font.Metrics{
|
||||||
Height: fixed.I(f.height),
|
Height: fixed.I(f.height),
|
||||||
Ascent: fixed.I(f.ascent),
|
Ascent: fixed.I(f.ascent),
|
||||||
|
Descent: fixed.I(f.height - f.ascent),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +149,9 @@ func (f *face) Kern(r0, r1 rune) fixed.Int26_6 { return 0 }
|
||||||
|
|
||||||
func (f *face) Metrics() font.Metrics {
|
func (f *face) Metrics() font.Metrics {
|
||||||
return font.Metrics{
|
return font.Metrics{
|
||||||
Height: fixed.I(f.height),
|
Height: fixed.I(f.height),
|
||||||
Ascent: fixed.I(f.ascent),
|
Ascent: fixed.I(f.ascent),
|
||||||
|
Descent: fixed.I(f.height - f.ascent),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user