浏览代码

fix struct style

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
68325a15
共有 6 个文件被更改,包括 61 次插入40 次删除
  1. 13
      Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs
  2. 2
      com.unity.uiwidgets/Runtime/ui2/painting.cs
  3. 80
      com.unity.uiwidgets/Runtime/ui2/text.cs
  4. 2
      engine/README.md
  5. 2
      engine/src/lib/ui/text/paragraph_builder.cc
  6. 2
      engine/src/shell/platform/unity/uiwidgets_panel.cc

13
Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs


using System;
using System.Collections.Generic;
using System.IO;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.engine2;

check = false;
}
var style = new ParagraphStyle(fontFamily: "Arial", height: 4);
var style = new ParagraphStyle(
fontFamily: "Arial",
height: 4,
strutStyle: new StrutStyle(fontFamily: "ranchers",
fontFamilyFallback: new List<string>() {"Roboto-RegularB"},
fontSize: 30),
ellipsis: "and so on..."
);
pb.addText("just for testxxx\n");
fontFamilyFallback: new List<string>() {"ranchers"},
fontSize: 30,
height: 1.5f
);

2
com.unity.uiwidgets/Runtime/ui2/painting.cs


this.blurRadius = blurRadius;
}
public static readonly uint _kColorDefault = 0xFF000000;
static readonly uint _kColorDefault = 0xFF000000;
// Constants for shadow encoding.
static readonly int _kBytesPerShadow = 16;

80
com.unity.uiwidgets/Runtime/ui2/text.cs


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)]

2
engine/README.md


convert icudtl.dat to object file in skia
```
cd SkiaRoot/third_party/externals/icu/flutter/icudtl.dat
cd SkiaRoot/third_party/externals/icu/flutter/
ld -r -b binary -o icudtl.o icudtl.dat
```
### Build flutter fml

2
engine/src/lib/ui/text/paragraph_builder.cc


#include "paragraph_builder.h"
#include "lib/ui/ui_mono_state.h"
#include "third_party/icu/source/common/unicode/ustring.h"
#include "unicode/ustring.h"
namespace uiwidgets {
namespace {

2
engine/src/shell/platform/unity/uiwidgets_panel.cc


// args.icu_data_path = icu_path.c_str();
args.icu_mapper = GetICUStaticMapping;
// Used for IOS build
// std::string icu_symbol_prefix = "_binary_icudtl_dat_start";
// std::string native_lib_path =
// "pathtodll/Plugins/x86_64/libUIWidgets_d.dll"; args.icu_mapper =

正在加载...
取消
保存