BREAKING CHANGE: DynamicSpriteFont had been moved to the project: https://github.com/rds1983/FontStashSharp
Library that extends functionality of the SpriteFont.
- Creation of SpriteFont in the run-time from ttf.
- Creation of SpriteFont in the run-time from AngelCode BMFont(only XML with single texture works for now).
There are two ways of referencing SpriteFontPlus in the project:
-
Through nuget(works only for MonoGame): https://www.nuget.org/packages/SpriteFontPlus/
-
As source code(works for both MonoGame and FNA):
a. Clone this repo.
b. Execute
git submodule update --init --recursive
within the folder the repo was cloned to.c. Add src/SpriteFontPlus.MonoGame.csproj or src/SpriteFontPlus.FNA.csproj to the solution.
Following code creates a SpriteFont from a ttf:
var fontBakeResult = TtfFontBaker.Bake(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"),
25,
1024,
1024,
new[]
{
CharacterRange.BasicLatin,
CharacterRange.Latin1Supplement,
CharacterRange.LatinExtendedA,
CharacterRange.Cyrillic
}
);
SpriteFont font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
Full sample is here: samples/SpriteFontPlus.Samples.TtfBaking
string fontData;
using (var stream = TitleContainer.OpenStream("Fonts/test.fnt"))
{
using (var reader = new StreamReader(stream))
{
fontData = reader.ReadToEnd();
}
}
SpriteFont font = BMFontLoader.Load(fontData, name => TitleContainer.OpenStream("Fonts/" + name), GraphicsDevice);
Full sample is here: samples/SpriteFontPlus.Samples.BMFont
- Clone this repo.
git submodule update --init --recursive
- Open a solution from the "build" folder.