CGFont.CreateFromProvider(CGDataProvider) Method

Definition

Creates a font from a data provider.

public static CoreGraphics.CGFont? CreateFromProvider(CoreGraphics.CGDataProvider provider);
static member CreateFromProvider : CoreGraphics.CGDataProvider -> CoreGraphics.CGFont

Parameters

provider
CGDataProvider

Data provider that wraps the font.

Returns

The constructed font, or null in case of failure.

Remarks

You can use this method to create CGFont instances from an in-memory representation of the font (for example, to embed binary fonts into your application to prevent easy copying of licensed fonts, or when you fetch the font from a streaming source and do not want to store it on disk).

//
// Load font into byte array from a file.
//
var myBuffer = File.ReadAllBytes ("demo.ttf");
var font = CGFont.CreateFromProvider (new CGDataProvider (myBuffer, 0, myBuffer.Count));

Applies to