|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Text; |
|
|
|
using Unity.UIWidgets.external.simplejson; |
|
|
|
using Unity.UIWidgets.services; |
|
|
|
using Rect = Unity.UIWidgets.ui.Rect; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() { |
|
|
|
return "TextHeightBehavior(\n" + |
|
|
|
" applyHeightToFirstAscent: $applyHeightToFirstAscent, \n" + |
|
|
|
" applyHeightToLastDescent: $applyHeightToLastDescent \n" + |
|
|
|
$" applyHeightToFirstAscent: {applyHeightToFirstAscent}, \n" + |
|
|
|
$" applyHeightToLastDescent: {applyHeightToLastDescent} \n" + |
|
|
|
")"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public partial class ui_ { |
|
|
|
public struct Float32List { |
|
|
|
public IntPtr data; |
|
|
|
public int length; |
|
|
|
} |
|
|
|
|
|
|
|
public static partial class ui_ { |
|
|
|
static readonly object VoidObject = new object(); |
|
|
|
|
|
|
|
internal static int[] _encodeTextStyle( |
|
|
|
Color color, |
|
|
|
TextDecoration decoration, |
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
internal static unsafe void setFloat(this byte[] bytes, int byteOffset, float value) { |
|
|
|
D.assert(byteOffset >= 0 && byteOffset + 4 < bytes.Length); |
|
|
|
fixed (byte* b = &bytes[byteOffset]) { |
|
|
|
*(float*) b = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal static byte[] _encodeStrut( |
|
|
|
string fontFamily, |
|
|
|
List<string> fontFamilyFallback, |
|
|
|
|
|
|
|
|
|
|
if (fontSize != null) { |
|
|
|
bitmask |= 1 << 3; |
|
|
|
data.setFloat32(byteCount, (float) fontSize); |
|
|
|
data.setFloat(byteCount, (float) fontSize); |
|
|
|
data.setFloat32(byteCount, (float) height); |
|
|
|
data.setFloat(byteCount, (float) height); |
|
|
|
data.setFloat32(byteCount, (float) leading); |
|
|
|
data.setFloat(byteCount, (float) leading); |
|
|
|
byteCount += 4; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
completerHandle.Free(); |
|
|
|
_sendFontChangeMessage(); |
|
|
|
try { |
|
|
|
callback(new object()); |
|
|
|
callback(VoidObject); |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
Debug.LogException(ex); |
|
|
|
|
|
|
IntPtr callbackHandle, |
|
|
|
string fontFamily); |
|
|
|
|
|
|
|
public struct Float32List { |
|
|
|
public IntPtr data; |
|
|
|
public int length; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ui_.Lists_Free(data.data); |
|
|
|
Lists_Free(data.data); |
|
|
|
public static unsafe extern void Lists_Free(IntPtr data); |
|
|
|
public static extern void Lists_Free(IntPtr data); |
|
|
|
} |
|
|
|
|
|
|
|
public class TextStyle : IEquatable<TextStyle> { |
|
|
|
|
|
|
|
|
|
|
public class StrutStyle : IEquatable<StrutStyle> { |
|
|
|
public StrutStyle( |
|
|
|
string fontFamily, |
|
|
|
List<string> fontFamilyFallback, |
|
|
|
float? fontSize, |
|
|
|
float? height, |
|
|
|
float? leading, |
|
|
|
FontWeight fontWeight, |
|
|
|
FontStyle? fontStyle, |
|
|
|
bool? forceStrutHeight |
|
|
|
string fontFamily = null, |
|
|
|
List<string> fontFamilyFallback = null, |
|
|
|
float? fontSize = null, |
|
|
|
float? height = null, |
|
|
|
float? leading = null, |
|
|
|
FontWeight fontWeight = null, |
|
|
|
FontStyle? fontStyle = null, |
|
|
|
bool? forceStrutHeight = null |
|
|
|
) { |
|
|
|
_encoded = ui_._encodeStrut( |
|
|
|
fontFamily, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class TextBox : IEquatable<TextBox> { |
|
|
|
public TextBox( |
|
|
|
TextBox( |
|
|
|
float left, |
|
|
|
float top, |
|
|
|
float right, |
|
|
|
|
|
|
static extern void Paragraph_layout(IntPtr ptr, float width); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern ui_.Float32List Paragraph_getRectsForRange(IntPtr ptr, int start, int end, |
|
|
|
static extern Float32List Paragraph_getRectsForRange(IntPtr ptr, int start, int end, |
|
|
|
static extern ui_.Float32List Paragraph_getRectsForPlaceholders(IntPtr ptr); |
|
|
|
static extern Float32List Paragraph_getRectsForPlaceholders(IntPtr ptr); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern unsafe void Paragraph_getPositionForOffset(IntPtr ptr, float dx, float dy, int* encodedPtr); |
|
|
|
|
|
|
static extern void Paragraph_paint(IntPtr ptr, IntPtr canvas, float x, float y); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern ui_.Float32List Paragraph_computeLineMetrics(IntPtr ptr); |
|
|
|
static extern Float32List Paragraph_computeLineMetrics(IntPtr ptr); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern void Paragraph_dispose(IntPtr ptr); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// See paragraph.cc for the layout of this return value.
|
|
|
|
ui_.Float32List _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) => |
|
|
|
Float32List _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) => |
|
|
|
Paragraph_getRectsForRange(_ptr, start, end, boxHeightStyle, boxWidthStyle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ui_.Float32List _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr); |
|
|
|
Float32List _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr); |
|
|
|
|
|
|
|
public unsafe TextPosition getPositionForOffset(Offset offset) { |
|
|
|
int[] encoded = new int[2]; |
|
|
|
|
|
|
return metrics; |
|
|
|
} |
|
|
|
|
|
|
|
ui_.Float32List _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr); |
|
|
|
Float32List _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr); |
|
|
|
[DllImport(NativeBindings.dllName, CallingConvention = CallingConvention.Cdecl)] |
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern IntPtr ParagraphBuilder_constructor( |
|
|
|
int[] encoded, |
|
|
|
int encodeSize, |
|
|
|
|
|
|
[In] string[] structFontFamily, |
|
|
|
string[] structFontFamily, |
|
|
|
int structFontFamilySize, |
|
|
|
float fontSize, |
|
|
|
float height, |
|
|
|
|
|
|
[DllImport(NativeBindings.dllName, CallingConvention = CallingConvention.Cdecl)] |
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
[In] string[] fontFamilies, |
|
|
|
string[] fontFamilies, |
|
|
|
int fontFamiliesSize, |
|
|
|
float fontSize, |
|
|
|
float letterSpacing, |
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern void ParagraphBuilder_pop(IntPtr ptr); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName, CallingConvention = CallingConvention.Cdecl)] |
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|
static extern IntPtr ParagraphBuilder_addText(IntPtr ptr, [MarshalAs(UnmanagedType.LPWStr)] string text); |
|
|
|
|
|
|
|
[DllImport(NativeBindings.dllName)] |
|
|
|