Content Pipeline:
Fixed SpriteFont Building (Importer/Processor). It now renders fine in the TextRendering Sample.
This commit is contained in:
parent
b82cfd40ee
commit
a56e950056
@ -137,7 +137,7 @@ namespace ANX.Framework.Content.Pipeline.Importer
|
|||||||
startElement.Value + " - " + endElement.Value);
|
startElement.Value + " - " + endElement.Value);
|
||||||
}
|
}
|
||||||
//add each char from the range to the list
|
//add each char from the range to the list
|
||||||
for (var i = startChar; i < endChar; i++)
|
for (var i = startChar; i <= endChar; i++)
|
||||||
{
|
{
|
||||||
characters.Add(Convert.ToChar(i));
|
characters.Add(Convert.ToChar(i));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ using ANX.Framework.NonXNA.Development;
|
|||||||
|
|
||||||
namespace ANX.Framework.Content.Pipeline.Processors
|
namespace ANX.Framework.Content.Pipeline.Processors
|
||||||
{
|
{
|
||||||
[PercentageComplete(90)]
|
[PercentageComplete(95)]
|
||||||
[Developer("SilentWarrior/Eagle Eye Studios")]
|
[Developer("SilentWarrior/Eagle Eye Studios")]
|
||||||
[TestState(TestStateAttribute.TestState.InProgress)]
|
[TestState(TestStateAttribute.TestState.InProgress)]
|
||||||
[ContentProcessor(DisplayName = "FontDescription Processor - ANX Framework")]
|
[ContentProcessor(DisplayName = "FontDescription Processor - ANX Framework")]
|
||||||
@ -50,7 +50,7 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
var font = new Font(input.FontName, input.Size, XnaFontStyleToGdiFontStyle(input.Style));
|
var font = new Font(input.FontName, input.Size, XnaFontStyleToGdiFontStyle(input.Style));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const int padding = 8;
|
const int padding = 4;
|
||||||
|
|
||||||
int width = padding;
|
int width = padding;
|
||||||
int height = padding;
|
int height = padding;
|
||||||
@ -86,7 +86,7 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
using (var bitmap = new Bitmap(width, height,
|
using (var bitmap = new Bitmap(width, height,
|
||||||
PixelFormat.Format32bppArgb))
|
PixelFormat.Format32bppArgb))
|
||||||
{
|
{
|
||||||
// Arrage all the glyphs onto a single larger bitmap.
|
// Arrange all the glyphs onto a single larger bitmap.
|
||||||
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap))
|
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
graphics.Clear(System.Drawing.Color.Magenta);
|
graphics.Clear(System.Drawing.Color.Magenta);
|
||||||
@ -94,10 +94,12 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
|
|
||||||
for (int i = 0; i < bitmaps.Count; i++)
|
for (int i = 0; i < bitmaps.Count; i++)
|
||||||
{
|
{
|
||||||
spriteFontContent.Cropping.Add(new Rectangle(xPositions[i], yPositions[i], bitmaps[i].Width,
|
//cropping defines the dimensions of a single character
|
||||||
bitmaps[i].Height));
|
spriteFontContent.Cropping.Add(new Rectangle(0, 0, bitmaps[i].Width - 1, //we need to subtract one unit of height and width to suppress nasty rendering artifacts.
|
||||||
graphics.DrawImage(bitmaps[i], xPositions[i],
|
bitmaps[i].Height - 1));
|
||||||
yPositions[i]);
|
//Glyphs defines the section and dimensions where the character is located on the texture
|
||||||
|
spriteFontContent.Glyphs.Add(new Rectangle(xPositions[i] + 1, yPositions[i] + 1, bitmaps[i].Width -1, bitmaps[i].Height-1));
|
||||||
|
graphics.DrawImage(bitmaps[i], xPositions[i], yPositions[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.Flush();
|
graphics.Flush();
|
||||||
@ -105,13 +107,14 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
spriteFontContent.Texture = ConvertBitmap(bitmap);
|
spriteFontContent.Texture = ConvertBitmap(bitmap);
|
||||||
spriteFontContent.CharacterMap = input.Characters.ToList();
|
spriteFontContent.CharacterMap = input.Characters.ToList();
|
||||||
spriteFontContent.DefaultCharacter = input.DefaultCharacter;
|
spriteFontContent.DefaultCharacter = input.DefaultCharacter;
|
||||||
spriteFontContent.Glyphs = spriteFontContent.Cropping;
|
|
||||||
spriteFontContent.Kerning = new List<Vector3>();
|
spriteFontContent.Kerning = new List<Vector3>();
|
||||||
for (var i = 0; i < input.Characters.Count; i++)
|
for (var i = 0; i < input.Characters.Count; i++)
|
||||||
{
|
{
|
||||||
var value = Vector3.Zero;
|
var value = Vector3.Zero;
|
||||||
if (input.UseKerning)
|
if (input.UseKerning)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException("Kerning is not implemented!");
|
||||||
|
//TODO: Implement!
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user