Beispiel #1
0
// Returns a TextProperties structure.
// Parameters:
//   read_default: if false, returns an empty structure.
//				   if true, returns a structure set with current canvas settings
func (self *Canvas) NewTextProperties(read_default bool) *TextProperties {
	if read_default == true {
		cfont := C.DrawGetFont(self.drawing)
		defer C.free(unsafe.Pointer(cfont))
		cfamily := C.DrawGetFontFamily(self.drawing)
		defer C.free(unsafe.Pointer(cfamily))
		csize := C.DrawGetFontSize(self.drawing)
		cweight := C.DrawGetFontWeight(self.drawing)
		calignment := C.DrawGetTextAlignment(self.drawing)
		cantialias := C.DrawGetTextAntialias(self.drawing)
		ckerning := C.DrawGetTextKerning(self.drawing)
		antialias := false
		if cantialias == C.MagickTrue {
			antialias = true
		}

		underColor := C.NewPixelWand()
		C.DrawGetTextUnderColor(self.drawing, underColor)
		return &TextProperties{
			Font:       C.GoString(cfont),
			Family:     C.GoString(cfamily),
			Size:       float64(csize),
			Weight:     uint(cweight),
			Alignment:  Alignment(calignment),
			Antialias:  antialias,
			Kerning:    float64(ckerning),
			UnderColor: underColor,
		}
	}
	return &TextProperties{
		UnderColor: C.NewPixelWand(),
	}
}
Beispiel #2
0
// Gets the spacing between characters in text.
func (dw *DrawingWand) GetTextKerning() float64 {
	return float64(C.DrawGetTextKerning(dw.dw))
}