/// <summary> /// Create a new font instance /// </summary> /// <param name="fontStream">Stream to the font data</param> /// <param name="fontSizeInPixels">The desired font size in pixels</param> public Font(Stream fontStream, float fontSizeInPixels) { SetupWoffDecompressorIfRequired(); FontSizeInPoints = fontSizeInPixels * PIXELS_TO_POINTS; loadedGlyphs = new Dictionary <char, Glyph>(); var reader = new OpenFontReader(); typeface = reader.Read(fontStream); pathBuilder = new GlyphPathBuilder(typeface); pathTranslator = new GlyphTranslatorToVertices(); }
/// <summary> /// Create a new font instance /// </summary> /// <param name="filePath">Path to the font file</param> /// <param name="fontSizeInPixels">The desired font size in pixels</param> public Font(string filePath, float fontSizeInPixels) { SetupWoffDecompressorIfRequired(); FontSizeInPoints = fontSizeInPixels * PIXELS_TO_POINTS; loadedGlyphs = new Dictionary <char, Glyph>(); using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var reader = new OpenFontReader(); typeface = reader.Read(fs); } pathBuilder = new GlyphPathBuilder(typeface); pathTranslator = new GlyphTranslatorToVertices(); }