public static FontFace LoadFont( Typeface typeface, TextureFontCreationParams creationParams, out SimpleFontAtlas fontAtlas) { //1. read font info NOpenFontFace openFont = (NOpenFontFace)OpenFontLoader.LoadFont(typeface, creationParams.scriptLang, creationParams.writeDirection); //------------------------ SimpleFontAtlasBuilder atlas1 = null; switch (creationParams.textureKind) { default: throw new System.NotSupportedException(); case TextureKind.AggSubPixel: atlas1 = CreateAggSubPixelRenderingTextureFont( typeface, creationParams.originalFontSizeInPoint, creationParams.hintTechnique, GetGlyphIndexIter(typeface, creationParams.langBits) ); break; case TextureKind.AggGrayScale: atlas1 = CreateAggTextureFont( typeface, creationParams.originalFontSizeInPoint, creationParams.hintTechnique, GetGlyphIndexIter(typeface, creationParams.langBits) ); break; case TextureKind.Msdf: atlas1 = CreateSampleMsdfTextureFont( typeface, creationParams.originalFontSizeInPoint, creationParams.hintTechnique, GetGlyphIndexIter(typeface, creationParams.langBits) ); break; } GlyphImage glyphImg2 = atlas1.BuildSingleImage(); fontAtlas = atlas1.CreateSimpleFontAtlas(); fontAtlas.TotalGlyph = glyphImg2; //string xmlFontFileInfo = ""; //GlyphImage glyphImg = null; //MySimpleFontAtlasBuilder atlasBuilder = new MySimpleFontAtlasBuilder(); //SimpleFontAtlas fontAtlas = atlasBuilder.LoadFontInfo(xmlFontFileInfo); //glyphImg = atlasBuilder.BuildSingleImage(); //we can create a new glyph or load from prebuilt file //fontAtlas.TotalGlyph = glyphImg; return(openFont); //var textureFontFace = new TextureFontFace(openFont, fontAtlas); //return textureFontFace; }
public static FontFace LoadFont( string fontfile, TextureFontCreationParams creationParams, out SimpleFontAtlas fontAtlas) { using (FileStream fs = new FileStream(fontfile, FileMode.Open, FileAccess.Read)) { var reader = new OpenFontReader(); Typeface typeface = reader.Read(fs); return(LoadFont(typeface, creationParams, out fontAtlas)); } }