public SimpleFontAtlas LoadFontInfo(System.IO.Stream dataStream) { FontAtlasFile atlasFile = new FontAtlasFile(); //read font atlas from stream data atlasFile.Read(dataStream); return(atlasFile.Result); }
private void button1_Click_1(object sender, EventArgs e) { PixelFarm.CpuBlit.MemBitmapExtensions.DefaultMemBitmapIO = new PixelFarm.Drawing.WinGdi.GdiBitmapIO(); var storageProvider = new LocalFileStorageProvider("", true); PixelFarm.Platforms.StorageService.RegisterProvider(storageProvider); var bmpFontMx = new BitmapFontManager <MemBitmap>( _textServices, atlas => { GlyphImage totalGlyphImg = atlas.TotalGlyph; return(MemBitmap.CreateFromCopy(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer())); } ); string multiSizeFontAtlasFilename = "tahoma_set1.multisize_fontAtlas"; string totalImgAtlasFilename = "tahoma_set1.multisize_fontAtlas.png"; //in this version, mutlsize font texture must use the same typeface { MultiSizeFontAtlasBuilder multiSizeFontAtlasBuilder = new MultiSizeFontAtlasBuilder(); { bmpFontMx.TextureKindForNewFont = PixelFarm.Drawing.BitmapAtlas.TextureKind.StencilLcdEffect; AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 10), bmpFontMx); AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 11), bmpFontMx); AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 12), bmpFontMx); AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 13), bmpFontMx); AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 14), bmpFontMx); bmpFontMx.TextureKindForNewFont = PixelFarm.Drawing.BitmapAtlas.TextureKind.Msdf; AddExistingOrCreateNewSimpleFontAtlas(multiSizeFontAtlasBuilder, new RequestFont("tahoma", 24), bmpFontMx); } //------- multiSizeFontAtlasBuilder.BuildMultiFontSize(multiSizeFontAtlasFilename, totalImgAtlasFilename); } { //test load the font altas back FontAtlasFile atlasFile = new FontAtlasFile(); using (FileStream fs = new FileStream(multiSizeFontAtlasFilename, FileMode.Open)) { atlasFile.Read(fs); } } }
public void LoadFontAtlas(string fontTextureInfoFile, string atlasImgFilename) { //TODO: extension method if (PixelFarm.Platforms.StorageService.Provider.DataExists(fontTextureInfoFile) && PixelFarm.Platforms.StorageService.Provider.DataExists(atlasImgFilename)) { using (System.IO.Stream fontTextureInfoStream = PixelFarm.Platforms.StorageService.Provider.ReadDataStream(fontTextureInfoFile)) using (System.IO.Stream fontTextureImgStream = PixelFarm.Platforms.StorageService.Provider.ReadDataStream(fontTextureInfoFile)) { try { FontAtlasFile fontAtlas = new FontAtlasFile(); fontAtlas.Read(fontTextureInfoStream); SimpleFontAtlas[] resultAtlases = fontAtlas.ResultSimpleFontAtlasList.ToArray(); _myGLBitmapFontMx.AddSimpleFontAtlas(resultAtlases, fontTextureImgStream); } catch (Exception ex) { throw ex; } } } //if (System.IO.File.Exists(fontTextureInfoFile)) //{ // using (System.IO.Stream dataStream = new System.IO.FileStream(fontTextureInfoFile, System.IO.FileMode.Open)) // { // try // { // FontAtlasFile fontAtlas = new FontAtlasFile(); // fontAtlas.Read(dataStream); // SimpleFontAtlas[] resultAtlases = fontAtlas.ResultSimpleFontAtlasList.ToArray(); // _myGLBitmapFontMx.AddSimpleFontAtlas(resultAtlases, atlasImgFilename); // } // catch (Exception ex) // { // throw ex; // } // } //} //else //{ //} }