Esempio n. 1
0
func builtInFont() *truetype.Font {
	font, err := freetype.ParseFont(misc.DejavusansTtf)
	if err != nil {
		logger.Warning.Printf("Could not parse default font because: %v", err)
		return nil
	}
	return font
}
Esempio n. 2
0
// ParseFont reads a font file and creates a freetype.Font type
func ParseFont(fontReader io.Reader) (*truetype.Font, error) {
	fontBytes, err := ioutil.ReadAll(fontReader)
	if err != nil {
		return nil, err
	}

	font, err := freetype.ParseFont(fontBytes)
	if err != nil {
		return nil, err
	}

	return font, nil
}
func setFont(k wini.Key, place **truetype.Font) {
	if v, ok := getLastString(k); ok {
		bs, err := ioutil.ReadFile(v)
		if err != nil {
			logger.Warning.Printf(
				"Could not get font data from '%s' because: %v", v, err)
			return
		}

		font, err := freetype.ParseFont(bs)
		if err != nil {
			logger.Warning.Printf(
				"Could not parse font data from '%s' because: %v", v, err)
			return
		}

		*place = font
	}
}