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) }
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)) }
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 }
//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)) }