MCPcopy
hub / github.com/EngoEngine/engo / CreatePreloaded

Method CreatePreloaded

common/font.go:79–98  ·  view source on GitHub ↗

CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload

()

Source from the content-addressed store, hash-verified

77
78// CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
79func (f *Font) CreatePreloaded() error {
80 fontres, err := engo.Files.Resource(f.URL)
81 if err != nil {
82 return err
83 }
84
85 fnt, ok := fontres.(FontResource)
86 if !ok {
87 return fmt.Errorf("preloaded font is not of type `*truetype.Font`: %s", f.URL)
88 }
89
90 f.TTF = fnt.Font
91 f.face = truetype.NewFace(f.TTF, &truetype.Options{
92 Size: f.Size,
93 DPI: dpi,
94 Hinting: font.HintingFull,
95 })
96 fontCache = append(fontCache, f)
97 return nil
98}
99
100// TextDimensions returns the total width, total height and total line size
101// of the input string written out in the Font.

Callers 8

SetupMethod · 0.95
NewMethod · 0.95
SetupMethod · 0.95
NewMethod · 0.80
SetupMethod · 0.80
SetupMethod · 0.80
SetupMethod · 0.80
SetupMethod · 0.80

Calls 1

ResourceMethod · 0.65

Tested by

no test coverage detected