Lookup returns the font Face corresponding to the provided Font descriptor, with the provided font size set. If no matching font Face could be found, the one corresponding to the default typeface is selected and returned.
(fnt Font, size Length)
| 244 | // If no matching font Face could be found, the one corresponding to |
| 245 | // the default typeface is selected and returned. |
| 246 | func (c *Cache) Lookup(fnt Font, size Length) Face { |
| 247 | c.mu.RLock() |
| 248 | defer c.mu.RUnlock() |
| 249 | |
| 250 | if len(c.faces) == 0 { |
| 251 | return Face{} |
| 252 | } |
| 253 | |
| 254 | face := c.lookup(fnt) |
| 255 | if face == nil { |
| 256 | fnt.Typeface = c.def |
| 257 | face = c.lookup(fnt) |
| 258 | } |
| 259 | |
| 260 | ff := Face{ |
| 261 | Font: fnt, |
| 262 | Face: face, |
| 263 | } |
| 264 | ff.Font.Size = size |
| 265 | return ff |
| 266 | } |
| 267 | |
| 268 | // Has returns whether the cache contains the exact font descriptor. |
| 269 | func (c *Cache) Has(fnt Font) bool { |