public unsafe NativeTextLayout CreateTextLayout(ref NativeParagraphStyle paragraphStyle, ref NativeTextStyle textStyle, ReadOnlySpan <char> text, float maxWidth, float maxHeight) { // This is to avoid a null-pointer which is rejected by DirectWrite, even though length 0 // is acceptable if (text.IsEmpty) { text = EmptyText; } fixed(char *textPtr = text) { if (!DrawingEngine_CreateTextLayout( _native, ref paragraphStyle, ref textStyle, textPtr, text.Length, maxWidth, maxHeight, out var textLayoutNative, out var error )) { throw new InvalidOperationException("Failed to create TextLayout: " + error); } return(new NativeTextLayout(textLayoutNative)); } }
private static extern unsafe bool DrawingEngine_CreateTextLayout( IntPtr drawingEngine, [In] ref NativeParagraphStyle paragraphStyle, [In] ref NativeTextStyle textStyle, char *text, int textLength, float maxWidth, float maxHeight, out IntPtr textLayout, [MarshalAs(UnmanagedType.LPWStr)] out string error );