in binding/HarfBuzzSharp/Font.cs [294:340]
public void SetFunctionsOpenType () =>
HarfBuzzApi.hb_ot_font_set_funcs (Handle);
public void Shape (Buffer buffer, params Feature[] features) =>
Shape (buffer, features, null);
public void Shape (Buffer buffer, IReadOnlyList<Feature> features, IReadOnlyList<string> shapers)
{
if (buffer == null)
throw new ArgumentNullException (nameof (buffer));
if (buffer.Direction == Direction.Invalid)
throw new InvalidOperationException ("Buffer's Direction must be valid.");
if (buffer.ContentType != ContentType.Unicode) {
throw new InvalidOperationException ("Buffer's ContentType must of type Unicode.");
}
void*[] shapersPtrs = null;
if (shapers?.Count > 0) {
shapersPtrs = new void*[shapers.Count + 1];
int i;
for (i = 0; i < shapers.Count; i++) {
shapersPtrs[i] = (void*)Marshal.StringToHGlobalAnsi (shapers[i]);
}
shapersPtrs[i] = null;
}
var featuresArray = features?.ToArray ();
fixed (Feature* fPtr = featuresArray)
fixed (void** sPtr = shapersPtrs) {
HarfBuzzApi.hb_shape_full (
Handle,
buffer.Handle,
fPtr,
(uint)(features?.Count ?? 0),
sPtr);
}
if (shapersPtrs != null) {
for (var i = 0; i < shapersPtrs.Length; i++) {
if (shapersPtrs[i] != null)
Marshal.FreeHGlobal ((IntPtr)shapersPtrs[i]);
}
}
}