cairo_atsui_font_t	*font = abstract_font; size_t				i; OSStatus			err; ATSUTextLayout		textLayout; ATSLayoutRecord		*layoutRecords; ItemCount			glyphCount, charCount; UniChar				*theText; ATSUStyle			style;   charCount = strlen(utf8);   err = ATSUCreateTextLayout(&textLayout);    theText = (UniChar *)malloc(charCount * sizeof(UniChar));  for (i = 0; i < charCount; i++) { theText[i] = utf8[i]; }  err = ATSUSetTextPointerLocation(   textLayout, theText, 0, charCount, charCount);   style = CreateSizedCopyOfStyle(font->style, sc);    err = ATSUSetRunStyle(	textLayout, style, kATSUFromTextBeginning, kATSUToTextEnd);     err = ATSUDirectGetLayoutDataArrayPtrFromTextLayout(	textLayout, 0, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void *)&layoutRecords, &glyphCount);  *nglyphs = glyphCount;   *glyphs = (cairo_glyph_t *)malloc(glyphCount * (sizeof(cairo_glyph_t))); if (*glyphs == NULL) { return CAIRO_STATUS_NO_MEMORY; }
cairo_atsui_font_t *font = abstract_font; size_t i; OSStatus err; ATSUTextLayout textLayout; ATSLayoutRecord *layoutRecords; ItemCount glyphCount, charCount; UniChar *theText; ATSUStyle style;
_cairo_atsui_font_text_to_glyphs(	void				*abstract_font,									cairo_font_scale_t	*sc,									const unsigned char	*utf8,									cairo_glyph_t		**glyphs, 									int					*nglyphs){	cairo_atsui_font_t	*font = abstract_font;	size_t				i;	OSStatus			err;	ATSUTextLayout		textLayout;	ATSLayoutRecord		*layoutRecords;	ItemCount			glyphCount, charCount;	UniChar				*theText;	ATSUStyle			style;			charCount = strlen(utf8);			err = ATSUCreateTextLayout(&textLayout);			// Set the text in the text layout object, so we can measure it	theText = (UniChar *)malloc(charCount * sizeof(UniChar));		for (i = 0; i < charCount; i++)	{		theText[i] = utf8[i];	}		err = ATSUSetTextPointerLocation(   textLayout, 										theText, 										0, 										charCount, 										charCount);			style = CreateSizedCopyOfStyle(font->style, sc);			// Set the style for all of the text	err = ATSUSetRunStyle(	textLayout, 							style, 							kATSUFromTextBeginning, 							kATSUToTextEnd);				// Get the glyphs from the text layout object	err = ATSUDirectGetLayoutDataArrayPtrFromTextLayout(	textLayout,															0,															kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, 															(void *)&layoutRecords,  															&glyphCount); 		*nglyphs = glyphCount;			*glyphs = (cairo_glyph_t *)malloc(glyphCount * (sizeof(cairo_glyph_t)));	if (*glyphs == NULL)	{	    return CAIRO_STATUS_NO_MEMORY;	}	for (i = 0; i < glyphCount; i++)	{		(*glyphs)[i].index = layoutRecords[i].glyphID;		(*glyphs)[i].x = FixedToFloat(layoutRecords[i].realPos);		(*glyphs)[i].y = 0;	}			free(theText);		ATSUDirectReleaseLayoutDataArrayPtr(	NULL, 											kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,											(void *)&layoutRecords); 		ATSUDisposeTextLayout(textLayout);		ATSUDisposeStyle(style);			return CAIRO_STATUS_SUCCESS;}