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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - NeomerArcana

Pages: [1]
2
Graphics / Re: Fonts and .ttf Metrics
« on: April 23, 2014, 12:08:23 am »
Thanks a lot guys. Your efforts are much appreciated

3
Graphics / Re: Fonts and .ttf Metrics
« on: April 22, 2014, 12:00:28 pm »
Thanks for your reply Laurent, and thanks for all your effort in SFML.

I don't think it's using the highest glyph character.

sf::Text t(L"ÙPenguin", f, 50);

Using this string is giving me the same problem. I've looked in FontForge and this character is just below the Ascender, so there should definitely not be that much whitespace above.

4
Graphics / Re: Fonts and .ttf Metrics
« on: April 22, 2014, 11:41:04 am »
Yes of course, here's the code. You will see that it prints "Penguin" in red text and retrieves the local bounds of the text to then draw a green box.

The text is positioned at 0,0 yet it doesn't appear there. You can also see that the local bounds don't start at 0,0 (from the console output).

The font is attached. I've tried this with several different fonts that I've downloaded from various websites. I've also tried it with "arial.ttf" taken, unmodified, directly from my C:/Windows/Fonts directory. Same problem persists.

This all leads me to think it's some issue with the way .ttf fonts are loaded. But I don't know enough about font file formats or FreeType to work it out.

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(1600, 900), "Pirate Game", sf::Style::Titlebar | sf::Style::Close);
   
        sf::Font f;
        f.loadFromFile("BOOTERFZ.ttf");
        sf::Text t("Penguin", f, 500);
        t.setPosition(0,0);
        t.setColor(sf::Color(255,0,0));
        sf::FloatRect ff = t.getLocalBounds();
        sf::RectangleShape r(sf::Vector2f(ff.width,ff.height));
        r.setPosition(ff.left,ff.top);
        r.setFillColor(sf::Color(0,255,0));
        std::cout << ff.left << ", " << ff.top << ", " << ff.width << ", " << ff.height << std::endl;
       
        while(window.isOpen())
        {
            sf::Event event;
            while(window.pollEvent(event))
            {
                if(event.type == sf::Event::Closed)
                {
                    window.close();
                }
            }
            window.clear();

            window.draw(r);
            window.draw(t);
            window.display();
        }

    return 0;
}
 

5
Graphics / Re: Fonts and .ttf Metrics
« on: April 21, 2014, 02:12:35 pm »
I guess I could just offset the position, the issue I have is that I'd like to not use a workaround and instead understand the reason so I can adjust my font file.

In SFGUI I'm unable to offset the text on a button anyway, which is why I've asked.

6
Graphics / Fonts and .ttf Metrics
« on: April 21, 2014, 12:40:05 pm »
Hi,

I've had an ongoing problem with SFML which I've also noticed in SFGUI. Basically, it's that a lot of .ttf fonts include accented unicode characters which gives the font a large Ascent and Descent value in the font metrics. Most programs I think ignore this stuff when typing text and sort of recalculate it on their own, but not the case in SFML (and therefore SFGUI).

So for example, outputting text in SFML at position 0,0 makes the text appear to be more at like 0,20 because of the whitespace above to make room for ascent characters. But if I then .getLocalBounds() on the object the local bounds do not start at 0,0 (my guess is because it calculates the ACTUAL bounds of the displayed text?).

I've tried downloading FontForge to manually edit the various Ascender and Descender values for my font, but it doesn't seem to have much of an effect. Changing the EM size seems to have an effect, but it's like SFML (or maybe it's FreeType behind the scenes) is ignoring it.

Does anyone know how I can edit the font, what specific values to change, to get it to use whatever value I want to decide where the "top" of the text could be? Currently the "top" is like the top of an accented uppercase A, but I want it to be the top of a regular A.

Is there anything I can do to the source of SFML to change the way it reads the font as well (if it's needed)?

7
General / Re: Help with SFML2.1 and Mingw-builds from Google
« on: November 22, 2013, 11:14:00 pm »
Problem was solved:

I don't quite understand why. But I placed all the generated .dll files in the project directory and it worked. I overwrote some old .dll files that were in there. I thought this would only affect the .exe during execution, not compile time, but maybe code::blocks looks in the project directory for files before it goes looking in the seach directories?

8
General / Re: Help with SFML2.1 and Mingw-builds from Google
« on: November 22, 2013, 11:28:23 am »
Thanks for the link to the updated library. I downloaded that using the installer.

I removed the code::blocks mingw from my Path variable and replaced it with the above installed directory. CMake picked up my new compiler easy. I built SFML2.1 using it no errors.

I then checked my toolchain and search directory settings in code::blocks, updated to my new ming2-build. Double checked it.

I'm getting the same error.

At this point, I see nothing wrong with the toolchain. Any other thoughts?

9
General / [SOLVED] Help with SFML2.1 and Mingw-builds
« on: November 22, 2013, 10:20:16 am »
Hi all,

I'm trying to successfully build SFML2.1 using the latest from http://code.google.com/p/mingw-builds/downloads/list. I'm doing this specifically because it supports std::thread on windows (I do not want to use boost or any other library).

I managed to build the libraries using cmake. But the when I compile a project using this new compiler and libraries I get a bunch of "multiple definition of" errors. (The project successfully compiles under sfml2.1 and gcc 4.7.0 (that comes with Code::Blocks 12.11))

The only thing I've noticed is that the configuration in cmake lists the code:blocks version of mingw32-make as the CMAKE_MAKE_PROGRAM. I'm unable to edit it due to the endless loop error you get for changing toolchain executables. I've tried changing the environment PATH to use my new google sourced compilers mingw32-make but it doesn't seem to pick it up.

Anyway, I'm not sure that's the problem.

Any help would be appreciated. If anyone can try building and compiling an SFML test project with the above mingw-build project it would help a lot.

10
Graphics / Re: Stroke a Vertex Array
« on: September 14, 2013, 03:27:40 am »
In case anyone searches the forum and finds this topic: the following code sorted me out:
https://github.com/SFML/SFML/wiki/Source%3A-line-with-thickness
Though I had to make a few minor edits.

11
Graphics / Re: Stroke a Vertex Array
« on: September 13, 2013, 09:34:18 am »
I think it does.

I'll investigate tonight.

Cheers.

12
Graphics / Stroke a Vertex Array
« on: September 13, 2013, 09:11:20 am »
Hi All,

I've been scratching my head on this one for a little and I'm really just after some guidance.

I've searched google and the forums and can't find an answer, or at least one I understand. I'm trying to stroke an array of vertices. Basically, exactly like how you stroke a path in Photoshop with a Brush.

I understand that SFML can't do this out of the box.

My use case is I have a berzier curve function which I use to calculate the coords of say 10 points along the curve. I'm then adding these points to a Vertex Array as a Line Array. I'd now like to drawn a nice thick 6 pixel line (brush) along this path.

I've sort of come to the conclusion that I'd need to do this using a Polygon. So I thought if I calculate the direction vector at each point, I could then calculate the point that's at a right angle direction to either side of my original point at a distance of half the stroke width. Then I would be able to add each of these points to a Vertex Array working along the two points that are 90 degrees from the first point, 90 degress from the second point and then at the last point I can work my way back down along the 270 degree angle points.

Then I can just fill the resulting polygon that's the width I want, and centered directly on the top of my original Vertex array.

I would like to get some validation on this before I go to all the effort of learning the necessary vector math. Is there a better way to do this? Has someone already gone to the effort to code it up for me?

Pages: [1]