public static FontFace LoadFont(string fontfile, ScriptLang scriptLang, WriteDirection writeDirection, out SimpleFontAtlas fontAtlas) { //1. read font info ManagedFontFace openFont = (ManagedFontFace)OpenFontLoader.LoadFont(fontfile, scriptLang, writeDirection); //2. build texture font on the fly! OR load from prebuilt file // //2.1 test build texture on the fly SimpleFontAtlasBuilder atlas1 = CreateSampleMsdfTextureFont(fontfile, 14, 0, 255); 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; var textureFontFace = new TextureFontFace(openFont, fontAtlas); return(textureFontFace); }
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; }