Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
//void                 pango_font_description_set_weight        (PangoFontDescription *desc,
//							       PangoWeight           weight);
func (v *FontDescription) SetWeight(weight Weight) {
	C.pango_font_description_set_weight(v.native(), (C.PangoWeight)(weight))
}
Ejemplo n.º 3
0
func (self *FontDescription) SetWeight(pango_Weight int) {
	C.pango_font_description_set_weight(self.object, C.PangoWeight(pango_Weight))
}