StyleCop
This commit is contained in:
@@ -19,6 +19,9 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public class SpriteFont
|
public class SpriteFont
|
||||||
{
|
{
|
||||||
|
static Library library = new Library();
|
||||||
|
static SheetBuilder builder;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
string name;
|
string name;
|
||||||
|
|
||||||
@@ -30,8 +33,7 @@ namespace OpenRA.Graphics
|
|||||||
face = new Face(library, name);
|
face = new Face(library, name);
|
||||||
face.SetPixelSizes((uint)size, (uint)size);
|
face.SetPixelSizes((uint)size, (uint)size);
|
||||||
|
|
||||||
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph, Pair<char, Color>.EqualityComparer);
|
||||||
Pair<char,Color>.EqualityComparer);
|
|
||||||
|
|
||||||
// setup a SheetBuilder for our private use
|
// setup a SheetBuilder for our private use
|
||||||
// TODO: SheetBuilder state is leaked between mod switches
|
// TODO: SheetBuilder state is leaked between mod switches
|
||||||
@@ -92,7 +94,7 @@ namespace OpenRA.Graphics
|
|||||||
return new int2((int)Math.Ceiling(lines.Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance))), lines.Length * size);
|
return new int2((int)Math.Ceiling(lines.Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance))), lines.Length * size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache<Pair<char,Color>, GlyphInfo> glyphs;
|
Cache<Pair<char, Color>, GlyphInfo> glyphs;
|
||||||
Face face;
|
Face face;
|
||||||
|
|
||||||
GlyphInfo CreateGlyph(Pair<char, Color> c)
|
GlyphInfo CreateGlyph(Pair<char, Color> c)
|
||||||
@@ -112,6 +114,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
// A new bitmap is generated each time this property is accessed, so we do need to dispose it.
|
// A new bitmap is generated each time this property is accessed, so we do need to dispose it.
|
||||||
using (var bitmap = face.Glyph.Bitmap)
|
using (var bitmap = face.Glyph.Bitmap)
|
||||||
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var p = (byte*)bitmap.Buffer;
|
var p = (byte*)bitmap.Buffer;
|
||||||
@@ -133,13 +136,12 @@ namespace OpenRA.Graphics
|
|||||||
p += bitmap.Pitch;
|
p += bitmap.Pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.sheet.CommitData();
|
s.sheet.CommitData();
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Library library = new Library();
|
|
||||||
static SheetBuilder builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlyphInfo
|
class GlyphInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user