/// <summary> /// Erstellt ein neues GameControl mit den gegebenen Dimensionen. /// </summary> /// <param name="bounds"></param> public GameControl(Rectangle bounds) { Location = bounds.Location; Size = bounds.Size.ToPoint(); font = BitmapFontManager.GetFontFromName("Calibri"); DrawArea = new Bitmap(bounds.Width, bounds.Height); }
void AddExistingOrCreateNewSimpleFontAtlas( MultiGlyphSizeBitmapAtlasBuilder multisizeFontAtlasBuilder, RequestFont reqFont, BitmapFontManager <MemBitmap> bmpFontMx) { int fontKey = reqFont.FontKey; string fontTextureFile = reqFont.Name + "_" + fontKey; string resolveFontTextureFile = fontTextureFile + ".info"; string fontTextureInfoFile = resolveFontTextureFile; string fontTextureImgFilename = fontTextureInfoFile + ".png"; _textServices.ResolveTypeface(reqFont); //resolve for 'actual' font if (PixelFarm.Platforms.StorageService.Provider.DataExists(resolveFontTextureFile) && File.Exists(fontTextureImgFilename)) { multisizeFontAtlasBuilder.AddSimpleAtlasFile(reqFont, resolveFontTextureFile, fontTextureImgFilename, bmpFontMx.TextureKindForNewFont ); } else { //create a new one SimpleBitmapAtlas fontAtlas = bmpFontMx.GetFontAtlas(reqFont, out MemBitmap fontBmp); bmpFontMx.GetFontAtlas(reqFont, out fontBmp); multisizeFontAtlasBuilder.AddSimpleAtlasFile(reqFont, resolveFontTextureFile, fontTextureImgFilename, bmpFontMx.TextureKindForNewFont); } }
public override void Init() { //steps : detail ... //1. create a text service (or get it from a singleton class) _textServices = new LayoutFarm.OpenFontTextService(); //2. create manager _bmpFontMx = new BitmapFontManager <MemBitmap>( TextureKind.StencilLcdEffect, _textServices, atlas => { GlyphImage totalGlyphImg = atlas.TotalGlyph; return(MemBitmap.CreateFromCopy(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer())); } ); //3. _font = new RequestFont("tahoma", 10); _fontAtlas = _bmpFontMx.GetFontAtlas(_font, out _fontBmp); //---------- }
public FontAtlasTextPrinter(AggPainter painter) { StartDrawOnLeftTop = true; _painter = painter; this.PositionTechnique = PositionTechnique.OpenFont; _textServices = new LayoutFarm.OpenFontTextService(); //2. create manager _bmpFontMx = new BitmapFontManager <MemBitmap>( TextureKind.StencilLcdEffect, _textServices, atlas => { GlyphImage totalGlyphImg = atlas.TotalGlyph; return(MemBitmap.CreateFromCopy(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer())); } ); //3. ChangeFont(new RequestFont("tahoma", 10)); SetupMaskPixelBlender(painter.Width, painter.Height); }
public FontAtlasTextPrinter(AggPainter painter) { StartDrawOnLeftTop = true; _painter = painter; this.PositionTechnique = PositionTechnique.OpenFont; _textServices = new LayoutFarm.OpenFontTextService(); //2. _bmpFontMx = new BitmapFontManager <MemBitmap>( _textServices, atlas => { GlyphImage totalGlyphImg = atlas.TotalGlyph; if (atlas.UseSharedGlyphImage) { if (!_sharedGlyphImgs.TryGetValue(totalGlyphImg, out MemBitmap found)) { found = MemBitmap.CreateFromCopy(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer()); _sharedGlyphImgs.Add(totalGlyphImg, found); } return(found); } else { return(MemBitmap.CreateFromCopy(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer())); } } ); //3. ChangeFont(painter.CurrentFont); SetupMaskPixelBlender(painter.Width, painter.Height); }
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 override void Init() { //steps : detail ... //1. create a text service (or get it from a singleton class) _textServices = new OpenFontTextService(); _txtClient = _textServices.CreateNewServiceClient(); //2. create manager _bmpFontMx = new BitmapFontManager <MemBitmap>( _textServices, atlas => MemBitmap.CreateFromCopy(atlas.MainBitmap) ); //3. _font = new RequestFont("tahoma", 16); _fontAtlas = _bmpFontMx.GetFontAtlas(_textServices.ResolveFont(_font), _font.StartCodePoint, _font.EndCodePoint, out _fontBmp); }
/// <summary> /// Erstellt einen neuen MainScreen. /// </summary> public MainScreen() { this.BackgroundImage = ContentLoader.LoadImage("MainScreenBackgroundImage.jpg"); buttonBackground = ContentLoader.LoadImage("buttonBackgroundImage.jpg"); startButton = new Button(); startButton.Text = "Start"; startButton.BackgroundImage = buttonBackground; startButton.Location = new Point(724, 368); startButton.Font.FontColor = Color.White; startButton.Click += new MouseEventHandler(OnStartButtonClick); this.AddControl(startButton); optionsButton = new Button(); optionsButton.Text = "Optionen"; optionsButton.Location = new Point(724, 270 + 168); optionsButton.BackgroundImage = buttonBackground; optionsButton.Font.FontColor = Color.White; optionsButton.Click += new MouseEventHandler(OptionsButtonClick); leaveButton = new Button(); leaveButton.Text = "Beenden"; leaveButton.Location = new Point(724, 340 + 168); leaveButton.BackgroundImage = buttonBackground; leaveButton.Font.FontColor = Color.White; leaveButton.Click += new MouseEventHandler(OnLeaveButtonClick); this.AddControl(optionsButton); this.AddControl(leaveButton); title = new Label(); title.Location = new Point(50, 50); title.Font = BitmapFontManager.GetFontFromName("Bloody"); title.Font.FontColor = Color.DarkRed; title.Font.Scale = 3.0f; title.Text = "Knight of War"; this.AddControl(title); }
/// <summary> /// Erstellt ein neues GameControl ohne spezifische Informationen. /// </summary> public GameControl() { font = BitmapFontManager.GetFontFromName("Calibri"); DrawArea = new Bitmap(size.X, size.Y); }