Esempio n. 1
0
//ShowTextGlyphs renders similarly to ShowGlyphs but, if the target surface
//support it, uses the provided text and cluster mapping to embed the text
//for the glyphs shown in the output.
//If the target surface does not support the extended attributes, this method
//behaves exactly as ShowGlyphs(glyphs).
//
//The mapping between s and glyphs is provided by clusters.
//Each cluster covers a number of text bytes and glyphs, and neighboring
//clusters cover neighboring areas of s and glyphs.
//The clusters should collectively cover s and glyphs in entirety.
//
//The first cluster always covers bytes from the beginning of s.
//If flags do not have TextClusterBackward set, the first cluster also covers
//the beginning of glyphs, otherwise it covers the end of the glyphs array and
//following clusters move backward.
//
//Originally cairo_show_text_glyphs.
func (c *Context) ShowTextGlyphs(s string, glyphs []Glyph, clusters []TextCluster, flags TextClusterFlags) *Context {
	gs, gn := XtensionGlyphsGotoC(glyphs, false)
	ts, tn := XtensionTextClustersGotoC(clusters, false)
	cs, cn := C.CString(s), C.int(len(s))
	C.cairo_show_text_glyphs(c.c, cs, cn, gs, gn, ts, tn, flags.c())
	C.free(unsafe.Pointer(cs))
	return c
}
Esempio n. 2
0
// void cairo_show_text_glyphs(cairo_t *cr, const char *utf8, int utf8_len,
// const cairo_glyph_t *glyphs, int num_glyphs,
// const cairo_text_cluster_t *clusters, int num_clusters,
// cairo_text_cluster_flags_t cluster_flags );
func (self *Surface) ShowTextGlyphs(text string, glyphs []Glyph, clusters []TextCluster, flag TextClusterFlag) {
	utf8 := C.CString(text)
	defer C.free(unsafe.Pointer(utf8))

	C.cairo_show_text_glyphs(self.context, utf8, C.int(len(text)),
		(*C.cairo_glyph_t)(unsafe.Pointer(&glyphs[0])), C.int(len(glyphs)),
		(*C.cairo_text_cluster_t)(unsafe.Pointer(&clusters[0])), C.int(len(clusters)),
		C.cairo_text_cluster_flags_t(flag))
}