-
Notifications
You must be signed in to change notification settings - Fork 33
/
Game1.cs
119 lines (102 loc) · 3.48 KB
/
Game1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace SpriteFontPlus.Samples.TtfBaking
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class Game1 : Game
{
private const int FontBitmapWidth = 1024;
private const int FontBitmapHeight = 1024;
GraphicsDeviceManager _graphics;
SpriteBatch _spriteBatch;
private SpriteFont _font, _fontJapanese;
public Game1()
{
_graphics = new GraphicsDeviceManager(this)
{
};
Content.RootDirectory = "Content";
IsMouseVisible = true;
Window.AllowUserResizing = true;
}
/// <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();
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
_spriteBatch.Begin();
// Render some text
_spriteBatch.DrawString(_font, "The quick brown fox jumps over the lazy dog",
new Vector2(0, 0), Color.White);
_spriteBatch.DrawString(_font, "Üben quält finſteren Jagdſchloß höfliche Bäcker größeren, N: Blåbærsyltetøy",
new Vector2(0, 30), Color.White);
_spriteBatch.DrawString(_font, "Høj bly gom vandt fræk sexquiz på wc, S: bäckasiner söka",
new Vector2(0, 60), Color.White);
_spriteBatch.DrawString(_font, "Sævör grét áðan því úlpan var ónýt, P: Pchnąć w tę łódź jeża lub osiem skrzyń fig",
new Vector2(0, 90), Color.White);
_spriteBatch.DrawString(_font, "Příliš žluťoučký kůň úpěl ďábelské kódy, R: В чащах юга жил-был цитрус? Да, но фальшивый экземпляр! ёъ.",
new Vector2(0, 120), Color.White);
_spriteBatch.DrawString(_font, "kilómetros y frío, añoraba, P: vôo à noite, F: Les naïfs ægithales hâtifs pondant à Noël où",
new Vector2(0, 150), Color.White);
_spriteBatch.DrawString(_fontJapanese, "いろはにほへど",
new Vector2(0, 180), Color.White);
_spriteBatch.End();
base.Draw(gameTime);
}
}
}