fix #8 by exporting utility function LoadFontFace
This commit is contained in:
parent
19103e0c61
commit
5917fd97e8
@ -594,7 +594,7 @@ func (dc *Context) SetFontFace(fontFace font.Face) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dc *Context) LoadFontFace(path string, points float64) error {
|
func (dc *Context) LoadFontFace(path string, points float64) error {
|
||||||
face, err := loadFontFace(path, points)
|
face, err := LoadFontFace(path, points)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dc.fontFace = face
|
dc.fontFace = face
|
||||||
dc.fontHeight = points * 72 / 96
|
dc.fontHeight = points * 72 / 96
|
||||||
|
3
util.go
3
util.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
|
_ "image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
@ -99,7 +100,7 @@ func unfix(x fixed.Int26_6) float64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadFontFace(path string, points float64) (font.Face, error) {
|
func LoadFontFace(path string, points float64) (font.Face, error) {
|
||||||
fontBytes, err := ioutil.ReadFile(path)
|
fontBytes, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user