/// <summary> /// Create a <see cref="Face"/> object from a given resource described by <see cref="OpenArgs"/>. /// </summary> /// <remarks><para> /// Unlike FreeType 1.x, this function automatically creates a glyph slot for the face object which can be /// accessed directly through <see cref="Face.Glyph"/>. /// </para><para> /// OpenFace can be used to quickly check whether the font format of a given font resource is supported by /// FreeType. If the ‘faceIndex’ field is negative, the function's return value is 0 if the font format is /// recognized, or non-zero otherwise; the function returns a more or less empty face handle in ‘*aface’ (if /// ‘aface’ isn't NULL). The only useful field in this special case is <see cref="Face.FaceCount"/> which gives /// the number of faces within the font file. After examination, the returned <see cref="Face"/> structure /// should be deallocated with a call to <see cref="Face.Dispose()"/>. /// </para><para> /// Each new face object created with this function also owns a default <see cref="FTSize"/> object, accessible /// as <see cref="Face.Size"/>. /// </para><para> /// See the discussion of reference counters in the description of FT_Reference_Face. /// </para></remarks> /// <param name="args"> /// A pointer to an <see cref="OpenArgs"/> structure which must be filled by the caller. /// </param> /// <param name="faceIndex">The index of the face within the font. The first face has index 0.</param> /// <returns> /// A handle to a new face object. If ‘faceIndex’ is greater than or equal to zero, it must be non-NULL. /// </returns> public Face OpenFace(OpenArgs args, int faceIndex) { if (disposed) { throw new ObjectDisposedException("Library", "Cannot access a disposed object."); } IntPtr faceRef; Error err = FT.FT_Open_Face(Reference, args.Reference, faceIndex, out faceRef); if (err != Error.Ok) { throw new FreeTypeException(err); } return(new Face(faceRef, this)); }