/// <summary> /// Initialize Font subsystem. /// </summary> private static void InitializeFontSystem() { if (SdlTtf.TTF_Init() != (int)SdlFlag.Success) { FontException.Generate(); } }
/// <summary> /// Font Constructor /// </summary> /// <param name="fileName">Font filename</param> /// <param name="pointSize">Size of font</param> public Font(string fileName, int pointSize) { if (!Font.IsFontSystemInitialized) { Font.InitializeFontSystem(); } this.Handle = SdlTtf.TTF_OpenFont(fileName, pointSize); if (this.Handle == IntPtr.Zero) { throw FontException.Generate(); } }
/// <summary> /// Create a Font from a byte array in memory. /// </summary> /// <param name="array">A array of byte that should be the font data</param> /// <param name="pointSize">Size of font</param> public Font(byte[] array, int pointSize) { if (array == null) { throw new ArgumentNullException("array"); } if (!Font.IsFontSystemInitialized) { Font.InitializeFontSystem(); } this.Handle = SdlTtf.TTF_OpenFontRW(Sdl.SDL_RWFromMem(array, array.Length), 0, pointSize); if (this.Handle == IntPtr.Zero) { throw FontException.Generate(); } }
/// <summary> /// Font Exception /// </summary> public FontException() { FontException.Generate(); }