Font path
Specify the font to use specifying a path or a font object
I just had a problem related to this, that draw2d couldn't find the fonts. I resolved it with this bit of code:
import (
"go/build"
"path/filepath"
)
func setupDraw2D() {
p, err := build.Default.Import("github.com/llgcode/draw2d", "", build.FindOnly)
if err != nil {
log.Fatalf("Couldn't find llgcode/draw2d files: %v", err)
}
draw2d.SetFontFolder(filepath.Join(p.Dir, "resource", "font"))
}
Perhaps the draw2d could do this itself, to ensure it has the correct path to the fonts directory?
Today font could be anywhere. Le 13 juil. 2015 16:20, "Andrew Brampton" [email protected] a écrit :
I just had a problem related to this, that draw2d couldn't find the fonts. I resolved it with this bit of code:
import ( "go/build" "path/filepath" ) func setupDraw2D() { p, err := build.Default.Import("github.com/llgcode/draw2d", "", build.FindOnly) if err != nil { log.Fatalf("Couldn't find llgcode/draw2d files: %v", err) }
draw2d.SetFontFolder(filepath.Join(p.Dir, "resource", "font"))}
Perhaps the draw2d could do this itself, to ensure it has the correct path to the fonts directory?
— Reply to this email directly or view it on GitHub https://github.com/llgcode/draw2d/issues/40#issuecomment-120943548.
ah, but the default of "./resources/font/" does not work for anyone who path is outside of your directory. This code makes the path somewhat agnostic, but is still a bit of a hack.
Would you accept a pull request that specifies a new type to handle font naming?
type FontNamerFunc func(fontData FontData) string
This would let anyone change how fonts are found.
Yes, It's a great idea. Thanks
-- Laurent.
On 9 August 2015 at 17:41, Steven Edwards [email protected] wrote:
Would you accept a pull request that specifies a new type to handle font naming?
type FontNamerFunc func(fontData FontData) string
This would let anyone change how fonts are found.
— Reply to this email directly or view it on GitHub https://github.com/llgcode/draw2d/issues/40#issuecomment-129199598.