Beispiel #1
0
        /// <summary>
        /// Disposes of this object.
        /// </summary>
        public void Dispose()
        {
            if (impl != null)
            {
                impl.Dispose();
            }

            impl = null;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a FontSurface object from the given fontFamily.
        /// </summary>
        /// <param name="fontFamily"></param>
        /// <param name="sizeInPoints"></param>
        /// <param name="style"></param>
        public FontSurface(string fontFamily, float sizeInPoints, FontStyle style)
        {
            if (sizeInPoints < 1)
            {
                throw new ArgumentOutOfRangeException("Font size must be positive and non-zero, but was " +
                                                      sizeInPoints.ToString() + ".");
            }

            impl = Display.Impl.CreateFont(fontFamily, sizeInPoints, style);

            Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose);
        }
Beispiel #3
0
        /// <summary>
        /// Constructs a FontSurface object from a resource.
        /// </summary>
        /// <param name="resources"></param>
        /// <param name="resourceName"></param>
        public FontSurface(AgateResourceCollection resources, string resourceName)
        {
            AgateResource      res     = resources[resourceName];
            BitmapFontResource bmpFont = res as BitmapFontResource;

            if (res is BitmapFontResource)
            {
                Surface surf = new Surface(bmpFont.Image);

                impl = new BitmapFontImpl(surf, bmpFont.FontMetrics);
            }
            else
            {
                throw new AgateResourceException(string.Format(
                                                     "The resource {0} is of type {1} which cannot be used to construct a font.",
                                                     resourceName, res.GetType().Name));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Private initializer to tell it what impl to use.
 /// </summary>
 /// <param name="implToUse"></param>
 private FontSurface(FontSurfaceImpl implToUse)
 {
     impl = implToUse;
 }
Beispiel #5
0
        /// <summary>
        /// Creates a bitmap font using the options passed in.  The Display driver
        /// must be capable of this, which is indicated in Display.Caps.CanCreateBitmapFont.
        /// </summary>
        /// <param name="bitmapOptions"></param>
        public FontSurface(BitmapFontOptions bitmapOptions)
        {
            impl = Display.Impl.CreateFont(bitmapOptions);

            Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose);
        }