示例#1
0
        /// <summary>
        /// Stroke a given outline glyph object with a given stroker, but only return either its inside or outside
        /// border.
        /// </summary>
        /// <remarks>
        /// The source glyph is untouched in case of error.
        /// </remarks>
        /// <param name="stroker">A stroker handle.</param>
        /// <param name="inside">A Boolean. If 1, return the inside border, otherwise the outside border.</param>
        /// <param name="destroy">A Boolean. If 1, the source glyph object is destroyed on success.</param>
        /// <returns>New glyph handle.</returns>
        public Glyph StrokeBorder(Stroker stroker, bool inside, bool destroy)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException("Glyph", "Cannot access a disposed object.");
            }

            if (stroker == null)
            {
                throw new ArgumentNullException("stroker");
            }

            IntPtr sourceRef = Reference;
            Error  err       = FT.FT_Glyph_StrokeBorder(ref sourceRef, stroker.Reference, inside, destroy);

            if (destroy && err == Error.Ok)
            {
                //if FT_Glyph_Stroke destroys the glyph, keep the C# side synchronized.
                IsDisposed = true;
                reference  = IntPtr.Zero;
            }

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

            //check if the pointer didn't change.
            if (sourceRef == Reference)
            {
                return(this);
            }
            return(new Glyph(sourceRef, Library));
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Font"/> class.
 /// </summary>
 public Font()
 {
     _library    = null;
     _face       = null;
     _stroker    = null;
     _familyName = string.Empty;
     _pages      = new Dictionary <int, Page>();
     _fontData   = null;
 }
示例#3
0
        /// <summary>
        /// Stroke a given outline glyph object with a given stroker.
        /// </summary>
        /// <remarks>
        /// The source glyph is untouched in case of error.
        /// </remarks>
        /// <param name="stroker">A stroker handle.</param>
        /// <param name="destroy">A Boolean. If 1, the source glyph object is destroyed on success.</param>
        /// <returns>New glyph handle.</returns>
        public Glyph Stroke(Stroker stroker)
        {
            if (stroker == null)
            {
                throw new ArgumentNullException("stroker");
            }

            IntPtr sourceRef = Reference;
            Error  err       = FT.FT_Glyph_Stroke(ref sourceRef, stroker.Reference, false);

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

            //check if the pointer didn't change.
            return(sourceRef == Reference ? this : new Glyph(sourceRef, Library));
        }
示例#4
0
        private void Initialize()
        {
            // Initialize FreeType
            // Note: we initialize FreeType for every font instance in order to avoid having a single
            // global manager that would create a lot of issues regarding creation and destruction order.
            _library = new SharpFont.Library();

            // Load the new font face from the specified data
            _face = new SharpFont.Face(_library, _fontData, 0);

            // Load the stroker that will be used to outline the font
            _stroker = new SharpFont.Stroker(_library);

            // Select the unicode character map
            _face.SelectCharmap(SharpFont.Encoding.Unicode);

            // Store the font family name
            _familyName = _face.FamilyName;
        }
示例#5
0
 internal void RemoveChildStroker(Stroker child)
 {
     childStrokers.Remove(child);
 }
示例#6
0
 internal void AddChildStroker(Stroker child)
 {
     childStrokers.Add(child);
 }
示例#7
0
文件: Glyph.cs 项目: none53/SharpFont
		/// <summary>
		/// Stroke a given outline glyph object with a given stroker, but only return either its inside or outside
		/// border.
		/// </summary>
		/// <remarks>
		/// The source glyph is untouched in case of error.
		/// </remarks>
		/// <param name="stroker">A stroker handle.</param>
		/// <param name="inside">A Boolean. If 1, return the inside border, otherwise the outside border.</param>
		/// <param name="destroy">A Boolean. If 1, the source glyph object is destroyed on success.</param>
		/// <returns>New glyph handle.</returns>
		public Glyph StrokeBorder(Stroker stroker, bool inside, bool destroy)
		{
			if (disposed)
				throw new ObjectDisposedException("Glyph", "Cannot access a disposed object.");

			if (stroker == null)
				throw new ArgumentNullException("stroker");

			IntPtr sourceRef = Reference;
			Error err = FT.FT_Glyph_StrokeBorder(ref sourceRef, stroker.Reference, inside, destroy);

			if (destroy && err == Error.Ok)
			{
				//if FT_Glyph_Stroke destroys the glyph, keep the C# side synchronized.
				disposed = true;
				reference = IntPtr.Zero;
			}

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

			//check if the pointer didn't change.
			if (sourceRef == Reference)
				return this;
			else
				return new Glyph(sourceRef, Library);
		}
示例#8
0
        /// <summary>
        /// Stroke a given outline glyph object with a given stroker, but only return either its inside or outside
        /// border.
        /// </summary>
        /// <remarks>
        /// The source glyph is untouched in case of error.
        /// </remarks>
        /// <param name="stroker">A stroker handle.</param>
        /// <param name="inside">A Boolean. If 1, return the inside border, otherwise the outside border.</param>
        /// <param name="destroy">A Boolean. If 1, the source glyph object is destroyed on success.</param>
        /// <returns>New glyph handle.</returns>
        public Glyph StrokeBorder(Stroker stroker, bool inside, bool destroy)
        {
            if (disposed)
                throw new ObjectDisposedException("Glyph", "Cannot access a disposed object.");

            if (stroker == null)
                throw new ArgumentNullException("stroker");

            IntPtr sourceRef = Reference;
            Error err = FT.FT_Glyph_StrokeBorder(ref sourceRef, stroker.Reference, inside, destroy);

            if (destroy)
            {
                //TODO when Glyph implements IDisposable, dispose the glyph.
            }

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

            if (sourceRef == Reference)
                return this;
            else
                return new Glyph(sourceRef, Library);
        }
示例#9
0
 internal void RemoveChildStroker(Stroker child)
 {
     childStrokers.Remove(child);
 }
示例#10
0
 internal void AddChildStroker(Stroker child)
 {
     childStrokers.Add(child);
 }