diff --git a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/CanvasExtensions.cs b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/CanvasExtensions.cs index 9e92aa2f..84446d0a 100644 --- a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/CanvasExtensions.cs +++ b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/CanvasExtensions.cs @@ -31,7 +31,8 @@ namespace SkiaSharp.HarfBuzz paintClone.TextEncoding = SKTextEncoding.GlyphId; paintClone.Typeface = shaper.Typeface; - canvas.DrawPositionedText(result.Codepoints, result.Points, paintClone); + var bytes = result.Codepoints.Select(cp => BitConverter.GetBytes((ushort)cp)).SelectMany(b => b).ToArray(); + canvas.DrawPositionedText(bytes, result.Points, paintClone); } } } diff --git a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/SKShaper.cs b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/SKShaper.cs index 225c1f14..f1b5d058 100644 --- a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/SKShaper.cs +++ b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/SKShaper.cs @@ -78,11 +78,11 @@ namespace SkiaSharp.HarfBuzz var points = new SKPoint[len]; var clusters = new uint[len]; - var codepointsTemp = new byte[len][]; + var codepoints = new uint[len]; for (var i = 0; i < len; i++) { - codepointsTemp[i] = BitConverter.GetBytes((ushort)info[i].Codepoint); + codepoints[i] = info[i].Codepoint; clusters[i] = info[i].Cluster; @@ -95,8 +95,6 @@ namespace SkiaSharp.HarfBuzz yOffset += pos[i].YAdvance * textSizeY; } - var codepoints = codepointsTemp.SelectMany(cp => cp).ToArray(); - return new Result(codepoints, clusters, points); } @@ -104,19 +102,19 @@ namespace SkiaSharp.HarfBuzz { public Result() { - Codepoints = new byte[0]; + Codepoints = new uint[0]; Clusters = new uint[0]; Points = new SKPoint[0]; } - public Result(byte[] codepoints, uint[] clusters, SKPoint[] points) + public Result(uint[] codepoints, uint[] clusters, SKPoint[] points) { Codepoints = codepoints; Clusters = clusters; Points = points; } - public byte[] Codepoints { get; private set; } + public uint[] Codepoints { get; private set; } public uint[] Clusters { get; private set; } diff --git a/tests/Tests/SKShaperTest.cs b/tests/Tests/SKShaperTest.cs index 2a3dcd19..4acacc47 100644 --- a/tests/Tests/SKShaperTest.cs +++ b/tests/Tests/SKShaperTest.cs @@ -38,7 +38,7 @@ namespace HarfBuzzSharp.Tests public void CorrectlyShapesArabicScriptAtAnOffset() { var clusters = new uint[] { 4, 2, 0 }; - var codepoints = new byte[] { 230, 3, 152, 3, 227, 3 }; + var codepoints = new uint[] { 998, 920, 995 }; var points = new SKPoint[] { new SKPoint(100, 200), new SKPoint(148.25f, 200), new SKPoint(170.75f, 200) }; using (var tf = SKTypeface.FromFamilyName("Tahoma")) @@ -57,7 +57,7 @@ namespace HarfBuzzSharp.Tests public void CorrectlyShapesArabicScript() { var clusters = new uint[] { 4, 2, 0 }; - var codepoints = new byte[] { 230, 3, 152, 3, 227, 3 }; + var codepoints = new uint[] { 998, 920, 995 }; var points = new SKPoint[] { new SKPoint(0, 0), new SKPoint(48.25f, 0), new SKPoint(70.75f, 0) }; using (var tf = SKTypeface.FromFamilyName("Tahoma"))