protected override Glyph GetGlyph(char character, ref Vector2 fontSize, bool uploadGpuResources) { // Add a safe guard to prevent the system to generate characters too big for the dynamic font cache texture fontSize.X = Math.Min(fontSize.X, 1024); fontSize.Y = Math.Min(fontSize.Y, 1024); // get the character data associated to the provided character and size var characterData = GetOrCreateCharacterData(fontSize, character); // generate the bitmap if it does not exist if (characterData.Bitmap == null) { FontManager.GenerateBitmap(characterData, false); } // upload the character to the GPU font texture and create the glyph if does not exists if (uploadGpuResources && characterData.Bitmap != null && !characterData.IsBitmapUploaded) { FontCacheManager.UploadCharacterBitmap(characterData); } // update the character usage info FontCacheManager.NotifyCharacterUtilization(characterData); return(characterData.Glyph); }
/// <summary> /// Load this system. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <exception cref="System.ArgumentNullException">graphicsDevice</exception> public void Load(GraphicsDevice graphicsDevice) { // TODO possibly load cached character bitmaps from the disk if (graphicsDevice == null) throw new ArgumentNullException("graphicsDevice"); GraphicsDevice = graphicsDevice; FontManager = new FontManager(); FontCacheManager = new FontCacheManager(this); }
/// <summary> /// Load this system. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <exception cref="System.ArgumentNullException">graphicsDevice</exception> public void Load(GraphicsDevice graphicsDevice) { // TODO possibly load cached character bitmaps from the disk if (graphicsDevice == null) { throw new ArgumentNullException("graphicsDevice"); } GraphicsDevice = graphicsDevice; FontManager = new FontManager(); FontCacheManager = new FontCacheManager(this); }