public Segment MakeSeg(UInt32 script, Featureval feats, string str, Bidirtl dir) { IntPtr strPtr = Marshal.StringToCoTaskMemUni(str); IntPtr error = new IntPtr(0); int numCodePoints = Graphite2Api.CountUnicodeCharacters(Encform.Utf16, strPtr, IntPtr.Zero, ref error); IntPtr segmentPtr = Graphite2Api.MakeSeg(_font, _face.FacePtr, script, feats.FeatureValPtr, Encform.Utf16, strPtr, numCodePoints, dir); Marshal.FreeCoTaskMem(strPtr); return(new Segment(segmentPtr)); }