Пример #1
0
		/// <summary>
		/// Applies a new set of rendered glyphs to the <see cref="Font"/>, adjusts its typeface metadata and clears out the <see cref="GlyphsDirty"/> flag.
		/// This method is used by the editor to update a Font after adjusting its properties.
		/// </summary>
		/// <param name="bitmap"></param>
		/// <param name="atlas"></param>
		/// <param name="glyphs"></param>
		/// <param name="height"></param>
		/// <param name="ascent"></param>
		/// <param name="bodyAscent"></param>
		/// <param name="descent"></param>
		/// <param name="baseLine"></param>
		public void SetGlyphData(PixelData bitmap, Rect[] atlas, GlyphData[] glyphs, int height, int ascent, int bodyAscent, int descent, int baseLine)
		{
			this.ReleaseResources();

			this.glyphs = glyphs;
			this.GenerateCharLookup();

			this.pixelData = new Pixmap(bitmap);
			this.pixelData.Atlas = atlas.ToList();
			this.height = height;
			this.ascent = ascent;
			this.bodyAscent = bodyAscent;
			this.descent = descent;
			this.baseLine = baseLine;
			for (int i = 0; i < this.glyphs.Length; i++)
			{
				this.maxGlyphWidth = Math.Max(this.maxGlyphWidth, this.glyphs[i].Width);
			}

			this.UpdateKerningData();
			this.GenerateTexMat();

			this.glyphsDirty = false;
		}
Пример #2
0
        /// <summary>
        /// Applies a new set of rendered glyphs to the <see cref="Font"/>, adjusts its typeface metadata and clears out the <see cref="GlyphsDirty"/> flag.
        /// This method is used by the editor to update a Font after adjusting its properties.
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="atlas"></param>
        /// <param name="glyphs"></param>
        /// <param name="metrics"></param>
        public void SetGlyphData(PixelData bitmap, Rect[] atlas, GlyphData[] glyphs, FontMetrics metrics)
        {
            this.ReleaseResources();

            this.glyphs = glyphs;
            this.GenerateCharLookup();

            this.pixelData = new Pixmap(bitmap);
            this.pixelData.Atlas = atlas.ToList();

            this.metrics = metrics;

            // Copy metrics data into local fields.
            // Remove this on the next major version step.
            this.size = metrics.Size;
            this.height = metrics.Height;
            this.ascent = metrics.Ascent;
            this.bodyAscent = metrics.BodyAscent;
            this.descent = metrics.Descent;
            this.baseLine = metrics.BaseLine;
            this.monospace = metrics.Monospace;

            this.maxGlyphWidth = 0;
            for (int i = 0; i < this.glyphs.Length; i++)
            {
                this.maxGlyphWidth = Math.Max(this.maxGlyphWidth, this.glyphs[i].Width);
            }

            this.UpdateKerningData();
            this.GenerateTexture();
            this.GenerateMaterial();
        }