using SharpDX.Direct3D9; public class MyFont { private Font _font; public MyFont(Device device) { _font = new Font(device, new FontDescription { FaceName = "Arial", Size = 20 }); device.DeviceLost += OnLostDevice; } private void OnLostDevice(object sender, EventArgs e) { _font.OnLostDevice(); _font.Dispose(); } }
using SharpDX.Direct3D9; public class GlobalFont { public static Font Font { get; set; } public static void Initialize(Device device) { Font = new Font(device, new FontDescription { FaceName = "Arial", Size = 20 }); device.DeviceLost += OnLostDevice; } private static void OnLostDevice(object sender, EventArgs e) { if (Font != null) { Font.OnLostDevice(); Font.Dispose(); Font = null; } } }Package Library: SharpDX.Direct3D9.