The shaper must return the raw uint

This commit is contained in:
Matthew Leibowitz 2017-05-01 21:07:25 -04:00
Родитель c80c4b0d5f
Коммит 1e83d00a23
3 изменённых файлов: 9 добавлений и 10 удалений

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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; }

Просмотреть файл

@ -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"))