private void DoLoad() { if (xnaFont == null) { BitMapSize(); Stream s; if (this.source == ContentSource.ResourceContent) { s = Game.ResourceContent.StreamInternalResource("Jypeli.Content.Fonts." + name); } else { s = new FileStream(name, FileMode.Open); } var fontBakeResult = TtfFontBaker.Bake(s, fontSize, bitMapSize, bitMapSize, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, } ); xnaFont = fontBakeResult.CreateSpriteFont(Game.GraphicsDevice); } }
public static void LoadFont(string FontPath, int FontSize) { Console.WriteLine("Font : Add font to cache"); FontPath = FontPath.Replace("/", "\\"); FontPath = Environment.CurrentDirectory + "\\" + Global.FONT_SourceFolder + "\\" + FontPath; FontPath = FontPath.Replace("\\\\", "\\"); Console.WriteLine("Font path {" + FontPath + "}"); string FontDescName = FontPath.Replace(Environment.CurrentDirectory + "\\" + Global.FONT_SourceFolder + "\\", "/") + ":" + FontSize; Console.WriteLine("Font name {" + FontDescName + "}"); var fontBakeResult = TtfFontBaker.Bake(File.ReadAllBytes(FontPath), FontSize, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic } ); CachedFonts.Add(fontBakeResult.CreateSpriteFont(Game1.Reference.GraphicsDevice)); CachedFonts_Key.Add(FontDescName); }
public static SpriteFont LoadSpriteFontFromFile(GraphicsDevice graphicsDevice, string filepath, float fontPixelHeight, int bitmapWidth, int bitmapHeight, IEnumerable <CharacterRange> characterRanges) { var fontBakerResult = TtfFontBaker.Bake(File.ReadAllBytes(filepath), fontPixelHeight, bitmapWidth, bitmapHeight, characterRanges); SpriteFont font = fontBakerResult.CreateSpriteFont(graphicsDevice); return(font); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); Sprites.ImportAll(this); SoundManager.LoadSfx(); var font = File.ReadAllBytes(Content.RootDirectory + "/font.ttf"); var res = TtfFontBaker.Bake(font, 16, 256, 256, new CharacterRange[] { new CharacterRange(' ', '~') }); Sprites.Font = res.CreateSpriteFont(GraphicsDevice); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); dash = Content.Load <Texture2D>("Dash"); redLed = Content.Load <Texture2D>("red"); blueLed = Content.Load <Texture2D>("blue"); greenLed = Content.Load <Texture2D>("green"); larry = Content.Load <Song>("ye"); var arialBuffer = File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"); arial100 = TtfFontBaker.Bake(arialBuffer, 100, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); arial10 = TtfFontBaker.Bake(arialBuffer, 10, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); arial70 = TtfFontBaker.Bake(arialBuffer, 70, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); arial50 = TtfFontBaker.Bake(arialBuffer, 50, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); arial16 = TtfFontBaker.Bake(arialBuffer, 16, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); }
public MonoGameGameFont(MonoGameFileHandle ttfFileHandle, int size) { size++; _spriteFont = TtfFontBaker.Bake(ttfFileHandle.readBytesAsByteArray(), size, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic } ).CreateSpriteFont(((MonoGameGraphics)Mdx.graphicsContext_)._graphicsDevice); _sharedFontGlyphLayout = newGlyphLayout(); _capHeight = _spriteFont.GetGlyphs()['A'].BoundsInTexture.Height; }
public MonoGameGameFont(MonoGameFileHandle ttfFileHandle, int size) { _fontName = ttfFileHandle.nameWithoutExtension(); _spriteFont = TtfFontBaker.Bake(ttfFileHandle.readBytes(), size, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic } ).CreateSpriteFont(((MonoGameGraphics)Mdx.graphicsContext)._graphicsDevice); _sharedFontGlyphLayout = newGlyphLayout(); _capHeight = _spriteFont.MeasureString("A").Y; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); _fontChinese = TtfFontBaker.Bake(@"Fonts\SourceHanSansCN-Normal.ttf", 20, 3 * 1024, 3 * 1024, new[] { new CharacterRange(' '), CharacterRange.BasicLatin, CharacterRange.Chinese, CharacterRange.ChineseSupplement, CharacterRange.ChineseSymbol0, CharacterRange.ChineseSymbol1, CharacterRange.ChineseSymbol2, CharacterRange.ChineseSymbol3, CharacterRange.ChineseSymbol4, CharacterRange.ChineseSymbol5, CharacterRange.ChineseSymbol6, CharacterRange.ChineseSymbol7, CharacterRange.ChineseSymbol8, CharacterRange.ChineseSymbol9, CharacterRange.ChineseSymbol10, CharacterRange.ChineseSymbol11, CharacterRange.ChineseSymbol12, CharacterRange.ChineseSymbol13, CharacterRange.ChineseSymbol14, CharacterRange.ChineseSymbol15, CharacterRange.ChineseSymbol16, CharacterRange.ChineseSymbol17, CharacterRange.ChineseSymbol18, CharacterRange.ChineseSymbol19, CharacterRange.ChineseSymbol20, CharacterRange.ChineseSymbol21, CharacterRange.ChineseSymbol22, CharacterRange.ChineseSymbol23, CharacterRange.ChineseSymbol24, CharacterRange.ChineseSymbol25, CharacterRange.ChineseSymbol26, CharacterRange.ChineseSymbol27, CharacterRange.ChineseSymbol28, }).CreateSpriteFont(GraphicsDevice); GC.Collect(); base.LoadContent(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); TtfFontBakerResult fontBakeResult; using (var stream = File.OpenRead("Fonts/DroidSans.ttf")) { // TODO: use this.Content to load your game content here fontBakeResult = TtfFontBaker.Bake(stream, 25, FontBitmapWidth, FontBitmapHeight, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic } ); _font = fontBakeResult.CreateSpriteFont(GraphicsDevice); } fontBakeResult = TtfFontBaker.Bake(File.ReadAllBytes("Fonts/DroidSansJapanese.ttf"), 25, FontBitmapWidth, FontBitmapHeight, new[] { new CharacterRange(' '), CharacterRange.Hiragana, CharacterRange.Katakana } ); _fontJapanese = fontBakeResult.CreateSpriteFont(GraphicsDevice); GC.Collect(); }
private static List <SpriteFont> BakeTtfFiles(string[] ttfFiles, GraphicsDevice graphicsDevice) { var fonts = new List <SpriteFont>(); foreach (string file in ttfFiles) { TtfFontBakerResult bakeResult = TtfFontBaker.Bake(File.ReadAllBytes(file), 50, 256, 256, new[] { CharacterRange.BasicLatin, //CharacterRange.Latin1Supplement, //CharacterRange.LatinExtendedA, //CharacterRange.LatinExtendedB, //CharacterRange.Cyrillic, //CharacterRange.CyrillicSupplement, //CharacterRange.Hiragana, //CharacterRange.Katakana }); SpriteFont font = bakeResult.CreateSpriteFont(graphicsDevice); fonts.Add(font); } return(fonts); }
public static SpriteFont LoadFont(string font) { SpriteFont outFont = null; // If font is already in memory, reference that instead of having to load the texture again if (LoadedFonts.ContainsKey(font)) { LoadedFonts.TryGetValue(font, out outFont); } else { if (File.Exists(ContentPath + "/" + font)) { outFont = TtfFontBaker.Bake(File.ReadAllBytes(ContentPath + "/" + font), 100, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(Game.graphics.GraphicsDevice); LoadedFonts.Add(font, outFont); } else { Debug.LogError("The Font \"" + font + "\" does not exist in conteht folder!", true, 2); } } return(outFont); }
protected override void LoadContent() { instance = this; spriteBatch = new SpriteBatch(GraphicsDevice); Controls.Initialize(); font = TtfFontBaker.Bake(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"), 25, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); UISprites[0] = Content.Load <Texture2D>("LeftBorder"); UISprites[1] = Content.Load <Texture2D>("RightBorder"); UISprites[2] = Content.Load <Texture2D>("UIBar"); UISprites[3] = Content.Load <Texture2D>("UIHealth"); UISprites[4] = Content.Load <Texture2D>("UIMiasma"); UISprites[5] = Content.Load <Texture2D>("SettingsBar"); UISprites[6] = Content.Load <Texture2D>("SettingsSlider"); EntitySprites[0] = Content.Load <Texture2D>("TheTransmission"); EntitySprites[1] = Content.Load <Texture2D>("MiasmaPulse"); EntitySprites[2] = Content.Load <Texture2D>("PewPew"); EntitySprites[3] = Content.Load <Texture2D>("LightGunship"); EntitySprites[4] = Content.Load <Texture2D>("LightCharger"); EntitySprites[5] = Content.Load <Texture2D>("LightArtillary"); EntitySprites[6] = Content.Load <Texture2D>("ArtillaryPulse"); EntitySprites[7] = Content.Load <Texture2D>("BeamShip"); EntitySprites[8] = Content.Load <Texture2D>("MediumGunship"); EntitySprites[9] = Content.Load <Texture2D>("Boss1"); EntitySprites[10] = Content.Load <Texture2D>("Shield"); EntitySprites[11] = Content.Load <Texture2D>("TeleportingFighter"); EntitySprites[12] = Content.Load <Texture2D>("Capsule"); EntitySprites[13] = Content.Load <Texture2D>("MediumCharger"); EntitySprites[14] = Content.Load <Texture2D>("Bomber"); EntitySprites[15] = Content.Load <Texture2D>("Bomb"); EntitySprites[16] = Content.Load <Texture2D>("Gemini"); EntitySprites[17] = Content.Load <Texture2D>("HelixBuilder"); EntitySprites[18] = Content.Load <Texture2D>("HelixSegment"); EntitySprites[19] = Content.Load <Texture2D>("MediumArtillary"); EntitySprites[20] = Content.Load <Texture2D>("BigArtillaryPulse"); EntitySprites[21] = Content.Load <Texture2D>("Carrier"); EntitySprites[22] = Content.Load <Texture2D>("Pulsar"); EntitySprites[23] = Content.Load <Texture2D>("Block"); EntitySprites[24] = Content.Load <Texture2D>("Missile"); EntitySprites[25] = Content.Load <Texture2D>("Wave"); EntitySprites[26] = Content.Load <Texture2D>("Spinner"); EntitySprites[27] = Content.Load <Texture2D>("EliteGunship"); EntitySprites[28] = Content.Load <Texture2D>("Spartan"); EntitySprites[29] = Content.Load <Texture2D>("SpartanShield"); EntitySprites[30] = Content.Load <Texture2D>("Jupiter"); EntitySprites[31] = Content.Load <Texture2D>("ArmTip"); EntitySprites[32] = Content.Load <Texture2D>("ArmTipBroken"); EntitySprites[33] = Content.Load <Texture2D>("LightingBolt"); EntitySprites[34] = Content.Load <Texture2D>("BallLightning"); EntitySprites[35] = Content.Load <Texture2D>("RuthlessCharger"); EntitySprites[36] = Content.Load <Texture2D>("Cruiser"); EntitySprites[37] = Content.Load <Texture2D>("BombardmentArtillary"); EntitySprites[38] = Content.Load <Texture2D>("AndromedaGunBase"); EntitySprites[39] = Content.Load <Texture2D>("AndromedaDart"); EntitySprites[40] = Content.Load <Texture2D>("AndromedaShield"); EntityExtras[0] = Content.Load <Texture2D>("LightArtillaryGun"); EntityExtras[1] = Content.Load <Texture2D>("DeathBeam"); EntityExtras[2] = Content.Load <Texture2D>("MediumGunshipTurret"); EntityExtras[3] = Content.Load <Texture2D>("Boss1Top"); EntityExtras[4] = Content.Load <Texture2D>("GeminiTurret"); EntityExtras[5] = Content.Load <Texture2D>("HelixBuilderTop"); EntityExtras[6] = Content.Load <Texture2D>("HelixGun"); EntityExtras[7] = Content.Load <Texture2D>("MediumArtillaryGun"); EntityExtras[8] = Content.Load <Texture2D>("CarrierTop"); EntityExtras[9] = Content.Load <Texture2D>("CarrierLeftGun"); EntityExtras[10] = Content.Load <Texture2D>("CarrierRightGun"); EntityExtras[11] = Content.Load <Texture2D>("PulsarBottom"); EntityExtras[12] = Content.Load <Texture2D>("BlockGun"); EntityExtras[13] = Content.Load <Texture2D>("MissilePrelaunch"); EntityExtras[14] = Content.Load <Texture2D>("MissileFull"); EntityExtras[15] = Content.Load <Texture2D>("TheTransmissionTurret"); EntityExtras[16] = Content.Load <Texture2D>("SpinnerBeam"); EntityExtras[17] = Content.Load <Texture2D>("SpartanClaw"); Sounds.LoadSounds(Content); int width = 1000; int height = 1; Texture2D line = new Texture2D(instance.GraphicsDevice, width, height); var dataColors = new Color[width * height]; //Color array for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { dataColors[x + y * height] = Color.White; } } line.SetData(0, null, dataColors, 0, width * height); EntityExtras[18] = line; EntityExtras[19] = Content.Load <Texture2D>("SideDoor"); EntityExtras[20] = Content.Load <Texture2D>("CenterDoor"); EntityExtras[21] = Content.Load <Texture2D>("JupiterBottom"); EntityExtras[22] = Content.Load <Texture2D>("ArmsCore"); EntityExtras[23] = Content.Load <Texture2D>("ArmSegment"); EntityExtras[24] = Content.Load <Texture2D>("LimbSegment"); EntityExtras[25] = Content.Load <Texture2D>("Hand"); EntityExtras[26] = Content.Load <Texture2D>("LightingBeam"); EntityExtras[27] = Content.Load <Texture2D>("LightningAnnihilator"); EntityExtras[29] = Content.Load <Texture2D>("BigLightningBeam"); EntityExtras[30] = Content.Load <Texture2D>("TheAndromeda"); EntityExtras[31] = Content.Load <Texture2D>("AndromedaMachineGun"); EntityExtras[32] = Content.Load <Texture2D>("AndromedaStarGunCenter"); EntityExtras[33] = Content.Load <Texture2D>("AndromedaStarGunPoint"); EntityExtras[34] = Content.Load <Texture2D>("AndromedaBombLauncher"); EntityExtras[35] = Content.Load <Texture2D>("AndromedaDartLauncher"); UpgradeSprites[0] = Content.Load <Texture2D>("UFirerateUp"); UpgradeSprites[1] = Content.Load <Texture2D>("UArmorUp"); UpgradeSprites[2] = Content.Load <Texture2D>("UTripleMiasma"); UpgradeSprites[3] = Content.Load <Texture2D>("UMiasmaBlast"); UpgradeSprites[4] = Content.Load <Texture2D>("UMiasmaGenerator"); UpgradeSprites[5] = Content.Load <Texture2D>("UMiasmaRay"); UpgradeSprites[6] = Content.Load <Texture2D>("USpeed"); UpgradeSprites[7] = Content.Load <Texture2D>("UWave"); UpgradeSprites[8] = Content.Load <Texture2D>("URichoche"); UpgradeSprites[9] = Content.Load <Texture2D>("UStableMiasma"); UpgradeSprites[10] = Content.Load <Texture2D>("ULeech"); UpgradeSprites[11] = Content.Load <Texture2D>("UContagus"); UpgradeSprites[12] = Content.Load <Texture2D>("UTurret"); UpgradeSprites[13] = Content.Load <Texture2D>("UConfuse"); ParticleSprites = Content.Load <Texture2D>("Particle"); width = 400; height = 800; stars = new Texture2D(instance.GraphicsDevice, width, height); dataColors = new Color[width * height]; //Color array for (int i = 0; i < 700; i++) { dataColors[random.Next(width * height)] = Color.White; } stars.SetData(0, null, dataColors, 0, width * height); ResetUpgradePool(); if (!File.Exists("saveData.txt")) { Save(); } Load(); Fleet.CreateFleets(); capsule = new Capsule(new Vector2(300, 700)); Sounds.UpdateMusicVolume(); }
public static SpriteFont LoadFont(string fileLocation, int fontSize, GraphicsDevice graphicsDevice) { return(TtfFontBaker.Bake(File.ReadAllBytes(RootDirectory + fileLocation), fontSize, 1024, 1024, new CharacterRange[] { CharacterRange.BasicLatin }).CreateSpriteFont(graphicsDevice)); }
protected override void LoadContent() // runs once when the game starts { instance = this; font = TtfFontBaker.Bake(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"), 25, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); //Idk how this works but it make fonts a lot easier spriteBatch = new SpriteBatch(GraphicsDevice); //Music and Sound effects by Eric Matyas //www.soundimage.org song = Content.Load <Song>("Retro-Frantic_V001_Looping"); MediaPlayer.Volume = .3f; MediaPlayer.IsRepeating = true; MediaPlayer.Play(song); sounds[0] = Content.Load <SoundEffect>("UI_Quirky26"); //linking sound sounds[1] = Content.Load <SoundEffect>("Laser-Ricochet2"); //shooting sounds[2] = Content.Load <SoundEffect>("Explosion1"); // ring eliminated //define all our textures playerArrow = drawTriangle(12, 1.4f); shot = drawSquare(10); for (int c = 1; c < CircleSizes.Length; c++) { CircleSizes[c] = drawRing(c); } linkTriangle = drawTriangle(12, 1f); pixel = new Texture2D(instance.GraphicsDevice, 1, 1); Color[] dataColors = { Color.White }; pixel.SetData(0, null, dataColors, 0, 1); int Xsize = 20; X = new Texture2D(instance.GraphicsDevice, Xsize, Xsize); dataColors = new Color[Xsize * Xsize]; for (int x = 0; x < Xsize; x++) { for (int y = 0; y < Xsize; y++) { if (x == y || x == Xsize - y) { dataColors[x + y * Xsize] = Color.White; } } } X.SetData(0, null, dataColors, 0, Xsize * Xsize); // L i n k int width = 880; Vector2 startTextAt = new Vector2(screenSize.X / 2 - width / 2, 200); new Ring(startTextAt); new Ring(startTextAt + new Vector2(0, 100)); new Ring(startTextAt + new Vector2(0, 200)); new Ring(startTextAt + new Vector2(120, 200)); new Ring(startTextAt + new Vector2(280, 200)); new Ring(startTextAt + new Vector2(280, 100)); new Ring(startTextAt + new Vector2(280, 0)); new Ring(startTextAt + new Vector2(440, 100)); new Ring(startTextAt + new Vector2(440, 200)); new Ring(startTextAt + new Vector2(440, 0)); new Ring(startTextAt + new Vector2(520, 0)); new Ring(startTextAt + new Vector2(600, 100)); new Ring(startTextAt + new Vector2(600, 200)); Ring r = new Ring(startTextAt + new Vector2(880, 200)); Ring r2 = new Ring(startTextAt + new Vector2(880, 0)); Ring r3 = new Ring(startTextAt + new Vector2(760, 0)); Ring r4 = new Ring(startTextAt + new Vector2(760, 200)); r.linkedTo = r2.linkedTo = r3.linkedTo = r4.linkedTo = new Ring(startTextAt + new Vector2(760, 100)); }