private igCalcTextSize ( Vector2 &pOut, char text, char text_end, bool hide_text_after_double_hash, float wrap_width ) : void | ||
pOut | Vector2 | |
text | char | |
text_end | char | |
hide_text_after_double_hash | bool | |
wrap_width | float | |
Результат | void |
public static unsafe Vector2 GetTextSize(string text, float wrapWidth = Int32.MaxValue) { Vector2 result; IntPtr buffer = Marshal.StringToHGlobalAnsi(text); byte * textStart = (byte *)buffer.ToPointer(); byte * textEnd = textStart + text.Length; ImGuiNative.igCalcTextSize(out result, (char *)textStart, (char *)textEnd, false, wrapWidth); return(result); }
private static Vector2 CalcTextSizeImpl( string text, int start = 0, int?length = null, bool hideTextAfterDoubleHash = false, float wrapWidth = -1.0f) { Vector2 ret; byte * nativeTextStart = null; byte * nativeTextEnd = null; int textByteCount = 0; if (text != null) { int textToCopyLen = length.HasValue ? length.Value : text.Length; textByteCount = Util.CalcSizeInUtf8(text, start, textToCopyLen); if (textByteCount > Util.StackAllocationSizeLimit) { nativeTextStart = Util.Allocate(textByteCount + 1); } else { byte *nativeTextStackBytes = stackalloc byte[textByteCount + 1]; nativeTextStart = nativeTextStackBytes; } int nativeTextOffset = Util.GetUtf8(text, start, textToCopyLen, nativeTextStart, textByteCount); nativeTextStart[nativeTextOffset] = 0; nativeTextEnd = nativeTextStart + nativeTextOffset; } ImGuiNative.igCalcTextSize(&ret, nativeTextStart, nativeTextEnd, *((byte *)(&hideTextAfterDoubleHash)), wrapWidth); if (textByteCount > Util.StackAllocationSizeLimit) { Util.Free(nativeTextStart); } return(ret); }