func NewFontDescription() *FontDescription { f := &FontDescription{} f.object = C.pango_font_description_new() FontDescriptionFinalizer(f) return f }
func (t *PDFStreamTextObject) WriteAt(text string, props TypesettingProps, x float64, y float64) error { var layout *C.PangoLayout var font_description *C.PangoFontDescription font_description = C.pango_font_description_new() cfontname := C.CString(props.Fontname) defer C.free(unsafe.Pointer(cfontname)) C.pango_font_description_set_family(font_description, cfontname) C.pango_font_description_set_weight(font_description, C.PANGO_WEIGHT_NORMAL) C.pango_font_description_set_absolute_size(font_description, C.double(props.Fontsize)*C.PANGO_SCALE) layout = C.pango_cairo_create_layout(t.context) C.pango_layout_set_font_description(layout, font_description) width := props.PageWidth - props.LeftMargin - props.RightMargin fmt.Printf("width is %f\n", width) C.pango_layout_set_width(layout, C.int(width*C.PANGO_SCALE)) C.pango_layout_set_justify(layout, C.TRUE) ctext := C.CString(text) defer C.free(unsafe.Pointer(ctext)) C.pango_layout_set_text(layout, ctext, -1) C.cairo_set_source_rgb(t.context, 0.0, 0.0, 0.0) C.cairo_move_to(t.context, C.double(x), C.double(y)) skip := props.Baselineskip nlines := int(C.pango_layout_get_line_count(layout)) for i := 0; i < nlines; i++ { C.cairo_move_to(t.context, C.double(x), C.double(y+float64(i)*skip)) C.pango_cairo_show_layout_line(t.context, C.pango_layout_get_line(layout, C.int(i))) } C.g_object_unref(C.gpointer(layout)) C.pango_font_description_free(font_description) return nil }
//PangoFontDescription *pango_font_description_new (void); func FontDescriptionNew() *FontDescription { c := C.pango_font_description_new() v := new(FontDescription) v.pangoFontDescription = c return v }
func NewFontDescription() *FontDescription { return &FontDescription{C.pango_font_description_new()} }