Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Face"/> class.
        /// </summary>
        /// <param name="library">The parent library.</param>
        /// <param name="path">The path of the font file.</param>
        /// <param name="faceIndex">The index of the face to take from the file.</param>
        public Face(Library library, string path, int faceIndex)
            : this()
        {
            IntPtr reference;
            Error err = FT.FT_New_Face(library.Reference, path, faceIndex, out reference);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            Reference = reference;
            parentLibrary = library;
            parentLibrary.AddChildFace(this);
        }
Пример #2
0
        //TODO make an overload with a FileStream instead of a byte[]
        /// <summary>
        /// Initializes a new instance of the <see cref="Face"/> class from a file that's already loaded into memory.
        /// </summary>
        /// <param name="library">The parent library.</param>
        /// <param name="file">The loaded file.</param>
        /// <param name="faceIndex">The index of the face to take from the file.</param>
        public unsafe Face(Library library, byte[] file, int faceIndex)
            : this()
        {
            memoryFaceHandle = GCHandle.Alloc(file, GCHandleType.Pinned);
            IntPtr reference;
            Error err = FT.FT_New_Memory_Face(library.Reference, memoryFaceHandle.AddrOfPinnedObject(), file.Length, faceIndex, out reference);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            Reference = reference;

            parentLibrary = library;
            parentLibrary.AddChildFace(this);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the Face class.
        /// </summary>
        /// <param name="reference">A pointer to the unmanaged memory containing the Face.</param>
        /// <param name="parent">The parent <see cref="Library"/>.</param>
        internal Face(IntPtr reference, Library parent)
            : this()
        {
            Reference = reference;

            if (parent != null)
            {
                parentLibrary = parent;
                parentLibrary.AddChildFace(this);
            }
            else
            {
                //if there's no parent, this is a marshalled duplicate.
                FT.FT_Reference_Face(Reference);
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Face"/> class from a file that's already loaded into memory.
        /// </summary>
        /// <param name="library">The parent library.</param>
        /// <param name="bufferPtr"></param>
        /// <param name="length"></param>
        /// <param name="faceIndex">The index of the face to take from the file.</param>
        public Face(Library library, IntPtr bufferPtr, int length, int faceIndex)
            : this()
        {
            Error err = FT.FT_New_Memory_Face(library.Reference, bufferPtr, length, faceIndex, out reference);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            Reference = reference;

            parentLibrary = library;
            parentLibrary.AddChildFace(this);
        }
Пример #5
0
        private Face(Library parent)
            : base(IntPtr.Zero)
        {
            childSizes = new List<FTSize>();

            if (parent != null)
            {
                parentLibrary = parent;
                parentLibrary.AddChildFace(this);
            }
            else
            {
                //if there's no parent, this is a marshalled duplicate.
                FT.FT_Reference_Face(Reference);
            }
        }
Пример #6
0
        //TODO make an overload with a FileStream instead of a byte[]
        /// <summary>
        /// Initializes a new instance of the <see cref="Face"/> class from a file that's already loaded into memory.
        /// </summary>
        /// <param name="library">The parent library.</param>
        /// <param name="file">The loaded file.</param>
        /// <param name="faceIndex">The index of the face to take from the file.</param>
        public unsafe Face(Library library, byte[] file, int faceIndex)
            : this()
        {
            fixed (byte* ptr = file)
            {
                IntPtr reference;
                Error err = FT.FT_New_Memory_Face(library.Reference, (IntPtr)ptr, file.Length, faceIndex, out reference);

                if (err != Error.Ok)
                    throw new FreeTypeException(err);

                Reference = reference;
            }

            parentLibrary = library;
            parentLibrary.AddChildFace(this);
        }