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, ScriptLang scriptLang, WriteDirection writeDirection = WriteDirection.LTR) { //read font file //TODO:... //set shape engine *** var openFont = new NOpenFontFace(typeface, typeface.Name, typeface.Filename); return(openFont); }
public static FontFace LoadFont( string fontpath, ScriptLang scriptLang, WriteDirection writeDirection = WriteDirection.LTR) { using (FileStream fs = new FileStream(fontpath, FileMode.Open, FileAccess.Read)) { var reader = new OpenFontReader(); Typeface t = reader.Read(fs); t.Filename = fontpath; return(LoadFont(t, scriptLang, writeDirection)); } }
public static FontFace LoadFont(string fontfile, ScriptLang scriptLang, WriteDirection writeDirection = WriteDirection.LTR) { //read font file OpenFontReader openTypeReader = new OpenFontReader(); Typeface typeface = null; using (FileStream fs = new FileStream(fontfile, FileMode.Open, FileAccess.Read, FileShare.Read)) { typeface = openTypeReader.Read(fs); if (typeface == null) { return(null); } } //TODO:... //set shape engine *** var openFont = new ManagedFontFace(typeface, typeface.Name, fontfile); return(openFont); }
//-------------------------------------------------------------------- static ScriptLang _(string fullname, string shortname) { var scriptLang = new ScriptLang(fullname, shortname); // if (registeredScriptTags.ContainsKey(shortname)) { if (shortname == "kana") { //*** //Hiragana and Katakana //both have same short name "kana" } else { //errors } } else { registeredScriptTags.Add(shortname, scriptLang); } return(scriptLang); }