示例#1
0
文件: id.go 项目: jimmyfrasche/cairo
func fontSetSubtypeID(f *C.cairo_font_face_t, s subtypeID) {
	if fontType(C.cairo_font_face_get_type(f)) != FontTypeUser {
		panic("font is not a user font")
	}
	if C.cairo_font_face_get_user_data(f, stkey) != nil {
		panic("font already has subtype set")
	}
	C.cairo_font_face_set_user_data(f, stkey, s.c(), free)
}
示例#2
0
文件: id.go 项目: jimmyfrasche/cairo
func fontGetSubtypeID(f *C.cairo_font_face_t) subtypeID {
	if fontType(C.cairo_font_face_get_type(f)) != FontTypeUser {
		panic("font is not a user font")
	}
	p := C.cairo_font_face_get_user_data(f, stkey)
	if p == nil {
		panic("no subtype set: font not registered")
	}
	return subtypeID(ctoint(p))
}
示例#3
0
func cFont(f *C.cairo_font_face_t) (Font, error) {
	t := fontType(C.cairo_font_face_get_type(f))
	fac, ok := cfonttogofont[t]
	if !ok {
		panic("No C → Go font converter registered for " + t.String())
	}
	F, err := fac(f)
	if err != nil {
		return nil, err
	}
	err = F.Err()
	if err != nil {
		return nil, err
	}
	return F, nil
}
示例#4
0
//Type reports the type of the font.
//
//Originally cairo_font_face_get_type.
func (f *XtensionFont) Type() fontType {
	return fontType(C.cairo_font_face_get_type(f.f))
}