Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML.Net 2.2 bug: Glyph.Advance too big  (Read 3495 times)

0 Members and 1 Guest are viewing this topic.

Nethanis

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SFML.Net 2.2 bug: Glyph.Advance too big
« 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.

Dejan Geci

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: SFML.Net 2.2 bug: Glyph.Advance too big
« Reply #1 on: April 10, 2015, 03:51:30 pm »
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

Nethanis

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML.Net 2.2 bug: Glyph.Advance too big
« Reply #2 on: April 11, 2015, 05:24:42 pm »
Oh, thanks for the reply. :) Somehow I didn't find it when looking through github.

zephyr

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: SFML.Net 2.2 bug: Glyph.Advance too big
« Reply #3 on: November 14, 2015, 07:58:39 am »
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);
        }
    }

 

anything