SFML community forums
Bindings - other languages => DotNet => Topic started by: Nethanis on April 10, 2015, 03:21:50 pm
-
Hello!
The Glyph.Advance value is way too big, it's enormous. The values for any font loaded, any character size of any character are above 1000000000 (one billion). Except for character size of 0, then the advance is also zero, but it's not very helpful. :P
Here's a code example.
using System;using SFML.Graphics;namespace SFMLGlyphAdvanceBug
{ class Program
{ static void Main
() { Font Font
= new Font
("arial.ttf"); Glyph Glyph
= Font
.GetGlyph('F', 30u,
false); Console
.WriteLine(Glyph
.Advance); // Output in SFML .Net 2.2: 1099956224 // Output in SFML .Net 2.1: 18 } }}
I found it when using my custom text class. Because of this bug, when drawing the text, only the first character is visible, the rest is moved outside the window.
It works just fine in SFML.Net 2.1.
The SFML text class is also drawn correctly.
I'm using 32-bit version of SFML.Net 2.2, Visual Studio 2013 with Update 4, Windows 8.1.
-
I think it's been fixed with https://github.com/SFML/SFML.Net/commit/659feb9a5fdf5d1f4553ee668da76b0abf655c03.
You have to build SFML yourself, or wait for 2.3
-
Oh, thanks for the reply. :) Somehow I didn't find it when looking through github.
-
Binaries for SFML 2.3 C# bindings haven't landed yet; I used this hack without recompile.
public static class GlyphPatcher
{
public static float GetGlyphAdvancePatch(this Glyph glyph)
{
var bytes = BitConverter.GetBytes(glyph.Advance);
return BitConverter.ToSingle(bytes, 0);
}
}