Skip to content
Merged
2 changes: 1 addition & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<MicrosoftTestingPlatformVersion>2.1.0</MicrosoftTestingPlatformVersion>
<SkiaSharpVersion>3.119.0</SkiaSharpVersion>
<HarfbuzzSharpVersion>8.3.1.1</HarfbuzzSharpVersion>
<UnoICUVersion>77.2.0-dev.10</UnoICUVersion>
<UnoICUVersion>77.2.0-dev.11</UnoICUVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private readonly record struct FontEntry(

private static readonly Dictionary<FontEntry, Task<SKTypeface?>> _fontCache = new();
private static readonly object _fontCacheGate = new();
private static readonly IFontFallbackService? _fontFallbackService = ApiExtensibility.CreateInstance<IFontFallbackService>(typeof(UnicodeText), out var service) ? service : null;
private static readonly IFontFallbackService? _fontFallbackService = ApiExtensibility.CreateInstance<IFontFallbackService>(typeof(FontDetailsCache), out var service) ? service : null;

private static async Task<SKTypeface?> LoadTypefaceFromApplicationUriAsync(Uri uri, FontWeight weight, FontStyle style, FontStretch stretch)
{
Expand Down
63 changes: 60 additions & 3 deletions src/Uno.UI/UI/Xaml/Documents/UnicodeText.ICU.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,23 @@ public static T GetMethod<T>()
return (T)value;
}

public static unsafe DisposableStruct<IntPtr> CreateBiDiAndSetPara(string text, int start, int end, byte paraLevel, out IntPtr bidi)
public static unsafe DisposableStruct<IntPtr> CreateBiDiAndSetPara(string text, int start, int end, byte paraLevel, out IntPtr bidi, byte[]? embeddingLevels = null)
{
bidi = GetMethod<ubidi_open>()();
fixed (char* textPtr = &text.GetPinnableReference())
{
GetMethod<ubidi_setPara>()(bidi, (IntPtr)(textPtr + start), end - start, paraLevel, IntPtr.Zero, out var setParaErrorCode);
int setParaErrorCode;
if (embeddingLevels is not null)
{
fixed (byte* embeddingLevelsPtr = embeddingLevels)
{
GetMethod<ubidi_setPara>()(bidi, (IntPtr)(textPtr + start), end - start, paraLevel, (IntPtr)embeddingLevelsPtr, out setParaErrorCode);
}
}
else
{
GetMethod<ubidi_setPara>()(bidi, (IntPtr)(textPtr + start), end - start, paraLevel, IntPtr.Zero, out setParaErrorCode);
}
if (setParaErrorCode > 0)
{
throw new InvalidOperationException($"{nameof(ubidi_setPara)} failed with error code {setParaErrorCode}");
Expand All @@ -191,7 +202,8 @@ public static void CheckErrorCode<T>(int status)
{
if (status > 0)
{
throw new InvalidOperationException($"{typeof(T).Name} failed with error code {status.ToString("X", CultureInfo.InvariantCulture)}");
var errorString = Marshal.PtrToStringUTF8(GetMethod<u_errorName>()(status));
throw new InvalidOperationException($"{typeof(T).Name} failed with error code {errorString}");
}
else if (status < 0)
{
Expand All @@ -210,9 +222,21 @@ public static void CheckErrorCode<T>(int status)
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ubidi_setPara(IntPtr pBiDi, IntPtr text, int length, byte paraLevel, IntPtr embeddingLevels, out int errorCode);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ubidi_setLine(IntPtr pBiDi, int start, int limit, IntPtr pLine, out int errorCode);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ubidi_getLogicalRun(IntPtr pBiDi, int logicalPosition, out int logicalLimit, out byte level);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr ubidi_getLevels(IntPtr pBiDi, out int errorCode);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate byte ubidi_getParaLevel(IntPtr pBiDi);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ubidi_getLogicalMap(IntPtr pBiDi, IntPtr indexMap, out int errorCode);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ubidi_countRuns(IntPtr pBiDI, out int errorCode);

Expand All @@ -231,6 +255,9 @@ public static void CheckErrorCode<T>(int status)
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ubrk_next(IntPtr bi);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int uscript_getScript(int codepoint, out int errorCode);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void u_getVersion(out UVersionInfo versionInfo);

Expand Down Expand Up @@ -276,6 +303,9 @@ public class BrowserICUSymbols
[DllImport("unoicu")]
static extern void uno_ubidi_setPara(IntPtr pBiDi, IntPtr text, int length, byte paraLevel, IntPtr embeddingLevels, out int errorCode);

[DllImport("unoicu")]
static extern void uno_ubidi_setLine(IntPtr pBiDi, int start, int limit, IntPtr pLine, out int errorCode);

[DllImport("unoicu")]
static extern void uno_ubidi_getLogicalRun(IntPtr pBiDi, int logicalPosition, out int logicalLimit, out byte level);

Expand All @@ -285,6 +315,15 @@ public class BrowserICUSymbols
[DllImport("unoicu")]
static extern int uno_ubidi_getVisualRun(IntPtr pBiDi, int runIndex, out int logicalStart, out int length);

[DllImport("unoicu")]
static extern IntPtr uno_ubidi_getLevels(IntPtr pBiDi, out int errorCode);

[DllImport("unoicu")]
static extern byte uno_ubidi_getParaLevel(IntPtr pBiDi);

[DllImport("unoicu")]
static extern void uno_ubidi_getLogicalMap(IntPtr pBiDi, IntPtr indexMap, out int errorCode);

[DllImport("unoicu")]
static extern IntPtr uno_ubrk_open(int type, IntPtr locale, IntPtr text, int textLength, out int status);

Expand All @@ -297,6 +336,9 @@ public class BrowserICUSymbols
[DllImport("unoicu")]
static extern int uno_ubrk_next(IntPtr bi);

[DllImport("unoicu")]
static extern int uno_uscript_getScript(int codepoint, out int errorCode);

[DllImport("unoicu")]
static extern void uno_u_getVersion(out UVersionInfo versionInfo);

Expand All @@ -321,6 +363,9 @@ private static class IOSICUSymbols
[DllImport("__Internal")]
static extern void ubidi_setPara_77(IntPtr pBiDi, IntPtr text, int length, byte paraLevel, IntPtr embeddingLevels, out int errorCode);

[DllImport("__Internal")]
static extern void ubidi_setLine_77(IntPtr pBiDi, int start, int limit, IntPtr pLine, out int errorCode);

[DllImport("__Internal")]
static extern void ubidi_getLogicalRun_77(IntPtr pBiDi, int logicalPosition, out int logicalLimit, out byte level);

Expand All @@ -330,6 +375,15 @@ private static class IOSICUSymbols
[DllImport("__Internal")]
static extern int ubidi_getVisualRun_77(IntPtr pBiDi, int runIndex, out int logicalStart, out int length);

[DllImport("__Internal")]
static extern IntPtr ubidi_getLevels_77(IntPtr pBiDi, out int errorCode);

[DllImport("__Internal")]
static extern byte ubidi_getParaLevel_77(IntPtr pBiDi);

[DllImport("__Internal")]
static extern void ubidi_getLogicalMap_77(IntPtr pBiDi, IntPtr indexMap, out int errorCode);

[DllImport("__Internal")]
static extern IntPtr ubrk_open_77(int type, IntPtr locale, IntPtr text, int textLength, out int status);

Expand All @@ -342,6 +396,9 @@ private static class IOSICUSymbols
[DllImport("__Internal")]
static extern int ubrk_next_77(IntPtr bi);

[DllImport("__Internal")]
static extern int uscript_getScript_77(int codepoint, out int errorCode);

[DllImport("__Internal")]
static extern void u_getVersion_77(out UVersionInfo versionInfo);

Expand Down
Loading
Loading